diff options
| author | Juanma Barranquero | 2003-03-28 17:38:50 +0000 |
|---|---|---|
| committer | Juanma Barranquero | 2003-03-28 17:38:50 +0000 |
| commit | b08b261e8b7aabbc3a7647e620728a6dbe973652 (patch) | |
| tree | b3e6ddccde0fa6118ce2cbb664240da2bfa711ae | |
| parent | 676b36fb1469b27553f2931140ac3b8b155364aa (diff) | |
| download | emacs-b08b261e8b7aabbc3a7647e620728a6dbe973652.tar.gz emacs-b08b261e8b7aabbc3a7647e620728a6dbe973652.zip | |
(checkdoc-display-status-buffer): Fix docstring.
(checkdoc-interactive, checkdoc-message-interactive): Make them perform spell
checking when appropriate.
(checkdoc-interactive-loop): Fix docstring and a few typos.
(checkdoc-interactive-ispell-loop)
(checkdoc-message-interactive-ispell-loop): New functions.
(checkdoc-next-error): Fix docstring.
(checkdoc-this-string-valid-engine): Fix typo.
(checkdoc-ispell-docstring-engine): Do test for checkdoc-autofix-flag = nil.
| -rw-r--r-- | lisp/emacs-lisp/checkdoc.el | 91 |
1 files changed, 71 insertions, 20 deletions
diff --git a/lisp/emacs-lisp/checkdoc.el b/lisp/emacs-lisp/checkdoc.el index b72608672e6..f9d1cacdc25 100644 --- a/lisp/emacs-lisp/checkdoc.el +++ b/lisp/emacs-lisp/checkdoc.el | |||
| @@ -509,8 +509,8 @@ the users will view as each check is completed." | |||
| 509 | 509 | ||
| 510 | (defun checkdoc-display-status-buffer (check) | 510 | (defun checkdoc-display-status-buffer (check) |
| 511 | "Display and update the status buffer for the current checkdoc mode. | 511 | "Display and update the status buffer for the current checkdoc mode. |
| 512 | CHECK is a vector stating the current status of each test as an | 512 | CHECK is a list of four strings stating the current status of each |
| 513 | element is the status of that level of test." | 513 | test; the nth string describes the status of the nth test." |
| 514 | (let (temp-buffer-setup-hook) | 514 | (let (temp-buffer-setup-hook) |
| 515 | (with-output-to-temp-buffer " *Checkdoc Status*" | 515 | (with-output-to-temp-buffer " *Checkdoc Status*" |
| 516 | (princ-list | 516 | (princ-list |
| @@ -537,7 +537,13 @@ checkdoc status window instead of the usual behavior." | |||
| 537 | (let ((checkdoc-spellcheck-documentation-flag | 537 | (let ((checkdoc-spellcheck-documentation-flag |
| 538 | (car (memq 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 | (prog1 |
| 541 | ;; Due to a design flaw, this will never spell check | ||
| 542 | ;; docstrings. | ||
| 543 | (checkdoc-interactive-loop start-here showstatus | ||
| 544 | 'checkdoc-next-error) | ||
| 545 | ;; This is a workaround to perform spell checking. | ||
| 546 | (checkdoc-interactive-ispell-loop start-here)))) | ||
| 541 | 547 | ||
| 542 | ;;;###autoload | 548 | ;;;###autoload |
| 543 | (defun checkdoc-message-interactive (&optional start-here showstatus) | 549 | (defun checkdoc-message-interactive (&optional start-here showstatus) |
| @@ -552,13 +558,21 @@ checkdoc status window instead of the usual behavior." | |||
| 552 | (let ((checkdoc-spellcheck-documentation-flag | 558 | (let ((checkdoc-spellcheck-documentation-flag |
| 553 | (car (memq checkdoc-spellcheck-documentation-flag | 559 | (car (memq checkdoc-spellcheck-documentation-flag |
| 554 | '(interactive t))))) | 560 | '(interactive t))))) |
| 555 | (checkdoc-interactive-loop start-here showstatus | 561 | (prog1 |
| 556 | 'checkdoc-next-message-error))) | 562 | ;; Due to a design flaw, this will never spell check messages. |
| 563 | (checkdoc-interactive-loop start-here showstatus | ||
| 564 | 'checkdoc-next-message-error) | ||
| 565 | ;; This is a workaround to perform spell checking. | ||
| 566 | (checkdoc-message-interactive-ispell-loop start-here)))) | ||
| 557 | 567 | ||
| 558 | (defun checkdoc-interactive-loop (start-here showstatus findfunc) | 568 | (defun checkdoc-interactive-loop (start-here showstatus findfunc) |
| 559 | "Interactively loop over all errors that can be found by a given method. | 569 | "Interactively loop over all errors that can be found by a given method. |
| 560 | Searching starts at START-HERE. SHOWSTATUS expresses the verbosity | 570 | |
| 561 | of the search, and whether ending the search will auto-exit this function. | 571 | If START-HERE is nil, searching starts at the beginning of the current |
| 572 | buffer, otherwise searching starts at START-HERE. SHOWSTATUS | ||
| 573 | expresses the verbosity of the search, and whether ending the search | ||
| 574 | will auto-exit this function. | ||
| 575 | |||
| 562 | FINDFUNC is a symbol representing a function that will position the | 576 | FINDFUNC is a symbol representing a function that will position the |
| 563 | cursor, and return error message text to present to the user. It is | 577 | cursor, and return error message text to present to the user. It is |
| 564 | assumed that the cursor will stop just before a major sexp, which will | 578 | assumed that the cursor will stop just before a major sexp, which will |
| @@ -614,7 +628,7 @@ style." | |||
| 614 | (goto-char (checkdoc-error-start (car (car err-list)))) | 628 | (goto-char (checkdoc-error-start (car (car err-list)))) |
| 615 | (if (not (pos-visible-in-window-p)) | 629 | (if (not (pos-visible-in-window-p)) |
| 616 | (recenter (- (window-height) 2))) | 630 | (recenter (- (window-height) 2))) |
| 617 | (setq c (checkdoc-read-event)))1 | 631 | (setq c (checkdoc-read-event))) |
| 618 | (if (not (integerp c)) (setq c ??)) | 632 | (if (not (integerp c)) (setq c ??)) |
| 619 | (cond | 633 | (cond |
| 620 | ;; Exit condition | 634 | ;; Exit condition |
| @@ -626,7 +640,7 @@ style." | |||
| 626 | (goto-char (cdr (car err-list))) | 640 | (goto-char (cdr (car err-list))) |
| 627 | ;; `automatic-then-never' tells the autofix function | 641 | ;; `automatic-then-never' tells the autofix function |
| 628 | ;; to only allow one fix to be automatic. The autofix | 642 | ;; to only allow one fix to be automatic. The autofix |
| 629 | ;; function will than set the flag to 'never, allowing | 643 | ;; function will then set the flag to 'never, allowing |
| 630 | ;; the checker to return a different error. | 644 | ;; the checker to return a different error. |
| 631 | (let ((checkdoc-autofix-flag 'automatic-then-never) | 645 | (let ((checkdoc-autofix-flag 'automatic-then-never) |
| 632 | (fixed nil)) | 646 | (fixed nil)) |
| @@ -691,7 +705,7 @@ style." | |||
| 691 | (setq returnme err-list | 705 | (setq returnme err-list |
| 692 | err-list nil | 706 | err-list nil |
| 693 | begin (point))) | 707 | begin (point))) |
| 694 | ;; Goofy s tuff | 708 | ;; Goofy stuff |
| 695 | (t | 709 | (t |
| 696 | (if (get-buffer-window "*Checkdoc Help*") | 710 | (if (get-buffer-window "*Checkdoc Help*") |
| 697 | (progn | 711 | (progn |
| @@ -720,13 +734,54 @@ style." | |||
| 720 | (message "Checkdoc: Done.") | 734 | (message "Checkdoc: Done.") |
| 721 | returnme)) | 735 | returnme)) |
| 722 | 736 | ||
| 737 | (defun checkdoc-interactive-ispell-loop (start-here) | ||
| 738 | "Interactively spell check doc strings in the current buffer. | ||
| 739 | If START-HERE is nil, searching starts at the beginning of the current | ||
| 740 | buffer, otherwise searching starts at START-HERE." | ||
| 741 | (when checkdoc-spellcheck-documentation-flag | ||
| 742 | (save-excursion | ||
| 743 | ;; Move point to where we need to start. | ||
| 744 | (if start-here | ||
| 745 | ;; Include whatever function point is in for good measure. | ||
| 746 | (beginning-of-defun) | ||
| 747 | (goto-char (point-min))) | ||
| 748 | ;; Loop over docstrings. | ||
| 749 | (while (checkdoc-next-docstring) | ||
| 750 | (message "Searching for doc string spell error...%d%%" | ||
| 751 | (/ (* 100 (point)) (point-max))) | ||
| 752 | (if (looking-at "\"") | ||
| 753 | (checkdoc-ispell-docstring-engine | ||
| 754 | (save-excursion (forward-sexp 1) (point-marker))))) | ||
| 755 | (message "Checkdoc: Done.")))) | ||
| 756 | |||
| 757 | (defun checkdoc-message-interactive-ispell-loop (start-here) | ||
| 758 | "Interactively spell check messages in the current buffer. | ||
| 759 | If START-HERE is nil, searching starts at the beginning of the current | ||
| 760 | buffer, otherwise searching starts at START-HERE." | ||
| 761 | (when checkdoc-spellcheck-documentation-flag | ||
| 762 | (save-excursion | ||
| 763 | ;; Move point to where we need to start. | ||
| 764 | (if start-here | ||
| 765 | ;; Include whatever function point is in for good measure. | ||
| 766 | (beginning-of-defun) | ||
| 767 | (goto-char (point-min))) | ||
| 768 | ;; Loop over message strings. | ||
| 769 | (while (checkdoc-message-text-next-string (point-max)) | ||
| 770 | (message "Searching for message string spell error...%d%%" | ||
| 771 | (/ (* 100 (point)) (point-max))) | ||
| 772 | (if (looking-at "\"") | ||
| 773 | (checkdoc-ispell-docstring-engine | ||
| 774 | (save-excursion (forward-sexp 1) (point-marker))))) | ||
| 775 | (message "Checkdoc: Done.")))) | ||
| 776 | |||
| 777 | |||
| 723 | (defun checkdoc-next-error (enable-fix) | 778 | (defun checkdoc-next-error (enable-fix) |
| 724 | "Find and return the next checkdoc error list, or nil. | 779 | "Find and return the next checkdoc error list, or nil. |
| 725 | Only documentation strings are checked. | 780 | Only documentation strings are checked. |
| 726 | Add error vector is of the form (WARNING . POSITION) where WARNING | 781 | An error list is of the form (WARNING . POSITION) where WARNING is the |
| 727 | is the warning text, and POSITION is the point in the buffer where the | 782 | warning text, and POSITION is the point in the buffer where the error |
| 728 | error was found. We can use points and not markers because we promise | 783 | was found. We can use points and not markers because we promise not |
| 729 | not to edit the buffer before point without re-executing this check. | 784 | to edit the buffer before point without re-executing this check. |
| 730 | Argument ENABLE-FIX will enable auto-fixing while looking for the next | 785 | Argument ENABLE-FIX will enable auto-fixing while looking for the next |
| 731 | error. This argument assumes that the cursor is already positioned to | 786 | error. This argument assumes that the cursor is already positioned to |
| 732 | perform the fix." | 787 | perform the fix." |
| @@ -1707,7 +1762,7 @@ function,command,variable,option or symbol." ms1)))))) | |||
| 1707 | ;; it occurs last. | 1762 | ;; it occurs last. |
| 1708 | (and checkdoc-verb-check-experimental-flag | 1763 | (and checkdoc-verb-check-experimental-flag |
| 1709 | (save-excursion | 1764 | (save-excursion |
| 1710 | ;; Maybe rebuild the monster-regex | 1765 | ;; Maybe rebuild the monster-regexp |
| 1711 | (checkdoc-create-common-verbs-regexp) | 1766 | (checkdoc-create-common-verbs-regexp) |
| 1712 | (let ((lim (save-excursion | 1767 | (let ((lim (save-excursion |
| 1713 | (end-of-line) | 1768 | (end-of-line) |
| @@ -2055,11 +2110,7 @@ before using the Ispell engine on it." | |||
| 2055 | (if (or (not checkdoc-spellcheck-documentation-flag) | 2110 | (if (or (not checkdoc-spellcheck-documentation-flag) |
| 2056 | ;; If the user wants no questions or fixing, then we must | 2111 | ;; If the user wants no questions or fixing, then we must |
| 2057 | ;; disable spell checking as not useful. | 2112 | ;; disable spell checking as not useful. |
| 2058 | ;; FIXME: Somehow, `checkdoc-autofix-flag' is always nil | 2113 | (not checkdoc-autofix-flag) |
| 2059 | ;; when `checkdoc-ispell-docstring-engine' is called to be | ||
| 2060 | ;; used on a docstring. As a workround, I commented out the | ||
| 2061 | ;; next line. | ||
| 2062 | ;; (not checkdoc-autofix-flag) | ||
| 2063 | (eq checkdoc-autofix-flag 'never)) | 2114 | (eq checkdoc-autofix-flag 'never)) |
| 2064 | nil | 2115 | nil |
| 2065 | (checkdoc-ispell-init) | 2116 | (checkdoc-ispell-init) |