[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 20de61c: Add new command checkdoc-package-keywords
From: |
Oleh Krehel |
Subject: |
[Emacs-diffs] master 20de61c: Add new command checkdoc-package-keywords |
Date: |
Mon, 08 Jun 2015 15:02:16 +0000 |
branch: master
commit 20de61c833d4c975dc1ed3062d8de75df8b5cd93
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
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.
---
etc/NEWS | 5 +++++
lisp/emacs-lisp/checkdoc.el | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 51d0a5f4..571adad 100644
--- a/etc/NEWS
+++ b/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\")"
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 869ae43..b20e4f1 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."
: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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 20de61c: Add new command checkdoc-package-keywords,
Oleh Krehel <=