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.
This commit is contained in:
parent
296dadb14e
commit
20de61c833
2 changed files with 44 additions and 0 deletions
5
etc/NEWS
5
etc/NEWS
|
@ -84,6 +84,11 @@ command line when `initial-buffer-choice' is non-nil.
|
|||
|
||||
* Changes in Emacs 25.1
|
||||
|
||||
** New command `checkdoc-package-keywords' checks if the
|
||||
current package keywords are recognized. Set the new option
|
||||
`checkdoc-package-keywords-flag' to non-nil to make
|
||||
`checkdoc-current-buffer' call this function automatically.
|
||||
|
||||
** New function `checkdoc-file' checks for style errors.
|
||||
It's meant for use together with `compile':
|
||||
emacs -batch --eval "(checkdoc-file \"subr.el\")"
|
||||
|
|
|
@ -267,6 +267,11 @@ made in the style guide relating to order."
|
|||
:type 'boolean)
|
||||
;;;###autoload(put 'checkdoc-arguments-in-order-flag 'safe-local-variable #'booleanp)
|
||||
|
||||
(defcustom checkdoc-package-keywords-flag nil
|
||||
"Non-nil means warn if this file's package keywords are not recognized.
|
||||
Currently, all recognized keywords must be on `finder-known-keywords'."
|
||||
:type 'boolean)
|
||||
|
||||
(define-obsolete-variable-alias 'checkdoc-style-hooks
|
||||
'checkdoc-style-functions "24.3")
|
||||
(defvar checkdoc-style-functions nil
|
||||
|
@ -315,6 +320,7 @@ This should be set in an Emacs Lisp file's local variables."
|
|||
|
||||
;;;###autoload
|
||||
(defun checkdoc-list-of-strings-p (obj)
|
||||
"Return t when OBJ is a list of strings."
|
||||
;; this is a function so it might be shared by checkdoc-proper-noun-list
|
||||
;; and/or checkdoc-ispell-lisp-words in the future
|
||||
(and (listp obj)
|
||||
|
@ -866,6 +872,8 @@ otherwise stop after the first error."
|
|||
(checkdoc-start)
|
||||
(checkdoc-message-text)
|
||||
(checkdoc-rogue-spaces)
|
||||
(when checkdoc-package-keywords-flag
|
||||
(checkdoc-package-keywords))
|
||||
(not (called-interactively-p 'interactive))
|
||||
(if take-notes (checkdoc-show-diagnostics))
|
||||
(message "Checking buffer for style...Done."))))
|
||||
|
@ -2644,6 +2652,37 @@ function called to create the messages."
|
|||
(setq checkdoc-pending-errors nil)
|
||||
nil)))
|
||||
|
||||
(defun checkdoc-get-keywords ()
|
||||
"Return a list of package keywords for the current file."
|
||||
(require 'finder)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(when (re-search-forward "^;; Keywords: \\(.*\\)$" nil t)
|
||||
(split-string (match-string-no-properties 1) ", " t))))
|
||||
|
||||
;;;###autoload
|
||||
(defun checkdoc-package-keywords ()
|
||||
"Find package keywords that aren't in `finder-known-keywords'."
|
||||
(interactive)
|
||||
(let ((unrecognized-keys
|
||||
(cl-remove-if
|
||||
(lambda (x) (assoc (intern-soft x) finder-known-keywords))
|
||||
(checkdoc-get-keywords))))
|
||||
(if unrecognized-keys
|
||||
(let* ((checkdoc-autofix-flag 'never)
|
||||
(checkdoc-generate-compile-warnings-flag t))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(re-search-forward "^;; Keywords: \\(.*\\)$" nil t)
|
||||
(checkdoc-start-section "checkdoc-package-keywords")
|
||||
(checkdoc-create-error
|
||||
(concat "Unrecognized keywords: "
|
||||
(mapconcat #'identity unrecognized-keys ", "))
|
||||
(match-beginning 1) (match-end 1)))
|
||||
(checkdoc-show-diagnostics))
|
||||
(when (called-interactively-p 'any)
|
||||
(message "No Package Keyword Errors.")))))
|
||||
|
||||
(custom-add-option 'emacs-lisp-mode-hook 'checkdoc-minor-mode)
|
||||
|
||||
(provide 'checkdoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue