diff options
| author | Richard M. Stallman | 1998-05-23 00:51:44 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-05-23 00:51:44 +0000 |
| commit | 5fecb21aeb611cd5e77c229b7fcf2da5d3387142 (patch) | |
| tree | 59605268fe8c22e8c2828361a82f803e10128ec3 | |
| parent | 55319655c74df6976cdd42002cc7b5041b168ab4 (diff) | |
| download | emacs-5fecb21aeb611cd5e77c229b7fcf2da5d3387142.tar.gz emacs-5fecb21aeb611cd5e77c229b7fcf2da5d3387142.zip | |
Many doc fixes.
Put two spaces between sentences.
(checkdoc-this-string-valid-engine): Fix message.
(checkdoc-ispell-lisp-words): Add "emacs".
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 258 |
1 files changed, 87 insertions, 171 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index 88b3d0d231f..d38e4554b6c 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | 25 | ||
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | ;; | 27 | ;; |
| 28 | ;; The emacs lisp manual has a nice chapter on how to write | 28 | ;; The Emacs Lisp manual has a nice chapter on how to write |
| 29 | ;; documentation strings. Many stylistic suggestions are fairly | 29 | ;; documentation strings. Many stylistic suggestions are fairly |
| 30 | ;; deterministic and easy to check for syntactically, but also easy | 30 | ;; deterministic and easy to check for syntactically, but also easy |
| 31 | ;; to forget. The main checkdoc engine will perform the stylistic | 31 | ;; to forget. The main checkdoc engine will perform the stylistic |
| @@ -35,7 +35,7 @@ | |||
| 35 | ;; 1) Periodically use `checkdoc'. `checkdoc-current-buffer' and | 35 | ;; 1) Periodically use `checkdoc'. `checkdoc-current-buffer' and |
| 36 | ;; `checkdoc-defun' to check your documentation. | 36 | ;; `checkdoc-defun' to check your documentation. |
| 37 | ;; 2) Use `checkdoc-minor-mode' to automatically check your | 37 | ;; 2) Use `checkdoc-minor-mode' to automatically check your |
| 38 | ;; documentation whenever you evaluate lisp code with C-M-x | 38 | ;; documentation whenever you evaluate Lisp code with C-M-x |
| 39 | ;; or [menu-bar emacs-lisp eval-buffer]. Additional key-bindings | 39 | ;; or [menu-bar emacs-lisp eval-buffer]. Additional key-bindings |
| 40 | ;; are also provided under C-c ? KEY | 40 | ;; are also provided under C-c ? KEY |
| 41 | ;; (require 'checkdoc) | 41 | ;; (require 'checkdoc) |
| @@ -57,7 +57,7 @@ | |||
| 57 | ;; variable `checkdoc-autofix-flag' controls how these types of errors | 57 | ;; variable `checkdoc-autofix-flag' controls how these types of errors |
| 58 | ;; are fixed. | 58 | ;; are fixed. |
| 59 | ;; | 59 | ;; |
| 60 | ;; Spell checking doc-strings: | 60 | ;; Spell checking doc strings: |
| 61 | ;; | 61 | ;; |
| 62 | ;; The variable `checkdoc-spellcheck-documentation-flag' can be set | 62 | ;; The variable `checkdoc-spellcheck-documentation-flag' can be set |
| 63 | ;; to customize how spell checking is to be done. Since spell | 63 | ;; to customize how spell checking is to be done. Since spell |
| @@ -69,8 +69,8 @@ | |||
| 69 | ;; advantage of the spell checking. You can instead use the | 69 | ;; advantage of the spell checking. You can instead use the |
| 70 | ;; interactive functions `checkdoc-ispell-*' to check the spelling of | 70 | ;; interactive functions `checkdoc-ispell-*' to check the spelling of |
| 71 | ;; your documentation. | 71 | ;; your documentation. |
| 72 | ;; There is a list of lisp-specific words which checkdoc will | 72 | ;; There is a list of Lisp-specific words which checkdoc will |
| 73 | ;; install into ispell on the fly, but only if ispell is not already | 73 | ;; install into Ispell on the fly, but only if Ispell is not already |
| 74 | ;; running. Use `ispell-kill-ispell' to make checkdoc restart it with | 74 | ;; running. Use `ispell-kill-ispell' to make checkdoc restart it with |
| 75 | ;; these words enabled. | 75 | ;; these words enabled. |
| 76 | ;; | 76 | ;; |
| @@ -102,93 +102,8 @@ | |||
| 102 | ;; Return a string which is the error you wish to report. The cursor | 102 | ;; Return a string which is the error you wish to report. The cursor |
| 103 | ;; position should be preserved. | 103 | ;; position should be preserved. |
| 104 | ;; | 104 | ;; |
| 105 | ;; This file requires lisp-mnt (lisp maintenance routines) for the | 105 | ;; This file requires lisp-mnt (Lisp maintenance routines) for the |
| 106 | ;; comment checkers. | 106 | ;; comment checkers. |
| 107 | ;; | ||
| 108 | ;; Requires custom for emacs v20. | ||
| 109 | |||
| 110 | ;;; Change log: | ||
| 111 | ;; 0.1 Initial revision | ||
| 112 | ;; 0.2 Fixed comments in this file to match the emacs lisp standards. | ||
| 113 | ;; Added new doc checks for: variable-flags, function arguments | ||
| 114 | ;; Added autofix functionality for white-space, and quoted variables. | ||
| 115 | ;; Unquoted symbols are allowed after ( character. (Sample code) | ||
| 116 | ;; Check for use of `? ' at end of line and warn. | ||
| 117 | ;; Check for spaces at end of lines for whole file, or one defun. | ||
| 118 | ;; Check for comments standards, including headinds like Code: | ||
| 119 | ;; and use of triple semicolons versus double semicolons | ||
| 120 | ;; Check that interactive functions have a doc-string. Optionally | ||
| 121 | ;; set `checkdoc-force-docstrings-flag' to non-nil to make all | ||
| 122 | ;; definitions have a doc-string. | ||
| 123 | ;; 0.3 Regexp changse for accuracy on var checking and param checking. | ||
| 124 | ;; lm-verify check expanded to each sub-call w/ more descriptive | ||
| 125 | ;; messages, and two autofix-options. | ||
| 126 | ;; Suggestions/patches from Christoph Wedler <wedler@fmi.uni-passau.de> | ||
| 127 | ;; XEmacs support w/ extents/overlays. | ||
| 128 | ;; Better Whitespace finding regexps | ||
| 129 | ;; Added `checkdoc-arguments-in-order-flag' to optionally turn off | ||
| 130 | ;; warnings of arguments that do not appear in order in doc | ||
| 131 | ;; strings. | ||
| 132 | ;; 0.4 New fix routine when two lines can be joined to make the | ||
| 133 | ;; first line a comlete sentence. | ||
| 134 | ;; Added ispell code. Use `checkdoc-spellcheck-documentation-flag' | ||
| 135 | ;; to enable or disable this test in certain contexts. | ||
| 136 | ;; Added ispell interface functions `checkdoc-ispell', | ||
| 137 | ;; `checkdoc-ispell-continue', `checkdoc-ispell-defun' | ||
| 138 | ;; `checkdoc-ispell-interactive', `checkdoc-ispell-current-buffer'. | ||
| 139 | ;; Loop through all potential unquoted symbols. | ||
| 140 | ;; Auto-fixing no longer screws up the "end" of the doc-string. | ||
| 141 | ;; Maintain a different syntax table when examining arguments. | ||
| 142 | ;; Autofix enabled for parameters which are not uppercase iff they | ||
| 143 | ;; occur in lower case in the doc-string. | ||
| 144 | ;; Autofix enable if there is no Code: label. | ||
| 145 | ;; The comment text ";; checkdoc-order: nil|t" inside a defun to | ||
| 146 | ;; enable or disable the checking of argument order for one defun. | ||
| 147 | ;; The comment text ";; checkdoc-params: (arg1 arg2)" inside a defun | ||
| 148 | ;; (Such as just before the doc string) will list ARG1 and ARG2 as | ||
| 149 | ;; being paramters that need not show up in the doc string. | ||
| 150 | ;; Brought in suggestions from Jari Aalto <jaalto@tre.tele.nokia.fi> | ||
| 151 | ;; More robustness (comments in/around doc-strings/ arg lists) | ||
| 152 | ;; Don't offer to `quote'afy symbols or keystroke representations | ||
| 153 | ;; that are in lists (sample code) This added new fn | ||
| 154 | ;; `checkdoc-in-sample-code-p' | ||
| 155 | ;; Added more comments near the ;;; comment check about why it | ||
| 156 | ;; is being done. ;;; Are also now allowed inside a defun. | ||
| 157 | ;; This added the function `checkdoc-outside-major-sexp' | ||
| 158 | ;; Added `checkdoc-interactive' which permits interactive | ||
| 159 | ;; perusal of document warnings, and editing of strings. | ||
| 160 | ;; Fixed `checkdoc-defun-info' to be more robust when creating | ||
| 161 | ;; the paramter list. | ||
| 162 | ;; Added list of verbs in the wrong tense, and their fixes. | ||
| 163 | ;; Added defconst/subst/advice to checked items. | ||
| 164 | ;; Added `checkdoc-style-hooks' and `checkdoc-comment-style-hooks' | ||
| 165 | ;; for adding in user tests. | ||
| 166 | ;; Added `checkdoc-continue', a version of checkdoc that continues | ||
| 167 | ;; from point. | ||
| 168 | ;; [X]Emacs 20 support for extended characters. | ||
| 169 | ;; Only check comments on real files. | ||
| 170 | ;; Put `checkdoc' and `checkdoc-continue' into keymap/menu | ||
| 171 | ;; 0.4.1 Made `custom' friendly. | ||
| 172 | ;; C-m in warning buffer also goes to error. | ||
| 173 | ;; Shrink error buffer to size of text. | ||
| 174 | ;; Added `checkdoc-tripple-semi-comment-check-flag'. | ||
| 175 | ;; `checkdoc-spellcheck-documentation-flag' off by default. | ||
| 176 | ;; Re-sorted check order so white space is removed before adding a . | ||
| 177 | ;; 0.4.2 Added some more comments in the commentary. | ||
| 178 | ;; You can now `quote' symbols that look like keystrokes | ||
| 179 | ;; When spell checking, meta variables can end in `th' or `s'. | ||
| 180 | ;; 0.4.3 Fixed bug where multi-function checking skips defuns that | ||
| 181 | ;; have comments before the doc-string. | ||
| 182 | ;; Fixed bug where keystrokes were identified from a variable name | ||
| 183 | ;; like ASSOC-P. | ||
| 184 | ;; 0.5 Added checks for basics in messages using `error'. | ||
| 185 | ;; Added check for symbols that are both functions and symbols. | ||
| 186 | ;; These references are ambiguous and should be prefixed with | ||
| 187 | ;; "function", or "variable". Added auto-fix for this also. | ||
| 188 | ;; Added auto fix for args that do not occur in the doc string. | ||
| 189 | ;; 0.5.1 Fixed question about putting a symbol in `quotes'. | ||
| 190 | ;; Added spaces to the end of all y/n questions. | ||
| 191 | ;; Added checks for y/n question endings to require "? " | ||
| 192 | 107 | ||
| 193 | ;;; TO DO: | 108 | ;;; TO DO: |
| 194 | ;; Hook into the byte compiler on a defun/defver level to generate | 109 | ;; Hook into the byte compiler on a defun/defver level to generate |
| @@ -221,13 +136,13 @@ | |||
| 221 | (` (defvar (, var) (, value) (, doc)))))) | 136 | (` (defvar (, var) (, value) (, doc)))))) |
| 222 | 137 | ||
| 223 | (defcustom checkdoc-autofix-flag 'semiautomatic | 138 | (defcustom checkdoc-autofix-flag 'semiautomatic |
| 224 | "*Non-nil means attempt auto-fixing of doc-strings. | 139 | "*Non-nil means attempt auto-fixing of doc strings. |
| 225 | If this value is the symbol 'query, then the user is queried before | 140 | If this value is the symbol `query', then the user is queried before |
| 226 | any change is made. If the value is 'automatic, then all changes are | 141 | any change is made. If the value is `automatic', then all changes are |
| 227 | made without asking unless the change is very-complex. If the value | 142 | made without asking unless the change is very-complex. If the value |
| 228 | is 'semiautomatic, or any other value, then simple fixes are made | 143 | is `semiautomatic', or any other value, then simple fixes are made |
| 229 | without asking, and complex changes are made by asking the user first. | 144 | without asking, and complex changes are made by asking the user first. |
| 230 | The value 'never is the same as nil, never ask or change anything." | 145 | The value `never' is the same as nil, never ask or change anything." |
| 231 | :group 'checkdoc | 146 | :group 'checkdoc |
| 232 | :type '(choice (const automatic) | 147 | :type '(choice (const automatic) |
| 233 | (const semiautomatic) | 148 | (const semiautomatic) |
| @@ -235,7 +150,7 @@ The value 'never is the same as nil, never ask or change anything." | |||
| 235 | (const never))) | 150 | (const never))) |
| 236 | 151 | ||
| 237 | (defcustom checkdoc-bouncy-flag t | 152 | (defcustom checkdoc-bouncy-flag t |
| 238 | "*Non-nil means to 'bounce' to auto-fix locations. | 153 | "*Non-nil means to \"bounce\" to auto-fix locations. |
| 239 | Setting this to nil will silently make fixes that require no user | 154 | Setting this to nil will silently make fixes that require no user |
| 240 | interaction. See `checkdoc-autofix-flag' for auto-fixing details." | 155 | interaction. See `checkdoc-autofix-flag' for auto-fixing details." |
| 241 | :group 'checkdoc | 156 | :group 'checkdoc |
| @@ -245,13 +160,13 @@ interaction. See `checkdoc-autofix-flag' for auto-fixing details." | |||
| 245 | "*Non-nil means that all checkable definitions should have documentation. | 160 | "*Non-nil means that all checkable definitions should have documentation. |
| 246 | Style guide dictates that interactive functions MUST have documentation, | 161 | Style guide dictates that interactive functions MUST have documentation, |
| 247 | and that its good but not required practice to make non user visible items | 162 | and that its good but not required practice to make non user visible items |
| 248 | have doc-strings." | 163 | have doc strings." |
| 249 | :group 'checkdoc | 164 | :group 'checkdoc |
| 250 | :type 'boolean) | 165 | :type 'boolean) |
| 251 | 166 | ||
| 252 | (defcustom checkdoc-tripple-semi-comment-check-flag t | 167 | (defcustom checkdoc-tripple-semi-comment-check-flag t |
| 253 | "*Non-nil means to check for multiple adjacent occurrences of ;;; comments. | 168 | "*Non-nil means to check for multiple adjacent occurrences of ;;; comments. |
| 254 | According to the style of emacs code in the lisp libraries, a block | 169 | According to the style of Emacs code in the Lisp libraries, a block |
| 255 | comment can look like this: | 170 | comment can look like this: |
| 256 | ;;; Title | 171 | ;;; Title |
| 257 | ;; text | 172 | ;; text |
| @@ -263,15 +178,15 @@ is ignored regardless of it's location in the code." | |||
| 263 | :type 'boolean) | 178 | :type 'boolean) |
| 264 | 179 | ||
| 265 | (defcustom checkdoc-spellcheck-documentation-flag nil | 180 | (defcustom checkdoc-spellcheck-documentation-flag nil |
| 266 | "*Non-nil means run ispell on doc-strings based on value. | 181 | "*Non-nil means run Ispell on doc strings based on value. |
| 267 | This will be automatically set to nil if ispell does not exist on your | 182 | This is automatically set to nil if Ispell does not exist on your |
| 268 | system. Possible values are: | 183 | system. Possible values are: |
| 269 | 184 | ||
| 270 | nil - Don't spell-check during basic style checks. | 185 | nil - Don't spell-check during basic style checks. |
| 271 | 'defun - Spell-check when style checking a single defun | 186 | defun - Spell-check when style checking a single defun |
| 272 | 'buffer - Spell-check only when style checking the whole buffer | 187 | buffer - Spell-check only when style checking the whole buffer |
| 273 | 'interactive - Spell-check only during `checkdoc-interactive' | 188 | interactive - Spell-check only during `checkdoc-interactive' |
| 274 | t - Always spell-check" | 189 | t - Always spell-check" |
| 275 | :group 'checkdoc | 190 | :group 'checkdoc |
| 276 | :type '(choice (const nil) | 191 | :type '(choice (const nil) |
| 277 | (const defun) | 192 | (const defun) |
| @@ -280,11 +195,11 @@ system. Possible values are: | |||
| 280 | (const t))) | 195 | (const t))) |
| 281 | 196 | ||
| 282 | (defvar checkdoc-ispell-lisp-words | 197 | (defvar checkdoc-ispell-lisp-words |
| 283 | '("alist" "etags" "iff" "keymap" "paren" "regexp" "sexp" "xemacs") | 198 | '("alist" "etags" "iff" "keymap" "paren" "regexp" "sexp" "emacs" "xemacs") |
| 284 | "List of words that are correct when spell-checking lisp documentation.") | 199 | "List of words that are correct when spell-checking Lisp documentation.") |
| 285 | 200 | ||
| 286 | (defcustom checkdoc-max-keyref-before-warn 10 | 201 | (defcustom checkdoc-max-keyref-before-warn 10 |
| 287 | "*The number of \\ [command-to-keystroke] tokens allowed in a doc-string. | 202 | "*The number of \\ [command-to-keystroke] tokens allowed in a doc string. |
| 288 | Any more than this and a warning is generated suggesting that the construct | 203 | Any more than this and a warning is generated suggesting that the construct |
| 289 | \\ {keymap} be used instead." | 204 | \\ {keymap} be used instead." |
| 290 | :group 'checkdoc | 205 | :group 'checkdoc |
| @@ -323,10 +238,9 @@ problem discovered. This is useful for adding additional checks.") | |||
| 323 | A search leaves the cursor in front of the parameter list.") | 238 | A search leaves the cursor in front of the parameter list.") |
| 324 | 239 | ||
| 325 | (defcustom checkdoc-verb-check-experimental-flag t | 240 | (defcustom checkdoc-verb-check-experimental-flag t |
| 326 | "*Non-nil means to attempt to check the voice of the doc-string. | 241 | "*Non-nil means to attempt to check the voice of the doc string. |
| 327 | This check keys off some words which are commonly misused. See the | 242 | This check keys off some words which are commonly misused. See the |
| 328 | variable `checkdoc-common-verbs-wrong-voice' if you wish to add your | 243 | variable `checkdoc-common-verbs-wrong-voice' if you wish to add your own." |
| 329 | own." | ||
| 330 | :group 'checkdoc | 244 | :group 'checkdoc |
| 331 | :type 'boolean) | 245 | :type 'boolean) |
| 332 | 246 | ||
| @@ -424,7 +338,7 @@ be re-created.") | |||
| 424 | (if checkdoc-syntax-table | 338 | (if checkdoc-syntax-table |
| 425 | nil | 339 | nil |
| 426 | (setq checkdoc-syntax-table (copy-syntax-table emacs-lisp-mode-syntax-table)) | 340 | (setq checkdoc-syntax-table (copy-syntax-table emacs-lisp-mode-syntax-table)) |
| 427 | ;; When dealing with syntax in doc-strings, make sure that - are encompased | 341 | ;; When dealing with syntax in doc strings, make sure that - are encompased |
| 428 | ;; in words so we can use cheap \\> to get the end of a symbol, not the | 342 | ;; in words so we can use cheap \\> to get the end of a symbol, not the |
| 429 | ;; end of a word in a conglomerate. | 343 | ;; end of a word in a conglomerate. |
| 430 | (modify-syntax-entry ?- "w" checkdoc-syntax-table) | 344 | (modify-syntax-entry ?- "w" checkdoc-syntax-table) |
| @@ -468,7 +382,7 @@ be re-created.") | |||
| 468 | (set list-var (cons element (symbol-value list-var))))) | 382 | (set list-var (cons element (symbol-value list-var))))) |
| 469 | ) | 383 | ) |
| 470 | 384 | ||
| 471 | ;; To be safe in new emacsen, we want to read events, not characters | 385 | ;; To be safe in new Emacsen, we want to read events, not characters |
| 472 | (if (fboundp 'read-event) | 386 | (if (fboundp 'read-event) |
| 473 | (defalias 'checkdoc-read-event 'read-event) | 387 | (defalias 'checkdoc-read-event 'read-event) |
| 474 | (defalias 'checkdoc-read-event 'read-char)) | 388 | (defalias 'checkdoc-read-event 'read-char)) |
| @@ -479,7 +393,7 @@ be re-created.") | |||
| 479 | (defun checkdoc-eval-current-buffer () | 393 | (defun checkdoc-eval-current-buffer () |
| 480 | "Evaluate and check documentation for the current buffer. | 394 | "Evaluate and check documentation for the current buffer. |
| 481 | Evaluation is done first because good documentation for something that | 395 | Evaluation is done first because good documentation for something that |
| 482 | doesn't work is just not useful. Comments, doc-strings, and rogue | 396 | doesn't work is just not useful. Comments, doc strings, and rogue |
| 483 | spacing are all verified." | 397 | spacing are all verified." |
| 484 | (interactive) | 398 | (interactive) |
| 485 | (checkdoc-call-eval-buffer nil) | 399 | (checkdoc-call-eval-buffer nil) |
| @@ -488,8 +402,9 @@ spacing are all verified." | |||
| 488 | ;;;###autoload | 402 | ;;;###autoload |
| 489 | (defun checkdoc-current-buffer (&optional take-notes) | 403 | (defun checkdoc-current-buffer (&optional take-notes) |
| 490 | "Check current buffer for document, comment, error style, and rogue spaces. | 404 | "Check current buffer for document, comment, error style, and rogue spaces. |
| 491 | Optional argument TAKE-NOTES non-nil will store all found errors in a | 405 | With a prefix argument (in Lisp, the argument TAKE-NOTES), |
| 492 | warnings buffer, otherwise it stops after the first error." | 406 | store all errors found in a warnings buffer, |
| 407 | otherwise stop after the first error." | ||
| 493 | (interactive "P") | 408 | (interactive "P") |
| 494 | (if (interactive-p) (message "Checking buffer for style...")) | 409 | (if (interactive-p) (message "Checking buffer for style...")) |
| 495 | ;; Assign a flag to spellcheck flag | 410 | ;; Assign a flag to spellcheck flag |
| @@ -526,7 +441,7 @@ errors. Does not check for comment or space warnings." | |||
| 526 | (beginning-of-defun) | 441 | (beginning-of-defun) |
| 527 | (while err-list | 442 | (while err-list |
| 528 | (goto-char (cdr (car err-list))) | 443 | (goto-char (cdr (car err-list))) |
| 529 | ;; The cursor should be just in front of the offending doc-string | 444 | ;; The cursor should be just in front of the offending doc string |
| 530 | (let ((cdo (save-excursion | 445 | (let ((cdo (save-excursion |
| 531 | (checkdoc-make-overlay (point) | 446 | (checkdoc-make-overlay (point) |
| 532 | (progn (forward-sexp 1) | 447 | (progn (forward-sexp 1) |
| @@ -535,7 +450,7 @@ errors. Does not check for comment or space warnings." | |||
| 535 | (unwind-protect | 450 | (unwind-protect |
| 536 | (progn | 451 | (progn |
| 537 | (checkdoc-overlay-put cdo 'face 'highlight) | 452 | (checkdoc-overlay-put cdo 'face 'highlight) |
| 538 | ;; Make sure the whole doc-string is visible if possible. | 453 | ;; Make sure the whole doc string is visible if possible. |
| 539 | (sit-for 0) | 454 | (sit-for 0) |
| 540 | (if (not (pos-visible-in-window-p | 455 | (if (not (pos-visible-in-window-p |
| 541 | (save-excursion (forward-sexp 1) (point)) | 456 | (save-excursion (forward-sexp 1) (point)) |
| @@ -592,7 +507,7 @@ not to edit the buffer before point without re-executing this check." | |||
| 592 | (let ((msg nil) (p (point))) | 507 | (let ((msg nil) (p (point))) |
| 593 | (condition-case nil | 508 | (condition-case nil |
| 594 | (while (and (not msg) (checkdoc-next-docstring)) | 509 | (while (and (not msg) (checkdoc-next-docstring)) |
| 595 | (message "Searching for doc-string error...%d%%" | 510 | (message "Searching for doc string error...%d%%" |
| 596 | (/ (* 100 (point)) (point-max))) | 511 | (/ (* 100 (point)) (point-max))) |
| 597 | (if (setq msg (checkdoc-this-string-valid)) | 512 | (if (setq msg (checkdoc-this-string-valid)) |
| 598 | (setq msg (cons msg (point))))) | 513 | (setq msg (cons msg (point))))) |
| @@ -615,7 +530,7 @@ a separate buffer." | |||
| 615 | 530 | ||
| 616 | ;;;###autoload | 531 | ;;;###autoload |
| 617 | (defun checkdoc-continue (&optional take-notes) | 532 | (defun checkdoc-continue (&optional take-notes) |
| 618 | "Find the next doc-string in the current buffer which is stylisticly poor. | 533 | "Find the next docstring in the current buffer which is stylisticly poor. |
| 619 | Prefix argument TAKE-NOTES means to continue through the whole buffer and | 534 | Prefix argument TAKE-NOTES means to continue through the whole buffer and |
| 620 | save warnings in a separate buffer. Second optional argument START-POINT | 535 | save warnings in a separate buffer. Second optional argument START-POINT |
| 621 | is the starting location. If this is nil, `point-min' is used instead." | 536 | is the starting location. If this is nil, `point-min' is used instead." |
| @@ -630,7 +545,7 @@ is the starting location. If this is nil, `point-min' is used instead." | |||
| 630 | ;; the user is navigating down through the buffer. | 545 | ;; the user is navigating down through the buffer. |
| 631 | (if take-notes (checkdoc-start-section "checkdoc")) | 546 | (if take-notes (checkdoc-start-section "checkdoc")) |
| 632 | (while (and (not wrong) (checkdoc-next-docstring)) | 547 | (while (and (not wrong) (checkdoc-next-docstring)) |
| 633 | ;; OK, lets look at the doc-string. | 548 | ;; OK, lets look at the doc string. |
| 634 | (setq msg (checkdoc-this-string-valid)) | 549 | (setq msg (checkdoc-this-string-valid)) |
| 635 | (if msg | 550 | (if msg |
| 636 | ;; Oops | 551 | ;; Oops |
| @@ -649,8 +564,8 @@ is the starting location. If this is nil, `point-min' is used instead." | |||
| 649 | (message "No style warnings."))))) | 564 | (message "No style warnings."))))) |
| 650 | 565 | ||
| 651 | (defun checkdoc-next-docstring () | 566 | (defun checkdoc-next-docstring () |
| 652 | "Find the next doc-string after point and return t. | 567 | "Move to the next doc string after point, and return t. |
| 653 | Return nil if there are no more doc-strings." | 568 | Return nil if there are no more doc strings." |
| 654 | (if (not (re-search-forward checkdoc-defun-regexp nil t)) | 569 | (if (not (re-search-forward checkdoc-defun-regexp nil t)) |
| 655 | nil | 570 | nil |
| 656 | ;; search drops us after the identifier. The next sexp is either | 571 | ;; search drops us after the identifier. The next sexp is either |
| @@ -661,7 +576,7 @@ Return nil if there are no more doc-strings." | |||
| 661 | 576 | ||
| 662 | ;;; ###autoload | 577 | ;;; ###autoload |
| 663 | (defun checkdoc-comments (&optional take-notes) | 578 | (defun checkdoc-comments (&optional take-notes) |
| 664 | "Find missing comment sections in the current emacs lisp file. | 579 | "Find missing comment sections in the current Emacs Lisp file. |
| 665 | Prefix argument TAKE-NOTES non-nil means to save warnings in a | 580 | Prefix argument TAKE-NOTES non-nil means to save warnings in a |
| 666 | separate buffer. Otherwise print a message. This returns the error | 581 | separate buffer. Otherwise print a message. This returns the error |
| 667 | if there is one." | 582 | if there is one." |
| @@ -713,10 +628,10 @@ of what was evaluated will be overwritten by the diagnostic message." | |||
| 713 | 628 | ||
| 714 | ;;;###autoload | 629 | ;;;###autoload |
| 715 | (defun checkdoc-defun (&optional no-error) | 630 | (defun checkdoc-defun (&optional no-error) |
| 716 | "Examine the doc-string of the function or variable under point. | 631 | "Examine the doc string of the function or variable under point. |
| 717 | Calls `error' if the doc-string produces diagnostics. If NO-ERROR is | 632 | Call `error' if the doc string has problems. If NO-ERROR is |
| 718 | non-nil, then do not call error, but call `message' instead. | 633 | non-nil, then do not call error, but call `message' instead. |
| 719 | If the document check passes, then check the function for rogue white | 634 | If the doc string passes the test, then check the function for rogue white |
| 720 | space at the end of each line." | 635 | space at the end of each line." |
| 721 | (interactive) | 636 | (interactive) |
| 722 | (save-excursion | 637 | (save-excursion |
| @@ -724,7 +639,7 @@ space at the end of each line." | |||
| 724 | (if (not (looking-at checkdoc-defun-regexp)) | 639 | (if (not (looking-at checkdoc-defun-regexp)) |
| 725 | ;; I found this more annoying than useful. | 640 | ;; I found this more annoying than useful. |
| 726 | ;;(if (not no-error) | 641 | ;;(if (not no-error) |
| 727 | ;; (message "Cannot check this sexp's doc-string.")) | 642 | ;; (message "Cannot check this sexp's docstring.")) |
| 728 | nil | 643 | nil |
| 729 | ;; search drops us after the identifier. The next sexp is either | 644 | ;; search drops us after the identifier. The next sexp is either |
| 730 | ;; the argument list or the value of the variable. skip it. | 645 | ;; the argument list or the value of the variable. skip it. |
| @@ -794,7 +709,7 @@ Prefix argument TAKE-NOTES is the same as for `checkdoc-comments'" | |||
| 794 | 709 | ||
| 795 | ;;;###autoload | 710 | ;;;###autoload |
| 796 | (defun checkdoc-ispell-defun (&optional take-notes) | 711 | (defun checkdoc-ispell-defun (&optional take-notes) |
| 797 | "Check the style and spelling of the current defun with ispell. | 712 | "Check the style and spelling of the current defun with Ispell. |
| 798 | Calls `checkdoc-defun' with spell-checking turned on. | 713 | Calls `checkdoc-defun' with spell-checking turned on. |
| 799 | Prefix argument TAKE-NOTES is the same as for `checkdoc-defun'" | 714 | Prefix argument TAKE-NOTES is the same as for `checkdoc-defun'" |
| 800 | (interactive) | 715 | (interactive) |
| @@ -874,10 +789,10 @@ Prefix argument TAKE-NOTES is the same as for `checkdoc-defun'" | |||
| 874 | 789 | ||
| 875 | ;;;###autoload | 790 | ;;;###autoload |
| 876 | (defun checkdoc-minor-mode (&optional arg) | 791 | (defun checkdoc-minor-mode (&optional arg) |
| 877 | "Toggle checkdoc minor mode. A mode for checking lisp doc-strings. | 792 | "Toggle Checkdoc minor mode, a mode for checking Lisp doc strings. |
| 878 | With prefix ARG, turn checkdoc minor mode on iff ARG is positive. | 793 | With prefix ARG, turn Checkdoc minor mode on iff ARG is positive. |
| 879 | 794 | ||
| 880 | In checkdoc minor mode, the usual bindings for `eval-defun' which is | 795 | In Checkdoc minor mode, the usual bindings for `eval-defun' which is |
| 881 | bound to \\<checkdoc-minor-keymap> \\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include | 796 | bound to \\<checkdoc-minor-keymap> \\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include |
| 882 | checking of documentation strings. | 797 | checking of documentation strings. |
| 883 | 798 | ||
| @@ -895,7 +810,7 @@ checking of documentation strings. | |||
| 895 | (if (fboundp 'run-hook-with-args-until-success) | 810 | (if (fboundp 'run-hook-with-args-until-success) |
| 896 | (apply 'run-hook-with-args-until-success hookvar args) | 811 | (apply 'run-hook-with-args-until-success hookvar args) |
| 897 | ;; This method was similar to above. We ignore the warning | 812 | ;; This method was similar to above. We ignore the warning |
| 898 | ;; since we will use the above for future emacs versions | 813 | ;; since we will use the above for future Emacs versions |
| 899 | (apply 'run-hook-with-args hookvar args))) | 814 | (apply 'run-hook-with-args hookvar args))) |
| 900 | 815 | ||
| 901 | (defsubst checkdoc-create-common-verbs-regexp () | 816 | (defsubst checkdoc-create-common-verbs-regexp () |
| @@ -927,13 +842,13 @@ checking of documentation strings. | |||
| 927 | ;;; Checking engines | 842 | ;;; Checking engines |
| 928 | ;; | 843 | ;; |
| 929 | (defun checkdoc-this-string-valid () | 844 | (defun checkdoc-this-string-valid () |
| 930 | "Return a message string if the current doc-string is invalid. | 845 | "Return a message string if the current doc string is invalid. |
| 931 | Check for style only, such as the first line always being a complete | 846 | Check for style only, such as the first line always being a complete |
| 932 | sentence, whitespace restrictions, and making sure there are no | 847 | sentence, whitespace restrictions, and making sure there are no |
| 933 | hard-coded key-codes such as C-[char] or mouse-[number] in the comment. | 848 | hard-coded key-codes such as C-[char] or mouse-[number] in the comment. |
| 934 | See the style guide in the Emacs Lisp manual for more details." | 849 | See the style guide in the Emacs Lisp manual for more details." |
| 935 | 850 | ||
| 936 | ;; Jump over comments between the last object and the doc-string | 851 | ;; Jump over comments between the last object and the doc string |
| 937 | (while (looking-at "[ \t\n]*;") | 852 | (while (looking-at "[ \t\n]*;") |
| 938 | (forward-line 1) | 853 | (forward-line 1) |
| 939 | (beginning-of-line) | 854 | (beginning-of-line) |
| @@ -949,13 +864,13 @@ See the style guide in the Emacs Lisp manual for more details." | |||
| 949 | (set-syntax-table old-syntax-table))))) | 864 | (set-syntax-table old-syntax-table))))) |
| 950 | 865 | ||
| 951 | (defun checkdoc-this-string-valid-engine () | 866 | (defun checkdoc-this-string-valid-engine () |
| 952 | "Return a message string if the current doc-string is invalid. | 867 | "Return a message string if the current doc string is invalid. |
| 953 | Depends on `checkdoc-this-string-valid' to reset the syntax table so that | 868 | Depends on `checkdoc-this-string-valid' to reset the syntax table so that |
| 954 | regexp short cuts work." | 869 | regexp short cuts work." |
| 955 | (let ((case-fold-search nil) | 870 | (let ((case-fold-search nil) |
| 956 | ;; Use a marker so if an early check modifies the text, | 871 | ;; Use a marker so if an early check modifies the text, |
| 957 | ;; we won't accidentally loose our place. This could cause | 872 | ;; we won't accidentally loose our place. This could cause |
| 958 | ;; end-of doc-string whitespace to also delete the " char. | 873 | ;; end-of doc string whitespace to also delete the " char. |
| 959 | (e (save-excursion (forward-sexp 1) (point-marker))) | 874 | (e (save-excursion (forward-sexp 1) (point-marker))) |
| 960 | (fp (checkdoc-defun-info))) | 875 | (fp (checkdoc-defun-info))) |
| 961 | (or | 876 | (or |
| @@ -1000,7 +915,7 @@ regexp short cuts work." | |||
| 1000 | (if (and (not (nth 1 fp)) ; not a variable | 915 | (if (and (not (nth 1 fp)) ; not a variable |
| 1001 | (or (nth 2 fp) ; is interactive | 916 | (or (nth 2 fp) ; is interactive |
| 1002 | checkdoc-force-docstrings-flag) ;or we always complain | 917 | checkdoc-force-docstrings-flag) ;or we always complain |
| 1003 | (not (checkdoc-char= (following-char) ?\"))) ; no doc-string | 918 | (not (checkdoc-char= (following-char) ?\"))) ; no doc string |
| 1004 | (if (nth 2 fp) | 919 | (if (nth 2 fp) |
| 1005 | "All interactive functions should have documentation" | 920 | "All interactive functions should have documentation" |
| 1006 | "All variables and subroutines might as well have a \ | 921 | "All variables and subroutines might as well have a \ |
| @@ -1053,7 +968,7 @@ documentation string")) | |||
| 1053 | (end-of-line) | 968 | (end-of-line) |
| 1054 | (current-column))) | 969 | (current-column))) |
| 1055 | (if (> (+ l1 l2 1) 80) | 970 | (if (> (+ l1 l2 1) 80) |
| 1056 | (setq msg "Incomplete auto-fix. Doc-string \ | 971 | (setq msg "Incomplete auto-fix; doc string \ |
| 1057 | may require more formatting") | 972 | may require more formatting") |
| 1058 | ;; We can merge these lines! Replace this CR | 973 | ;; We can merge these lines! Replace this CR |
| 1059 | ;; with a space. | 974 | ;; with a space. |
| @@ -1073,7 +988,7 @@ may require more formatting") | |||
| 1073 | (< (current-column) numc)) | 988 | (< (current-column) numc)) |
| 1074 | (if (checkdoc-autofix-ask-replace | 989 | (if (checkdoc-autofix-ask-replace |
| 1075 | p (1+ p) | 990 | p (1+ p) |
| 1076 | "1st line not a complete sentence. Join these lines? " | 991 | "1st line not a complete sentence. Join these lines? " |
| 1077 | " " t) | 992 | " " t) |
| 1078 | (progn | 993 | (progn |
| 1079 | ;; They said yes. We have more fill work to do... | 994 | ;; They said yes. We have more fill work to do... |
| @@ -1150,7 +1065,7 @@ mouse-[0-3]\\)\\)\\>")) | |||
| 1150 | (if m | 1065 | (if m |
| 1151 | (concat | 1066 | (concat |
| 1152 | "Keycode " (match-string 1) | 1067 | "Keycode " (match-string 1) |
| 1153 | " embedded in doc-string. Use \\\\<keymap> & \\\\[function] " | 1068 | " embedded in doc string. Use \\\\<keymap> & \\\\[function] " |
| 1154 | "instead")))) | 1069 | "instead")))) |
| 1155 | ;; It is not practical to use `\\[...]' very many times, because | 1070 | ;; It is not practical to use `\\[...]' very many times, because |
| 1156 | ;; display of the documentation string will become slow. So use this | 1071 | ;; display of the documentation string will become slow. So use this |
| @@ -1160,7 +1075,7 @@ mouse-[0-3]\\)\\)\\>")) | |||
| 1160 | (if (re-search-forward "\\\\\\\\\\[\\w+" e t | 1075 | (if (re-search-forward "\\\\\\\\\\[\\w+" e t |
| 1161 | (1+ checkdoc-max-keyref-before-warn)) | 1076 | (1+ checkdoc-max-keyref-before-warn)) |
| 1162 | "Too many occurrences of \\[function]. Use \\{keymap} instead")) | 1077 | "Too many occurrences of \\[function]. Use \\{keymap} instead")) |
| 1163 | ;; Ambiguous quoted symbol. When a symbol is both bound and fbound, | 1078 | ;; Ambiguous quoted symbol. When a symbol is both bound and fbound, |
| 1164 | ;; and is referred to in documentation, it should be prefixed with | 1079 | ;; and is referred to in documentation, it should be prefixed with |
| 1165 | ;; something to disambiguate it. This check must be before the | 1080 | ;; something to disambiguate it. This check must be before the |
| 1166 | ;; 80 column check because it will probably break that. | 1081 | ;; 80 column check because it will probably break that. |
| @@ -1234,7 +1149,7 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1234 | (setq found (intern-soft ms)) | 1149 | (setq found (intern-soft ms)) |
| 1235 | (or (boundp found) (fboundp found))) | 1150 | (or (boundp found) (fboundp found))) |
| 1236 | (progn | 1151 | (progn |
| 1237 | (setq msg (format "Add quotes around lisp symbol `%s'? " | 1152 | (setq msg (format "Add quotes around Lisp symbol `%s'? " |
| 1238 | ms)) | 1153 | ms)) |
| 1239 | (if (checkdoc-autofix-ask-replace | 1154 | (if (checkdoc-autofix-ask-replace |
| 1240 | (match-beginning 1) (+ (match-beginning 1) | 1155 | (match-beginning 1) (+ (match-beginning 1) |
| @@ -1247,7 +1162,7 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1247 | (if (re-search-forward "\\(`\\(t\\|nil\\)'\\)" e t) | 1162 | (if (re-search-forward "\\(`\\(t\\|nil\\)'\\)" e t) |
| 1248 | (if (checkdoc-autofix-ask-replace | 1163 | (if (checkdoc-autofix-ask-replace |
| 1249 | (match-beginning 1) (match-end 1) | 1164 | (match-beginning 1) (match-end 1) |
| 1250 | (format "%s should not appear in quotes. Remove? " | 1165 | (format "%s should not appear in quotes. Remove? " |
| 1251 | (match-string 2)) | 1166 | (match-string 2)) |
| 1252 | (match-string 2) t) | 1167 | (match-string 2) t) |
| 1253 | nil | 1168 | nil |
| @@ -1267,11 +1182,11 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1267 | ;; If the variable has -flag in the name, make sure | 1182 | ;; If the variable has -flag in the name, make sure |
| 1268 | (if (and (string-match "-flag$" (car fp)) | 1183 | (if (and (string-match "-flag$" (car fp)) |
| 1269 | (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+"))) | 1184 | (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+"))) |
| 1270 | "Flag variable doc-strings should start: Non-nil means") | 1185 | "Flag variable doc strings should start: Non-nil means") |
| 1271 | ;; If the doc-string starts with "Non-nil means" | 1186 | ;; If the doc string starts with "Non-nil means" |
| 1272 | (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+") | 1187 | (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+") |
| 1273 | (not (string-match "-flag$" (car fp)))) | 1188 | (not (string-match "-flag$" (car fp)))) |
| 1274 | "Flag variables should end in: -flag") | 1189 | "Flag variables should end in `-flag'") |
| 1275 | ;; Done with variables | 1190 | ;; Done with variables |
| 1276 | )) | 1191 | )) |
| 1277 | (t | 1192 | (t |
| @@ -1321,7 +1236,7 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1321 | (if (checkdoc-autofix-ask-replace | 1236 | (if (checkdoc-autofix-ask-replace |
| 1322 | (match-beginning 1) (match-end 1) | 1237 | (match-beginning 1) (match-end 1) |
| 1323 | (format | 1238 | (format |
| 1324 | "Argument `%s' should appear as `%s'. Fix? " | 1239 | "Argument `%s' should appear as `%s'. Fix? " |
| 1325 | (car args) (upcase (car args))) | 1240 | (car args) (upcase (car args))) |
| 1326 | (upcase (car args)) t) | 1241 | (upcase (car args)) t) |
| 1327 | (setq found (match-beginning 1)))))) | 1242 | (setq found (match-beginning 1)))))) |
| @@ -1330,9 +1245,9 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1330 | ;; It wasn't found at all! Offer to attach this new symbol | 1245 | ;; It wasn't found at all! Offer to attach this new symbol |
| 1331 | ;; to the end of the documentation string. | 1246 | ;; to the end of the documentation string. |
| 1332 | (if (y-or-n-p | 1247 | (if (y-or-n-p |
| 1333 | (format "Add %s documentation to end of doc-string?" | 1248 | (format "Add %s documentation to end of doc string?" |
| 1334 | (upcase (car args)))) | 1249 | (upcase (car args)))) |
| 1335 | ;; No do some majic an invent a doc string. | 1250 | ;; Now do some magic and invent a doc string. |
| 1336 | (save-excursion | 1251 | (save-excursion |
| 1337 | (goto-char e) (forward-char -1) | 1252 | (goto-char e) (forward-char -1) |
| 1338 | (insert "\n" | 1253 | (insert "\n" |
| @@ -1345,17 +1260,17 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1345 | (insert ".")) | 1260 | (insert ".")) |
| 1346 | nil) | 1261 | nil) |
| 1347 | (format | 1262 | (format |
| 1348 | "Argument `%s' should appear as `%s' in the doc-string" | 1263 | "Argument `%s' should appear as `%s' in the doc string" |
| 1349 | (car args) (upcase (car args)))) | 1264 | (car args) (upcase (car args)))) |
| 1350 | (if (or (and order (eq order 'yes)) | 1265 | (if (or (and order (eq order 'yes)) |
| 1351 | (and (not order) checkdoc-arguments-in-order-flag)) | 1266 | (and (not order) checkdoc-arguments-in-order-flag)) |
| 1352 | (if (< found last-pos) | 1267 | (if (< found last-pos) |
| 1353 | "Arguments occur in the doc-string out of order")))) | 1268 | "Arguments occur in the doc string out of order")))) |
| 1354 | ;; Done with functions | 1269 | ;; Done with functions |
| 1355 | ))) | 1270 | ))) |
| 1356 | ;; Make sure the doc-string has correctly spelled english words | 1271 | ;; Make sure the doc string has correctly spelled english words |
| 1357 | ;; in it. This functions is extracted due to it's complexity, | 1272 | ;; in it. This functions is extracted due to its complexity, |
| 1358 | ;; and reliance on the ispell program. | 1273 | ;; and reliance on the Ispell program. |
| 1359 | (checkdoc-ispell-docstring-engine e) | 1274 | (checkdoc-ispell-docstring-engine e) |
| 1360 | ;; User supplied checks | 1275 | ;; User supplied checks |
| 1361 | (save-excursion (checkdoc-run-hooks 'checkdoc-style-hooks fp e)) | 1276 | (save-excursion (checkdoc-run-hooks 'checkdoc-style-hooks fp e)) |
| @@ -1365,7 +1280,7 @@ function,command,variable,option or symbol." (match-string 3))))))) | |||
| 1365 | (defun checkdoc-defun-info nil | 1280 | (defun checkdoc-defun-info nil |
| 1366 | "Return a list of details about the current sexp. | 1281 | "Return a list of details about the current sexp. |
| 1367 | It is a list of the form: | 1282 | It is a list of the form: |
| 1368 | '( NAME VARIABLE INTERACTIVE NODOCPARAMS PARAMETERS ... ) | 1283 | (NAME VARIABLE INTERACTIVE NODOCPARAMS PARAMETERS ...) |
| 1369 | where NAME is the name, VARIABLE is t if this is a `defvar', | 1284 | where NAME is the name, VARIABLE is t if this is a `defvar', |
| 1370 | INTERACTIVE is nil if this is not an interactive function, otherwise | 1285 | INTERACTIVE is nil if this is not an interactive function, otherwise |
| 1371 | it is the position of the `interactive' call, and PARAMETERS is a | 1286 | it is the position of the `interactive' call, and PARAMETERS is a |
| @@ -1443,7 +1358,7 @@ from the comment." | |||
| 1443 | (nreverse ret)))) | 1358 | (nreverse ret)))) |
| 1444 | 1359 | ||
| 1445 | (defun checkdoc-in-sample-code-p (start limit) | 1360 | (defun checkdoc-in-sample-code-p (start limit) |
| 1446 | "Return Non-nil if the current point is in a code-fragment. | 1361 | "Return non-nil if the current point is in a code fragment. |
| 1447 | A code fragment is identified by an open parenthesis followed by a | 1362 | A code fragment is identified by an open parenthesis followed by a |
| 1448 | symbol which is a valid function, or a parenthesis that is quoted with the ' | 1363 | symbol which is a valid function, or a parenthesis that is quoted with the ' |
| 1449 | character. Only the region from START to LIMIT is is allowed while | 1364 | character. Only the region from START to LIMIT is is allowed while |
| @@ -1470,7 +1385,7 @@ searching for the bounding parenthesis." | |||
| 1470 | (eval-when-compile (require 'ispell)) | 1385 | (eval-when-compile (require 'ispell)) |
| 1471 | 1386 | ||
| 1472 | (defun checkdoc-ispell-init () | 1387 | (defun checkdoc-ispell-init () |
| 1473 | "Initialize ispell process (default version) with lisp words. | 1388 | "Initialize Ispell process (default version) with Lisp words. |
| 1474 | The words used are from `checkdoc-ispell-lisp-words'. If `ispell' | 1389 | The words used are from `checkdoc-ispell-lisp-words'. If `ispell' |
| 1475 | cannot be loaded, then set `checkdoc-spellcheck-documentation-flag' to | 1390 | cannot be loaded, then set `checkdoc-spellcheck-documentation-flag' to |
| 1476 | nil." | 1391 | nil." |
| @@ -1479,7 +1394,7 @@ nil." | |||
| 1479 | (condition-case nil | 1394 | (condition-case nil |
| 1480 | (progn | 1395 | (progn |
| 1481 | (ispell-buffer-local-words) | 1396 | (ispell-buffer-local-words) |
| 1482 | ;; This code copied in part from ispell.el emacs 19.34 | 1397 | ;; This code copied in part from ispell.el Emacs 19.34 |
| 1483 | (let ((w checkdoc-ispell-lisp-words)) | 1398 | (let ((w checkdoc-ispell-lisp-words)) |
| 1484 | (while w | 1399 | (while w |
| 1485 | (process-send-string | 1400 | (process-send-string |
| @@ -1490,9 +1405,9 @@ nil." | |||
| 1490 | (error (setq checkdoc-spellcheck-documentation-flag nil))))) | 1405 | (error (setq checkdoc-spellcheck-documentation-flag nil))))) |
| 1491 | 1406 | ||
| 1492 | (defun checkdoc-ispell-docstring-engine (end) | 1407 | (defun checkdoc-ispell-docstring-engine (end) |
| 1493 | "Run the ispell tools on the doc-string between point and END. | 1408 | "Run the Ispell tools on the doc string between point and END. |
| 1494 | Since ispell isn't lisp smart, we must pre-process the doc-string | 1409 | Since Ispell isn't Lisp-smart, we must pre-process the doc string |
| 1495 | before using the ispell engine on it." | 1410 | before using the Ispell engine on it." |
| 1496 | (if (not checkdoc-spellcheck-documentation-flag) | 1411 | (if (not checkdoc-spellcheck-documentation-flag) |
| 1497 | nil | 1412 | nil |
| 1498 | (checkdoc-ispell-init) | 1413 | (checkdoc-ispell-init) |
| @@ -1556,13 +1471,13 @@ Some editors & news agents may remove it"))) | |||
| 1556 | ;; end of different lines. | 1471 | ;; end of different lines. |
| 1557 | (progn | 1472 | (progn |
| 1558 | (goto-char start) | 1473 | (goto-char start) |
| 1559 | ;; There is no documentation in the elisp manual about this check, | 1474 | ;; There is no documentation in the Emacs Lisp manual about this check, |
| 1560 | ;; it is intended to help clean up messy code and reduce the file size. | 1475 | ;; it is intended to help clean up messy code and reduce the file size. |
| 1561 | (while (and (not msg) (re-search-forward "[^ \t\n]\\([ \t]+\\)$" end t)) | 1476 | (while (and (not msg) (re-search-forward "[^ \t\n]\\([ \t]+\\)$" end t)) |
| 1562 | ;; This is not a complex activity | 1477 | ;; This is not a complex activity |
| 1563 | (if (checkdoc-autofix-ask-replace | 1478 | (if (checkdoc-autofix-ask-replace |
| 1564 | (match-beginning 1) (match-end 1) | 1479 | (match-beginning 1) (match-end 1) |
| 1565 | "White space at end of line. Remove? " "") | 1480 | "White space at end of line. Remove? " "") |
| 1566 | nil | 1481 | nil |
| 1567 | (setq msg "White space found at end of line"))))) | 1482 | (setq msg "White space found at end of line"))))) |
| 1568 | ;; Return an error and leave the cursor at that spot, or restore | 1483 | ;; Return an error and leave the cursor at that spot, or restore |
| @@ -1581,7 +1496,7 @@ Some editors & news agents may remove it"))) | |||
| 1581 | (require 'lisp-mnt)) | 1496 | (require 'lisp-mnt)) |
| 1582 | 1497 | ||
| 1583 | (defun checkdoc-file-comments-engine () | 1498 | (defun checkdoc-file-comments-engine () |
| 1584 | "Return a message string if this file does not match the emacs standard. | 1499 | "Return a message string if this file does not match the Emacs standard. |
| 1585 | This checks for style only, such as the first line, Commentary:, | 1500 | This checks for style only, such as the first line, Commentary:, |
| 1586 | Code:, and others referenced in the style guide." | 1501 | Code:, and others referenced in the style guide." |
| 1587 | (if (featurep 'lisp-mnt) | 1502 | (if (featurep 'lisp-mnt) |
| @@ -1674,7 +1589,7 @@ Code:, and others referenced in the style guide." | |||
| 1674 | (if (and (checkdoc-outside-major-sexp) ;in code is ok. | 1589 | (if (and (checkdoc-outside-major-sexp) ;in code is ok. |
| 1675 | (checkdoc-autofix-ask-replace | 1590 | (checkdoc-autofix-ask-replace |
| 1676 | (match-beginning 1) (match-end 1) | 1591 | (match-beginning 1) (match-end 1) |
| 1677 | "Multiple occurances of ;;; found. Use ;; instead? " | 1592 | "Multiple occurances of ;;; found. Use ;; instead? " |
| 1678 | "" complex-replace)) | 1593 | "" complex-replace)) |
| 1679 | ;; Learn that, yea, the user did want to do this a | 1594 | ;; Learn that, yea, the user did want to do this a |
| 1680 | ;; whole bunch of times. | 1595 | ;; whole bunch of times. |
| @@ -1688,9 +1603,9 @@ Code:, and others referenced in the style guide." | |||
| 1688 | (goto-char (lm-commentary-mark)) | 1603 | (goto-char (lm-commentary-mark)) |
| 1689 | ;; Spellcheck between the commentary, and the first | 1604 | ;; Spellcheck between the commentary, and the first |
| 1690 | ;; non-comment line. We could use lm-commentary, but that | 1605 | ;; non-comment line. We could use lm-commentary, but that |
| 1691 | ;; returns a string, and ispell wants to talk to a buffer. | 1606 | ;; returns a string, and Ispell wants to talk to a buffer. |
| 1692 | ;; Since the comments talk about lisp, use the specialized | 1607 | ;; Since the comments talk about Lisp, use the specialized |
| 1693 | ;; spell-checker we also used for doc-strings. | 1608 | ;; spell-checker we also used for doc strings. |
| 1694 | (checkdoc-ispell-docstring-engine (save-excursion | 1609 | (checkdoc-ispell-docstring-engine (save-excursion |
| 1695 | (re-search-forward "^[^;]" nil t) | 1610 | (re-search-forward "^[^;]" nil t) |
| 1696 | (point)))) | 1611 | (point)))) |
| @@ -1957,7 +1872,7 @@ function called to create the messages." | |||
| 1957 | (shrink-window-if-larger-than-buffer))) | 1872 | (shrink-window-if-larger-than-buffer))) |
| 1958 | 1873 | ||
| 1959 | (defgroup checkdoc nil | 1874 | (defgroup checkdoc nil |
| 1960 | "Support for doc-string checking in emacs lisp." | 1875 | "Support for doc string checking in Emacs Lisp." |
| 1961 | :prefix "checkdoc" | 1876 | :prefix "checkdoc" |
| 1962 | :group 'lisp | 1877 | :group 'lisp |
| 1963 | :version "20.3") | 1878 | :version "20.3") |
| @@ -1966,4 +1881,5 @@ function called to create the messages." | |||
| 1966 | (lambda () (checkdoc-minor-mode 1))) | 1881 | (lambda () (checkdoc-minor-mode 1))) |
| 1967 | 1882 | ||
| 1968 | (provide 'checkdoc) | 1883 | (provide 'checkdoc) |
| 1884 | |||
| 1969 | ;;; checkdoc.el ends here | 1885 | ;;; checkdoc.el ends here |