From 53e079b543eed76d9f5899b2b2c14c72abd96fed Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Mon, 7 Dec 2009 14:28:49 -0800 Subject: [PATCH] support filenames with spaces. bind mojo-target-device by default. --- CHANGELOG | 10 ++++++++++ COMMANDS | 3 ++- mojo.el | 29 +++++++++++++++++++++++++---- src/code.el | 13 +++++++++++-- src/info.json | 2 +- 5 files changed, 49 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index cc78965..5bd7d33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,16 @@ CHANGELOG ========= +sjs 2009-12-07 +v 0.9.10 (bug fix) + + - All arguments sent through mojo-cmd now quoted before being + sent to the shell (in case filenames contain spaces). Values + are unintelligently wrapped in double quotes, this is *not* + escaping, just brain-dead quoting. + + - New default key binding: C-c C-c C-d runs mojo-target-device + sjs 2009-12-04 v 0.9.9 (bug fix) diff --git a/COMMANDS b/COMMANDS index c1a8062..f5bae4b 100644 --- a/COMMANDS +++ b/COMMANDS @@ -8,6 +8,7 @@ Default key bindings: * C-c C-c S -- mojo-switch-to-stylesheet * C-c C-c v -- mojo-switch-to-view * C-c C-c SPC -- mojo-switch-file-dwim + * C-c C-c C-d -- mojo-target-device * C-c C-c C-e -- mojo-emulate * C-c C-c C-p -- mojo-package * C-c C-c C-r -- mojo-package-install-and-inspect @@ -141,4 +142,4 @@ The complete command list: Set the log level. mojo-set-escape-html-in-templates - Enable or disable escaping of HTML in templates. \ No newline at end of file + Enable or disable escaping of HTML in templates. diff --git a/mojo.el b/mojo.el index 15f66e1..7af7839 100644 --- a/mojo.el +++ b/mojo.el @@ -1,6 +1,6 @@ ;;; mojo.el --- Interactive functions for webOS development -;; 2009-12-04 15:44:24 -(defconst mojo-version "0.9.9") +;; 2009-12-07 14:28:52 +(defconst mojo-version "0.9.10") (require 'json) @@ -86,6 +86,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.") ;; * C-c C-c S -- mojo-switch-to-stylesheet ;; * C-c C-c v -- mojo-switch-to-view ;; * C-c C-c SPC -- mojo-switch-file-dwim +;; * C-c C-c C-d -- mojo-target-device ;; * C-c C-c C-e -- mojo-emulate ;; * C-c C-c C-p -- mojo-package ;; * C-c C-c C-r -- mojo-package-install-and-inspect @@ -221,6 +222,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.") ;; mojo-set-escape-html-in-templates ;; Enable or disable escaping of HTML in templates. + ;;; Customizable Options: ;; ;; Below are customizable option list: @@ -243,6 +245,16 @@ ideas. Send me a pull request on github if you hack on mojo.el.") ;; CHANGELOG ;; ========= ;; +;; sjs 2009-12-07 +;; v 0.9.10 (bug fix) +;; +;; - All arguments sent through mojo-cmd now quoted before being +;; sent to the shell (in case filenames contain spaces). Values +;; are unintelligently wrapped in double quotes, this is *not* +;; escaping, just brain-dead quoting. +;; +;; - New default key binding: C-c C-c C-d runs mojo-target-device +;; ;; sjs 2009-12-04 ;; v 0.9.9 (bug fix) ;; @@ -364,6 +376,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.") * C-c C-c S -- \\[mojo-switch-to-stylesheet] * C-c C-c v -- \\[mojo-switch-to-view] * C-c C-c SPC -- \\[mojo-switch-file-dwim] + * C-c C-c C-d -- \\[mojo-target-device] * C-c C-c C-e -- \\[mojo-emulate] * C-c C-c C-p -- \\[mojo-package] * C-c C-c C-r -- \\[mojo-package-install-and-inspect] @@ -386,6 +399,7 @@ ideas. Send me a pull request on github if you hack on mojo.el.") ("\C-c\C-cS" . mojo-switch-to-stylesheet) ("\C-c\C-cv" . mojo-switch-to-view) ("\C-c\C-c " . mojo-switch-file-dwim) + ("\C-c\C-c\C-d" . mojo-target-device) ("\C-c\C-c\C-e" . mojo-emulate) ("\C-c\C-c\C-p" . mojo-package) ("\C-c\C-c\C-r" . mojo-package-install-and-inspect) @@ -464,6 +478,7 @@ NAME is the name of the scene." (defun mojo-emulate () "Launch the palm emulator." (interactive) + (mojo-target-emulator) ;; target emulator from now on (unless (mojo-emulator-running-p) (mojo-cmd "palm-emulator" nil))) @@ -1119,6 +1134,12 @@ This command only works on Unix-like systems." ((windows-nt) (concat mojo-sdk-directory "/bin/" cmd ".bat")) (t (concat mojo-sdk-directory "/bin/" cmd)))) +(defun mojo-quote (string) + "Wrap a string in double quotes. + +Used to quote filenames sent to shell commands." + (concat "\"" string "\"")) + ;;* lowlevel cmd (defun mojo-cmd (cmd args) "General interface for running mojo-sdk commands. @@ -1128,8 +1149,8 @@ CMD is the name of the command (without path or extension) to execute. ARGS is a list of all arguments to the command. These arguments are NOT shell quoted." (let ((cmd (mojo-path-to-cmd cmd)) - (args (mojo-string-join " " args))) - (if mojo-debug (message "running %s with args %s " cmd args)) + (args (mojo-string-join " " (mapcar 'mojo-quote args)))) + (when mojo-debug (message "running %s with args %s " cmd args)) (shell-command (concat cmd " " args)))) ;;* lowlevel cmd diff --git a/src/code.el b/src/code.el index 1462d04..73fa453 100644 --- a/src/code.el +++ b/src/code.el @@ -21,6 +21,7 @@ * C-c C-c S -- \\[mojo-switch-to-stylesheet] * C-c C-c v -- \\[mojo-switch-to-view] * C-c C-c SPC -- \\[mojo-switch-file-dwim] + * C-c C-c C-d -- \\[mojo-target-device] * C-c C-c C-e -- \\[mojo-emulate] * C-c C-c C-p -- \\[mojo-package] * C-c C-c C-r -- \\[mojo-package-install-and-inspect] @@ -43,6 +44,7 @@ ("\C-c\C-cS" . mojo-switch-to-stylesheet) ("\C-c\C-cv" . mojo-switch-to-view) ("\C-c\C-c " . mojo-switch-file-dwim) + ("\C-c\C-c\C-d" . mojo-target-device) ("\C-c\C-c\C-e" . mojo-emulate) ("\C-c\C-c\C-p" . mojo-package) ("\C-c\C-c\C-r" . mojo-package-install-and-inspect) @@ -121,6 +123,7 @@ NAME is the name of the scene." (defun mojo-emulate () "Launch the palm emulator." (interactive) + (mojo-target-emulator) ;; target emulator from now on (unless (mojo-emulator-running-p) (mojo-cmd "palm-emulator" nil))) @@ -776,6 +779,12 @@ This command only works on Unix-like systems." ((windows-nt) (concat mojo-sdk-directory "/bin/" cmd ".bat")) (t (concat mojo-sdk-directory "/bin/" cmd)))) +(defun mojo-quote (string) + "Wrap a string in double quotes. + +Used to quote filenames sent to shell commands." + (concat "\"" string "\"")) + ;;* lowlevel cmd (defun mojo-cmd (cmd args) "General interface for running mojo-sdk commands. @@ -785,8 +794,8 @@ CMD is the name of the command (without path or extension) to execute. ARGS is a list of all arguments to the command. These arguments are NOT shell quoted." (let ((cmd (mojo-path-to-cmd cmd)) - (args (mojo-string-join " " args))) - (if mojo-debug (message "running %s with args %s " cmd args)) + (args (mojo-string-join " " (mapcar 'mojo-quote args)))) + (when mojo-debug (message "running %s with args %s " cmd args)) (shell-command (concat cmd " " args)))) ;;* lowlevel cmd diff --git a/src/info.json b/src/info.json index 070c6dc..0532811 100644 --- a/src/info.json +++ b/src/info.json @@ -2,6 +2,6 @@ "title": "mojo.el", "filename": "../mojo.el", "basename": "mojo.el", - "version": "0.9.9", + "version": "0.9.10", "template": "template.el" } \ No newline at end of file