diff options
Diffstat (limited to 'lisp/emacs-lisp/checkdoc.el')
-rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 73 |
1 files changed, 50 insertions, 23 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 00cc7777e1a..e10ea736cd2 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el @@ -304,13 +304,22 @@ variable `checkdoc-common-verbs-wrong-voice' if you wish to add your own." Do not set this by hand, use a function like `checkdoc-current-buffer' with a universal argument.") -(defcustom checkdoc-symbol-words nil +(defcustom checkdoc-symbol-words '("byte-code" "command-line" "top-level") "A list of symbol names (strings) which also happen to make good words. These words are ignored when unquoted symbols are searched for. This should be set in an Emacs Lisp file's local variables." - :type '(repeat (symbol :tag "Word"))) + :type '(repeat (string :tag "Word")) + :version "28.1") ;;;###autoload(put 'checkdoc-symbol-words 'safe-local-variable #'checkdoc-list-of-strings-p) +(defcustom checkdoc-column-zero-backslash-before-paren t + "Non-nil means to warn if there is no '\\' before '(' in column zero. +This backslash is no longer needed on Emacs 27.1 or later. + +See Info node `(elisp) Documentation Tips' for background." + :type 'boolean + :version "28.1") + ;;;###autoload (defun checkdoc-list-of-strings-p (obj) "Return t when OBJ is a list of strings." @@ -320,7 +329,7 @@ This should be set in an Emacs Lisp file's local variables." (not (memq nil (mapcar #'stringp obj))))) (defvar checkdoc-proper-noun-list - '("ispell" "xemacs" "emacs" "lisp") + '("ispell" "emacs" "lisp") "List of words (not capitalized) which should be capitalized.") (defvar checkdoc-proper-noun-regexp @@ -1402,16 +1411,17 @@ buffer, otherwise stop after the first error." (match-beginning 1) (match-end 1))))) ;; * Check for '(' in column 0. - (save-excursion - (when (re-search-forward "^(" e t) - (if (checkdoc-autofix-ask-replace (match-beginning 0) - (match-end 0) - (format-message "Escape this `('? ") - "\\(") - nil - (checkdoc-create-error - "Open parenthesis in column 0 should be escaped" - (match-beginning 0) (match-end 0))))) + (when checkdoc-column-zero-backslash-before-paren + (save-excursion + (when (re-search-forward "^(" e t) + (if (checkdoc-autofix-ask-replace (match-beginning 0) + (match-end 0) + (format-message "Escape this `('? ") + "\\(") + nil + (checkdoc-create-error + "Open parenthesis in column 0 should be escaped" + (match-beginning 0) (match-end 0)))))) ;; * Do not start or end a documentation string with whitespace. (let (start end) (if (or (if (looking-at "\"\\([ \t\n]+\\)") @@ -1998,6 +2008,32 @@ The text checked is between START and LIMIT." (setq c (1+ c))) (and (< 0 c) (= (% c 2) 0)))))) +(defun checkdoc-in-abbreviation-p (begin) + "Return non-nil if point is at an abbreviation. +Examples of abbreviations handled: \"e.g.\", \"i.e.\", \"cf.\"." + (save-excursion + (goto-char begin) + (condition-case nil + (progn + (forward-sexp -1) + ;; Piece of an abbreviation. + (looking-at + (rx (or letter ; single letter, as in "a." + (seq + ;; There might exist an escaped parenthesis, as + ;; this is often used in docstrings. In this + ;; case, `forward-sexp' will have skipped over it, + ;; so we need to skip it here too. + (? "\\(") + ;; The abbreviations: + (or (seq (any "cC") "f") ; cf. + (seq (any "eE") ".g") ; e.g. + (seq (any "iI") "." (any "eE")))) ; i.e. + "etc" ; etc. + "vs") ; vs. + "."))) + (error t)))) + (defun checkdoc-proper-noun-region-engine (begin end) "Check all text between BEGIN and END for lower case proper nouns. These are Emacs centric proper nouns which should be capitalized for @@ -2060,16 +2096,7 @@ If the offending word is in a piece of quoted text, then it is skipped." (e (match-end 1))) (unless (or (checkdoc-in-sample-code-p begin end) (checkdoc-in-example-string-p begin end) - (save-excursion - (goto-char b) - (condition-case nil - (progn - (forward-sexp -1) - ;; piece of an abbreviation - ;; FIXME etc - (looking-at - "\\([a-zA-Z]\\|[iI]\\.?e\\|[eE]\\.?g\\|[cC]f\\)\\.")) - (error t)))) + (checkdoc-in-abbreviation-p b)) (if (checkdoc-autofix-ask-replace b e "There should be two spaces after a period. Fix? " |