From 548d1770dab47b73d46d49c012dfabbc5c925a48 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:31:42 +0900 Subject: [PATCH 1/6] add Cask file to easy resolve dependencies, build etc --- Cask | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 Cask diff --git a/Cask b/Cask new file mode 100644 index 0000000..9633587 --- /dev/null +++ b/Cask @@ -0,0 +1,4 @@ +(source gnu) +(source melpa) + +(package-file "smog.el") From 1e7198bd31cab4d02967eab2c94016563a9b0edc Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:32:11 +0900 Subject: [PATCH 2/6] add .gitignore file --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d88ecb9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.cask +*.elc From 1cc39ab3520671e6ffb5e0939ff96f47963e7ef0 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:35:14 +0900 Subject: [PATCH 3/6] fix indent (first column is space) --- smog.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smog.el b/smog.el index c2e514f..0a8d9cf 100644 --- a/smog.el +++ b/smog.el @@ -168,7 +168,7 @@ Further details can be found in the =style(1)= man page.\n" (interactive) (when (smog--style-installed-p) (let* ((smog-buffer (current-buffer)) - (smog-output (get-buffer-create "*Readability*")) + (smog-output (get-buffer-create "*Readability*")) (region-p (use-region-p)) ;; beginning of either buffer or region (selection-start (if region-p From 3a1bb7f503004bba88c3b18be5007ba3de3e759a Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:38:19 +0900 Subject: [PATCH 4/6] use shell-quote-argument to create safe shell command --- smog.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/smog.el b/smog.el index 0a8d9cf..627a545 100644 --- a/smog.el +++ b/smog.el @@ -145,7 +145,8 @@ Further details can be found in the =style(1)= man page.\n" (smog-target (buffer-file-name (current-buffer)))) ;; run the shell command. synchronously. (shell-command - (format "%s '%s'" smog-command smog-target) smog-output) + (mapconcat #'shell-quote-argument (list smog-command smog-target) " ") + smog-output) ;; output the results and add references (in org-mode if it's available) (with-current-buffer smog-output (goto-char (point-min)) From 7a656bb3aa45e90f7888cb44bb1b87578cc301ee Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:38:51 +0900 Subject: [PATCH 5/6] as eq returns boolean, if statement is unneeded --- smog.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/smog.el b/smog.el index 627a545..1bbfeef 100644 --- a/smog.el +++ b/smog.el @@ -130,10 +130,9 @@ Further details can be found in the =style(1)= man page.\n" (defun smog--style-installed-p () "Is the style command installed?" - (if (eq 0 (condition-case nil - (call-process "style") - (error (message "The program 'style' isn't installed or can't be found.")))) - t nil)) + (eq 0 (condition-case nil + (call-process "style") + (error (message "The program 'style' isn't installed or can't be found."))))) ;;;###autoload (defun smog-check-buffer () From 2153d8ec205bd1b4a6abdb5ab015bbcece189372 Mon Sep 17 00:00:00 2001 From: conao3 Date: Tue, 11 Feb 2020 04:43:00 +0900 Subject: [PATCH 6/6] separate error message --- smog.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/smog.el b/smog.el index 1bbfeef..dbbfc9d 100644 --- a/smog.el +++ b/smog.el @@ -130,9 +130,12 @@ Further details can be found in the =style(1)= man page.\n" (defun smog--style-installed-p () "Is the style command installed?" - (eq 0 (condition-case nil - (call-process "style") - (error (message "The program 'style' isn't installed or can't be found."))))) + (let ((program "style")) + (unless (executable-find program) + (message "The program 'style' isn't installed or can't be found.")) + (eq 0 (condition-case nil + (call-process program) + (error (message "The program 'style' test run exit abnormally.")))))) ;;;###autoload (defun smog-check-buffer ()