diff options
| author | Oleh Krehel | 2015-06-08 16:41:00 +0200 |
|---|---|---|
| committer | Oleh Krehel | 2015-06-08 16:54:51 +0200 |
| commit | 20de61c833d4c975dc1ed3062d8de75df8b5cd93 (patch) | |
| tree | 29e05d2e77443f133e3203af4e927f5bd1822301 | |
| parent | 296dadb14e19926de1fc5e0015cb8d4f10f9547a (diff) | |
| download | emacs-20de61c833d4c975dc1ed3062d8de75df8b5cd93.tar.gz emacs-20de61c833d4c975dc1ed3062d8de75df8b5cd93.zip | |
Add new command checkdoc-package-keywords
* lisp/emacs-lisp/checkdoc.el (checkdoc-package-keywords-flag): New
defcustom.
(checkdoc-list-of-strings-p): Add doc.
(checkdoc-current-buffer): When `checkdoc-package-keywords-flag' is
non-nil, call `checkdoc-package-keywords'.
(checkdoc-get-keywords): New defun.
(checkdoc-package-keywords): New command. Warns if the current file
has package.el-style keywords that aren't in `finder-known-keywords'.
* etc/NEWS: Add entry.
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 39 |
2 files changed, 44 insertions, 0 deletions
| @@ -84,6 +84,11 @@ command line when `initial-buffer-choice' is non-nil. | |||
| 84 | 84 | ||
| 85 | * Changes in Emacs 25.1 | 85 | * Changes in Emacs 25.1 |
| 86 | 86 | ||
| 87 | ** New command `checkdoc-package-keywords' checks if the | ||
| 88 | current package keywords are recognized. Set the new option | ||
| 89 | `checkdoc-package-keywords-flag' to non-nil to make | ||
| 90 | `checkdoc-current-buffer' call this function automatically. | ||
| 91 | |||
| 87 | ** New function `checkdoc-file' checks for style errors. | 92 | ** New function `checkdoc-file' checks for style errors. |
| 88 | It's meant for use together with `compile': | 93 | It's meant for use together with `compile': |
| 89 | emacs -batch --eval "(checkdoc-file \"subr.el\")" | 94 | emacs -batch --eval "(checkdoc-file \"subr.el\")" |
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 869ae431950..b20e4f1e2df 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -267,6 +267,11 @@ made in the style guide relating to order." | |||
| 267 | :type 'boolean) | 267 | :type 'boolean) |
| 268 | ;;;###autoload(put 'checkdoc-arguments-in-order-flag 'safe-local-variable #'booleanp) | 268 | ;;;###autoload(put 'checkdoc-arguments-in-order-flag 'safe-local-variable #'booleanp) |
| 269 | 269 | ||
| 270 | (defcustom checkdoc-package-keywords-flag nil | ||
| 271 | "Non-nil means warn if this file's package keywords are not recognized. | ||
| 272 | Currently, all recognized keywords must be on `finder-known-keywords'." | ||
| 273 | :type 'boolean) | ||
| 274 | |||
| 270 | (define-obsolete-variable-alias 'checkdoc-style-hooks | 275 | (define-obsolete-variable-alias 'checkdoc-style-hooks |
| 271 | 'checkdoc-style-functions "24.3") | 276 | 'checkdoc-style-functions "24.3") |
| 272 | (defvar checkdoc-style-functions nil | 277 | (defvar checkdoc-style-functions nil |
| @@ -315,6 +320,7 @@ This should be set in an Emacs Lisp file's local variables." | |||
| 315 | 320 | ||
| 316 | ;;;###autoload | 321 | ;;;###autoload |
| 317 | (defun checkdoc-list-of-strings-p (obj) | 322 | (defun checkdoc-list-of-strings-p (obj) |
| 323 | "Return t when OBJ is a list of strings." | ||
| 318 | ;; this is a function so it might be shared by checkdoc-proper-noun-list | 324 | ;; this is a function so it might be shared by checkdoc-proper-noun-list |
| 319 | ;; and/or checkdoc-ispell-lisp-words in the future | 325 | ;; and/or checkdoc-ispell-lisp-words in the future |
| 320 | (and (listp obj) | 326 | (and (listp obj) |
| @@ -866,6 +872,8 @@ otherwise stop after the first error." | |||
| 866 | (checkdoc-start) | 872 | (checkdoc-start) |
| 867 | (checkdoc-message-text) | 873 | (checkdoc-message-text) |
| 868 | (checkdoc-rogue-spaces) | 874 | (checkdoc-rogue-spaces) |
| 875 | (when checkdoc-package-keywords-flag | ||
| 876 | (checkdoc-package-keywords)) | ||
| 869 | (not (called-interactively-p 'interactive)) | 877 | (not (called-interactively-p 'interactive)) |
| 870 | (if take-notes (checkdoc-show-diagnostics)) | 878 | (if take-notes (checkdoc-show-diagnostics)) |
| 871 | (message "Checking buffer for style...Done.")))) | 879 | (message "Checking buffer for style...Done.")))) |
| @@ -2644,6 +2652,37 @@ function called to create the messages." | |||
| 2644 | (setq checkdoc-pending-errors nil) | 2652 | (setq checkdoc-pending-errors nil) |
| 2645 | nil))) | 2653 | nil))) |
| 2646 | 2654 | ||
| 2655 | (defun checkdoc-get-keywords () | ||
| 2656 | "Return a list of package keywords for the current file." | ||
| 2657 | (require 'finder) | ||
| 2658 | (save-excursion | ||
| 2659 | (goto-char (point-min)) | ||
| 2660 | (when (re-search-forward "^;; Keywords: \\(.*\\)$" nil t) | ||
| 2661 | (split-string (match-string-no-properties 1) ", " t)))) | ||
| 2662 | |||
| 2663 | ;;;###autoload | ||
| 2664 | (defun checkdoc-package-keywords () | ||
| 2665 | "Find package keywords that aren't in `finder-known-keywords'." | ||
| 2666 | (interactive) | ||
| 2667 | (let ((unrecognized-keys | ||
| 2668 | (cl-remove-if | ||
| 2669 | (lambda (x) (assoc (intern-soft x) finder-known-keywords)) | ||
| 2670 | (checkdoc-get-keywords)))) | ||
| 2671 | (if unrecognized-keys | ||
| 2672 | (let* ((checkdoc-autofix-flag 'never) | ||
| 2673 | (checkdoc-generate-compile-warnings-flag t)) | ||
| 2674 | (save-excursion | ||
| 2675 | (goto-char (point-min)) | ||
| 2676 | (re-search-forward "^;; Keywords: \\(.*\\)$" nil t) | ||
| 2677 | (checkdoc-start-section "checkdoc-package-keywords") | ||
| 2678 | (checkdoc-create-error | ||
| 2679 | (concat "Unrecognized keywords: " | ||
| 2680 | (mapconcat #'identity unrecognized-keys ", ")) | ||
| 2681 | (match-beginning 1) (match-end 1))) | ||
| 2682 | (checkdoc-show-diagnostics)) | ||
| 2683 | (when (called-interactively-p 'any) | ||
| 2684 | (message "No Package Keyword Errors."))))) | ||
| 2685 | |||
| 2647 | (custom-add-option 'emacs-lisp-mode-hook 'checkdoc-minor-mode) | 2686 | (custom-add-option 'emacs-lisp-mode-hook 'checkdoc-minor-mode) |
| 2648 | 2687 | ||
| 2649 | (provide 'checkdoc) | 2688 | (provide 'checkdoc) |