]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/checkdoc.el
; Merge from origin/emacs-25
[gnu-emacs] / lisp / emacs-lisp / checkdoc.el
index 14c2a1b872e4b1a8b0d549f8112674f39eaf705c..3a81adeb6a6dd0058690c56b8e17af5fc941d4f5 100644 (file)
@@ -1,6 +1,6 @@
 ;;; checkdoc.el --- check documentation strings for style requirements  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1997-1998, 2001-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1997-1998, 2001-2016 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Version: 0.6.2
@@ -270,6 +270,7 @@ made in the style guide relating to order."
 (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'."
+  :version "25.1"
   :type 'boolean)
 
 (define-obsolete-variable-alias 'checkdoc-style-hooks
@@ -1419,7 +1420,7 @@ regexp short cuts work.  FP is the function defun information."
        (when (re-search-forward "^(" e t)
         (if (checkdoc-autofix-ask-replace (match-beginning 0)
                                           (match-end 0)
-                                          "Escape this '('? "
+                                          (format-message "Escape this `('? ")
                                           "\\(")
             nil
           (checkdoc-create-error
@@ -1579,7 +1580,7 @@ mouse-[0-3]\\)\\)\\>"))
             (if (and sym (boundp sym) (fboundp sym)
                      (save-excursion
                        (goto-char mb)
-                       (forward-word -1)
+                       (forward-word-strictly -1)
                        (not (looking-at
                              "variable\\|option\\|function\\|command\\|symbol"))))
                 (if (checkdoc-autofix-ask-replace
@@ -1595,7 +1596,7 @@ mouse-[0-3]\\)\\)\\>"))
                             nil t nil nil "variable")))
                       (goto-char (1- mb))
                       (insert disambiguate " ")
-                      (forward-word 1))
+                      (forward-word-strictly 1))
                   (setq ret
                         (format "Disambiguate %s by preceding w/ \
 function,command,variable,option or symbol." ms1))))))
@@ -1637,6 +1638,17 @@ function,command,variable,option or symbol." ms1))))))
             ;; * If a user option variable records a true-or-false
             ;;   condition, give it a name that ends in `-flag'.
 
+            ;; "True ..." should be "Non-nil ..."
+            (when (looking-at "\"\\*?\\(True\\)\\b")
+               (if (checkdoc-autofix-ask-replace
+                    (match-beginning 1) (match-end 1)
+                    "Say \"Non-nil\" instead of \"True\"? "
+                    "Non-nil")
+                   nil
+                 (checkdoc-create-error
+                  "\"True\" should usually be \"Non-nil\""
+                  (match-beginning 1) (match-end 1))))
+
             ;; If the variable has -flag in the name, make sure
             (if (and (string-match "-flag$" (car fp))
                      (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+")))
@@ -1663,7 +1675,7 @@ function,command,variable,option or symbol." ms1))))))
             ;;           (concat "\\<" (regexp-quote (car fp)) "\\>")
             ;;           newname))
             ;;         (checkdoc-create-error
-            ;;          "Flag variable names should normally end in ‘-flag’" s
+            ;;          "Flag variable names should normally end in `-flag'" s
             ;;          (marker-position e)))))
             ;; Done with variables
             ))
@@ -1714,8 +1726,8 @@ function,command,variable,option or symbol." ms1))))))
                                e t))
                             (if (checkdoc-autofix-ask-replace
                                  (match-beginning 1) (match-end 1)
-                                 (format
-                                  "If this is the argument ‘%s’, it should appear as %s.  Fix? "
+                                 (format-message
+                                  "If this is the argument `%s', it should appear as %s.  Fix? "
                                   (car args) (upcase (car args)))
                                  (upcase (car args)) t)
                                 (setq found (match-beginning 1))))))
@@ -1740,8 +1752,8 @@ function,command,variable,option or symbol." ms1))))))
                             (insert "."))
                         nil)
                     (checkdoc-create-error
-                     (format
-                      "Argument ‘%s’ should appear (as %s) in the doc string"
+                     (format-message
+                      "Argument `%s' should appear (as %s) in the doc string"
                       (car args) (upcase (car args)))
                      s (marker-position e)))
                 (if (or (and order (eq order 'yes))
@@ -1797,6 +1809,16 @@ Replace with \"%s\"? " original replace)
                            "Probably \"%s\" should be imperative \"%s\""
                            original replace)
                           (match-beginning 1) (match-end 1))))))
