Commit 20de61c8 authored by Oleh Krehel's avatar Oleh Krehel
Browse files

Add new command checkdoc-package-keywords

* lisp/emacs-lisp/checkdoc.el (checkdoc-package-keywords-flag): New
(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.
parent 296dadb1
......@@ -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."
(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."
(when checkdoc-package-keywords-flag
(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)
(defun checkdoc-get-keywords ()
"Return a list of package keywords for the current file."
(require 'finder)
(goto-char (point-min))
(when (re-search-forward "^;; Keywords: \\(.*\\)$" nil t)
(split-string (match-string-no-properties 1) ", " t))))
(defun checkdoc-package-keywords ()
"Find package keywords that aren't in `finder-known-keywords'."
(let ((unrecognized-keys
(lambda (x) (assoc (intern-soft x) finder-known-keywords))
(if unrecognized-keys
(let* ((checkdoc-autofix-flag 'never)
(checkdoc-generate-compile-warnings-flag t))
(goto-char (point-min))
(re-search-forward "^;; Keywords: \\(.*\\)$" nil t)
(checkdoc-start-section "checkdoc-package-keywords")
(concat "Unrecognized keywords: "
(mapconcat #'identity unrecognized-keys ", "))
(match-beginning 1) (match-end 1)))
(when (called-interactively-p 'any)
(message "No Package Keyword Errors.")))))
(custom-add-option 'emacs-lisp-mode-hook 'checkdoc-minor-mode)
(provide 'checkdoc)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment