Mercurial > emacs
comparison lisp/emacs-lisp/checkdoc.el @ 46841:99952aa7f2c3
(checkdoc, checkdoc-interactive)
(checkdoc-message-interactive, checkdoc-interactive-loop)
(checkdoc-current-buffer, checkdoc-continue, checkdoc-comments)
(checkdoc-defun):
Update checkdoc-spellcheck-documentation-flag correctly.
(checkdoc-ispell-docstring-engine): Don't test for
checkdoc-autofix-flag = nil.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 09 Aug 2002 01:56:00 +0000 |
parents | bf7784999bbd |
children | 1ecb81625b1d |
comparison
equal
deleted
inserted
replaced
46840:65ec8c8b0b3e | 46841:99952aa7f2c3 |
---|---|
89 ;; Spell checking text: | 89 ;; Spell checking text: |
90 ;; | 90 ;; |
91 ;; The variable `checkdoc-spellcheck-documentation-flag' can be set | 91 ;; The variable `checkdoc-spellcheck-documentation-flag' can be set |
92 ;; to customize how spell checking is to be done. Since spell | 92 ;; to customize how spell checking is to be done. Since spell |
93 ;; checking can be quite slow, you can optimize how best you want your | 93 ;; checking can be quite slow, you can optimize how best you want your |
94 ;; checking done. The default is 'defun, which spell checks each time | 94 ;; checking done. The default is `defun', which spell checks each time |
95 ;; `checkdoc-defun' or `checkdoc-eval-defun' is used. Setting to nil | 95 ;; `checkdoc-defun' or `checkdoc-eval-defun' is used. Setting to nil |
96 ;; prevents spell checking during normal usage. | 96 ;; prevents spell checking during normal usage. |
97 ;; Setting this variable to nil does not mean you cannot take | 97 ;; Setting this variable to nil does not mean you cannot take |
98 ;; advantage of the spell checking. You can instead use the | 98 ;; advantage of the spell checking. You can instead use the |
99 ;; interactive functions `checkdoc-ispell-*' to check the spelling of | 99 ;; interactive functions `checkdoc-ispell-*' to check the spelling of |
465 The current status of the check will be displayed in a buffer which | 465 The current status of the check will be displayed in a buffer which |
466 the users will view as each check is completed." | 466 the users will view as each check is completed." |
467 (interactive) | 467 (interactive) |
468 (let ((status (list "Checking..." "-" "-" "-")) | 468 (let ((status (list "Checking..." "-" "-" "-")) |
469 (checkdoc-spellcheck-documentation-flag | 469 (checkdoc-spellcheck-documentation-flag |
470 (member checkdoc-spellcheck-documentation-flag | 470 (car (memq checkdoc-spellcheck-documentation-flag |
471 '(buffer interactive t))) | 471 '(buffer interactive t)))) |
472 ;; if the user set autofix to never, then that breaks the | 472 ;; if the user set autofix to never, then that breaks the |
473 ;; obviously requested asking implied by using this function. | 473 ;; obviously requested asking implied by using this function. |
474 ;; Set it to paranoia level. | 474 ;; Set it to paranoia level. |
475 (checkdoc-autofix-flag (if (or (not checkdoc-autofix-flag) | 475 (checkdoc-autofix-flag (if (or (not checkdoc-autofix-flag) |
476 (eq checkdoc-autofix-flag 'never)) | 476 (eq checkdoc-autofix-flag 'never)) |
533 errors. Does not check for comment or space warnings. | 533 errors. Does not check for comment or space warnings. |
534 Optional argument SHOWSTATUS indicates that we should update the | 534 Optional argument SHOWSTATUS indicates that we should update the |
535 checkdoc status window instead of the usual behavior." | 535 checkdoc status window instead of the usual behavior." |
536 (interactive "P") | 536 (interactive "P") |
537 (let ((checkdoc-spellcheck-documentation-flag | 537 (let ((checkdoc-spellcheck-documentation-flag |
538 (member checkdoc-spellcheck-documentation-flag | 538 (car (memq checkdoc-spellcheck-documentation-flag |
539 '(interactive t)))) | 539 '(interactive t))))) |
540 (checkdoc-interactive-loop start-here showstatus 'checkdoc-next-error))) | 540 (checkdoc-interactive-loop start-here showstatus 'checkdoc-next-error))) |
541 | 541 |
542 ;;;###autoload | 542 ;;;###autoload |
543 (defun checkdoc-message-interactive (&optional start-here showstatus) | 543 (defun checkdoc-message-interactive (&optional start-here showstatus) |
544 "Interactively check the current buffer for message string errors. | 544 "Interactively check the current buffer for message string errors. |
548 errors. Does not check for comment or space warnings. | 548 errors. Does not check for comment or space warnings. |
549 Optional argument SHOWSTATUS indicates that we should update the | 549 Optional argument SHOWSTATUS indicates that we should update the |
550 checkdoc status window instead of the usual behavior." | 550 checkdoc status window instead of the usual behavior." |
551 (interactive "P") | 551 (interactive "P") |
552 (let ((checkdoc-spellcheck-documentation-flag | 552 (let ((checkdoc-spellcheck-documentation-flag |
553 (member checkdoc-spellcheck-documentation-flag | 553 (car (memq checkdoc-spellcheck-documentation-flag |
554 '(interactive t)))) | 554 '(interactive t))))) |
555 (checkdoc-interactive-loop start-here showstatus | 555 (checkdoc-interactive-loop start-here showstatus |
556 'checkdoc-next-message-error))) | 556 'checkdoc-next-message-error))) |
557 | 557 |
558 (defun checkdoc-interactive-loop (start-here showstatus findfunc) | 558 (defun checkdoc-interactive-loop (start-here showstatus findfunc) |
559 "Interactively loop over all errors that can be found by a given method. | 559 "Interactively loop over all errors that can be found by a given method. |
567 ;; Determine where to start the test | 567 ;; Determine where to start the test |
568 (let* ((begin (prog1 (point) | 568 (let* ((begin (prog1 (point) |
569 (if (not start-here) (goto-char (point-min))))) | 569 (if (not start-here) (goto-char (point-min))))) |
570 ;; Assign a flag to spellcheck flag | 570 ;; Assign a flag to spellcheck flag |
571 (checkdoc-spellcheck-documentation-flag | 571 (checkdoc-spellcheck-documentation-flag |
572 (member checkdoc-spellcheck-documentation-flag | 572 (car (memq checkdoc-spellcheck-documentation-flag |
573 '(buffer interactive t))) | 573 '(buffer interactive t)))) |
574 ;; Fetch the error list | 574 ;; Fetch the error list |
575 (err-list (list (funcall findfunc nil))) | 575 (err-list (list (funcall findfunc nil))) |
576 (cdo nil) | 576 (cdo nil) |
577 (returnme nil) | 577 (returnme nil) |
578 c) | 578 c) |
801 otherwise stop after the first error." | 801 otherwise stop after the first error." |
802 (interactive "P") | 802 (interactive "P") |
803 (if (interactive-p) (message "Checking buffer for style...")) | 803 (if (interactive-p) (message "Checking buffer for style...")) |
804 ;; Assign a flag to spellcheck flag | 804 ;; Assign a flag to spellcheck flag |
805 (let ((checkdoc-spellcheck-documentation-flag | 805 (let ((checkdoc-spellcheck-documentation-flag |
806 (memq checkdoc-spellcheck-documentation-flag '(buffer t))) | 806 (car (memq checkdoc-spellcheck-documentation-flag |
807 '(buffer t)))) | |
807 (checkdoc-autofix-flag (if take-notes 'never | 808 (checkdoc-autofix-flag (if take-notes 'never |
808 checkdoc-autofix-flag)) | 809 checkdoc-autofix-flag)) |
809 (checkdoc-generate-compile-warnings-flag | 810 (checkdoc-generate-compile-warnings-flag |
810 (or take-notes checkdoc-generate-compile-warnings-flag))) | 811 (or take-notes checkdoc-generate-compile-warnings-flag))) |
811 (if take-notes | 812 (if take-notes |
845 is the starting location. If this is nil, `point-min' is used instead." | 846 is the starting location. If this is nil, `point-min' is used instead." |
846 (interactive "P") | 847 (interactive "P") |
847 (let ((wrong nil) (msg nil) (errors nil) | 848 (let ((wrong nil) (msg nil) (errors nil) |
848 ;; Assign a flag to spellcheck flag | 849 ;; Assign a flag to spellcheck flag |
849 (checkdoc-spellcheck-documentation-flag | 850 (checkdoc-spellcheck-documentation-flag |
850 (member checkdoc-spellcheck-documentation-flag | 851 (car (memq checkdoc-spellcheck-documentation-flag |
851 '(buffer t))) | 852 '(buffer t)))) |
852 (checkdoc-autofix-flag (if take-notes 'never | 853 (checkdoc-autofix-flag (if take-notes 'never |
853 checkdoc-autofix-flag)) | 854 checkdoc-autofix-flag)) |
854 (checkdoc-generate-compile-warnings-flag | 855 (checkdoc-generate-compile-warnings-flag |
855 (or take-notes checkdoc-generate-compile-warnings-flag))) | 856 (or take-notes checkdoc-generate-compile-warnings-flag))) |
856 (save-excursion | 857 (save-excursion |
889 (interactive "P") | 890 (interactive "P") |
890 (if take-notes (checkdoc-start-section "checkdoc-comments")) | 891 (if take-notes (checkdoc-start-section "checkdoc-comments")) |
891 (if (not buffer-file-name) | 892 (if (not buffer-file-name) |
892 (error "Can only check comments for a file buffer")) | 893 (error "Can only check comments for a file buffer")) |
893 (let* ((checkdoc-spellcheck-documentation-flag | 894 (let* ((checkdoc-spellcheck-documentation-flag |
894 (member checkdoc-spellcheck-documentation-flag | 895 (car (memq checkdoc-spellcheck-documentation-flag |
895 '(buffer t))) | 896 '(buffer t)))) |
896 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag)) | 897 (checkdoc-autofix-flag (if take-notes 'never checkdoc-autofix-flag)) |
897 (e (checkdoc-file-comments-engine)) | 898 (e (checkdoc-file-comments-engine)) |
898 (checkdoc-generate-compile-warnings-flag | 899 (checkdoc-generate-compile-warnings-flag |
899 (or take-notes checkdoc-generate-compile-warnings-flag))) | 900 (or take-notes checkdoc-generate-compile-warnings-flag))) |
900 (if e (error (checkdoc-error-text e))) | 901 (if e (error (checkdoc-error-text e))) |
969 ;; the argument list or the value of the variable. skip it. | 970 ;; the argument list or the value of the variable. skip it. |
970 (goto-char (match-end 0)) | 971 (goto-char (match-end 0)) |
971 (forward-sexp 1) | 972 (forward-sexp 1) |
972 (skip-chars-forward " \n\t") | 973 (skip-chars-forward " \n\t") |
973 (let* ((checkdoc-spellcheck-documentation-flag | 974 (let* ((checkdoc-spellcheck-documentation-flag |
974 (member checkdoc-spellcheck-documentation-flag | 975 (car (memq checkdoc-spellcheck-documentation-flag |
975 '(defun t))) | 976 '(defun t)))) |
976 (beg (save-excursion (beginning-of-defun) (point))) | 977 (beg (save-excursion (beginning-of-defun) (point))) |
977 (end (save-excursion (end-of-defun) (point))) | 978 (end (save-excursion (end-of-defun) (point))) |
978 (msg (checkdoc-this-string-valid))) | 979 (msg (checkdoc-this-string-valid))) |
979 (if msg (if no-error | 980 (if msg (if no-error |
980 (message (checkdoc-error-text msg)) | 981 (message (checkdoc-error-text msg)) |
2050 Since Ispell isn't Lisp-smart, we must pre-process the doc string | 2051 Since Ispell isn't Lisp-smart, we must pre-process the doc string |
2051 before using the Ispell engine on it." | 2052 before using the Ispell engine on it." |
2052 (if (or (not checkdoc-spellcheck-documentation-flag) | 2053 (if (or (not checkdoc-spellcheck-documentation-flag) |
2053 ;; If the user wants no questions or fixing, then we must | 2054 ;; If the user wants no questions or fixing, then we must |
2054 ;; disable spell checking as not useful. | 2055 ;; disable spell checking as not useful. |
2055 (not checkdoc-autofix-flag) | 2056 ;; FIXME: Somehow, `checkdoc-autofix-flag' is always nil |
2057 ;; when `checkdoc-ispell-docstring-engine' is called to be | |
2058 ;; used on a docstring. As a workround, I commented out the | |
2059 ;; next line. | |
2060 ;; (not checkdoc-autofix-flag) | |
2056 (eq checkdoc-autofix-flag 'never)) | 2061 (eq checkdoc-autofix-flag 'never)) |
2057 nil | 2062 nil |
2058 (checkdoc-ispell-init) | 2063 (checkdoc-ispell-init) |
2059 (save-excursion | 2064 (save-excursion |
2060 (skip-chars-forward "^a-zA-Z") | 2065 (skip-chars-forward "^a-zA-Z") |