aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1999-11-26 17:33:36 +0000
committerRichard M. Stallman1999-11-26 17:33:36 +0000
commit995e028a96412b40adb92200ecd33dfcf784f448 (patch)
treec59f735f575fcfd2c398dc0fcb2c33cdd3313c7e
parent88a26eb4135ae3ba887a6094144991d074f1e563 (diff)
downloademacs-995e028a96412b40adb92200ecd33dfcf784f448.tar.gz
emacs-995e028a96412b40adb92200ecd33dfcf784f448.zip
(checkdoc-this-string-valid-engine):
Improve messages for capitalization of arg names, for flag variables, for t and nil, for imperatives. Call them imperatives rather than infinitives sans "to". (checkdoc-common-verbs-wrong-voice): Add "moves". (checkdoc-message-text-engine): Improve messages for y-or-n-p. (checkdoc-file-comments-engine): Don't convert comments from 3-semicolon to 2-semicolon. That is a matter of style. (checkdoc-triple-semi-comment-check-flag): Variable deleted. (checkdoc-comments): Don't bind that variable.
-rw-r--r--lisp/emacs-lisp/checkdoc.el82
1 files changed, 17 insertions, 65 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el
index 102e6850a1e..62d4566124d 100644
--- a/lisp/emacs-lisp/checkdoc.el
+++ b/lisp/emacs-lisp/checkdoc.el
@@ -233,19 +233,6 @@ it indicates that a modifying clause follows."
233 :group 'checkdoc 233 :group 'checkdoc
234 :type 'boolean) 234 :type 'boolean)
235 235
236(defcustom checkdoc-triple-semi-comment-check-flag t
237 "*Non-nil means to check for multiple adjacent occurrences of ;;; comments.
238According to the style of Emacs code in the Lisp libraries, a block
239comment can look like this:
240;;; Title
241;; text
242;; text
243But when inside a function, code can be commented out using the ;;;
244construct for all lines. When this variable is nil, the ;;; construct
245is ignored regardless of its location in the code."
246 :group 'checkdoc
247 :type 'boolean)
248
249(defcustom checkdoc-spellcheck-documentation-flag nil 236(defcustom checkdoc-spellcheck-documentation-flag nil
250 "*Non-nil means run Ispell on text based on value. 237 "*Non-nil means run Ispell on text based on value.
251This is automatically set to nil if Ispell does not exist on your 238This is automatically set to nil if Ispell does not exist on your
@@ -382,6 +369,7 @@ This should be set in an Emacs Lisp file's local variables."
382 ("makes" . "make") 369 ("makes" . "make")
383 ("marks" . "mark") 370 ("marks" . "mark")
384 ("matches" . "match") 371 ("matches" . "match")
372 ("moves" . "move")
385 ("notifies" . "notify") 373 ("notifies" . "notify")
386 ("offers" . "offer") 374 ("offers" . "offer")
387 ("parses" . "parse") 375 ("parses" . "parse")
@@ -924,9 +912,6 @@ if there is one."
924 (member checkdoc-spellcheck-documentation-flag 912 (member checkdoc-spellcheck-documentation-flag
925 '(buffer t))) 913 '(buffer t)))
926 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag)) 914 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag))
927 ;; This is just irritating when taking notes.
928 (checkdoc-triple-semi-comment-check-flag
929 (if take-notes nil checkdoc-triple-semi-comment-check-flag))
930 (e (checkdoc-file-comments-engine)) 915 (e (checkdoc-file-comments-engine))
931 (checkdoc-generate-compile-warnings-flag 916 (checkdoc-generate-compile-warnings-flag
932 (or take-notes checkdoc-generate-compile-warnings-flag))) 917 (or take-notes checkdoc-generate-compile-warnings-flag)))
@@ -1623,7 +1608,7 @@ function,command,variable,option or symbol." ms1))))))
1623 (if (and (string-match "-flag$" (car fp)) 1608 (if (and (string-match "-flag$" (car fp))
1624 (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+"))) 1609 (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+")))
1625 (checkdoc-create-error 1610 (checkdoc-create-error
1626 "Flag variable doc strings should start: Non-nil means" 1611 "Flag variable doc strings should usually start: Non-nil means"
1627 s (marker-position e) t)) 1612 s (marker-position e) t))
1628 ;; If the doc string starts with "Non-nil means" 1613 ;; If the doc string starts with "Non-nil means"
1629 (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+") 1614 (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+")
@@ -1638,7 +1623,7 @@ function,command,variable,option or symbol." ms1))))))
1638 (concat "\\<" (regexp-quote (car fp)) "\\>") 1623 (concat "\\<" (regexp-quote (car fp)) "\\>")
1639 (concat (car fp) "-flag"))) 1624 (concat (car fp) "-flag")))
1640 (checkdoc-create-error 1625 (checkdoc-create-error
1641 "Flag variables should end in `-flag'" s 1626 "Flag variable names should normally end in `-flag'" s
1642 (marker-position e)))) 1627 (marker-position e))))
1643 ;; Done with variables 1628 ;; Done with variables
1644 )) 1629 ))
@@ -1689,7 +1674,7 @@ function,command,variable,option or symbol." ms1))))))
1689 (if (checkdoc-autofix-ask-replace 1674 (if (checkdoc-autofix-ask-replace
1690 (match-beginning 1) (match-end 1) 1675 (match-beginning 1) (match-end 1)
1691 (format 1676 (format
1692 "Argument `%s' should appear as `%s'. Fix? " 1677 "If this is the argument `%s', it should appear as %s. Fix? "
1693 (car args) (upcase (car args))) 1678 (car args) (upcase (car args)))
1694 (upcase (car args)) t) 1679 (upcase (car args)) t)
1695 (setq found (match-beginning 1)))))) 1680 (setq found (match-beginning 1))))))
@@ -1715,7 +1700,7 @@ function,command,variable,option or symbol." ms1))))))
1715 nil) 1700 nil)
1716 (checkdoc-create-error 1701 (checkdoc-create-error
1717 (format 1702 (format
1718 "Argument `%s' should appear (as `%s') in the doc string" 1703 "Argument `%s' should appear (as %s) in the doc string"
1719 (car args) (upcase (car args))) 1704 (car args) (upcase (car args)))
1720 s (marker-position e))) 1705 s (marker-position e)))
1721 (if (or (and order (eq order 'yes)) 1706 (if (or (and order (eq order 'yes))
@@ -1725,8 +1710,8 @@ function,command,variable,option or symbol." ms1))))))
1725 "Arguments occur in the doc string out of order" 1710 "Arguments occur in the doc string out of order"
1726 s (marker-position e) t))))) 1711 s (marker-position e) t)))))
1727 ;; * For consistency, phrase the verb in the first sentence of a 1712 ;; * For consistency, phrase the verb in the first sentence of a
1728 ;; documentation string for functions as an infinitive with 1713 ;; documentation string for functions as an imperative.
1729 ;; "to" omitted. For instance, use `Return the cons of A and 1714 ;; For instance, use `Return the cons of A and
1730 ;; B.' in preference to `Returns the cons of A and B.' 1715 ;; B.' in preference to `Returns the cons of A and B.'
1731 ;; Usually it looks good to do likewise for the rest of the 1716 ;; Usually it looks good to do likewise for the rest of the
1732 ;; first paragraph. Subsequent paragraphs usually look better 1717 ;; first paragraph. Subsequent paragraphs usually look better
@@ -1762,15 +1747,15 @@ function,command,variable,option or symbol." ms1))))))
1762 (cdr rs))))) 1747 (cdr rs)))))
1763 (if (checkdoc-autofix-ask-replace 1748 (if (checkdoc-autofix-ask-replace
1764 (match-beginning 1) (match-end 1) 1749 (match-beginning 1) (match-end 1)
1765 (format "Use the infinitive for `%s'. \ 1750 (format "Use the imperative for \"%s\". \
1766Replace with `%s'? " original replace) 1751Replace with \"%s\"? " original replace)
1767 replace t) 1752 replace t)
1768 (setq rs nil))) 1753 (setq rs nil)))
1769 (if rs 1754 (if rs
1770 ;; there was a match, but no replace 1755 ;; there was a match, but no replace
1771 (checkdoc-create-error 1756 (checkdoc-create-error
1772 (format 1757 (format
1773 "Infinitive `%s' should be replaced with `%s'" 1758 "Probably \"%s\" should be imperative \"%s\""
1774 original replace) 1759 original replace)
1775 (match-beginning 1) (match-end 1)))))) 1760 (match-beginning 1) (match-end 1))))))
1776 ;; Done with functions 1761 ;; Done with functions
@@ -1823,7 +1808,7 @@ Replace with `%s'? " original replace)
1823 (match-string 2) t) 1808 (match-string 2) t)
1824 nil 1809 nil
1825 (checkdoc-create-error 1810 (checkdoc-create-error
1826 "Symbols t and nil should not appear in `quotes'" 1811 "Symbols t and nil should not appear in `...' quotes"
1827 (match-beginning 1) (match-end 1))))) 1812 (match-beginning 1) (match-end 1)))))
1828 ;; Here is some basic sentence formatting 1813 ;; Here is some basic sentence formatting
1829 (checkdoc-sentencespace-region-engine (point) e) 1814 (checkdoc-sentencespace-region-engine (point) e)
@@ -2315,39 +2300,6 @@ Code:, and others referenced in the style guide."
2315 (1- (point-max)) (point-max))))) 2300 (1- (point-max)) (point-max)))))
2316 err)) 2301 err))
2317 ;; The below checks will not return errors if the user says NO 2302 ;; The below checks will not return errors if the user says NO
2318
2319 ;; Ok, now let's look for multiple occurrences of ;;;, and offer
2320 ;; to remove the extra ";" if applicable. This pre-supposes
2321 ;; that the user has semiautomatic fixing on to be useful.
2322
2323 ;; In the info node (elisp)Library Headers a header is three ;
2324 ;; (the header) followed by text of only two ;
2325 ;; In (elisp)Comment Tips, however it says this:
2326 ;; * Another use for triple-semicolon comments is for commenting out
2327 ;; lines within a function. We use triple-semicolons for this
2328 ;; precisely so that they remain at the left margin.
2329 (let ((msg nil))
2330 (goto-char (point-min))
2331 (while (and checkdoc-triple-semi-comment-check-flag
2332 (not msg) (re-search-forward "^;;;[^;]" nil t))
2333 ;; We found a triple, let's check all following lines.
2334 (if (not (bolp)) (progn (beginning-of-line) (forward-line 1)))
2335 (let ((complex-replace t)
2336 (dont-replace nil))
2337 (while (looking-at ";;\\(;\\)[^;#]")
2338 (if (and (not dont-replace)
2339 (checkdoc-outside-major-sexp) ;in code is ok.
2340 (checkdoc-autofix-ask-replace
2341 (match-beginning 1) (match-end 1)
2342 "Multiple occurrences of ;;; found. Use ;; instead? "
2343 "" complex-replace))
2344 ;; Learn that, yea, the user did want to do this a
2345 ;; whole bunch of times.
2346 (setq complex-replace nil)
2347 ;; In this case, skip all this crap
2348 (setq dont-replace t))
2349 (beginning-of-line)
2350 (forward-line 1)))))
2351 2303
2352 ;; Let's spellcheck the commentary section. This is the only 2304 ;; Let's spellcheck the commentary section. This is the only
2353 ;; section that is easy to pick out, and it is also the most 2305 ;; section that is easy to pick out, and it is also the most
@@ -2496,22 +2448,22 @@ Argument TYPE specifies the type of question, such as `error or `y-or-n-p."
2496 ;; If we see a ?, then replace with "? ". 2448 ;; If we see a ?, then replace with "? ".
2497 (if (checkdoc-autofix-ask-replace 2449 (if (checkdoc-autofix-ask-replace
2498 (match-beginning 0) (match-end 0) 2450 (match-beginning 0) (match-end 0)
2499 "y-or-n-p text should end with \"? \". Fix? " 2451 "`y-or-n-p' argument should end with \"? \". Fix? "
2500 "? " t) 2452 "? " t)
2501 nil 2453 nil
2502 (checkdoc-create-error 2454 (checkdoc-create-error
2503 "y-or-n-p text should end with \"? \"" 2455 "`y-or-n-p' argument should end with \"? \""
2504 (match-beginning 0) (match-end 0))) 2456 (match-beginning 0) (match-end 0)))
2505 (if (save-excursion (forward-sexp 1) 2457 (if (save-excursion (forward-sexp 1)
2506 (forward-char -2) 2458 (forward-char -2)
2507 (looking-at " ")) 2459 (looking-at " "))
2508 (if (checkdoc-autofix-ask-replace 2460 (if (checkdoc-autofix-ask-replace
2509 (match-beginning 0) (match-end 0) 2461 (match-beginning 0) (match-end 0)
2510 "y-or-n-p text should end with \"? \". Fix? " 2462 "`y-or-n-p' argument should end with \"? \". Fix? "
2511 "? " t) 2463 "? " t)
2512 nil 2464 nil
2513 (checkdoc-create-error 2465 (checkdoc-create-error
2514 "y-or-n-p text should end with \"? \"" 2466 "`y-or-n-p' argument should end with \"? \""
2515 (match-beginning 0) (match-end 0))) 2467 (match-beginning 0) (match-end 0)))
2516 (if (and ;; if this isn't true, we have a problem. 2468 (if (and ;; if this isn't true, we have a problem.
2517 (save-excursion (forward-sexp 1) 2469 (save-excursion (forward-sexp 1)
@@ -2519,11 +2471,11 @@ Argument TYPE specifies the type of question, such as `error or `y-or-n-p."
2519 (looking-at "\"")) 2471 (looking-at "\""))
2520 (checkdoc-autofix-ask-replace 2472 (checkdoc-autofix-ask-replace
2521 (match-beginning 0) (match-end 0) 2473 (match-beginning 0) (match-end 0)
2522 "y-or-n-p text should end with \"? \". Fix? " 2474 "`y-or-n-p' argument should end with \"? \". Fix? "
2523 "? \"" t)) 2475 "? \"" t))
2524 nil 2476 nil
2525 (checkdoc-create-error 2477 (checkdoc-create-error
2526 "y-or-n-p text should end with \"? \"" 2478 "`y-or-n-p' argument should end with \"? \""
2527 (match-beginning 0) (match-end 0))))))) 2479 (match-beginning 0) (match-end 0)))))))
2528 ;; Now, let's just run the spell checker on this guy. 2480 ;; Now, let's just run the spell checker on this guy.
2529 (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1) 2481 (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1)