Abandon normal instructions
This commit is contained in:
parent
b7430fc17d
commit
2fc5fef0f5
1 changed files with 49 additions and 38 deletions
87
smog.el
87
smog.el
|
@ -46,7 +46,18 @@
|
||||||
:group 'wp)
|
:group 'wp)
|
||||||
|
|
||||||
(defcustom smog-command "style -L en"
|
(defcustom smog-command "style -L en"
|
||||||
"The command to use to run style including any flags (see 'style -h' for details)."
|
"The command to use to run style (including any flags).
|
||||||
|
|
||||||
|
From GNU style 1.11
|
||||||
|
-L, --language set the document language.
|
||||||
|
-l, --print-long print all sentences longer than <length> words
|
||||||
|
-r, --print-ari print all sentences with an ARI greater than than <ari>
|
||||||
|
-p, --print-passive print all sentences phrased in the passive voice
|
||||||
|
-N, --print-nom print all sentences containing nominalizations
|
||||||
|
-n, --print-nom-passive print all sentences phrased in the passive voice or
|
||||||
|
containing nominalizations
|
||||||
|
-h, --help print this message
|
||||||
|
--version print the version"
|
||||||
:type '(string)
|
:type '(string)
|
||||||
:group 'smog)
|
:group 'smog)
|
||||||
|
|
||||||
|
@ -134,35 +145,35 @@ Further details can be found in the =style(1)= man page.\n"
|
||||||
(unless (executable-find program)
|
(unless (executable-find program)
|
||||||
(message "The program 'style' isn't installed or can't be found.\nTry installing the 'diction' package for your OS or download the source from http://ftp.gnu.org/gnu/diction/"))
|
(message "The program 'style' isn't installed or can't be found.\nTry installing the 'diction' package for your OS or download the source from http://ftp.gnu.org/gnu/diction/"))
|
||||||
(eq 0 (condition-case nil
|
(eq 0 (condition-case nil
|
||||||
(call-process program)
|
(call-process program)
|
||||||
(error (message "The program 'style' test run exit abnormally."))))))
|
(error (message "The program 'style' test run exit abnormally."))))))
|
||||||
|
|
||||||
(defun smog-check-buffer ()
|
(defun smog-check-buffer ()
|
||||||
"Analyse the surface characteristics of a buffer."
|
"Analyse the surface characteristics of a buffer."
|
||||||
(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*"))
|
||||||
(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
|
||||||
(concat smog-command " " (shell-quote-argument smog-target))
|
(concat smog-command " " (shell-quote-argument smog-target))
|
||||||
smog-output)
|
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))
|
||||||
(if (buffer-modified-p smog-buffer)
|
(if (buffer-modified-p smog-buffer)
|
||||||
(insert (format
|
(insert (format
|
||||||
"\nChanges to the file '%s' have not been saved. Analysis may be inaccurate.\n\n"
|
"\nChanges to the file '%s' have not been saved. Analysis may be inaccurate.\n\n"
|
||||||
smog-target))
|
smog-target))
|
||||||
(insert (format "\n*Style analysis* of the file \[\[%s\]\[%s\]\] \n\n"
|
(insert (format "\n*Style analysis* of the file \[\[%s\]\[%s\]\] \n\n"
|
||||||
smog-target smog-buffer)))
|
smog-target smog-buffer)))
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(insert smog-reference)
|
(insert smog-reference)
|
||||||
(when (fboundp 'org-mode)
|
(when (fboundp 'org-mode)
|
||||||
(org-mode))
|
(org-mode))
|
||||||
(when (fboundp 'org-update-radio-target-regexp)
|
(when (fboundp 'org-update-radio-target-regexp)
|
||||||
(org-update-radio-target-regexp))))))
|
(org-update-radio-target-regexp))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun smog-check ()
|
(defun smog-check ()
|
||||||
|
@ -170,30 +181,30 @@ 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
|
||||||
(region-beginning)
|
(region-beginning)
|
||||||
(point-min)))
|
(point-min)))
|
||||||
;; end of either buffer or region
|
;; end of either buffer or region
|
||||||
(selection-end (if region-p
|
(selection-end (if region-p
|
||||||
(region-end)
|
(region-end)
|
||||||
(point-max))))
|
(point-max))))
|
||||||
;; run the shell command. synchronously.
|
;; run the shell command. synchronously.
|
||||||
(shell-command-on-region selection-start selection-end
|
(shell-command-on-region selection-start selection-end
|
||||||
(format "%s" smog-command) smog-output)
|
(format "%s" smog-command) 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))
|
||||||
(insert (format "\n*Style analysis* of %s*%s*\n\n"
|
(insert (format "\n*Style analysis* of %s*%s*\n\n"
|
||||||
(if region-p "the selected region of " "") smog-buffer))
|
(if region-p "the selected region of " "") smog-buffer))
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(insert smog-reference)
|
(insert smog-reference)
|
||||||
(when (fboundp 'org-mode)
|
(when (fboundp 'org-mode)
|
||||||
(org-mode))
|
(org-mode))
|
||||||
(when (fboundp 'org-update-radio-target-regexp)
|
(when (fboundp 'org-update-radio-target-regexp)
|
||||||
(org-update-radio-target-regexp))))))
|
(org-update-radio-target-regexp))))))
|
||||||
|
|
||||||
(provide 'smog)
|
(provide 'smog)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue