diff options
| author | Stefan Monnier | 2008-05-30 14:51:48 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-05-30 14:51:48 +0000 |
| commit | 145b63776b1beebd20faa429c278e2b7d9d0e260 (patch) | |
| tree | 5e8dd1f5504d7201119c6d697b4418d2b202501d | |
| parent | a266686a02fa5068dbf172fbef6726d28a47bfbe (diff) | |
| download | emacs-145b63776b1beebd20faa429c278e2b7d9d0e260.tar.gz emacs-145b63776b1beebd20faa429c278e2b7d9d0e260.zip | |
(checkdoc-this-string-valid-engine):
Don't encourage naming variables with "-flag".
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 39 |
2 files changed, 26 insertions, 18 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4dca3ca7d5b..59d10082e62 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-05-30 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): | ||
| 4 | Don't encourage naming variables with "-flag". | ||
| 5 | |||
| 1 | 2008-05-30 Glenn Morris <rgm@gnu.org> | 6 | 2008-05-30 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * Makefile.in (update-elclist): Hide the warning when it does not apply, | 8 | * Makefile.in (update-elclist): Hide the warning when it does not apply, |
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 8da93b7a327..de23111754a 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -1636,25 +1636,28 @@ function,command,variable,option or symbol." ms1)))))) | |||
| 1636 | (checkdoc-create-error | 1636 | (checkdoc-create-error |
| 1637 | "Flag variable doc strings should usually start: Non-nil means" | 1637 | "Flag variable doc strings should usually start: Non-nil means" |
| 1638 | s (marker-position e) t)) | 1638 | s (marker-position e) t)) |
| 1639 | ;; Don't rename variable to "foo-flag". This is unnecessary | ||
| 1640 | ;; and such names often end up inconvenient when the variable | ||
| 1641 | ;; is later expanded to non-boolean values. --Stef | ||
| 1639 | ;; If the doc string starts with "Non-nil means" | 1642 | ;; If the doc string starts with "Non-nil means" |
| 1640 | (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+") | 1643 | ;; (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+") |
| 1641 | (not (string-match "-flag$" (car fp)))) | 1644 | ;; (not (string-match "-flag$" (car fp)))) |
| 1642 | (let ((newname | 1645 | ;; (let ((newname |
| 1643 | (if (string-match "-p$" (car fp)) | 1646 | ;; (if (string-match "-p$" (car fp)) |
| 1644 | (concat (substring (car fp) 0 -2) "-flag") | 1647 | ;; (concat (substring (car fp) 0 -2) "-flag") |
| 1645 | (concat (car fp) "-flag")))) | 1648 | ;; (concat (car fp) "-flag")))) |
| 1646 | (if (checkdoc-y-or-n-p | 1649 | ;; (if (checkdoc-y-or-n-p |
| 1647 | (format | 1650 | ;; (format |
| 1648 | "Rename to %s and Query-Replace all occurrences? " | 1651 | ;; "Rename to %s and Query-Replace all occurrences? " |
| 1649 | newname)) | 1652 | ;; newname)) |
| 1650 | (progn | 1653 | ;; (progn |
| 1651 | (beginning-of-defun) | 1654 | ;; (beginning-of-defun) |
| 1652 | (query-replace-regexp | 1655 | ;; (query-replace-regexp |
| 1653 | (concat "\\<" (regexp-quote (car fp)) "\\>") | 1656 | ;; (concat "\\<" (regexp-quote (car fp)) "\\>") |
| 1654 | newname)) | 1657 | ;; newname)) |
| 1655 | (checkdoc-create-error | 1658 | ;; (checkdoc-create-error |
| 1656 | "Flag variable names should normally end in `-flag'" s | 1659 | ;; "Flag variable names should normally end in `-flag'" s |
| 1657 | (marker-position e))))) | 1660 | ;; (marker-position e))))) |
| 1658 | ;; Done with variables | 1661 | ;; Done with variables |
| 1659 | )) | 1662 | )) |
| 1660 | (t | 1663 | (t |