Merge pull request #4 from conao3/feature

fixes from @conao3
This commit is contained in:
nik gaffney 2020-02-11 11:21:39 +11:00 committed by GitHub
commit 16c1e1ebd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
/.cask
*.elc

4
Cask Normal file
View file

@ -0,0 +1,4 @@
(source gnu)
(source melpa)
(package-file "smog.el")

15
smog.el
View file

@ -130,10 +130,12 @@ Further details can be found in the =style(1)= man page.\n"
(defun smog--style-installed-p () (defun smog--style-installed-p ()
"Is the style command installed?" "Is the style command installed?"
(if (eq 0 (condition-case nil (let ((program "style"))
(call-process "style") (unless (executable-find program)
(error (message "The program 'style' isn't installed or can't be found.")))) (message "The program 'style' isn't installed or can't be found."))
t nil)) (eq 0 (condition-case nil
(call-process program)
(error (message "The program 'style' test run exit abnormally."))))))
;;;###autoload ;;;###autoload
(defun smog-check-buffer () (defun smog-check-buffer ()
@ -145,7 +147,8 @@ Further details can be found in the =style(1)= man page.\n"
(smog-target (buffer-file-name (current-buffer)))) (smog-target (buffer-file-name (current-buffer))))
;; run the shell command. synchronously. ;; run the shell command. synchronously.
(shell-command (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) ;; output the results and add references (in org-mode if it's available)
(with-current-buffer smog-output (with-current-buffer smog-output
(goto-char (point-min)) (goto-char (point-min))
@ -168,7 +171,7 @@ Further details can be found in the =style(1)= man page.\n"
(interactive) (interactive)
(when (smog--style-installed-p) (when (smog--style-installed-p)
(let* ((smog-buffer (current-buffer)) (let* ((smog-buffer (current-buffer))
(smog-output (get-buffer-create "*Readability*")) (smog-output (get-buffer-create "*Readability*"))
(region-p (use-region-p)) (region-p (use-region-p))
;; beginning of either buffer or region ;; beginning of either buffer or region
(selection-start (if region-p (selection-start (if region-p