annotate lisp/emacs-lisp/checkdoc.el @ 79537:bb68325eec9b

*** empty log message ***
author Juanma Barranquero <lekktu@gmail.com>
date Tue, 04 Dec 2007 15:43:26 +0000
parents 793ccd507663
children 78ee6fae0e41 e5a68f18fcb9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38436
b174db545cfd Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 37426
diff changeset
1 ;;; checkdoc.el --- check documentation strings for style requirements
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2
64751
5b1a238fcbb4 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64379
diff changeset
3 ;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 73647
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
5
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
7 ;; Version: 0.6.2
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
8 ;; Keywords: docs, maint, lisp
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
9
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
11
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
78217
935157c0b596 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 75346
diff changeset
14 ;; the Free Software Foundation; either version 3, or (at your option)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
15 ;; any later version.
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
16
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
21
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 58899
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 58899
diff changeset
25 ;; Boston, MA 02110-1301, USA.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
26
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
28 ;;
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
29 ;; The Emacs Lisp manual has a nice chapter on how to write
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
30 ;; documentation strings. Many stylistic suggestions are fairly
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
31 ;; deterministic and easy to check for syntactically, but also easy
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
32 ;; to forget. The main checkdoc engine will perform the stylistic
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
33 ;; checks needed to make sure these styles are remembered.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
34 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
35 ;; There are two ways to use checkdoc:
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
36 ;; 1) Periodically use `checkdoc' or `checkdoc-current-buffer'.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
37 ;; `checkdoc' is a more interactive version of
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
38 ;; `checkdoc-current-buffer'
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
39 ;; 2) Use `checkdoc-minor-mode' to automatically check your
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
40 ;; documentation whenever you evaluate Lisp code with C-M-x
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
41 ;; or [menu-bar emacs-lisp eval-buffer]. Additional key-bindings
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
42 ;; are also provided under C-c ? KEY
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
43 ;; (require 'checkdoc)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
44 ;; (add-hook 'emacs-lisp-mode-hook
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
45 ;; '(lambda () (checkdoc-minor-mode 1)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
46 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
47 ;; Using `checkdoc':
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
48 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
49 ;; The commands `checkdoc' and `checkdoc-ispell' are the top-level
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
50 ;; entry points to all of the different checks that are available. It
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
51 ;; breaks examination of your Lisp file into four sections (comments,
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
52 ;; documentation, messages, and spacing) and indicates its current
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
53 ;; state in a status buffer.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
54 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
55 ;; The Comments check examines your headers, footers, and
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
56 ;; various tags (such as "Code:") to make sure that your code is ready
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
57 ;; for easy integration into existing systems.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
58 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
59 ;; The Documentation check deals with documentation strings
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
60 ;; and their elements that help make Emacs easier to use.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
61 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
62 ;; The Messages check ensures that the strings displayed in the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
63 ;; minibuffer by some commands (such as `error' and `y-or-n-p')
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
64 ;; are consistent with the Emacs environment.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
65 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
66 ;; The Spacing check cleans up white-space at the end of lines.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
67 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
68 ;; The interface while working with documentation and messages is
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
69 ;; slightly different when being run in the interactive mode. The
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
70 ;; interface offers several options, including the ability to skip to
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
71 ;; the next error, or back up to previous errors. Auto-fixing is
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
72 ;; turned off at this stage, but you can use the `f' or `F' key to fix
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
73 ;; a given error (if the fix is available.)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
74 ;;
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
75 ;; Auto-fixing:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
76 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
77 ;; There are four classifications of style errors in terms of how
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
78 ;; easy they are to fix. They are simple, complex, really complex,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
79 ;; and impossible. (Impossible really means that checkdoc does not
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
80 ;; have a fixing routine yet.) Typically white-space errors are
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
81 ;; classified as simple, and are auto-fixed by default. Typographic
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
82 ;; changes are considered complex, and the user is asked if they want
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
83 ;; the problem fixed before checkdoc makes the change. These changes
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
84 ;; can be done without asking if `checkdoc-autofix-flag' is properly
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
85 ;; set. Potentially redundant changes are considered really complex,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
86 ;; and the user is always asked before a change is inserted. The
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
87 ;; variable `checkdoc-autofix-flag' controls how these types of errors
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
88 ;; are fixed.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
89 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
90 ;; Spell checking text:
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
91 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
92 ;; The variable `checkdoc-spellcheck-documentation-flag' can be set
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
93 ;; to customize how spell checking is to be done. Since spell
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
94 ;; checking can be quite slow, you can optimize how best you want your
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
95 ;; checking done. The default is `defun', which spell checks each time
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
96 ;; `checkdoc-defun' or `checkdoc-eval-defun' is used. Setting to nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
97 ;; prevents spell checking during normal usage.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
98 ;; Setting this variable to nil does not mean you cannot take
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
99 ;; advantage of the spell checking. You can instead use the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
100 ;; interactive functions `checkdoc-ispell-*' to check the spelling of
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
101 ;; your documentation.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
102 ;; There is a list of Lisp-specific words which checkdoc will
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
103 ;; install into Ispell on the fly, but only if Ispell is not already
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
104 ;; running. Use `ispell-kill-ispell' to make checkdoc restart it with
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
105 ;; these words enabled.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
106 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
107 ;; Checking parameters:
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
108 ;;
22514
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
109 ;; You might not always want a function to have its parameters listed
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
110 ;; in order. When this is the case, put the following comment just in
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
111 ;; front of the documentation string: "; checkdoc-order: nil" This
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
112 ;; overrides the value of `checkdoc-arguments-in-order-flag'.
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
113 ;;
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
114 ;; If you specifically wish to avoid mentioning a parameter of a
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
115 ;; function in the doc string (such as a hidden parameter, or a
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
116 ;; parameter which is very obvious like events), you can have checkdoc
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
117 ;; skip looking for it by putting the following comment just in front
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
118 ;; of the documentation string: "; checkdoc-params: (args go here)"
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
119 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
120 ;; Checking message strings:
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
121 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
122 ;; The text that follows the `error' and `y-or-n-p' commands is
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
123 ;; also checked. The documentation for `error' clearly states some
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
124 ;; simple style rules to follow which checkdoc will auto-fix for you.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
125 ;; `y-or-n-p' also states that it should end in a space. I added that
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
126 ;; it should end in "? " since that is almost always used.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
127 ;;
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
128 ;; Adding your own checks:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
129 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
130 ;; You can experiment with adding your own checks by setting the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
131 ;; hooks `checkdoc-style-hooks' and `checkdoc-comment-style-hooks'.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
132 ;; Return a string which is the error you wish to report. The cursor
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
133 ;; position should be preserved.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
134 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
135 ;; Error errors:
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
136 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
137 ;; Checkdoc does not always flag errors correctly. There are a
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
138 ;; couple ways you can coax your file into passing all of checkdoc's
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
139 ;; tests through buffer local variables.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
140 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
141 ;; The variable `checkdoc-verb-check-experimental-flag' can be used
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
142 ;; to turn off the check for verb-voice in case you use words that are
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
143 ;; not semantically verbs, but are still in the incomplete list.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
144 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
145 ;; The variable `checkdoc-symbol-words' can be a list of words that
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
146 ;; happen to also be symbols. This is not a problem for one-word
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
147 ;; symbols, but if you use a hyphenated word that is also a symbol,
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
148 ;; then you may need this.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
149 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
150 ;; The symbol `checkdoc-force-docstrings-flag' can be set to nil if
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
151 ;; you have many undocumented functions you don't wish to document.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
152 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
153 ;; See the above section "Checking Parameters" for details about
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
154 ;; parameter checking.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
155 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
156 ;; Dependencies:
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
157 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
158 ;; This file requires lisp-mnt (Lisp maintenance routines) for the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
159 ;; comment checkers.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
160 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
161 ;; Requires custom for Emacs v20.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
162
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
163 ;;; TO DO:
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
164 ;; Hook into the byte compiler on a defun/defvar level to generate
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
165 ;; warnings in the byte-compiler's warning/error buffer.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
166 ;; Better ways to override more typical `eval' functions. Advice
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
167 ;; might be good but hard to turn on/off as a minor mode.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
168 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
169 ;;; Maybe Do:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
170 ;; Code sweep checks for "forbidden functions", proper use of hooks,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
171 ;; proper keybindings, and other items from the manual that are
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
172 ;; not specifically docstring related. Would this even be useful?
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
173
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
174 ;;; Code:
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
175 (defvar checkdoc-version "0.6.1"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
176 "Release version of checkdoc you are currently running.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
177
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
178 ;; From custom web page for compatibility between versions of custom:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
179 (eval-and-compile
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
180 (condition-case ()
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
181 (require 'custom)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
182 (error nil))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
183 (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
184 nil ;; We've got what we needed
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
185 ;; We have the old custom-library, hack around it!
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
186 (defmacro defgroup (&rest args)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
187 nil)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
188 (defmacro custom-add-option (&rest args)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
189 nil)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
190 (defmacro defcustom (var value doc &rest args)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41222
diff changeset
191 `(defvar ,var ,value ,doc))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
192
65191
9dda4c47e83d (compilation-error-regexp-alist, compilation-mode-font-lock-keywords):
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
193 (defvar compilation-error-regexp-alist)
9dda4c47e83d (compilation-error-regexp-alist, compilation-mode-font-lock-keywords):
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
194 (defvar compilation-mode-font-lock-keywords)
9dda4c47e83d (compilation-error-regexp-alist, compilation-mode-font-lock-keywords):
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
195
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
196 (defgroup checkdoc nil
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
197 "Support for doc string checking in Emacs Lisp."
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
198 :prefix "checkdoc"
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
199 :group 'lisp
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
200 :version "20.3")
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
201
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
202 (defcustom checkdoc-autofix-flag 'semiautomatic
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
203 "Non-nil means attempt auto-fixing of doc strings.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
204 If this value is the symbol `query', then the user is queried before
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
205 any change is made. If the value is `automatic', then all changes are
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
206 made without asking unless the change is very-complex. If the value
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
207 is `semiautomatic' or any other value, then simple fixes are made
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
208 without asking, and complex changes are made by asking the user first.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
209 The value `never' is the same as nil, never ask or change anything."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
210 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
211 :type '(choice (const automatic)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
212 (const query)
22579
d0ad271c7774 (checkdoc-autofix-flag): Use `other'
Andreas Schwab <schwab@suse.de>
parents: 22514
diff changeset
213 (const never)
d0ad271c7774 (checkdoc-autofix-flag): Use `other'
Andreas Schwab <schwab@suse.de>
parents: 22514
diff changeset
214 (other :tag "semiautomatic" semiautomatic)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
215
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
216 (defcustom checkdoc-bouncy-flag t
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
217 "Non-nil means to \"bounce\" to auto-fix locations.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
218 Setting this to nil will silently make fixes that require no user
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
219 interaction. See `checkdoc-autofix-flag' for auto-fixing details."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
220 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
221 :type 'boolean)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
222
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
223 (defcustom checkdoc-force-docstrings-flag t
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
224 "Non-nil means that all checkable definitions should have documentation.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
225 Style guide dictates that interactive functions MUST have documentation,
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
226 and that it's good but not required practice to make non user visible items
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
227 have doc strings."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
228 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
229 :type 'boolean)
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
230 (put 'checkdoc-force-docstrings-flag 'safe-local-variable 'booleanp)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
231
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
232 (defcustom checkdoc-force-history-flag t
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
233 "Non-nil means that files should have a History section or ChangeLog file.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
234 This helps document the evolution of, and recent changes to, the package."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
235 :group 'checkdoc
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
236 :type 'boolean)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
237
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
238 (defcustom checkdoc-permit-comma-termination-flag nil
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
239 "Non-nil means the first line of a docstring may end with a comma.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
240 Ordinarily, a full sentence is required. This may be misleading when
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
241 there is a substantial caveat to the one-line description -- the comma
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
242 should be used when the first part could stand alone as a sentence, but
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
243 it indicates that a modifying clause follows."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
244 :group 'checkdoc
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
245 :type 'boolean)
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
246 (put 'checkdoc-permit-comma-termination-flag 'safe-local-variable 'booleanp)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
247
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
248 (defcustom checkdoc-spellcheck-documentation-flag nil
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
249 "Non-nil means run Ispell on text based on value.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
250 This is automatically set to nil if Ispell does not exist on your
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
251 system. Possible values are:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
252
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
253 nil - Don't spell-check during basic style checks.
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
254 defun - Spell-check when style checking a single defun
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
255 buffer - Spell-check when style checking the whole buffer
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
256 interactive - Spell-check during any interactive check.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
257 t - Always spell-check"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
258 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
259 :type '(choice (const nil)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
260 (const defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
261 (const buffer)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
262 (const interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
263 (const t)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
264
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
265 (defvar checkdoc-ispell-lisp-words
78473
793ccd507663 (checkdoc-ispell-lisp-words): Remove `iff'.
Glenn Morris <rgm@gnu.org>
parents: 78217
diff changeset
266 '("alist" "emacs" "etags" "keymap" "paren" "regexp" "sexp" "xemacs")
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
267 "List of words that are correct when spell-checking Lisp documentation.")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
268
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
269 (defcustom checkdoc-max-keyref-before-warn 10
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
270 "The number of \\ [command-to-keystroke] tokens allowed in a doc string.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
271 Any more than this and a warning is generated suggesting that the construct
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
272 \\ {keymap} be used instead."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
273 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
274 :type 'integer)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
275
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
276 (defcustom checkdoc-arguments-in-order-flag t
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
277 "Non-nil means warn if arguments appear out of order.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
278 Setting this to nil will mean only checking that all the arguments
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
279 appear in the proper form in the documentation, not that they are in
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
280 the same order as they appear in the argument list. No mention is
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
281 made in the style guide relating to order."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
282 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
283 :type 'boolean)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
284
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
285 (defvar checkdoc-style-hooks nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
286 "Hooks called after the standard style check is completed.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
287 All hooks must return nil or a string representing the error found.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
288 Useful for adding new user implemented commands.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
289
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
290 Each hook is called with two parameters, (DEFUNINFO ENDPOINT).
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
291 DEFUNINFO is the return value of `checkdoc-defun-info'. ENDPOINT is the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
292 location of end of the documentation string.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
293
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
294 (defvar checkdoc-comment-style-hooks nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
295 "Hooks called after the standard comment style check is completed.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
296 Must return nil if no errors are found, or a string describing the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
297 problem discovered. This is useful for adding additional checks.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
298
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
299 (defvar checkdoc-diagnostic-buffer "*Style Warnings*"
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
300 "Name of warning message buffer.")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
301
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
302 (defvar checkdoc-defun-regexp
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
303 "^(def\\(un\\|var\\|custom\\|macro\\|const\\|subst\\|advice\\)\
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
304 \\s-+\\(\\(\\sw\\|\\s_\\)+\\)[ \t\n]+"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
305 "Regular expression used to identify a defun.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
306 A search leaves the cursor in front of the parameter list.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
307
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
308 (defcustom checkdoc-verb-check-experimental-flag t
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
309 "Non-nil means to attempt to check the voice of the doc string.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
310 This check keys off some words which are commonly misused. See the
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
311 variable `checkdoc-common-verbs-wrong-voice' if you wish to add your own."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
312 :group 'checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
313 :type 'boolean)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
314
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
315 (defvar checkdoc-generate-compile-warnings-flag nil
46363
bf7784999bbd Fix doc typos.
Richard M. Stallman <rms@gnu.org>
parents: 45897
diff changeset
316 "Non-nil means generate warnings in a buffer for browsing.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
317 Do not set this by hand, use a function like `checkdoc-current-buffer'
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
318 with a universal argument.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
319
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
320 (defcustom checkdoc-symbol-words nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
321 "A list of symbols which also happen to make good words.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
322 These symbol-words are ignored when unquoted symbols are searched for.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
323 This should be set in an Emacs Lisp file's local variables."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
324 :group 'checkdoc
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
325 :type '(repeat (symbol :tag "Word")))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
326
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
327 (defvar checkdoc-proper-noun-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
328 '("ispell" "xemacs" "emacs" "lisp")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
329 "List of words (not capitalized) which should be capitalized.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
330
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
331 (defvar checkdoc-proper-noun-regexp
64182
176ffa79bdd8 (checkdoc-proper-noun-list):
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
332 (let ((expr "\\_<\\(")
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
333 (l checkdoc-proper-noun-list))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
334 (while l
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
335 (setq expr (concat expr (car l) (if (cdr l) "\\|" ""))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
336 l (cdr l)))
64182
176ffa79bdd8 (checkdoc-proper-noun-list):
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
337 (concat expr "\\)\\_>"))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
338 "Regular expression derived from `checkdoc-proper-noun-regexp'.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
339
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
340 (defvar checkdoc-common-verbs-regexp nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
341 "Regular expression derived from `checkdoc-common-verbs-regexp'.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
342
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
343 (defvar checkdoc-common-verbs-wrong-voice
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
344 '(("adds" . "add")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
345 ("allows" . "allow")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
346 ("appends" . "append")
22514
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
347 ("applies" . "apply")
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
348 ("arranges" . "arrange")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
349 ("brings" . "bring")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
350 ("calls" . "call")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
351 ("catches" . "catch")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
352 ("changes" . "change")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
353 ("checks" . "check")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
354 ("contains" . "contain")
37162
0b99eb07fc17 (checkdoc-common-verbs-wrong-voice): Add
Gerd Moellmann <gerd@gnu.org>
parents: 33495
diff changeset
355 ("converts" . "convert")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
356 ("creates" . "create")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
357 ("destroys" . "destroy")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
358 ("disables" . "disable")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
359 ("executes" . "execute")
22514
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
360 ("evals" . "evaluate")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
361 ("evaluates" . "evaluate")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
362 ("finds" . "find")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
363 ("forces" . "force")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
364 ("gathers" . "gather")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
365 ("generates" . "generate")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
366 ("goes" . "go")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
367 ("guesses" . "guess")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
368 ("highlights" . "highlight")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
369 ("holds" . "hold")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
370 ("ignores" . "ignore")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
371 ("indents" . "indent")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
372 ("initializes" . "initialize")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
373 ("inserts" . "insert")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
374 ("installs" . "install")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
375 ("investigates" . "investigate")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
376 ("keeps" . "keep")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
377 ("kills" . "kill")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
378 ("leaves" . "leave")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
379 ("lets" . "let")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
380 ("loads" . "load")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
381 ("looks" . "look")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
382 ("makes" . "make")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
383 ("marks" . "mark")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
384 ("matches" . "match")
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
385 ("moves" . "move")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
386 ("notifies" . "notify")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
387 ("offers" . "offer")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
388 ("parses" . "parse")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
389 ("performs" . "perform")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
390 ("prepares" . "prepare")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
391 ("prepends" . "prepend")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
392 ("reads" . "read")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
393 ("raises" . "raise")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
394 ("removes" . "remove")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
395 ("replaces" . "replace")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
396 ("resets" . "reset")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
397 ("restores" . "restore")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
398 ("returns" . "return")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
399 ("runs" . "run")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
400 ("saves" . "save")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
401 ("says" . "say")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
402 ("searches" . "search")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
403 ("selects" . "select")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
404 ("sets" . "set")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
405 ("sex" . "s*x")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
406 ("shows" . "show")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
407 ("signifies" . "signify")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
408 ("sorts" . "sort")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
409 ("starts" . "start")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
410 ("stores" . "store")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
411 ("switches" . "switch")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
412 ("tells" . "tell")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
413 ("tests" . "test")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
414 ("toggles" . "toggle")
22514
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
415 ("tries" . "try")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
416 ("turns" . "turn")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
417 ("undoes" . "undo")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
418 ("unloads" . "unload")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
419 ("unmarks" . "unmark")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
420 ("updates" . "update")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
421 ("uses" . "use")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
422 ("yanks" . "yank")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
423 )
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
424 "Alist of common words in the wrong voice and what should be used instead.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
425 Set `checkdoc-verb-check-experimental-flag' to nil to avoid this costly
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
426 and experimental check. Do not modify this list without setting
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
427 the value of `checkdoc-common-verbs-regexp' to nil which cause it to
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
428 be re-created.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
429
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
430 (defvar checkdoc-syntax-table nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
431 "Syntax table used by checkdoc in document strings.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
432
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
433 (if checkdoc-syntax-table
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
434 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
435 (setq checkdoc-syntax-table (copy-syntax-table emacs-lisp-mode-syntax-table))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
436 ;; When dealing with syntax in doc strings, make sure that - are encompassed
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
437 ;; in words so we can use cheap \\> to get the end of a symbol, not the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
438 ;; end of a word in a conglomerate.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
439 (modify-syntax-entry ?- "w" checkdoc-syntax-table)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
440 )
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48943
diff changeset
441
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
442
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
443 ;;; Compatibility
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
444 ;;
64379
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
445 (defalias 'checkdoc-make-overlay
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
446 (if (featurep 'xemacs) 'make-extent 'make-overlay))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
447 (defalias 'checkdoc-overlay-put
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
448 (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
449 (defalias 'checkdoc-delete-overlay
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
450 (if (featurep 'xemacs) 'delete-extent 'delete-overlay))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
451 (defalias 'checkdoc-overlay-start
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
452 (if (featurep 'xemacs) 'extent-start 'overlay-start))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
453 (defalias 'checkdoc-overlay-end
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
454 (if (featurep 'xemacs) 'extent-end 'overlay-end))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
455 (defalias 'checkdoc-mode-line-update
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
456 (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update))
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
457 (defalias 'checkdoc-char=
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
458 (if (featurep 'xemacs) 'char= '=))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
459
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
460 ;;; User level commands
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
461 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
462 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
463 (defun checkdoc ()
46363
bf7784999bbd Fix doc typos.
Richard M. Stallman <rms@gnu.org>
parents: 45897
diff changeset
464 "Interactively check the entire buffer for style errors.
bf7784999bbd Fix doc typos.
Richard M. Stallman <rms@gnu.org>
parents: 45897
diff changeset
465 The current status of the check will be displayed in a buffer which
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
466 the users will view as each check is completed."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
467 (interactive)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
468 (let ((status (list "Checking..." "-" "-" "-"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
469 (checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
470 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
471 '(buffer interactive t))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
472 ;; if the user set autofix to never, then that breaks the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
473 ;; obviously requested asking implied by using this function.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
474 ;; Set it to paranoia level.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
475 (checkdoc-autofix-flag (if (or (not checkdoc-autofix-flag)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
476 (eq checkdoc-autofix-flag 'never))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
477 'query
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
478 checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
479 tmp)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
480 (checkdoc-display-status-buffer status)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
481 ;; check the comments
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
482 (if (not buffer-file-name)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
483 (setcar status "Not checked")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
484 (if (checkdoc-file-comments-engine)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
485 (setcar status "Errors")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
486 (setcar status "Ok")))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
487 (setcar (cdr status) "Checking...")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
488 (checkdoc-display-status-buffer status)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
489 ;; Check the documentation
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
490 (setq tmp (checkdoc-interactive nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
491 (if tmp
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
492 (setcar (cdr status) (format "%d Errors" (length tmp)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
493 (setcar (cdr status) "Ok"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
494 (setcar (cdr (cdr status)) "Checking...")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
495 (checkdoc-display-status-buffer status)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
496 ;; Check the message text
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
497 (if (setq tmp (checkdoc-message-interactive nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
498 (setcar (cdr (cdr status)) (format "%d Errors" (length tmp)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
499 (setcar (cdr (cdr status)) "Ok"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
500 (setcar (cdr (cdr (cdr status))) "Checking...")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
501 (checkdoc-display-status-buffer status)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
502 ;; Rogue spacing
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
503 (if (condition-case nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
504 (checkdoc-rogue-spaces nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
505 (error t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
506 (setcar (cdr (cdr (cdr status))) "Errors")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
507 (setcar (cdr (cdr (cdr status))) "Ok"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
508 (checkdoc-display-status-buffer status)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
509
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
510 (defun checkdoc-display-status-buffer (check)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
511 "Display and update the status buffer for the current checkdoc mode.
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
512 CHECK is a list of four strings stating the current status of each
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
513 test; the nth string describes the status of the nth test."
25697
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
514 (let (temp-buffer-setup-hook)
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
515 (with-output-to-temp-buffer " *Checkdoc Status*"
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
516 (princ-list
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
517 "Buffer comments and tags: " (nth 0 check) "\n"
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
518 "Documentation style: " (nth 1 check) "\n"
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
519 "Message/Query text style: " (nth 2 check) "\n"
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
520 "Unwanted Spaces: " (nth 3 check)
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
521 )))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
522 (shrink-window-if-larger-than-buffer
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
523 (get-buffer-window " *Checkdoc Status*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
524 (message nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
525 (sit-for 0))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
526
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
527 ;;;###autoload
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
528 (defun checkdoc-interactive (&optional start-here showstatus)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
529 "Interactively check the current buffer for doc string errors.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
530 Prefix argument START-HERE will start the checking from the current
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
531 point, otherwise the check starts at the beginning of the current
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
532 buffer. Allows navigation forward and backwards through document
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
533 errors. Does not check for comment or space warnings.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
534 Optional argument SHOWSTATUS indicates that we should update the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
535 checkdoc status window instead of the usual behavior."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
536 (interactive "P")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
537 (let ((checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
538 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
539 '(interactive t)))))
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
540 (prog1
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
541 ;; Due to a design flaw, this will never spell check
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
542 ;; docstrings.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
543 (checkdoc-interactive-loop start-here showstatus
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
544 'checkdoc-next-error)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
545 ;; This is a workaround to perform spell checking.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
546 (checkdoc-interactive-ispell-loop start-here))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
547
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
548 ;;;###autoload
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
549 (defun checkdoc-message-interactive (&optional start-here showstatus)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
550 "Interactively check the current buffer for message string errors.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
551 Prefix argument START-HERE will start the checking from the current
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
552 point, otherwise the check starts at the beginning of the current
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
553 buffer. Allows navigation forward and backwards through document
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
554 errors. Does not check for comment or space warnings.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
555 Optional argument SHOWSTATUS indicates that we should update the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
556 checkdoc status window instead of the usual behavior."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
557 (interactive "P")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
558 (let ((checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
559 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
560 '(interactive t)))))
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
561 (prog1
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
562 ;; Due to a design flaw, this will never spell check messages.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
563 (checkdoc-interactive-loop start-here showstatus
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
564 'checkdoc-next-message-error)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
565 ;; This is a workaround to perform spell checking.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
566 (checkdoc-message-interactive-ispell-loop start-here))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
567
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
568 (defun checkdoc-interactive-loop (start-here showstatus findfunc)
46363
bf7784999bbd Fix doc typos.
Richard M. Stallman <rms@gnu.org>
parents: 45897
diff changeset
569 "Interactively loop over all errors that can be found by a given method.
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
570
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
571 If START-HERE is nil, searching starts at the beginning of the current
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
572 buffer, otherwise searching starts at START-HERE. SHOWSTATUS
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
573 expresses the verbosity of the search, and whether ending the search
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
574 will auto-exit this function.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
575
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
576 FINDFUNC is a symbol representing a function that will position the
42706
be541feb06cc Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 41608
diff changeset
577 cursor, and return error message text to present to the user. It is
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
578 assumed that the cursor will stop just before a major sexp, which will
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
579 be highlighted to present the user with feedback as to the offending
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
580 style."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
581 ;; Determine where to start the test
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
582 (let* ((begin (prog1 (point)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
583 (if (not start-here) (goto-char (point-min)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
584 ;; Assign a flag to spellcheck flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
585 (checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
586 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
587 '(buffer interactive t))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
588 ;; Fetch the error list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
589 (err-list (list (funcall findfunc nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
590 (cdo nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
591 (returnme nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
592 c)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
593 (save-window-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
594 (if (not (car err-list)) (setq err-list nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
595 ;; Include whatever function point is in for good measure.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
596 (beginning-of-defun)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
597 (while err-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
598 (goto-char (cdr (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
599 ;; The cursor should be just in front of the offending doc string
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
600 (if (stringp (car (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
601 (setq cdo (save-excursion (checkdoc-make-overlay
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
602 (point) (progn (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
603 (point)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
604 (setq cdo (checkdoc-make-overlay
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
605 (checkdoc-error-start (car (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
606 (checkdoc-error-end (car (car err-list))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
607 (unwind-protect
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
608 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
609 (checkdoc-overlay-put cdo 'face 'highlight)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
610 ;; Make sure the whole doc string is visible if possible.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
611 (sit-for 0)
27444
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
612 (if (and (looking-at "\"")
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
613 (not (pos-visible-in-window-p
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
614 (save-excursion (forward-sexp 1) (point))
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
615 (selected-window))))
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
616 (let ((l (count-lines (point)
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
617 (save-excursion
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
618 (forward-sexp 1) (point)))))
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
619 (if (> l (window-height))
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
620 (recenter 1)
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
621 (recenter (/ (- (window-height) l) 2))))
89c53b25be12 (checkdoc-interactive-loop): Don't lose on a function with an empty
Dave Love <fx@gnu.org>
parents: 26615
diff changeset
622 (recenter))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
623 (message "%s (C-h,%se,n,p,q)" (checkdoc-error-text
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
624 (car (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
625 (if (checkdoc-error-unfixable (car (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
626 "" "f,"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
627 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
628 (goto-char (checkdoc-error-start (car (car err-list))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
629 (if (not (pos-visible-in-window-p))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
630 (recenter (- (window-height) 2)))
64379
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
631 (setq c (read-event)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
632 (if (not (integerp c)) (setq c ??))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
633 (cond
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
634 ;; Exit condition
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
635 ((checkdoc-char= c ?\C-g) (signal 'quit nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
636 ;; Request an auto-fix
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
637 ((or (checkdoc-char= c ?y) (checkdoc-char= c ?f))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
638 (checkdoc-delete-overlay cdo)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
639 (setq cdo nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
640 (goto-char (cdr (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
641 ;; `automatic-then-never' tells the autofix function
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
642 ;; to only allow one fix to be automatic. The autofix
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
643 ;; function will then set the flag to 'never, allowing
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
644 ;; the checker to return a different error.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
645 (let ((checkdoc-autofix-flag 'automatic-then-never)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
646 (fixed nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
647 (funcall findfunc t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
648 (setq fixed (not (eq checkdoc-autofix-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
649 'automatic-then-never)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
650 (if (not fixed)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
651 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
652 (message "A Fix was not available.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
653 (sit-for 2))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
654 (setq err-list (cdr err-list))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
655 (beginning-of-defun)
54873
bbf96a27b6c5 (checkdoc-output-mode-map, checkdoc-find-error-mouse, checkdoc-find-error):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54498
diff changeset
656 (let ((ne (funcall findfunc nil)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
657 (if ne
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
658 (setq err-list (cons ne err-list))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
659 (cond ((not err-list)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
660 (message "No More Stylistic Errors.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
661 (sit-for 2))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
662 (t
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
663 (message
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
664 "No Additional style errors. Continuing...")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
665 (sit-for 2))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
666 ;; Move to the next error (if available)
65191
9dda4c47e83d (compilation-error-regexp-alist, compilation-mode-font-lock-keywords):
Juanma Barranquero <lekktu@gmail.com>
parents: 64751
diff changeset
667 ((or (checkdoc-char= c ?n) (checkdoc-char= c ?\s))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
668 (let ((ne (funcall findfunc nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
669 (if (not ne)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
670 (if showstatus
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
671 (setq returnme err-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
672 err-list nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
673 (if (not err-list)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
674 (message "No More Stylistic Errors.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
675 (message "No Additional style errors. Continuing..."))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
676 (sit-for 2))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
677 (setq err-list (cons ne err-list)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
678 ;; Go backwards in the list of errors
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
679 ((or (checkdoc-char= c ?p) (checkdoc-char= c ?\C-?))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
680 (if (/= (length err-list) 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
681 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
682 (setq err-list (cdr err-list))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
683 (goto-char (cdr (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
684 (beginning-of-defun))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
685 (message "No Previous Errors.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
686 (sit-for 2)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
687 ;; Edit the buffer recursively.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
688 ((checkdoc-char= c ?e)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
689 (checkdoc-recursive-edit
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
690 (checkdoc-error-text (car (car err-list))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
691 (checkdoc-delete-overlay cdo)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
692 (setq err-list (cdr err-list)) ;back up the error found.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
693 (beginning-of-defun)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
694 (let ((ne (funcall findfunc nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
695 (if (not ne)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
696 (if showstatus
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
697 (setq returnme err-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
698 err-list nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
699 (message "No More Stylistic Errors.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
700 (sit-for 2))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
701 (setq err-list (cons ne err-list)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
702 ;; Quit checkdoc
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
703 ((checkdoc-char= c ?q)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
704 (setq returnme err-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
705 err-list nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
706 begin (point)))
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
707 ;; Goofy stuff
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
708 (t
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
709 (if (get-buffer-window "*Checkdoc Help*")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
710 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
711 (delete-window (get-buffer-window "*Checkdoc Help*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
712 (kill-buffer "*Checkdoc Help*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
713 (with-output-to-temp-buffer "*Checkdoc Help*"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
714 (princ-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
715 "Checkdoc Keyboard Summary:\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
716 (if (checkdoc-error-unfixable (car (car err-list)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
717 ""
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
718 (concat
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
719 "f, y - auto Fix this warning without asking (if\
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
720 available.)\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
721 " Very complex operations will still query.\n")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
722 )
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
723 "e - Enter recursive Edit. Press C-M-c to exit.\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
724 "SPC, n - skip to the Next error.\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
725 "DEL, p - skip to the Previous error.\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
726 "q - Quit checkdoc.\n"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
727 "C-h - Toggle this help buffer."))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
728 (shrink-window-if-larger-than-buffer
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
729 (get-buffer-window "*Checkdoc Help*"))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
730 (if cdo (checkdoc-delete-overlay cdo)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
731 (goto-char begin)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
732 (if (get-buffer "*Checkdoc Help*") (kill-buffer "*Checkdoc Help*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
733 (message "Checkdoc: Done.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
734 returnme))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
735
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
736 (defun checkdoc-interactive-ispell-loop (start-here)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
737 "Interactively spell check doc strings in the current buffer.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
738 If START-HERE is nil, searching starts at the beginning of the current
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
739 buffer, otherwise searching starts at START-HERE."
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
740 (when checkdoc-spellcheck-documentation-flag
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
741 (save-excursion
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
742 ;; Move point to where we need to start.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
743 (if start-here
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
744 ;; Include whatever function point is in for good measure.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
745 (beginning-of-defun)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
746 (goto-char (point-min)))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
747 ;; Loop over docstrings.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
748 (while (checkdoc-next-docstring)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
749 (message "Searching for doc string spell error...%d%%"
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
750 (/ (* 100 (point)) (point-max)))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
751 (if (looking-at "\"")
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
752 (checkdoc-ispell-docstring-engine
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
753 (save-excursion (forward-sexp 1) (point-marker)))))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
754 (message "Checkdoc: Done."))))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
755
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
756 (defun checkdoc-message-interactive-ispell-loop (start-here)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
757 "Interactively spell check messages in the current buffer.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
758 If START-HERE is nil, searching starts at the beginning of the current
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
759 buffer, otherwise searching starts at START-HERE."
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
760 (when checkdoc-spellcheck-documentation-flag
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
761 (save-excursion
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
762 ;; Move point to where we need to start.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
763 (if start-here
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
764 ;; Include whatever function point is in for good measure.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
765 (beginning-of-defun)
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
766 (goto-char (point-min)))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
767 ;; Loop over message strings.
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
768 (while (checkdoc-message-text-next-string (point-max))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
769 (message "Searching for message string spell error...%d%%"
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
770 (/ (* 100 (point)) (point-max)))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
771 (if (looking-at "\"")
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
772 (checkdoc-ispell-docstring-engine
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
773 (save-excursion (forward-sexp 1) (point-marker)))))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
774 (message "Checkdoc: Done."))))
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
775
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
776
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
777 (defun checkdoc-next-error (enable-fix)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
778 "Find and return the next checkdoc error list, or nil.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
779 Only documentation strings are checked.
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
780 An error list is of the form (WARNING . POSITION) where WARNING is the
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
781 warning text, and POSITION is the point in the buffer where the error
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
782 was found. We can use points and not markers because we promise not
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
783 to edit the buffer before point without re-executing this check.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
784 Argument ENABLE-FIX will enable auto-fixing while looking for the next
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
785 error. This argument assumes that the cursor is already positioned to
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
786 perform the fix."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
787 (if enable-fix
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
788 (checkdoc-this-string-valid)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
789 (let ((msg nil) (p (point))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
790 (checkdoc-autofix-flag nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
791 (condition-case nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
792 (while (and (not msg) (checkdoc-next-docstring))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
793 (message "Searching for doc string error...%d%%"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
794 (/ (* 100 (point)) (point-max)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
795 (if (setq msg (checkdoc-this-string-valid))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
796 (setq msg (cons msg (point)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
797 ;; Quit.. restore position, Other errors, leave alone
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
798 (quit (goto-char p)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
799 msg)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
800
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
801 (defun checkdoc-next-message-error (enable-fix)
41222
3d601db16361 (princ-list, checkdoc-read-event, add-to-list): Delete compatibility code.
Richard M. Stallman <rms@gnu.org>
parents: 40926
diff changeset
802 "Find and return the next checkdoc message related error list, or nil.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
803 Only text for error and `y-or-n-p' strings are checked. See
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
804 `checkdoc-next-error' for details on the return value.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
805 Argument ENABLE-FIX turns on the auto-fix feature. This argument
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
806 assumes that the cursor is already positioned to perform the fix."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
807 (if enable-fix
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
808 (checkdoc-message-text-engine)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
809 (let ((msg nil) (p (point)) (type nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
810 (checkdoc-autofix-flag nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
811 (condition-case nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
812 (while (and (not msg)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
813 (setq type
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
814 (checkdoc-message-text-next-string (point-max))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
815 (message "Searching for message string error...%d%%"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
816 (/ (* 100 (point)) (point-max)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
817 (if (setq msg (checkdoc-message-text-engine type))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
818 (setq msg (cons msg (point)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
819 ;; Quit.. restore position, Other errors, leave alone
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
820 (quit (goto-char p)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
821 msg)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
822
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
823 (defun checkdoc-recursive-edit (msg)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
824 "Enter recursive edit to permit a user to fix some error checkdoc has found.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
825 MSG is the error that was found, which is displayed in a help buffer."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
826 (with-output-to-temp-buffer "*Checkdoc Help*"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
827 (princ-list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
828 "Error message:\n " msg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
829 "\n\nEdit to fix this problem, and press C-M-c to continue."))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
830 (shrink-window-if-larger-than-buffer
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
831 (get-buffer-window "*Checkdoc Help*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
832 (message "When you're done editing press C-M-c to continue.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
833 (unwind-protect
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
834 (recursive-edit)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
835 (if (get-buffer-window "*Checkdoc Help*")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
836 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
837 (delete-window (get-buffer-window "*Checkdoc Help*"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
838 (kill-buffer "*Checkdoc Help*")))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
839
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
840 ;;;###autoload
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
841 (defun checkdoc-eval-current-buffer ()
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
842 "Evaluate and check documentation for the current buffer.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
843 Evaluation is done first because good documentation for something that
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
844 doesn't work is just not useful. Comments, doc strings, and rogue
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
845 spacing are all verified."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
846 (interactive)
64379
12443a1e01ee (checkdoc-make-overlay, checkdoc-overlay-put, checkdoc-delete-overlay)
Richard M. Stallman <rms@gnu.org>
parents: 64182
diff changeset
847 (eval-buffer nil)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
848 (checkdoc-current-buffer t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
849
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
850 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
851 (defun checkdoc-current-buffer (&optional take-notes)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
852 "Check current buffer for document, comment, error style, and rogue spaces.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
853 With a prefix argument (in Lisp, the argument TAKE-NOTES),
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
854 store all errors found in a warnings buffer,
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
855 otherwise stop after the first error."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
856 (interactive "P")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
857 (if (interactive-p) (message "Checking buffer for style..."))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
858 ;; Assign a flag to spellcheck flag
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
859 (let ((checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
860 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
861 '(buffer t))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
862 (checkdoc-autofix-flag (if take-notes 'never
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
863 checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
864 (checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
865 (or take-notes checkdoc-generate-compile-warnings-flag)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
866 (if take-notes
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
867 (checkdoc-start-section "checkdoc-current-buffer"))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
868 ;; every test is responsible for returning the cursor.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
869 (or (and buffer-file-name ;; only check comments in a file
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
870 (checkdoc-comments))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
871 (checkdoc-start)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
872 (checkdoc-message-text)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
873 (checkdoc-rogue-spaces)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
874 (not (interactive-p))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
875 (if take-notes (checkdoc-show-diagnostics))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
876 (message "Checking buffer for style...Done."))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
877
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
878 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
879 (defun checkdoc-start (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
880 "Start scanning the current buffer for documentation string style errors.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
881 Only documentation strings are checked.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
882 Use `checkdoc-continue' to continue checking if an error cannot be fixed.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
883 Prefix argument TAKE-NOTES means to collect all the warning messages into
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
884 a separate buffer."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
885 (interactive "P")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
886 (let ((p (point)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
887 (goto-char (point-min))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
888 (if (and take-notes (interactive-p))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
889 (checkdoc-start-section "checkdoc-start"))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
890 (checkdoc-continue take-notes)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
891 ;; Go back since we can't be here without success above.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
892 (goto-char p)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
893 nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
894
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
895 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
896 (defun checkdoc-continue (&optional take-notes)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
897 "Find the next doc string in the current buffer which has a style error.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
898 Prefix argument TAKE-NOTES means to continue through the whole buffer and
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
899 save warnings in a separate buffer. Second optional argument START-POINT
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
900 is the starting location. If this is nil, `point-min' is used instead."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
901 (interactive "P")
54873
bbf96a27b6c5 (checkdoc-output-mode-map, checkdoc-find-error-mouse, checkdoc-find-error):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54498
diff changeset
902 (let ((wrong nil) (msg nil)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
903 ;; Assign a flag to spellcheck flag
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
904 (checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
905 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
906 '(buffer t))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
907 (checkdoc-autofix-flag (if take-notes 'never
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
908 checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
909 (checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
910 (or take-notes checkdoc-generate-compile-warnings-flag)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
911 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
912 ;; If we are taking notes, encompass the whole buffer, otherwise
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
913 ;; the user is navigating down through the buffer.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
914 (while (and (not wrong) (checkdoc-next-docstring))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
915 ;; OK, let's look at the doc string.
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
916 (setq msg (checkdoc-this-string-valid))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
917 (if msg (setq wrong (point)))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
918 (if wrong
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
919 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
920 (goto-char wrong)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
921 (if (not take-notes)
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
922 (error "%s" (checkdoc-error-text msg)))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
923 (checkdoc-show-diagnostics)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
924 (if (interactive-p)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
925 (message "No style warnings."))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
926
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
927 (defun checkdoc-next-docstring ()
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
928 "Move to the next doc string after point, and return t.
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
929 Return nil if there are no more doc strings."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
930 (if (not (re-search-forward checkdoc-defun-regexp nil t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
931 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
932 ;; search drops us after the identifier. The next sexp is either
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
933 ;; the argument list or the value of the variable. skip it.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
934 (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
935 (skip-chars-forward " \n\t")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
936 t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
937
37426
71d360920aad Fix autoload cookies.
Gerd Moellmann <gerd@gnu.org>
parents: 37162
diff changeset
938 ;;;###autoload
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
939 (defun checkdoc-comments (&optional take-notes)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
940 "Find missing comment sections in the current Emacs Lisp file.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
941 Prefix argument TAKE-NOTES non-nil means to save warnings in a
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
942 separate buffer. Otherwise print a message. This returns the error
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
943 if there is one."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
944 (interactive "P")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
945 (if take-notes (checkdoc-start-section "checkdoc-comments"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
946 (if (not buffer-file-name)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
947 (error "Can only check comments for a file buffer"))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
948 (let* ((checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
949 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
950 '(buffer t))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
951 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
952 (e (checkdoc-file-comments-engine))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
953 (checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
954 (or take-notes checkdoc-generate-compile-warnings-flag)))
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
955 (if e (error "%s" (checkdoc-error-text e)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
956 (checkdoc-show-diagnostics)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
957 e))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
958
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
959 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
960 (defun checkdoc-rogue-spaces (&optional take-notes interact)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
961 "Find extra spaces at the end of lines in the current file.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
962 Prefix argument TAKE-NOTES non-nil means to save warnings in a
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
963 separate buffer. Otherwise print a message. This returns the error
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
964 if there is one.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
965 Optional argument INTERACT permits more interactive fixing."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
966 (interactive "P")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
967 (if take-notes (checkdoc-start-section "checkdoc-rogue-spaces"))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
968 (let* ((checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
969 (e (checkdoc-rogue-space-check-engine nil nil interact))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
970 (checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
971 (or take-notes checkdoc-generate-compile-warnings-flag)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
972 (if (not (interactive-p))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
973 e
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
974 (if e
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
975 (message (checkdoc-error-text e))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
976 (checkdoc-show-diagnostics)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
977 (message "Space Check: done.")))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
978
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
979 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
980 (defun checkdoc-message-text (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
981 "Scan the buffer for occurrences of the error function, and verify text.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
982 Optional argument TAKE-NOTES causes all errors to be logged."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
983 (interactive "P")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
984 (if take-notes (checkdoc-start-section "checkdoc-message-text"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
985 (let* ((p (point)) e
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
986 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
987 (checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
988 (or take-notes checkdoc-generate-compile-warnings-flag)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
989 (setq e (checkdoc-message-text-search))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
990 (if (not (interactive-p))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
991 e
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
992 (if e
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
993 (error "%s" (checkdoc-error-text e))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
994 (checkdoc-show-diagnostics)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
995 (goto-char p))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
996 (if (interactive-p) (message "Checking interactive message text...done.")))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48943
diff changeset
997
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
998 ;;;###autoload
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
999 (defun checkdoc-eval-defun ()
22514
dee11277c07d (checkdoc-eval-defun): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents: 22195
diff changeset
1000 "Evaluate the current form with `eval-defun' and check its documentation.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1001 Evaluation is done first so the form will be read before the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1002 documentation is checked. If there is a documentation error, then the display
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1003 of what was evaluated will be overwritten by the diagnostic message."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1004 (interactive)
40291
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
1005 (call-interactively 'eval-defun)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1006 (checkdoc-defun))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1007
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1008 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1009 (defun checkdoc-defun (&optional no-error)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1010 "Examine the doc string of the function or variable under point.
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1011 Call `error' if the doc string has problems. If NO-ERROR is
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1012 non-nil, then do not call error, but call `message' instead.
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1013 If the doc string passes the test, then check the function for rogue white
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1014 space at the end of each line."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1015 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1016 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1017 (beginning-of-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1018 (if (not (looking-at checkdoc-defun-regexp))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1019 ;; I found this more annoying than useful.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1020 ;;(if (not no-error)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1021 ;; (message "Cannot check this sexp's doc string."))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1022 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1023 ;; search drops us after the identifier. The next sexp is either
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1024 ;; the argument list or the value of the variable. skip it.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1025 (goto-char (match-end 0))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1026 (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1027 (skip-chars-forward " \n\t")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1028 (let* ((checkdoc-spellcheck-documentation-flag
46841
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
1029 (car (memq checkdoc-spellcheck-documentation-flag
99952aa7f2c3 (checkdoc, checkdoc-interactive)
Richard M. Stallman <rms@gnu.org>
parents: 46363
diff changeset
1030 '(defun t))))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1031 (beg (save-excursion (beginning-of-defun) (point)))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1032 (end (save-excursion (end-of-defun) (point)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1033 (msg (checkdoc-this-string-valid)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1034 (if msg (if no-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1035 (message (checkdoc-error-text msg))
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
1036 (error "%s" (checkdoc-error-text msg)))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1037 (setq msg (checkdoc-message-text-search beg end))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1038 (if msg (if no-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1039 (message (checkdoc-error-text msg))
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
1040 (error "%s" (checkdoc-error-text msg)))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1041 (setq msg (checkdoc-rogue-space-check-engine beg end))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1042 (if msg (if no-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1043 (message (checkdoc-error-text msg))
58899
9715276c90ce (checkdoc-continue, checkdoc-comments, checkdoc-message-text, checkdoc-defun):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 57072
diff changeset
1044 (error "%s" (checkdoc-error-text msg))))))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1045 (if (interactive-p) (message "Checkdoc: done."))))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1046
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1047 ;;; Ispell interface for forcing a spell check
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1048 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1049
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1050 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1051 (defun checkdoc-ispell (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1052 "Check the style and spelling of everything interactively.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1053 Calls `checkdoc' with spell-checking turned on.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1054 Prefix argument TAKE-NOTES is the same as for `checkdoc'"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1055 (interactive)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1056 (let ((checkdoc-spellcheck-documentation-flag t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1057 (call-interactively 'checkdoc nil current-prefix-arg)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1058
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1059 ;;;###autoload
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1060 (defun checkdoc-ispell-current-buffer (&optional take-notes)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1061 "Check the style and spelling of the current buffer.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1062 Calls `checkdoc-current-buffer' with spell-checking turned on.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1063 Prefix argument TAKE-NOTES is the same as for `checkdoc-current-buffer'"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1064 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1065 (let ((checkdoc-spellcheck-documentation-flag t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1066 (call-interactively 'checkdoc-current-buffer nil current-prefix-arg)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1067
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1068 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1069 (defun checkdoc-ispell-interactive (&optional take-notes)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1070 "Check the style and spelling of the current buffer interactively.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1071 Calls `checkdoc-interactive' with spell-checking turned on.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1072 Prefix argument TAKE-NOTES is the same as for `checkdoc-interactive'"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1073 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1074 (let ((checkdoc-spellcheck-documentation-flag t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1075 (call-interactively 'checkdoc-interactive nil current-prefix-arg)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1076
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1077 ;;;###autoload
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1078 (defun checkdoc-ispell-message-interactive (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1079 "Check the style and spelling of message text interactively.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1080 Calls `checkdoc-message-interactive' with spell-checking turned on.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1081 Prefix argument TAKE-NOTES is the same as for `checkdoc-message-interactive'"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1082 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1083 (let ((checkdoc-spellcheck-documentation-flag t))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1084 (call-interactively 'checkdoc-message-interactive nil current-prefix-arg)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1085
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1086 ;;;###autoload
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1087 (defun checkdoc-ispell-message-text (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1088 "Check the style and spelling of message text interactively.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1089 Calls `checkdoc-message-text' with spell-checking turned on.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1090 Prefix argument TAKE-NOTES is the same as for `checkdoc-message-text'"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1091 (interactive)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1092 (let ((checkdoc-spellcheck-documentation-flag t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1093 (call-interactively 'checkdoc-message-text nil current-prefix-arg)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1094
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1095 ;;;###autoload
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1096 (defun checkdoc-ispell-start (&optional take-notes)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1097 "Check the style and spelling of the current buffer.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1098 Calls `checkdoc-start' with spell-checking turned on.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1099 Prefix argument TAKE-NOTES is the same as for `checkdoc-start'"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1100 (interactive)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1101 (let ((checkdoc-spellcheck-documentation-flag t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1102 (call-interactively 'checkdoc-start nil current-prefix-arg)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1103
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1104 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1105 (defun checkdoc-ispell-continue (&optional take-notes)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1106 "Check the style and spelling of the current buffer after point.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1107 Calls `checkdoc-continue' with spell-checking turned on.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1108 Prefix argument TAKE-NOTES is the same as for `checkdoc-continue'"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1109 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1110 (let ((checkdoc-spellcheck-documentation-flag t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1111 (call-interactively 'checkdoc-continue nil current-prefix-arg)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1112
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1113 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1114 (defun checkdoc-ispell-comments (&optional take-notes)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1115 "Check the style and spelling of the current buffer's comments.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1116 Calls `checkdoc-comments' with spell-checking turned on.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1117 Prefix argument TAKE-NOTES is the same as for `checkdoc-comments'"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1118 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1119 (let ((checkdoc-spellcheck-documentation-flag t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1120 (call-interactively 'checkdoc-comments nil current-prefix-arg)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1121
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1122 ;;;###autoload
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1123 (defun checkdoc-ispell-defun (&optional take-notes)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1124 "Check the style and spelling of the current defun with Ispell.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1125 Calls `checkdoc-defun' with spell-checking turned on.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1126 Prefix argument TAKE-NOTES is the same as for `checkdoc-defun'"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1127 (interactive)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1128 (let ((checkdoc-spellcheck-documentation-flag t))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1129 (call-interactively 'checkdoc-defun nil current-prefix-arg)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1130
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1131 ;;; Error Management
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1132 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1133 ;; Errors returned from checkdoc functions can have various
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1134 ;; features and behaviors, so we need some ways of specifying
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1135 ;; them, and making them easier to use in the wacked-out interfaces
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1136 ;; people are requesting
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1137 (defun checkdoc-create-error (text start end &optional unfixable)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1138 "Used to create the return error text returned from all engines.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1139 TEXT is the descriptive text of the error. START and END define the region
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1140 it is sensible to highlight when describing the problem.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1141 Optional argument UNFIXABLE means that the error has no auto-fix available.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1142
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1143 A list of the form (TEXT START END UNFIXABLE) is returned if we are not
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1144 generating a buffered list of errors."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1145 (if checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1146 (progn (checkdoc-error start text)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1147 nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1148 (list text start end unfixable)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1149
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1150 (defun checkdoc-error-text (err)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1151 "Return the text specified in the checkdoc ERR."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1152 ;; string-p part is for backwards compatibility
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1153 (if (stringp err) err (car err)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1154
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1155 (defun checkdoc-error-start (err)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1156 "Return the start point specified in the checkdoc ERR."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1157 ;; string-p part is for backwards compatibility
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1158 (if (stringp err) nil (nth 1 err)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1159
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1160 (defun checkdoc-error-end (err)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1161 "Return the end point specified in the checkdoc ERR."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1162 ;; string-p part is for backwards compatibility
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1163 (if (stringp err) nil (nth 2 err)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1164
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1165 (defun checkdoc-error-unfixable (err)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1166 "Return the t if we cannot autofix the error specified in the checkdoc ERR."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1167 ;; string-p part is for backwards compatibility
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1168 (if (stringp err) nil (nth 3 err)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1169
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1170 ;;; Minor Mode specification
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1171 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1172
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1173 (defvar checkdoc-minor-mode-map
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1174 (let ((map (make-sparse-keymap))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1175 (pmap (make-sparse-keymap)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1176 ;; Override some bindings
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1177 (define-key map "\C-\M-x" 'checkdoc-eval-defun)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1178 (define-key map "\C-x`" 'checkdoc-continue)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1179 (if (not (string-match "XEmacs" emacs-version))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1180 (define-key map [menu-bar emacs-lisp eval-buffer]
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1181 'checkdoc-eval-current-buffer))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1182 ;; Add some new bindings under C-c ?
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1183 (define-key pmap "x" 'checkdoc-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1184 (define-key pmap "X" 'checkdoc-ispell-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1185 (define-key pmap "`" 'checkdoc-continue)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1186 (define-key pmap "~" 'checkdoc-ispell-continue)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1187 (define-key pmap "s" 'checkdoc-start)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1188 (define-key pmap "S" 'checkdoc-ispell-start)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1189 (define-key pmap "d" 'checkdoc)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1190 (define-key pmap "D" 'checkdoc-ispell)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1191 (define-key pmap "b" 'checkdoc-current-buffer)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1192 (define-key pmap "B" 'checkdoc-ispell-current-buffer)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1193 (define-key pmap "e" 'checkdoc-eval-current-buffer)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1194 (define-key pmap "m" 'checkdoc-message-text)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1195 (define-key pmap "M" 'checkdoc-ispell-message-text)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1196 (define-key pmap "c" 'checkdoc-comments)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1197 (define-key pmap "C" 'checkdoc-ispell-comments)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1198 (define-key pmap " " 'checkdoc-rogue-spaces)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1199
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1200 ;; bind our submap into map
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1201 (define-key map "\C-c?" pmap)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1202 map)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1203 "Keymap used to override evaluation key-bindings for documentation checking.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1204
49621
45cd70f39238 (checkdoc-minor-keymap): Add obsolescence declaration and remove redundant info
Juanma Barranquero <lekktu@gmail.com>
parents: 49598
diff changeset
1205 (defvaralias 'checkdoc-minor-keymap 'checkdoc-minor-mode-map)
45cd70f39238 (checkdoc-minor-keymap): Add obsolescence declaration and remove redundant info
Juanma Barranquero <lekktu@gmail.com>
parents: 49598
diff changeset
1206 (make-obsolete-variable 'checkdoc-minor-keymap
45cd70f39238 (checkdoc-minor-keymap): Add obsolescence declaration and remove redundant info
Juanma Barranquero <lekktu@gmail.com>
parents: 49598
diff changeset
1207 'checkdoc-minor-mode-map)
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1208
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1209 ;; Add in a menubar with easy-menu
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1210
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1211 (easy-menu-define
48943
d096b3c93f80 Don't define a name for the minor mode menu.
Richard M. Stallman <rms@gnu.org>
parents: 48403
diff changeset
1212 nil checkdoc-minor-mode-map "Checkdoc Minor Mode Menu"
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1213 '("CheckDoc"
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1214 ["Interactive Buffer Style Check" checkdoc t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1215 ["Interactive Buffer Style and Spelling Check" checkdoc-ispell t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1216 ["Check Buffer" checkdoc-current-buffer t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1217 ["Check and Spell Buffer" checkdoc-ispell-current-buffer t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1218 "---"
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1219 ["Interactive Style Check" checkdoc-interactive t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1220 ["Interactive Style and Spelling Check" checkdoc-ispell-interactive t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1221 ["Find First Style Error" checkdoc-start t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1222 ["Find First Style or Spelling Error" checkdoc-ispell-start t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1223 ["Next Style Error" checkdoc-continue t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1224 ["Next Style or Spelling Error" checkdoc-ispell-continue t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1225 ["Interactive Message Text Style Check" checkdoc-message-interactive t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1226 ["Interactive Message Text Style and Spelling Check"
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1227 checkdoc-ispell-message-interactive t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1228 ["Check Message Text" checkdoc-message-text t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1229 ["Check and Spell Message Text" checkdoc-ispell-message-text t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1230 ["Check Comment Style" checkdoc-comments buffer-file-name]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1231 ["Check Comment Style and Spelling" checkdoc-ispell-comments
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1232 buffer-file-name]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1233 ["Check for Rogue Spaces" checkdoc-rogue-spaces t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1234 "---"
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1235 ["Check Defun" checkdoc-defun t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1236 ["Check and Spell Defun" checkdoc-ispell-defun t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1237 ["Check and Evaluate Defun" checkdoc-eval-defun t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1238 ["Check and Evaluate Buffer" checkdoc-eval-current-buffer t]
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1239 ))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1240 ;; XEmacs requires some weird stuff to add this menu in a minor mode.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1241 ;; What is it?
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1242
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1243 ;;;###autoload
45258
be966e885dcc (checkdoc-minor-mode): Define it with define-minor-mode.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 43133
diff changeset
1244 (define-minor-mode checkdoc-minor-mode
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1245 "Toggle Checkdoc minor mode, a mode for checking Lisp doc strings.
78473
793ccd507663 (checkdoc-ispell-lisp-words): Remove `iff'.
Glenn Morris <rgm@gnu.org>
parents: 78217
diff changeset
1246 With prefix ARG, turn Checkdoc minor mode on if ARG is positive, otherwise
793ccd507663 (checkdoc-ispell-lisp-words): Remove `iff'.
Glenn Morris <rgm@gnu.org>
parents: 78217
diff changeset
1247 turn it off.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1248
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1249 In Checkdoc minor mode, the usual bindings for `eval-defun' which is
55446
2849e4ae725f (checkdoc-minor-mode): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 55110
diff changeset
1250 bound to \\<checkdoc-minor-mode-map>\\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1251 checking of documentation strings.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1252
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1253 \\{checkdoc-minor-mode-map}"
48403
68ad51bc7338 (checkdoc-minor-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48195
diff changeset
1254 nil " CDoc" nil
68ad51bc7338 (checkdoc-minor-mode): Add group.
Markus Rost <rost@math.uni-bielefeld.de>
parents: 48195
diff changeset
1255 :group 'checkdoc)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1256
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1257 ;;; Subst utils
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1258 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1259 (defsubst checkdoc-run-hooks (hookvar &rest args)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1260 "Run hooks in HOOKVAR with ARGS."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1261 (if (fboundp 'run-hook-with-args-until-success)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1262 (apply 'run-hook-with-args-until-success hookvar args)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1263 ;; This method was similar to above. We ignore the warning
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1264 ;; since we will use the above for future Emacs versions
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1265 (apply 'run-hook-with-args hookvar args)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1266
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1267 (defsubst checkdoc-create-common-verbs-regexp ()
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1268 "Rebuild the contents of `checkdoc-common-verbs-regexp'."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1269 (or checkdoc-common-verbs-regexp
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1270 (setq checkdoc-common-verbs-regexp
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1271 (concat "\\<\\("
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1272 (mapconcat (lambda (e) (concat (car e)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1273 checkdoc-common-verbs-wrong-voice "\\|")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1274 "\\)\\>"))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1275
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1276 ;; Profiler says this is not yet faster than just calling assoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1277 ;;(defun checkdoc-word-in-alist-vector (word vector)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1278 ;; "Check to see if WORD is in the car of an element of VECTOR.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1279 ;;VECTOR must be sorted. The CDR should be a replacement. Since the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1280 ;;word list is getting bigger, it is time for a quick bisecting search."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1281 ;; (let ((max (length vector)) (min 0) i
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1282 ;; (found nil) (fw nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1283 ;; (setq i (/ max 2))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1284 ;; (while (and (not found) (/= min max))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1285 ;; (setq fw (car (aref vector i)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1286 ;; (cond ((string= word fw) (setq found (cdr (aref vector i))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1287 ;; ((string< word fw) (setq max i))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1288 ;; (t (setq min i)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1289 ;; (setq i (/ (+ max min) 2))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1290 ;; )
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1291 ;; found))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1292
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1293 ;;; Checking engines
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1294 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1295 (defun checkdoc-this-string-valid ()
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1296 "Return a message string if the current doc string is invalid.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1297 Check for style only, such as the first line always being a complete
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1298 sentence, whitespace restrictions, and making sure there are no
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1299 hard-coded key-codes such as C-[char] or mouse-[number] in the comment.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1300 See the style guide in the Emacs Lisp manual for more details."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1301
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1302 ;; Jump over comments between the last object and the doc string
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1303 (while (looking-at "[ \t\n]*;")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1304 (forward-line 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1305 (beginning-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1306 (skip-chars-forward " \n\t"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1307
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1308 (let ((fp (checkdoc-defun-info))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1309 (err nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1310 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1311 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1312 ;; * Every command, function, or variable intended for users to know
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1313 ;; about should have a documentation string.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1314 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1315 ;; * An internal variable or subroutine of a Lisp program might as well
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1316 ;; have a documentation string. In earlier Emacs versions, you could
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1317 ;; save space by using a comment instead of a documentation string,
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1318 ;; but that is no longer the case.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1319 (if (and (not (nth 1 fp)) ; not a variable
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1320 (or (nth 2 fp) ; is interactive
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1321 checkdoc-force-docstrings-flag) ;or we always complain
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1322 (not (checkdoc-char= (following-char) ?\"))) ; no doc string
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1323 ;; Sometimes old code has comments where the documentation should
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1324 ;; be. Let's see if we can find the comment, and offer to turn it
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1325 ;; into documentation for them.
25697
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
1326 (let ((have-comment nil)
6060f83b1ffc (checkdoc-display-status-buffer): Avoid
Dave Love <fx@gnu.org>
parents: 23371
diff changeset
1327 (comment-start ";")) ; in case it's not default
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1328 (condition-case nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1329 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1330 (forward-sexp -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1331 (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1332 (skip-chars-forward "\n \t")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1333 (setq have-comment (looking-at comment-start)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1334 (error nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1335 (if have-comment
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1336 (if (or (eq checkdoc-autofix-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1337 'automatic-then-never)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1338 (checkdoc-y-or-n-p
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1339 "Convert comment to documentation? "))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1340 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1341 ;; Our point is at the beginning of the comment!
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1342 ;; Insert a quote, then remove the comment chars.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1343 (insert "\"")
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1344 (let ((docstring-start-point (point)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1345 (while (looking-at comment-start)
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1346 (while (looking-at comment-start)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1347 (delete-char 1))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1348 (if (looking-at "[ \t]+")
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1349 (delete-region (match-beginning 0) (match-end 0)))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1350 (forward-line 1)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1351 (beginning-of-line)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1352 (skip-chars-forward " \t")
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1353 (if (looking-at comment-start)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1354 (progn
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1355 (beginning-of-line)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1356 (zap-to-char 1 ?\;))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1357 (beginning-of-line)
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1358 (forward-char -1)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1359 (insert "\"")
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1360 (forward-char -1)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1361 ;; quote any double-quote characters in the comment.
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1362 (while (search-backward "\"" docstring-start-point t)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1363 (insert "\\"))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1364 (if (eq checkdoc-autofix-flag 'automatic-then-never)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1365 (setq checkdoc-autofix-flag 'never))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1366 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1367 "You should convert this comment to documentation"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1368 (point) (save-excursion (end-of-line) (point))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1369 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1370 (if (nth 2 fp)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1371 "All interactive functions should have documentation"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1372 "All variables and subroutines might as well have a \
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1373 documentation string")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1374 (point) (+ (point) 1) t)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1375 (if (and (not err) (looking-at "\""))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1376 (let ((old-syntax-table (syntax-table)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1377 (unwind-protect
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1378 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1379 (set-syntax-table checkdoc-syntax-table)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1380 (checkdoc-this-string-valid-engine fp))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1381 (set-syntax-table old-syntax-table)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1382 err)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1383
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1384 (defun checkdoc-this-string-valid-engine (fp)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1385 "Return an error list or string if the current doc string is invalid.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1386 Depends on `checkdoc-this-string-valid' to reset the syntax table so that
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1387 regexp short cuts work. FP is the function defun information."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1388 (let ((case-fold-search nil)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1389 ;; Use a marker so if an early check modifies the text,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1390 ;; we won't accidentally loose our place. This could cause
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1391 ;; end-of doc string whitespace to also delete the " char.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1392 (s (point))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1393 (e (if (looking-at "\"")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1394 (save-excursion (forward-sexp 1) (point-marker))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1395 (point))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1396 (or
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1397 ;; * *Do not* indent subsequent lines of a documentation string so that
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1398 ;; the text is lined up in the source code with the text of the first
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1399 ;; line. This looks nice in the source code, but looks bizarre when
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1400 ;; users view the documentation. Remember that the indentation
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1401 ;; before the starting double-quote is not part of the string!
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1402 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1403 (forward-line 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1404 (beginning-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1405 (if (and (< (point) e)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1406 (looking-at "\\([ \t]+\\)[^ \t\n]"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1407 (if (checkdoc-autofix-ask-replace (match-beginning 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1408 (match-end 1)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1409 "Remove this whitespace? "
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1410 "")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1411 nil
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1412 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1413 "Second line should not have indentation"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1414 (match-beginning 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1415 (match-end 1)))))
39319
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1416 ;; * Check for '(' in column 0.
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1417 (save-excursion
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1418 (when (re-search-forward "^(" e t)
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1419 (if (checkdoc-autofix-ask-replace (match-beginning 0)
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1420 (match-end 0)
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1421 "Escape this '('? "
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1422 "\\(")
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1423 nil
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1424 (checkdoc-create-error
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1425 "Open parenthesis in column 0 should be escaped"
bce0864bc830 (checkdoc-this-string-valid-engine):
Gerd Moellmann <gerd@gnu.org>
parents: 38436
diff changeset
1426 (match-beginning 0) (match-end 0)))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1427 ;; * Do not start or end a documentation string with whitespace.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1428 (let (start end)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1429 (if (or (if (looking-at "\"\\([ \t\n]+\\)")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1430 (setq start (match-beginning 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1431 end (match-end 1)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1432 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1433 (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1434 (forward-char -1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1435 (if (/= (skip-chars-backward " \t\n") 0)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1436 (setq start (point)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1437 end (1- e)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1438 (if (checkdoc-autofix-ask-replace
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1439 start end "Remove this whitespace? " "")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1440 nil
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1441 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1442 "Documentation strings should not start or end with whitespace"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1443 start end))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1444 ;; * The first line of the documentation string should consist of one
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1445 ;; or two complete sentences that stand on their own as a summary.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1446 ;; `M-x apropos' displays just the first line, and if it doesn't
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1447 ;; stand on its own, the result looks bad. In particular, start the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1448 ;; first line with a capital letter and end with a period.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1449 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1450 (end-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1451 (skip-chars-backward " \t\n")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1452 (if (> (point) e) (goto-char e)) ;of the form (defun n () "doc" nil)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1453 (forward-char -1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1454 (cond
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1455 ((and (checkdoc-char= (following-char) ?\")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1456 ;; A backslashed double quote at the end of a sentence
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1457 (not (checkdoc-char= (preceding-char) ?\\)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1458 ;; We might have to add a period in this case
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1459 (forward-char -1)
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1460 (if (looking-at "[.!?]")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1461 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1462 (forward-char 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1463 (if (checkdoc-autofix-ask-replace
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1464 (point) (1+ (point)) "Add period to sentence? "
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1465 ".\"" t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1466 nil
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1467 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1468 "First sentence should end with punctuation"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1469 (point) (1+ (point))))))
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1470 ((looking-at "[\\!?;:.)]")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1471 ;; These are ok
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1472 nil)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1473 ((and checkdoc-permit-comma-termination-flag (looking-at ","))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1474 nil)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1475 (t
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1476 ;; If it is not a complete sentence, let's see if we can
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1477 ;; predict a clever way to make it one.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1478 (let ((msg "First line is not a complete sentence")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1479 (e (point)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1480 (beginning-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1481 (if (re-search-forward "\\. +" e t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1482 ;; Here we have found a complete sentence, but no break.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1483 (if (checkdoc-autofix-ask-replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1484 (1+ (match-beginning 0)) (match-end 0)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1485 "First line not a complete sentence. Add RET here? "
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1486 "\n" t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1487 (let (l1 l2)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1488 (forward-line 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1489 (end-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1490 (setq l1 (current-column)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1491 l2 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1492 (forward-line 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1493 (end-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1494 (current-column)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1495 (if (> (+ l1 l2 1) 80)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1496 (setq msg "Incomplete auto-fix; doc string \
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1497 may require more formatting")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1498 ;; We can merge these lines! Replace this CR
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1499 ;; with a space.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1500 (delete-char 1) (insert " ")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1501 (setq msg nil))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1502 ;; Let's see if there is enough room to draw the next
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1503 ;; line's sentence up here. I often get hit w/
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1504 ;; auto-fill moving my words around.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1505 (let ((numc (progn (end-of-line) (- 80 (current-column))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1506 (p (point)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1507 (forward-line 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1508 (beginning-of-line)
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1509 (if (and (re-search-forward "[.!?:\"]\\([ \t\n]+\\|\"\\)"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1510 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1511 (end-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1512 (point))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1513 t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1514 (< (current-column) numc))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1515 (if (checkdoc-autofix-ask-replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1516 p (1+ p)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1517 "1st line not a complete sentence. Join these lines? "
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1518 " " t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1519 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1520 ;; They said yes. We have more fill work to do...
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1521 (goto-char (match-beginning 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1522 (delete-region (point) (match-end 1))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1523 (insert "\n")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1524 (setq msg nil))))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1525 (if msg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1526 (checkdoc-create-error msg s (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1527 (goto-char s)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1528 (end-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1529 (point)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1530 nil) ))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1531 ;; Continuation of above. Make sure our sentence is capitalized.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1532 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1533 (skip-chars-forward "\"\\*")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1534 (if (looking-at "[a-z]")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1535 (if (checkdoc-autofix-ask-replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1536 (match-beginning 0) (match-end 0)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1537 "Capitalize your sentence? " (upcase (match-string 0))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1538 t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1539 nil
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1540 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1541 "First line should be capitalized"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1542 (match-beginning 0) (match-end 0)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1543 nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1544 ;; * Don't write key sequences directly in documentation strings.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1545 ;; Instead, use the `\\[...]' construct to stand for them.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1546 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1547 (let ((f nil) (m nil) (start (point))
21181
2b9774c50f91 Updated to 0.4.3:
Eric M. Ludlam <zappo@gnu.org>
parents: 20953
diff changeset
1548 (re "[^`A-Za-z0-9_]\\([CMA]-[a-zA-Z]\\|\\(\\([CMA]-\\)?\
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1549 mouse-[0-3]\\)\\)\\>"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1550 ;; Find the first key sequence not in a sample
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1551 (while (and (not f) (setq m (re-search-forward re e t)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1552 (setq f (not (checkdoc-in-sample-code-p start e))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1553 (if m
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1554 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1555 (concat
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1556 "Keycode " (match-string 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1557 " embedded in doc string. Use \\\\<keymap> & \\\\[function] "
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1558 "instead")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1559 (match-beginning 1) (match-end 1) t))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1560 ;; It is not practical to use `\\[...]' very many times, because
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1561 ;; display of the documentation string will become slow. So use this
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1562 ;; to describe the most important commands in your major mode, and
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1563 ;; then use `\\{...}' to display the rest of the mode's keymap.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1564 (save-excursion
57072
9dd4195f1c06 (checkdoc-this-string-valid-engine):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55446
diff changeset
1565 (if (and (re-search-forward "\\\\\\\\\\[\\w+" e t
9dd4195f1c06 (checkdoc-this-string-valid-engine):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55446
diff changeset
1566 (1+ checkdoc-max-keyref-before-warn))
9dd4195f1c06 (checkdoc-this-string-valid-engine):
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55446
diff changeset
1567 (not (re-search-forward "\\\\\\\\{\\w+}" e t)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1568 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1569 "Too many occurrences of \\[function]. Use \\{keymap} instead"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1570 s (marker-position e))))
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1571 ;; Ambiguous quoted symbol. When a symbol is both bound and fbound,
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1572 ;; and is referred to in documentation, it should be prefixed with
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1573 ;; something to disambiguate it. This check must be before the
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1574 ;; 80 column check because it will probably break that.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1575 (save-excursion
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1576 (let ((case-fold-search t)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1577 (ret nil) mb me)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1578 (while (and (re-search-forward "`\\(\\sw\\(\\sw\\|\\s_\\)+\\)'" e t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1579 (not ret))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1580 (let* ((ms1 (match-string 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1581 (sym (intern-soft ms1)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1582 (setq mb (match-beginning 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1583 me (match-end 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1584 (if (and sym (boundp sym) (fboundp sym)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1585 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1586 (goto-char mb)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1587 (forward-word -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1588 (not (looking-at
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1589 "variable\\|option\\|function\\|command\\|symbol"))))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1590 (if (checkdoc-autofix-ask-replace
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1591 mb me "Prefix this ambiguous symbol? " ms1 t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1592 ;; We didn't actually replace anything. Here we find
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1593 ;; out what special word form they wish to use as
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1594 ;; a prefix.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1595 (let ((disambiguate
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1596 (completing-read
65680
ed770a0a7846 2005-09-24 Emilio C. Lopes <eclig@gmx.net>
Romain Francoise <romain@orebokech.com>
parents: 65191
diff changeset
1597 "Disambiguating Keyword (default variable): "
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1598 '(("function") ("command") ("variable")
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1599 ("option") ("symbol"))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1600 nil t nil nil "variable")))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1601 (goto-char (1- mb))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1602 (insert disambiguate " ")
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1603 (forward-word 1))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1604 (setq ret
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1605 (format "Disambiguate %s by preceding w/ \
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1606 function,command,variable,option or symbol." ms1))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1607 (if ret
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1608 (checkdoc-create-error ret mb me)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1609 nil)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1610 ;; * Format the documentation string so that it fits in an
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1611 ;; Emacs window on an 80-column screen. It is a good idea
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1612 ;; for most lines to be no wider than 60 characters. The
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1613 ;; first line can be wider if necessary to fit the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1614 ;; information that ought to be there.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1615 (save-excursion
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1616 (let ((start (point))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1617 (eol nil))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1618 (while (and (< (point) e)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1619 (or (progn (end-of-line) (setq eol (point))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1620 (< (current-column) 80))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1621 (progn (beginning-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1622 (re-search-forward "\\\\\\\\[[<{]"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1623 eol t))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1624 (checkdoc-in-sample-code-p start e)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1625 (forward-line 1))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1626 (end-of-line)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1627 (if (and (< (point) e) (> (current-column) 80))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1628 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1629 "Some lines are over 80 columns wide"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1630 s (save-excursion (goto-char s) (end-of-line) (point)) ))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1631 ;; Here we deviate to tests based on a variable or function.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1632 ;; We must do this before checking for symbols in quotes because there
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1633 ;; is a chance that just such a symbol might really be an argument.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1634 (cond ((eq (nth 1 fp) t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1635 ;; This is if we are in a variable
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1636 (or
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1637 ;; * The documentation string for a variable that is a
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1638 ;; yes-or-no flag should start with words such as Non-nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1639 ;; means..., to make it clear that all non-`nil' values are
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1640 ;; equivalent and indicate explicitly what `nil' and non-`nil'
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1641 ;; mean.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1642 ;; * If a user option variable records a true-or-false
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1643 ;; condition, give it a name that ends in `-flag'.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1644
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1645 ;; If the variable has -flag in the name, make sure
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1646 (if (and (string-match "-flag$" (car fp))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1647 (not (looking-at "\"\\*?Non-nil\\s-+means\\s-+")))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1648 (checkdoc-create-error
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1649 "Flag variable doc strings should usually start: Non-nil means"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1650 s (marker-position e) t))
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1651 ;; If the doc string starts with "Non-nil means"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1652 (if (and (looking-at "\"\\*?Non-nil\\s-+means\\s-+")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1653 (not (string-match "-flag$" (car fp))))
43133
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1654 (let ((newname
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1655 (if (string-match "-p$" (car fp))
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1656 (concat (substring (car fp) 0 -2) "-flag")
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1657 (concat (car fp) "-flag"))))
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1658 (if (checkdoc-y-or-n-p
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1659 (format
45897
19b72b42b514 (checkdoc-this-string-valid-engine): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents: 45258
diff changeset
1660 "Rename to %s and Query-Replace all occurrences? "
43133
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1661 newname))
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1662 (progn
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1663 (beginning-of-defun)
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1664 (query-replace-regexp
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1665 (concat "\\<" (regexp-quote (car fp)) "\\>")
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1666 newname))
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1667 (checkdoc-create-error
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1668 "Flag variable names should normally end in `-flag'" s
c929176c272b (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 42706
diff changeset
1669 (marker-position e)))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1670 ;; Done with variables
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1671 ))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1672 (t
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1673 ;; This if we are in a function definition
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1674 (or
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1675 ;; * When a function's documentation string mentions the value
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1676 ;; of an argument of the function, use the argument name in
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1677 ;; capital letters as if it were a name for that value. Thus,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1678 ;; the documentation string of the function `/' refers to its
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1679 ;; second argument as `DIVISOR', because the actual argument
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1680 ;; name is `divisor'.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1681
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1682 ;; Addendum: Make sure they appear in the doc in the same
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1683 ;; order that they are found in the arg list.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1684 (let ((args (cdr (cdr (cdr (cdr fp)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1685 (last-pos 0)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1686 (found 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1687 (order (and (nth 3 fp) (car (nth 3 fp))))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1688 (nocheck (append '("&optional" "&rest") (nth 3 fp)))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1689 (inopts nil))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1690 (while (and args found (> found last-pos))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1691 (if (member (car args) nocheck)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1692 (setq args (cdr args)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1693 inopts t)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1694 (setq last-pos found
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1695 found (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1696 (re-search-forward
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1697 (concat "\\<" (upcase (car args))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1698 ;; Require whitespace OR
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1699 ;; ITEMth<space> OR
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1700 ;; ITEMs<space>
40291
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
1701 "\\(\\>\\|th\\>\\|s\\>\\|[.,;:]\\)")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1702 e t)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1703 (if (not found)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1704 (let ((case-fold-search t))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1705 ;; If the symbol was not found, let's see if we
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1706 ;; can find it with a different capitalization
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1707 ;; and see if the user wants to capitalize it.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1708 (if (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1709 (re-search-forward
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1710 (concat "\\<\\(" (car args)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1711 ;; Require whitespace OR
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1712 ;; ITEMth<space> OR
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1713 ;; ITEMs<space>
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1714 "\\)\\(\\>\\|th\\>\\|s\\>\\)")
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
1715 e t))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1716 (if (checkdoc-autofix-ask-replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1717 (match-beginning 1) (match-end 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1718 (format
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1719 "If this is the argument `%s', it should appear as %s. Fix? "
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1720 (car args) (upcase (car args)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1721 (upcase (car args)) t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1722 (setq found (match-beginning 1))))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1723 (if found (setq args (cdr args)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1724 (if (not found)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1725 ;; It wasn't found at all! Offer to attach this new symbol
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1726 ;; to the end of the documentation string.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1727 (if (checkdoc-y-or-n-p
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1728 (format
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1729 "Add %s documentation to end of doc string? "
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1730 (upcase (car args))))
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1731 ;; Now do some magic and invent a doc string.
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1732 (save-excursion
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1733 (goto-char e) (forward-char -1)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1734 (insert "\n"
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1735 (if inopts "Optional a" "A")
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1736 "rgument " (upcase (car args))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1737 " ")
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1738 (insert (read-string "Describe: "))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1739 (if (not (save-excursion (forward-char -1)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1740 (looking-at "[.?!]")))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1741 (insert "."))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
1742 nil)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1743 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1744 (format
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1745 "Argument `%s' should appear (as %s) in the doc string"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1746 (car args) (upcase (car args)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1747 s (marker-position e)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1748 (if (or (and order (eq order 'yes))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1749 (and (not order) checkdoc-arguments-in-order-flag))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1750 (if (< found last-pos)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1751 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1752 "Arguments occur in the doc string out of order"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1753 s (marker-position e) t)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1754 ;; * For consistency, phrase the verb in the first sentence of a
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1755 ;; documentation string for functions as an imperative.
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1756 ;; For instance, use `Return the cons of A and
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1757 ;; B.' in preference to `Returns the cons of A and B.'
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1758 ;; Usually it looks good to do likewise for the rest of the
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1759 ;; first paragraph. Subsequent paragraphs usually look better
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1760 ;; if they have proper subjects.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1761 ;;
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1762 ;; This is the least important of the above tests. Make sure
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1763 ;; it occurs last.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1764 (and checkdoc-verb-check-experimental-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1765 (save-excursion
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
1766 ;; Maybe rebuild the monster-regexp
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1767 (checkdoc-create-common-verbs-regexp)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1768 (let ((lim (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1769 (end-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1770 ;; check string-continuation
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1771 (if (checkdoc-char= (preceding-char) ?\\)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1772 (progn (forward-line 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1773 (end-of-line)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1774 (point)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1775 (rs nil) replace original (case-fold-search t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1776 (while (and (not rs)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1777 (re-search-forward
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1778 checkdoc-common-verbs-regexp
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1779 lim t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1780 (setq original (buffer-substring-no-properties
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1781 (match-beginning 1) (match-end 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1782 rs (assoc (downcase original)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1783 checkdoc-common-verbs-wrong-voice))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1784 (if (not rs) (error "Verb voice alist corrupted"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1785 (setq replace (let ((case-fold-search nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1786 (save-match-data
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1787 (if (string-match "^[A-Z]" original)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1788 (capitalize (cdr rs))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1789 (cdr rs)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1790 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1791 (match-beginning 1) (match-end 1)
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1792 (format "Use the imperative for \"%s\". \
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1793 Replace with \"%s\"? " original replace)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1794 replace t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1795 (setq rs nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1796 (if rs
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1797 ;; there was a match, but no replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1798 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1799 (format
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1800 "Probably \"%s\" should be imperative \"%s\""
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1801 original replace)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1802 (match-beginning 1) (match-end 1))))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1803 ;; Done with functions
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1804 )))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1805 ;;* When a documentation string refers to a Lisp symbol, write it as
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1806 ;; it would be printed (which usually means in lower case), with
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1807 ;; single-quotes around it. For example: `lambda'. There are two
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1808 ;; exceptions: write t and nil without single-quotes. (In this
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1809 ;; manual, we normally do use single-quotes for those symbols.)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1810 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1811 (let ((found nil) (start (point)) (msg nil) (ms nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1812 (while (and (not msg)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1813 (re-search-forward
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1814 "[^-([`':a-zA-Z]\\(\\w+[:-]\\(\\w\\|\\s_\\)+\\)[^]']"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1815 e t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1816 (setq ms (match-string 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1817 (save-match-data
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1818 ;; A . is a \s_ char, so we must remove periods from
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1819 ;; sentences more carefully.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1820 (if (string-match "\\.$" ms)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1821 (setq ms (substring ms 0 (1- (length ms))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1822 (if (and (not (checkdoc-in-sample-code-p start e))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1823 (not (checkdoc-in-example-string-p start e))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1824 (not (member ms checkdoc-symbol-words))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1825 (setq found (intern-soft ms))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1826 (or (boundp found) (fboundp found)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1827 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1828 (setq msg (format "Add quotes around Lisp symbol `%s'? "
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1829 ms))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1830 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1831 (match-beginning 1) (+ (match-beginning 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1832 (length ms))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1833 msg (concat "`" ms "'") t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1834 (setq msg nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1835 (setq msg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1836 (format "Lisp symbol `%s' should appear in quotes"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1837 ms))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1838 (if msg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1839 (checkdoc-create-error msg (match-beginning 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1840 (+ (match-beginning 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1841 (length ms)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1842 nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1843 ;; t and nil case
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1844 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1845 (if (re-search-forward "\\(`\\(t\\|nil\\)'\\)" e t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1846 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1847 (match-beginning 1) (match-end 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1848 (format "%s should not appear in quotes. Remove? "
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1849 (match-string 2))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1850 (match-string 2) t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1851 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1852 (checkdoc-create-error
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
1853 "Symbols t and nil should not appear in `...' quotes"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1854 (match-beginning 1) (match-end 1)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1855 ;; Here is some basic sentence formatting
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1856 (checkdoc-sentencespace-region-engine (point) e)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1857 ;; Here are common proper nouns that should always appear capitalized.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1858 (checkdoc-proper-noun-region-engine (point) e)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1859 ;; Make sure the doc string has correctly spelled English words
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1860 ;; in it. This function is extracted due to its complexity,
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1861 ;; and reliance on the Ispell program.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1862 (checkdoc-ispell-docstring-engine e)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1863 ;; User supplied checks
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1864 (save-excursion (checkdoc-run-hooks 'checkdoc-style-hooks fp e))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1865 ;; Done!
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1866 )))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1867
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1868 (defun checkdoc-defun-info nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1869 "Return a list of details about the current sexp.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1870 It is a list of the form:
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1871 (NAME VARIABLE INTERACTIVE NODOCPARAMS PARAMETERS ...)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1872 where NAME is the name, VARIABLE is t if this is a `defvar',
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1873 INTERACTIVE is nil if this is not an interactive function, otherwise
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1874 it is the position of the `interactive' call, and PARAMETERS is a
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1875 string which is the name of each variable in the function's argument
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1876 list. The NODOCPARAMS is a sublist of parameters specified by a checkdoc
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1877 comment for a given defun. If the first element is not a string, then
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1878 the token checkdoc-order: <TOKEN> exists, and TOKEN is a symbol read
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1879 from the comment."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1880 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1881 (beginning-of-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1882 (let ((defun (looking-at "(def\\(un\\|macro\\|subst\\|advice\\)"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1883 (is-advice (looking-at "(defadvice"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1884 (lst nil)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1885 (ret nil)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1886 (oo (make-vector 3 0))) ;substitute obarray for `read'
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1887 (forward-char 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1888 (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1889 (skip-chars-forward " \n\t")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1890 (setq ret
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1891 (list (buffer-substring-no-properties
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1892 (point) (progn (forward-sexp 1) (point)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1893 (if (not defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1894 (setq ret (cons t ret))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1895 ;; The variable spot
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1896 (setq ret (cons nil ret))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1897 ;; Interactive
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1898 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1899 (setq ret (cons
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
1900 (re-search-forward "^\\s-*(interactive"
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1901 (save-excursion (end-of-defun) (point))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1902 t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1903 ret)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1904 (skip-chars-forward " \t\n")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1905 (let ((bss (buffer-substring (point) (save-excursion (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1906 (point))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1907 ;; Overload th main obarray so read doesn't intern the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1908 ;; local symbols of the function we are checking.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1909 ;; Without this we end up cluttering the symbol space w/
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1910 ;; useless symbols.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1911 (obarray oo))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1912 ;; Ok, check for checkdoc parameter comment here
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1913 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1914 (setq ret
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1915 (cons
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1916 (let ((sl1 nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1917 (if (re-search-forward ";\\s-+checkdoc-order:\\s-+"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1918 (save-excursion (end-of-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1919 (point))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1920 t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1921 (setq sl1 (list (cond ((looking-at "nil") 'no)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1922 ((looking-at "t") 'yes)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1923 (if (re-search-forward ";\\s-+checkdoc-params:\\s-+"
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1924 (save-excursion (end-of-defun)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1925 (point))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1926 t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1927 (let ((sl nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1928 (goto-char (match-end 0))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1929 (condition-case nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1930 (setq lst (read (current-buffer)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1931 (error (setq lst nil))) ; error in text
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1932 (if (not (listp lst)) ; not a list of args
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1933 (setq lst (list lst)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1934 (if (and lst (not (symbolp (car lst)))) ;weird arg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1935 (setq lst nil))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1936 (while lst
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1937 (setq sl (cons (symbol-name (car lst)) sl)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1938 lst (cdr lst)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1939 (setq sl1 (append sl1 sl))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1940 sl1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1941 ret)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1942 ;; Read the list of parameters, but do not put the symbols in
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1943 ;; the standard obarray.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1944 (setq lst (read bss)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1945 ;; This is because read will intern nil if it doesn't into the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1946 ;; new obarray.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1947 (if (not (listp lst)) (setq lst nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1948 (if is-advice nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1949 (while lst
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1950 (setq ret (cons (symbol-name (car lst)) ret)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1951 lst (cdr lst)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1952 (nreverse ret))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1953
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1954 (defun checkdoc-in-sample-code-p (start limit)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
1955 "Return non-nil if the current point is in a code fragment.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1956 A code fragment is identified by an open parenthesis followed by a
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1957 symbol which is a valid function or a word in all CAPS, or a parenthesis
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1958 that is quoted with the ' character. Only the region from START to LIMIT
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1959 is is allowed while searching for the bounding parenthesis."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1960 (save-match-data
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1961 (save-restriction
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1962 (narrow-to-region start limit)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1963 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1964 (and (condition-case nil (progn (up-list 1) t) (error nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1965 (condition-case nil (progn (forward-list -1) t) (error nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1966 (or (save-excursion (forward-char -1) (looking-at "'("))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1967 (and (looking-at "(\\(\\(\\w\\|[-:_]\\)+\\)[ \t\n;]")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1968 (let ((ms (buffer-substring-no-properties
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1969 (match-beginning 1) (match-end 1))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1970 ;; if this string is function bound, we are in
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1971 ;; sample code. If it has a - or : character in
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1972 ;; the name, then it is probably supposed to be bound
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1973 ;; but isn't yet.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1974 (or (fboundp (intern-soft ms))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1975 (let ((case-fold-search nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1976 (string-match "^[A-Z-]+$" ms))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1977 (string-match "\\w[-:_]+\\w" ms))))))))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
1978
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1979 (defun checkdoc-in-example-string-p (start limit)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1980 "Return non-nil if the current point is in an \"example string\".
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1981 This string is identified by the characters \\\" surrounding the text.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1982 The text checked is between START and LIMIT."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1983 (save-match-data
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1984 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1985 (let ((p (point))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1986 (c 0))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1987 (goto-char start)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1988 (while (and (< (point) p) (re-search-forward "\\\\\"" limit t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1989 (setq c (1+ c)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1990 (and (< 0 c) (= (% c 2) 0))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1991
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1992 (defun checkdoc-proper-noun-region-engine (begin end)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1993 "Check all text between BEGIN and END for lower case proper nouns.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1994 These are Emacs centric proper nouns which should be capitalized for
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1995 consistency. Return an error list if any are not fixed, but
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1996 internally skip over no answers.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1997 If the offending word is in a piece of quoted text, then it is skipped."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1998 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
1999 (let ((case-fold-search nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2000 (errtxt nil) bb be
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2001 (old-syntax-table (syntax-table)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2002 (unwind-protect
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2003 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2004 (set-syntax-table checkdoc-syntax-table)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2005 (goto-char begin)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2006 (while (re-search-forward checkdoc-proper-noun-regexp end t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2007 (let ((text (match-string 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2008 (b (match-beginning 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2009 (e (match-end 1)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2010 (if (and (not (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2011 (goto-char b)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2012 (forward-char -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2013 (looking-at "`\\|\"\\|\\.\\|\\\\")))
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2014 ;; surrounded by /, as in a URL or filename: /emacs/
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2015 (not (and (= ?/ (char-after e))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2016 (= ?/ (char-before b))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2017 (not (checkdoc-in-example-string-p begin end)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2018 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2019 b e (format "Text %s should be capitalized. Fix? "
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2020 text)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2021 (capitalize text) t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2022 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2023 (if errtxt
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2024 ;; If there is already an error, then generate
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2025 ;; the warning output if applicable
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2026 (if checkdoc-generate-compile-warnings-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2027 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2028 (format
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2029 "Name %s should appear capitalized as %s"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2030 text (capitalize text))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2031 b e))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2032 (setq errtxt
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2033 (format
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2034 "Name %s should appear capitalized as %s"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2035 text (capitalize text))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2036 bb b be e)))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2037 (set-syntax-table old-syntax-table))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2038 (if errtxt (checkdoc-create-error errtxt bb be)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2039
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2040 (defun checkdoc-sentencespace-region-engine (begin end)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2041 "Make sure all sentences have double spaces between BEGIN and END."
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2042 (if sentence-end-double-space
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2043 (save-excursion
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2044 (let ((case-fold-search nil)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2045 (errtxt nil) bb be
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2046 (old-syntax-table (syntax-table)))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2047 (unwind-protect
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2048 (progn
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2049 (set-syntax-table checkdoc-syntax-table)
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2050 (goto-char begin)
40291
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2051 (while (re-search-forward "[^ .0-9]\\(\\. \\)[^ \n]" end t)
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2052 (let ((b (match-beginning 1))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2053 (e (match-end 1)))
40291
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2054 (unless (or (checkdoc-in-sample-code-p begin end)
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2055 (checkdoc-in-example-string-p begin end)
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2056 (save-excursion
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2057 (goto-char b)
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2058 (condition-case nil
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2059 (progn
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2060 (forward-sexp -1)
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2061 ;; piece of an abbreviation
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2062 (looking-at
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2063 "\\([a-z]\\|[iI]\\.?e\\|[eE]\\.?g\\)\\."))
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2064 (error t))))
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2065 (if (checkdoc-autofix-ask-replace
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2066 b e
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2067 "There should be two spaces after a period. Fix? "
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2068 ". ")
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2069 nil
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2070 (if errtxt
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2071 ;; If there is already an error, then generate
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2072 ;; the warning output if applicable
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2073 (if checkdoc-generate-compile-warnings-flag
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2074 (checkdoc-create-error
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2075 "There should be two spaces after a period"
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2076 b e))
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2077 (setq errtxt
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2078 "There should be two spaces after a period"
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2079 bb b be e)))))))
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2080 (set-syntax-table old-syntax-table))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2081 (if errtxt (checkdoc-create-error errtxt bb be))))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2082
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2083 ;;; Ispell engine
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2084 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2085 (eval-when-compile (require 'ispell))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2086
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2087 (defun checkdoc-ispell-init ()
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2088 "Initialize Ispell process (default version) with Lisp words.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2089 The words used are from `checkdoc-ispell-lisp-words'. If `ispell'
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2090 cannot be loaded, then set `checkdoc-spellcheck-documentation-flag' to
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2091 nil."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2092 (require 'ispell)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2093 (if (not (symbol-value 'ispell-process)) ;Silence byteCompiler
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2094 (condition-case nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2095 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2096 (ispell-buffer-local-words)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2097 ;; This code copied in part from ispell.el Emacs 19.34
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2098 (let ((w checkdoc-ispell-lisp-words))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2099 (while w
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2100 (process-send-string
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2101 ;; Silence byte compiler
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2102 (symbol-value 'ispell-process)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2103 (concat "@" (car w) "\n"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2104 (setq w (cdr w)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2105 (error (setq checkdoc-spellcheck-documentation-flag nil)))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2106
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2107 (defun checkdoc-ispell-docstring-engine (end)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2108 "Run the Ispell tools on the doc string between point and END.
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2109 Since Ispell isn't Lisp-smart, we must pre-process the doc string
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2110 before using the Ispell engine on it."
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2111 (if (or (not checkdoc-spellcheck-documentation-flag)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2112 ;; If the user wants no questions or fixing, then we must
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2113 ;; disable spell checking as not useful.
50330
e3d87b72b575 (checkdoc-display-status-buffer): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 49621
diff changeset
2114 (not checkdoc-autofix-flag)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2115 (eq checkdoc-autofix-flag 'never))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2116 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2117 (checkdoc-ispell-init)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2118 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2119 (skip-chars-forward "^a-zA-Z")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2120 (let ((word nil) (sym nil) (case-fold-search nil) (err nil))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2121 (while (and (not err) (< (point) end))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2122 (if (save-excursion (forward-char -1) (looking-at "[('`]"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2123 ;; Skip lists describing meta-syntax, or bound variables
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2124 (forward-sexp 1)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2125 (setq word (buffer-substring-no-properties
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2126 (point) (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2127 (skip-chars-forward "a-zA-Z-")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2128 (point)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2129 sym (intern-soft word))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2130 (if (and sym (or (boundp sym) (fboundp sym)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2131 ;; This is probably repetitive in most cases, but not always.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2132 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2133 ;; Find out how we spell-check this word.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2134 (if (or
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
2135 ;; All caps w/ option th, or s tacked on the end
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2136 ;; for pluralization or numberthness.
20603
24dda0afd915 Added some more comments in the commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 20085
diff changeset
2137 (string-match "^[A-Z][A-Z]+\\(s\\|th\\)?$" word)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2138 (looking-at "}") ; a keymap expression
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2139 )
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2140 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2141 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2142 (if (not (eq checkdoc-autofix-flag 'never))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2143 (let ((lk last-input-event))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2144 (ispell-word nil t)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2145 (if (not (equal last-input-event lk))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2146 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2147 (sit-for 0)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2148 (message "Continuing..."))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2149 ;; Nothing here.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2150 )))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2151 (skip-chars-forward "^a-zA-Z"))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2152 err))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2153
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2154 ;;; Rogue space checking engine
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2155 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2156 (defun checkdoc-rogue-space-check-engine (&optional start end interact)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2157 "Return a message list if there is a line with white space at the end.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2158 If `checkdoc-autofix-flag' permits, delete that whitespace instead.
73647
cacf1e7f0aaf (checkdoc-rogue-space-check-engine): Use "non-nil" in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents: 72565
diff changeset
2159 If optional arguments START and END are non-nil, bound the check to
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2160 this region.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2161 Optional argument INTERACT may permit the user to fix problems on the fly."
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2162 (let ((p (point))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2163 (msg nil) s e (f nil))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2164 (if (not start) (setq start (point-min)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2165 ;; If end is nil, it means end of buffer to search anyway
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2166 (or
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2167 ;; Check for an error if `? ' or `?\ ' is used at the end of a line.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2168 ;; (It's dangerous)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2169 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2170 (goto-char start)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2171 (while (and (not msg) (re-search-forward "\\?\\\\?[ \t][ \t]*$" end t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2172 (setq msg
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2173 "Don't use `? ' at the end of a line. \
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2174 News agents may remove it"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2175 s (match-beginning 0) e (match-end 0) f t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2176 ;; If interactive is passed down, give them a chance to fix things.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2177 (if (and interact (y-or-n-p (concat msg ". Fix? ")))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2178 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2179 (checkdoc-recursive-edit msg)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2180 (setq msg nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2181 (goto-char s)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2182 (beginning-of-line)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2183 ;; Check for, and potentially remove whitespace appearing at the
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2184 ;; end of different lines.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2185 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2186 (goto-char start)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2187 ;; There is no documentation in the Emacs Lisp manual about this check,
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2188 ;; it is intended to help clean up messy code and reduce the file size.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2189 (while (and (not msg) (re-search-forward "[^ \t\n;]\\([ \t]+\\)$" end t))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2190 ;; This is not a complex activity
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2191 (if (checkdoc-autofix-ask-replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2192 (match-beginning 1) (match-end 1)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2193 "White space at end of line. Remove? " "")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2194 nil
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2195 (setq msg "White space found at end of line"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2196 s (match-beginning 1) e (match-end 1))))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2197 ;; Return an error and leave the cursor at that spot, or restore
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2198 ;; the cursor.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2199 (if msg
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2200 (checkdoc-create-error msg s e f)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2201 (goto-char p)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2202 nil)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2203
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2204 ;;; Comment checking engine
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2205 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2206 (eval-when-compile
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2207 ;; We must load this to:
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2208 ;; a) get symbols for compile and
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2209 ;; b) determine if we have lm-history symbol which doesn't always exist
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2210 (require 'lisp-mnt))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2211
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2212 (defun checkdoc-file-comments-engine ()
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2213 "Return a message list if this file does not match the Emacs standard.
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2214 This checks for style only, such as the first line, Commentary:,
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2215 Code:, and others referenced in the style guide."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2216 (if (featurep 'lisp-mnt)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2217 nil
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2218 (require 'lisp-mnt)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2219 ;; Old XEmacs don't have `lm-commentary-mark'
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2220 (if (and (not (fboundp 'lm-commentary-mark)) (boundp 'lm-commentary))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2221 (defalias 'lm-commentary-mark 'lm-commentary)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2222 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2223 (let* ((f1 (file-name-nondirectory (buffer-file-name)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2224 (fn (file-name-sans-extension f1))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2225 (fe (substring f1 (length fn)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2226 (err nil))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2227 (goto-char (point-min))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2228 ;; This file has been set up where ERR is a variable. Each check is
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2229 ;; asked, and the function will make sure that if the user does not
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2230 ;; auto-fix some error, that we still move on to the next auto-fix,
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2231 ;; AND we remember the past errors.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2232 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2233 err
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2234 ;; Lisp Maintenance checks first
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2235 ;; Was: (lm-verify) -> not flexible enough for some people
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2236 ;; * Summary at the beginning of the file:
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2237 (if (not (lm-summary))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2238 ;; This certifies as very complex so always ask unless
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2239 ;; it's set to never
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2240 (if (checkdoc-y-or-n-p "There is no first line summary! Add one? ")
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2241 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2242 (goto-char (point-min))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2243 (insert ";;; " fn fe " --- " (read-string "Summary: ") "\n"))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2244 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2245 "The first line should be of the form: \";;; package --- Summary\""
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2246 (point-min) (save-excursion (goto-char (point-min)) (end-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2247 (point))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2248 nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2249 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2250 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2251 (or
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2252 ;; * Commentary Section
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2253 (if (not (lm-commentary-mark))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2254 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2255 (goto-char (point-min))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2256 (cond
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2257 ((re-search-forward
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2258 "write\\s-+to\\s-+the\\s-+Free Software Foundation, Inc."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2259 nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2260 (re-search-forward "^;;\\s-*\n\\|^\n" nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2261 ((or (re-search-forward "^;;; History" nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2262 (re-search-forward "^;;; Code" nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2263 (re-search-forward "^(require" nil t)
40926
14c471312660 (checkdoc-file-comments-engine):
Richard M. Stallman <rms@gnu.org>
parents: 40291
diff changeset
2264 (re-search-forward "^(" nil t))
72565
186382a0d1cc * emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): Insert
Chong Yidong <cyd@stupidchicken.com>
parents: 72533
diff changeset
2265 (beginning-of-line))
186382a0d1cc * emacs-lisp/checkdoc.el (checkdoc-file-comments-engine): Insert
Chong Yidong <cyd@stupidchicken.com>
parents: 72533
diff changeset
2266 (t (re-search-forward ";;; .* --- .*\n")))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2267 (if (checkdoc-y-or-n-p
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2268 "You should have a \";;; Commentary:\", add one? ")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2269 (insert "\n;;; Commentary:\n;; \n\n")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2270 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2271 "You should have a section marked \";;; Commentary:\""
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2272 nil nil t)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2273 nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2274 err))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2275 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2276 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2277 (or
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2278 ;; * History section. Say nothing if there is a file ChangeLog
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2279 (if (or (not checkdoc-force-history-flag)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2280 (file-exists-p "ChangeLog")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2281 (file-exists-p "../ChangeLog")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2282 (let ((fn 'lm-history-mark)) ;bestill byte-compiler
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2283 (and (fboundp fn) (funcall fn))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2284 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2285 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2286 (goto-char (or (lm-commentary-mark) (point-min)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2287 (cond
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2288 ((re-search-forward
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2289 "write\\s-+to\\s-+the\\s-+Free Software Foundation, Inc."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2290 nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2291 (re-search-forward "^;;\\s-*\n\\|^\n" nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2292 ((or (re-search-forward "^;;; Code" nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2293 (re-search-forward "^(require" nil t)
40926
14c471312660 (checkdoc-file-comments-engine):
Richard M. Stallman <rms@gnu.org>
parents: 40291
diff changeset
2294 (re-search-forward "^(" nil t))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2295 (beginning-of-line)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2296 (if (checkdoc-y-or-n-p
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2297 "You should have a \";;; History:\", add one? ")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2298 (insert "\n;;; History:\n;; \n\n")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2299 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2300 "You should have a section marked \";;; History:\" or use a ChangeLog"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2301 (point) nil))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2302 err))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2303 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2304 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2305 (or
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2306 ;; * Code section
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2307 (if (not (lm-code-mark))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2308 (let ((cont t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2309 (goto-char (point-min))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2310 (while (and cont (re-search-forward "^(" nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2311 (setq cont (looking-at "require\\s-+")))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2312 (if (and (not cont)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2313 (checkdoc-y-or-n-p
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2314 "There is no ;;; Code: marker. Insert one? "))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2315 (progn (beginning-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2316 (insert ";;; Code:\n")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2317 nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2318 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2319 "You should have a section marked \";;; Code:\""
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2320 (point) nil)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2321 nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2322 err))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2323 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2324 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2325 (or
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2326 ;; * A footer. Not compartmentalized from lm-verify: too bad.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2327 ;; The following is partially clipped from lm-verify
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2328 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2329 (goto-char (point-max))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2330 (if (not (re-search-backward
64182
176ffa79bdd8 (checkdoc-proper-noun-list):
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
2331 (concat "^;;;[ \t]+" (regexp-quote fn) "\\(" (regexp-quote fe)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2332 "\\)?[ \t]+ends here[ \t]*$"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2333 "\\|^;;;[ \t]+ End of file[ \t]+"
64182
176ffa79bdd8 (checkdoc-proper-noun-list):
Richard M. Stallman <rms@gnu.org>
parents: 64085
diff changeset
2334 (regexp-quote fn) "\\(" (regexp-quote fe) "\\)?")
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2335 nil t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2336 (if (checkdoc-y-or-n-p "No identifiable footer! Add one? ")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2337 (progn
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2338 (goto-char (point-max))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2339 (insert "\n(provide '" fn ")\n\n;;; " fn fe " ends here\n"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2340 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2341 (format "The footer should be: (provide '%s)\\n;;; %s%s ends here"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2342 fn fn fe)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2343 (1- (point-max)) (point-max)))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2344 err))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2345 ;; The below checks will not return errors if the user says NO
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2346
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2347 ;; Let's spellcheck the commentary section. This is the only
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2348 ;; section that is easy to pick out, and it is also the most
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2349 ;; visible section (with the finder).
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2350 (let ((cm (lm-commentary-mark)))
51156
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2351 (when cm
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2352 (save-excursion
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2353 (goto-char cm)
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2354 (let ((e (copy-marker (lm-commentary-end))))
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2355 ;; Since the comments talk about Lisp, use the
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2356 ;; specialized spell-checker we also used for doc
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2357 ;; strings.
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2358 (checkdoc-sentencespace-region-engine (point) e)
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2359 (checkdoc-proper-noun-region-engine (point) e)
46ef9a326558 (checkdoc-file-comments-engine): Use
Lute Kamstra <lute@gnu.org>
parents: 50330
diff changeset
2360 (checkdoc-ispell-docstring-engine e)))))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2361 (setq
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2362 err
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2363 (or
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2364 ;; Generic Full-file checks (should be comment related)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2365 (checkdoc-run-hooks 'checkdoc-comment-style-hooks)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2366 err))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2367 ;; Done with full file comment checks
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2368 err)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2369
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2370 (defun checkdoc-outside-major-sexp ()
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2371 "Return t if point is outside the bounds of a valid sexp."
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2372 (save-match-data
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2373 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2374 (let ((p (point)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2375 (or (progn (beginning-of-defun) (bobp))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2376 (progn (end-of-defun) (< (point) p)))))))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2377
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2378 ;;; `error' and `message' text verifier.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2379 ;;
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2380 (defun checkdoc-message-text-search (&optional beg end)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2381 "Search between BEG and END for a style error with message text.
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2382 Optional arguments BEG and END represent the boundary of the check.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2383 The default boundary is the entire buffer."
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2384 (let ((e nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2385 (type nil))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2386 (if (not (or beg end)) (setq beg (point-min) end (point-max)))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2387 (goto-char beg)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2388 (while (setq type (checkdoc-message-text-next-string end))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2389 (setq e (checkdoc-message-text-engine type)))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2390 e))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 48943
diff changeset
2391
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2392 (defun checkdoc-message-text-next-string (end)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2393 "Move cursor to the next checkable message string after point.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2394 Return the message classification.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2395 Argument END is the maximum bounds to search in."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2396 (let ((return nil))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2397 (while (and (not return)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2398 (re-search-forward
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2399 "(\\s-*\\(\\(\\w\\|\\s_\\)*error\\|\
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2400 \\(\\w\\|\\s_\\)*y-or-n-p\\(-with-timeout\\)?\
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2401 \\|checkdoc-autofix-ask-replace\\)[ \t\n]+" end t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2402 (let* ((fn (match-string 1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2403 (type (cond ((string-match "error" fn)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2404 'error)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2405 (t 'y-or-n-p))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2406 (if (string-match "checkdoc-autofix-ask-replace" fn)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2407 (progn (forward-sexp 2)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2408 (skip-chars-forward " \t\n")))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2409 (if (and (eq type 'y-or-n-p)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2410 (looking-at "(format[ \t\n]+"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2411 (goto-char (match-end 0)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2412 (skip-chars-forward " \t\n")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2413 (if (not (looking-at "\""))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2414 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2415 (setq return type))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2416 return))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2417
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2418 (defun checkdoc-message-text-engine (&optional type)
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2419 "Return or fix errors found in strings passed to a message display function.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2420 According to the documentation for the function `error', the error list
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2421 should not end with a period, and should start with a capital letter.
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2422 The function `y-or-n-p' has similar constraints.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2423 Argument TYPE specifies the type of question, such as `error or `y-or-n-p."
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2424 ;; If type is nil, then attempt to derive it.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2425 (if (not type)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2426 (save-excursion
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2427 (up-list -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2428 (if (looking-at "(format")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2429 (up-list -1))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2430 (setq type
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2431 (cond ((looking-at "(error")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2432 'error)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2433 (t 'y-or-n-p)))))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2434 (let ((case-fold-search nil))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2435 (or
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2436 ;; From the documentation of the symbol `error':
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2437 ;; In Emacs, the convention is that error messages start with a capital
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2438 ;; letter but *do not* end with a period. Please follow this convention
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2439 ;; for the sake of consistency.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2440 (if (and (save-excursion (forward-char 1)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2441 (looking-at "[a-z]\\w+"))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2442 (not (checkdoc-autofix-ask-replace
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2443 (match-beginning 0) (match-end 0)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2444 "Capitalize your message text? "
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2445 (capitalize (match-string 0))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2446 t)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2447 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2448 "Messages should start with a capital letter"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2449 (match-beginning 0) (match-end 0))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2450 nil)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2451 ;; In general, sentences should have two spaces after the period.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2452 (checkdoc-sentencespace-region-engine (point)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2453 (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2454 (point)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2455 ;; Look for proper nouns in this region too.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2456 (checkdoc-proper-noun-region-engine (point)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2457 (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2458 (point)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2459 ;; Here are message type specific questions.
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2460 (if (and (eq type 'error)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2461 (save-excursion (forward-sexp 1)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2462 (forward-char -2)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2463 (looking-at "\\."))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2464 (not (checkdoc-autofix-ask-replace (match-beginning 0)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2465 (match-end 0)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2466 "Remove period from error? "
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2467 ""
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2468 t)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2469 (checkdoc-create-error
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2470 "Error messages should *not* end with a period"
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2471 (match-beginning 0) (match-end 0))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2472 nil)
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2473 ;; `y-or-n-p' documentation explicitly says:
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2474 ;; It should end in a space; `y-or-n-p' adds `(y or n) ' to it.
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2475 ;; I added the ? requirement. Without it, it is unclear that we
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2476 ;; ask a question and it appears to be an undocumented style.
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2477 (if (eq type 'y-or-n-p)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2478 (if (not (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2479 (forward-char -3)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2480 (not (looking-at "\\? "))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2481 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2482 (if (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2483 (forward-char -2)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2484 (looking-at "\\?"))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2485 ;; If we see a ?, then replace with "? ".
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2486 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2487 (match-beginning 0) (match-end 0)
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2488 "`y-or-n-p' argument should end with \"? \". Fix? "
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2489 "? " t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2490 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2491 (checkdoc-create-error
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2492 "`y-or-n-p' argument should end with \"? \""
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2493 (match-beginning 0) (match-end 0)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2494 (if (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2495 (forward-char -2)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2496 (looking-at " "))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2497 (if (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2498 (match-beginning 0) (match-end 0)
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2499 "`y-or-n-p' argument should end with \"? \". Fix? "
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2500 "? " t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2501 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2502 (checkdoc-create-error
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2503 "`y-or-n-p' argument should end with \"? \""
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2504 (match-beginning 0) (match-end 0)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2505 (if (and ;; if this isn't true, we have a problem.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2506 (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2507 (forward-char -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2508 (looking-at "\""))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2509 (checkdoc-autofix-ask-replace
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2510 (match-beginning 0) (match-end 0)
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2511 "`y-or-n-p' argument should end with \"? \". Fix? "
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2512 "? \"" t))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2513 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2514 (checkdoc-create-error
26615
1d769c66f407 (checkdoc-this-string-valid-engine):
Richard M. Stallman <rms@gnu.org>
parents: 25697
diff changeset
2515 "`y-or-n-p' argument should end with \"? \""
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2516 (match-beginning 0) (match-end 0)))))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2517 ;; Now, let's just run the spell checker on this guy.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2518 (checkdoc-ispell-docstring-engine (save-excursion (forward-sexp 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2519 (point)))
22111
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2520 )))
38f78542051a Updated with latest version. Changes include:
Eric M. Ludlam <zappo@gnu.org>
parents: 21651
diff changeset
2521
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2522 ;;; Auto-fix helper functions
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2523 ;;
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2524 (defun checkdoc-y-or-n-p (question)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2525 "Like `y-or-n-p', but pays attention to `checkdoc-autofix-flag'.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2526 Argument QUESTION is the prompt passed to `y-or-n-p'."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2527 (prog1
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2528 (if (or (not checkdoc-autofix-flag)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2529 (eq checkdoc-autofix-flag 'never))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2530 nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2531 (y-or-n-p question))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2532 (if (eq checkdoc-autofix-flag 'automatic-then-never)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2533 (setq checkdoc-autofix-flag 'never))))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2534
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2535 (defun checkdoc-autofix-ask-replace (start end question replacewith
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2536 &optional complex)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2537 "Highlight between START and END and queries the user with QUESTION.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2538 If the user says yes, or if `checkdoc-autofix-flag' permits, replace
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2539 the region marked by START and END with REPLACEWITH. If optional flag
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2540 COMPLEX is non-nil, then we may ask the user a question. See the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2541 documentation for `checkdoc-autofix-flag' for details.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2542
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2543 If a section is auto-replaced without asking the user, this function
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2544 will pause near the fixed code so the user will briefly see what
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2545 happened.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2546
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2547 This function returns non-nil if the text was replaced.
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2548
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2549 This function will not modify `match-data'."
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2550 (if (and checkdoc-autofix-flag
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2551 (not (eq checkdoc-autofix-flag 'never)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2552 (let ((o (checkdoc-make-overlay start end))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2553 (ret nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2554 (md (match-data)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2555 (unwind-protect
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2556 (progn
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2557 (checkdoc-overlay-put o 'face 'highlight)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2558 (if (or (eq checkdoc-autofix-flag 'automatic)
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2559 (eq checkdoc-autofix-flag 'automatic-then-never)
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2560 (and (eq checkdoc-autofix-flag 'semiautomatic)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2561 (not complex))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2562 (and (or (eq checkdoc-autofix-flag 'query) complex)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2563 (y-or-n-p question)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2564 (save-excursion
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2565 (goto-char start)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2566 ;; On the off chance this is automatic, display
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2567 ;; the question anyway so the user knows what's
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2568 ;; going on.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2569 (if checkdoc-bouncy-flag (message "%s -> done" question))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2570 (delete-region start end)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2571 (insert replacewith)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2572 (if checkdoc-bouncy-flag (sit-for 0))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2573 (setq ret t)))
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2574 (checkdoc-delete-overlay o)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2575 (set-match-data md))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2576 (checkdoc-delete-overlay o)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2577 (set-match-data md))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2578 (if (eq checkdoc-autofix-flag 'automatic-then-never)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2579 (setq checkdoc-autofix-flag 'never))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2580 ret)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2581
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2582 ;;; Warning management
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2583 ;;
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2584 (defvar checkdoc-output-font-lock-keywords
55110
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2585 '(("^\\*\\*\\* \\(.+\\.el\\): \\([^ \n]+\\)"
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2586 (1 font-lock-function-name-face)
55110
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2587 (2 font-lock-comment-face)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2588 "Keywords used to highlight a checkdoc diagnostic buffer.")
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2589
55110
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2590 (defvar checkdoc-output-error-regex-alist
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2591 '(("^\\(.+\\.el\\):\\([0-9]+\\): " 1 2)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2592
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2593 (defvar checkdoc-pending-errors nil
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2594 "Non-nil when there are errors that have not been displayed yet.")
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2595
55110
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2596 (define-derived-mode checkdoc-output-mode compilation-mode "Checkdoc"
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2597 "Set up the major mode for the buffer containing the list of errors."
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2598 (set (make-local-variable 'compilation-error-regexp-alist)
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2599 checkdoc-output-error-regex-alist)
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2600 (set (make-local-variable 'compilation-mode-font-lock-keywords)
9454ec4dffea (checkdoc-output-error-regex-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 55060
diff changeset
2601 checkdoc-output-font-lock-keywords))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2602
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2603 (defun checkdoc-buffer-label ()
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2604 "The name to use for a checkdoc buffer in the error list."
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2605 (if (buffer-file-name)
55060
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2606 (file-relative-name (buffer-file-name))
23192
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2607 (concat "#<buffer "(buffer-name) ">")))
1ea9db09a678 (checkdoc-buffer-label): New function.
Eric M. Ludlam <zappo@gnu.org>
parents: 22674
diff changeset
2608
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2609 (defun checkdoc-start-section (check-type)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2610 "Initialize the checkdoc diagnostic buffer for a pass.
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2611 Create the header so that the string CHECK-TYPE is displayed as the
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2612 function called to create the messages."
55060
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2613 (let ((dir default-directory)
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2614 (label (checkdoc-buffer-label)))
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2615 (with-current-buffer (get-buffer-create checkdoc-diagnostic-buffer)
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2616 (checkdoc-output-mode)
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2617 (setq default-directory dir)
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2618 (goto-char (point-max))
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2619 (insert "\n\n\C-l\n*** " label ": " check-type " V " checkdoc-version))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2620
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2621 (defun checkdoc-error (point msg)
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2622 "Store POINT and MSG as errors in the checkdoc diagnostic buffer."
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2623 (setq checkdoc-pending-errors t)
55060
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2624 (let ((text (list "\n" (checkdoc-buffer-label) ":"
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2625 (int-to-string
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2626 (count-lines (point-min) (or point (point-min))))
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2627 ": " msg)))
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2628 (with-current-buffer (get-buffer checkdoc-diagnostic-buffer)
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2629 (goto-char (point-max))
4a1324ad659c (checkdoc-output-mode): Make it a normal major mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 54873
diff changeset
2630 (apply 'insert text))))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2631
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2632 (defun checkdoc-show-diagnostics ()
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2633 "Display the checkdoc diagnostic buffer in a temporary window."
22674
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2634 (if checkdoc-pending-errors
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2635 (let ((b (get-buffer checkdoc-diagnostic-buffer)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2636 (if b (progn (pop-to-buffer b)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2637 (goto-char (point-max))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2638 (re-search-backward "\C-l" nil t)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2639 (beginning-of-line)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2640 (forward-line 1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2641 (recenter 0)))
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2642 (other-window -1)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2643 (setq checkdoc-pending-errors nil)
f72e7540940a (checkdoc): Updated commentary.
Eric M. Ludlam <zappo@gnu.org>
parents: 22579
diff changeset
2644 nil)))
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2645
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2646 (custom-add-option 'emacs-lisp-mode-hook
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2647 (lambda () (checkdoc-minor-mode 1)))
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2648
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
2649 (add-to-list 'debug-ignored-errors
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
2650 "Argument `.*' should appear (as .*) in the doc string")
54498
79d56d8a420a (checkdoc-error): Dont' assume point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
2651 (add-to-list 'debug-ignored-errors
79d56d8a420a (checkdoc-error): Dont' assume point-min == 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
2652 "Lisp symbol `.*' should appear in quotes")
40291
7642548b1466 (checkdoc-eval-defun): Call eval-defun
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 39319
diff changeset
2653 (add-to-list 'debug-ignored-errors "Disambiguate .* by preceding .*")
33495
07c7cb89c236 (checkdoc-minor-mode) <defvar>: Remove.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27444
diff changeset
2654
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2655 (provide 'checkdoc)
22195
bab34c7c16fb Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 22111
diff changeset
2656
72533
56fd2cceac24 Remove * in defcustoms.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68648
diff changeset
2657 ;; arch-tag: c49a7ec8-3bb7-46f2-bfbc-d5f26e033b26
20085
05408326bad6 Initial revision
Karl Heuer <kwzh@gnu.org>
parents:
diff changeset
2658 ;;; checkdoc.el ends here