+            ;; "Return true ..." should be "Return non-nil ..."
+            (when (looking-at "\"Return \\(true\\)\\b")
+               (if (checkdoc-autofix-ask-replace
+                    (match-beginning 1) (match-end 1)
+                    "Say \"non-nil\" instead of \"true\"? "
+                    "non-nil")
+                   nil
+                 (checkdoc-create-error
+                  "\"true\" should usually be \"non-nil\""
+                  (match-beginning 1) (match-end 1))))
             ;; Done with functions
             )))
      ;;* When a documentation string refers to a Lisp symbol, write it as
@@ -1824,16 +1846,16 @@ Replace with \"%s\"? " original replace)
                    (setq found (intern-soft ms))
                    (or (boundp found) (fboundp found)))
               (progn
-                (setq msg (format "Add quotes around Lisp symbol ‘%s’? "
-                                  ms))
+                (setq msg (format-message
+                            "Add quotes around Lisp symbol `%s'? " ms))
                 (if (checkdoc-autofix-ask-replace
                      (match-beginning 1) (+ (match-beginning 1)
                                             (length ms))
-                     msg (concat "‘" ms "’") t)
+                     msg (format-message "`%s'" ms) t)
                     (setq msg nil)
                   (setq msg
-                        (format "Lisp symbol ‘%s’ should appear in quotes"
-                                ms))))))
+                        (format-message
+                          "Lisp symbol `%s' should appear in quotes" ms))))))
         (if msg
             (checkdoc-create-error msg (match-beginning 1)
                                    (+ (match-beginning 1)
@@ -1849,7 +1871,7 @@ Replace with \"%s\"? " original replace)
                (match-string 2) t)
               nil
             (checkdoc-create-error
-             "Symbols t and nil should not appear in ‘...’ quotes"
+             "Symbols t and nil should not appear in single quotes"
              (match-beginning 1) (match-end 1)))))
      ;; Here is some basic sentence formatting
      (checkdoc-sentencespace-region-engine (point) e)
@@ -1954,7 +1976,7 @@ from the comment."
   "Return non-nil if the current point is in a code fragment.
 A code fragment is identified by an open parenthesis followed by a
 symbol which is a valid function or a word in all CAPS, or a parenthesis
-that is quoted with the ' character.  Only the region from START to LIMIT
+that is quoted with the \\=' character.  Only the region from START to LIMIT
 is allowed while searching for the bounding parenthesis."
   (save-match-data
     (save-restriction
@@ -2487,22 +2509,24 @@ Argument TYPE specifies the type of question, such as `error' or `y-or-n-p'."
               ;; If we see a ?, then replace with "? ".
               (if (checkdoc-autofix-ask-replace
                    (match-beginning 0) (match-end 0)
-                   "‘y-or-n-p’ argument should end with \"? \".  Fix? "
+                    (format-message
+                     "`y-or-n-p' argument should end with \"? \".  Fix? ")
                    "? " t)
                   nil
                 (checkdoc-create-error
-                 "‘y-or-n-p’ argument should end with \"? \""
+                 "`y-or-n-p' argument should end with \"? \""
                  (match-beginning 0) (match-end 0)))
             (if (save-excursion (forward-sexp 1)
                                 (forward-char -2)
                                 (looking-at " "))
                 (if (checkdoc-autofix-ask-replace
                      (match-beginning 0) (match-end 0)
-                     "‘y-or-n-p’ argument should end with \"? \".  Fix? "
+                      (format-message
+                       "`y-or-n-p' argument should end with \"? \".  Fix? ")
                      "? " t)
                     nil
                   (checkdoc-create-error
-                   "‘y-or-n-p’ argument should end with \"? \""
+                   "`y-or-n-p' argument should end with \"? \""
                    (match-beginning 0) (match-end 0)))
               (if (and ;; if this isn't true, we have a problem.
                    (save-excursion (forward-sexp 1)
@@ -2510,11 +2534,12 @@ Argument TYPE specifies the type of question, such as `error' or `y-or-n-p'."
                                    (looking-at "\""))
                    (checkdoc-autofix-ask-replace
                     (match-beginning 0) (match-end 0)
-                    "‘y-or-n-p’ argument should end with \"? \".  Fix? "
+                     (format-message
+                      "`y-or-n-p' argument should end with \"? \".  Fix? ")
                     "? \"" t))
                   nil
                 (checkdoc-create-error
-                 "‘y-or-n-p’ argument should end with \"? \""
+                 "`y-or-n-p' argument should end with \"? \""
                  (match-beginning 0) (match-end 0)))))))
      ;; Now, let's just run the spell checker on this guy.
      (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1)