Mercurial > emacs
comparison lisp/emacs-lisp/checkdoc.el @ 33495:07c7cb89c236
(checkdoc-minor-mode) <defvar>: Remove.
(checkdoc-minor-mode-map): New map, replaces checkdoc-minor-keymap.
(checkdoc-minor-keymap): Backward compatibility.
(checkdoc-minor-menu): Don't bother checking checkdoc-minor-keymap.
(checkdoc-minor-mode) <defun>: Use easy-mmode-define-minor-mode.
(checkdoc-this-string-valid-engine): Be a bit more strict
to avoid matching substrings of `...' quoted vars/funs.
(checkdoc-defun-info): Only look for `interactive' if alone.
(debug-ignored-errors): Add "arg doesn't appear in docstring".
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Tue, 14 Nov 2000 20:10:22 +0000 |
parents | 89c53b25be12 |
children | 0b99eb07fc17 |
comparison
equal
deleted
inserted
replaced
33494:6c0cd7e2d92d | 33495:07c7cb89c236 |
---|---|
1130 ;; string-p part is for backwards compatibility | 1130 ;; string-p part is for backwards compatibility |
1131 (if (stringp err) nil (nth 3 err))) | 1131 (if (stringp err) nil (nth 3 err))) |
1132 | 1132 |
1133 ;;; Minor Mode specification | 1133 ;;; Minor Mode specification |
1134 ;; | 1134 ;; |
1135 (defvar checkdoc-minor-mode nil | 1135 |
1136 "Non-nil in `emacs-lisp-mode' for automatic documentation checking.") | 1136 (defvar checkdoc-minor-mode-map |
1137 (make-variable-buffer-local 'checkdoc-minor-mode) | |
1138 | |
1139 (checkdoc-add-to-list 'minor-mode-alist '(checkdoc-minor-mode " CDoc")) | |
1140 | |
1141 (defvar checkdoc-minor-keymap | |
1142 (let ((map (make-sparse-keymap)) | 1137 (let ((map (make-sparse-keymap)) |
1143 (pmap (make-sparse-keymap))) | 1138 (pmap (make-sparse-keymap))) |
1144 ;; Override some bindings | 1139 ;; Override some bindings |
1145 (define-key map "\C-\M-x" 'checkdoc-eval-defun) | 1140 (define-key map "\C-\M-x" 'checkdoc-eval-defun) |
1146 (define-key map "\C-x`" 'checkdoc-continue) | 1141 (define-key map "\C-x`" 'checkdoc-continue) |
1168 ;; bind our submap into map | 1163 ;; bind our submap into map |
1169 (define-key map "\C-c?" pmap) | 1164 (define-key map "\C-c?" pmap) |
1170 map) | 1165 map) |
1171 "Keymap used to override evaluation key-bindings for documentation checking.") | 1166 "Keymap used to override evaluation key-bindings for documentation checking.") |
1172 | 1167 |
1168 (defvar checkdoc-minor-keymap checkdoc-minor-mode-map | |
1169 "Obsolete! Use `checkdoc-minor-mode-map'.") | |
1170 | |
1173 ;; Add in a menubar with easy-menu | 1171 ;; Add in a menubar with easy-menu |
1174 | 1172 |
1175 (if checkdoc-minor-keymap | 1173 (easy-menu-define |
1176 (easy-menu-define | 1174 checkdoc-minor-menu checkdoc-minor-mode-map "Checkdoc Minor Mode Menu" |
1177 checkdoc-minor-menu checkdoc-minor-keymap "Checkdoc Minor Mode Menu" | 1175 '("CheckDoc" |
1178 '("CheckDoc" | 1176 ["Interactive Buffer Style Check" checkdoc t] |
1179 ["Interactive Buffer Style Check" checkdoc t] | 1177 ["Interactive Buffer Style and Spelling Check" checkdoc-ispell t] |
1180 ["Interactive Buffer Style and Spelling Check" checkdoc-ispell t] | 1178 ["Check Buffer" checkdoc-current-buffer t] |
1181 ["Check Buffer" checkdoc-current-buffer t] | 1179 ["Check and Spell Buffer" checkdoc-ispell-current-buffer t] |
1182 ["Check and Spell Buffer" checkdoc-ispell-current-buffer t] | 1180 "---" |
1183 "---" | 1181 ["Interactive Style Check" checkdoc-interactive t] |
1184 ["Interactive Style Check" checkdoc-interactive t] | 1182 ["Interactive Style and Spelling Check" checkdoc-ispell-interactive t] |
1185 ["Interactive Style and Spelling Check" checkdoc-ispell-interactive t] | 1183 ["Find First Style Error" checkdoc-start t] |
1186 ["Find First Style Error" checkdoc-start t] | 1184 ["Find First Style or Spelling Error" checkdoc-ispell-start t] |
1187 ["Find First Style or Spelling Error" checkdoc-ispell-start t] | 1185 ["Next Style Error" checkdoc-continue t] |
1188 ["Next Style Error" checkdoc-continue t] | 1186 ["Next Style or Spelling Error" checkdoc-ispell-continue t] |
1189 ["Next Style or Spelling Error" checkdoc-ispell-continue t] | 1187 ["Interactive Message Text Style Check" checkdoc-message-interactive t] |
1190 ["Interactive Message Text Style Check" checkdoc-message-interactive t] | 1188 ["Interactive Message Text Style and Spelling Check" |
1191 ["Interactive Message Text Style and Spelling Check" | 1189 checkdoc-ispell-message-interactive t] |
1192 checkdoc-ispell-message-interactive t] | 1190 ["Check Message Text" checkdoc-message-text t] |
1193 ["Check Message Text" checkdoc-message-text t] | 1191 ["Check and Spell Message Text" checkdoc-ispell-message-text t] |
1194 ["Check and Spell Message Text" checkdoc-ispell-message-text t] | 1192 ["Check Comment Style" checkdoc-comments buffer-file-name] |
1195 ["Check Comment Style" checkdoc-comments buffer-file-name] | 1193 ["Check Comment Style and Spelling" checkdoc-ispell-comments |
1196 ["Check Comment Style and Spelling" checkdoc-ispell-comments | 1194 buffer-file-name] |
1197 buffer-file-name] | 1195 ["Check for Rogue Spaces" checkdoc-rogue-spaces t] |
1198 ["Check for Rogue Spaces" checkdoc-rogue-spaces t] | 1196 "---" |
1199 "---" | 1197 ["Check Defun" checkdoc-defun t] |
1200 ["Check Defun" checkdoc-defun t] | 1198 ["Check and Spell Defun" checkdoc-ispell-defun t] |
1201 ["Check and Spell Defun" checkdoc-ispell-defun t] | 1199 ["Check and Evaluate Defun" checkdoc-eval-defun t] |
1202 ["Check and Evaluate Defun" checkdoc-eval-defun t] | 1200 ["Check and Evaluate Buffer" checkdoc-eval-current-buffer t] |
1203 ["Check and Evaluate Buffer" checkdoc-eval-current-buffer t] | 1201 )) |
1204 ))) | |
1205 ;; XEmacs requires some weird stuff to add this menu in a minor mode. | 1202 ;; XEmacs requires some weird stuff to add this menu in a minor mode. |
1206 ;; What is it? | 1203 ;; What is it? |
1207 | 1204 |
1208 ;; Allow re-insertion of a new keymap | |
1209 (let ((a (assoc 'checkdoc-minor-mode minor-mode-map-alist))) | |
1210 (if a | |
1211 (setcdr a checkdoc-minor-keymap) | |
1212 (checkdoc-add-to-list 'minor-mode-map-alist (cons 'checkdoc-minor-mode | |
1213 checkdoc-minor-keymap)))) | |
1214 | |
1215 ;;;###autoload | 1205 ;;;###autoload |
1216 (defun checkdoc-minor-mode (&optional arg) | 1206 (easy-mmode-define-minor-mode checkdoc-minor-mode |
1217 "Toggle Checkdoc minor mode, a mode for checking Lisp doc strings. | 1207 "Toggle Checkdoc minor mode, a mode for checking Lisp doc strings. |
1218 With prefix ARG, turn Checkdoc minor mode on iff ARG is positive. | 1208 With prefix ARG, turn Checkdoc minor mode on iff ARG is positive. |
1219 | 1209 |
1220 In Checkdoc minor mode, the usual bindings for `eval-defun' which is | 1210 In Checkdoc minor mode, the usual bindings for `eval-defun' which is |
1221 bound to \\<checkdoc-minor-keymap> \\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include | 1211 bound to \\<checkdoc-minor-mode-map> \\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include |
1222 checking of documentation strings. | 1212 checking of documentation strings. |
1223 | 1213 |
1224 \\{checkdoc-minor-keymap}" | 1214 \\{checkdoc-minor-mode-map}" |
1225 (interactive "P") | 1215 nil " CDoc" nil) |
1226 (setq checkdoc-minor-mode | |
1227 (not (or (and (null arg) checkdoc-minor-mode) | |
1228 (<= (prefix-numeric-value arg) 0)))) | |
1229 (checkdoc-mode-line-update)) | |
1230 | 1216 |
1231 ;;; Subst utils | 1217 ;;; Subst utils |
1232 ;; | 1218 ;; |
1233 (defsubst checkdoc-run-hooks (hookvar &rest args) | 1219 (defsubst checkdoc-run-hooks (hookvar &rest args) |
1234 "Run hooks in HOOKVAR with ARGS." | 1220 "Run hooks in HOOKVAR with ARGS." |
1767 ;; manual, we normally do use single-quotes for those symbols.) | 1753 ;; manual, we normally do use single-quotes for those symbols.) |
1768 (save-excursion | 1754 (save-excursion |
1769 (let ((found nil) (start (point)) (msg nil) (ms nil)) | 1755 (let ((found nil) (start (point)) (msg nil) (ms nil)) |
1770 (while (and (not msg) | 1756 (while (and (not msg) |
1771 (re-search-forward | 1757 (re-search-forward |
1772 "[^([`':a-zA-Z]\\(\\w+[:-]\\(\\w\\|\\s_\\)+\\)[^]']" | 1758 "[^-([`':a-zA-Z]\\(\\w+[:-]\\(\\w\\|\\s_\\)+\\)[^]']" |
1773 e t)) | 1759 e t)) |
1774 (setq ms (match-string 1)) | 1760 (setq ms (match-string 1)) |
1775 (save-match-data | 1761 (save-match-data |
1776 ;; A . is a \s_ char, so we must remove periods from | 1762 ;; A . is a \s_ char, so we must remove periods from |
1777 ;; sentences more carefully. | 1763 ;; sentences more carefully. |
1853 ;; The variable spot | 1839 ;; The variable spot |
1854 (setq ret (cons nil ret)) | 1840 (setq ret (cons nil ret)) |
1855 ;; Interactive | 1841 ;; Interactive |
1856 (save-excursion | 1842 (save-excursion |
1857 (setq ret (cons | 1843 (setq ret (cons |
1858 (re-search-forward "(interactive" | 1844 (re-search-forward "^\\s-*(interactive" |
1859 (save-excursion (end-of-defun) (point)) | 1845 (save-excursion (end-of-defun) (point)) |
1860 t) | 1846 t) |
1861 ret))) | 1847 ret))) |
1862 (skip-chars-forward " \t\n") | 1848 (skip-chars-forward " \t\n") |
1863 (let ((bss (buffer-substring (point) (save-excursion (forward-sexp 1) | 1849 (let ((bss (buffer-substring (point) (save-excursion (forward-sexp 1) |
2653 :version "20.3") | 2639 :version "20.3") |
2654 | 2640 |
2655 (custom-add-option 'emacs-lisp-mode-hook | 2641 (custom-add-option 'emacs-lisp-mode-hook |
2656 (lambda () (checkdoc-minor-mode 1))) | 2642 (lambda () (checkdoc-minor-mode 1))) |
2657 | 2643 |
2644 (add-to-list 'debug-ignored-errors | |
2645 "Argument `.*' should appear (as .*) in the doc string") | |
2646 | |
2658 (provide 'checkdoc) | 2647 (provide 'checkdoc) |
2659 | 2648 |
2660 ;;; checkdoc.el ends here | 2649 ;;; checkdoc.el ends here |