509 |
|
|
510 |
(defun checkdoc-display-status-buffer (check) |
(defun checkdoc-display-status-buffer (check) |
511 |
"Display and update the status buffer for the current checkdoc mode. |
"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 |
CHECK is a list of four strings stating the current status of each |
513 |
element is the status of that level of test." |
test; the nth string describes the status of the nth test." |
514 |
(let (temp-buffer-setup-hook) |
(let (temp-buffer-setup-hook) |
515 |
(with-output-to-temp-buffer " *Checkdoc Status*" |
(with-output-to-temp-buffer " *Checkdoc Status*" |
516 |
(princ-list |
(princ-list |
537 |
(let ((checkdoc-spellcheck-documentation-flag |
(let ((checkdoc-spellcheck-documentation-flag |
538 |
(car (memq checkdoc-spellcheck-documentation-flag |
(car (memq checkdoc-spellcheck-documentation-flag |
539 |
'(interactive t))))) |
'(interactive t))))) |
540 |
(checkdoc-interactive-loop start-here showstatus 'checkdoc-next-error))) |
(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)))) |
547 |
|
|
548 |
;;;###autoload |
;;;###autoload |
549 |
(defun checkdoc-message-interactive (&optional start-here showstatus) |
(defun checkdoc-message-interactive (&optional start-here showstatus) |
558 |
(let ((checkdoc-spellcheck-documentation-flag |
(let ((checkdoc-spellcheck-documentation-flag |
559 |
(car (memq checkdoc-spellcheck-documentation-flag |
(car (memq checkdoc-spellcheck-documentation-flag |
560 |
'(interactive t))))) |
'(interactive t))))) |
561 |
(checkdoc-interactive-loop start-here showstatus |
(prog1 |
562 |
'checkdoc-next-message-error))) |
;; 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)))) |
567 |
|
|
568 |
(defun checkdoc-interactive-loop (start-here showstatus findfunc) |
(defun checkdoc-interactive-loop (start-here showstatus findfunc) |
569 |
"Interactively loop over all errors that can be found by a given method. |
"Interactively loop over all errors that can be found by a given method. |
570 |
Searching starts at START-HERE. SHOWSTATUS expresses the verbosity |
|
571 |
of the search, and whether ending the search will auto-exit this function. |
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 |
|
|
576 |
FINDFUNC is a symbol representing a function that will position the |
FINDFUNC is a symbol representing a function that will position the |
577 |
cursor, and return error message text to present to the user. It is |
cursor, and return error message text to present to the user. It is |
578 |
assumed that the cursor will stop just before a major sexp, which will |
assumed that the cursor will stop just before a major sexp, which will |
628 |
(goto-char (checkdoc-error-start (car (car err-list)))) |
(goto-char (checkdoc-error-start (car (car err-list)))) |
629 |
(if (not (pos-visible-in-window-p)) |
(if (not (pos-visible-in-window-p)) |
630 |
(recenter (- (window-height) 2))) |
(recenter (- (window-height) 2))) |
631 |
(setq c (checkdoc-read-event)))1 |
(setq c (checkdoc-read-event))) |
632 |
(if (not (integerp c)) (setq c ??)) |
(if (not (integerp c)) (setq c ??)) |
633 |
(cond |
(cond |
634 |
;; Exit condition |
;; Exit condition |
640 |
(goto-char (cdr (car err-list))) |
(goto-char (cdr (car err-list))) |
641 |
;; `automatic-then-never' tells the autofix function |
;; `automatic-then-never' tells the autofix function |
642 |
;; to only allow one fix to be automatic. The autofix |
;; to only allow one fix to be automatic. The autofix |
643 |
;; function will than set the flag to 'never, allowing |
;; function will then set the flag to 'never, allowing |
644 |
;; the checker to return a different error. |
;; the checker to return a different error. |
645 |
(let ((checkdoc-autofix-flag 'automatic-then-never) |
(let ((checkdoc-autofix-flag 'automatic-then-never) |
646 |
(fixed nil)) |
(fixed nil)) |
705 |
(setq returnme err-list |
(setq returnme err-list |
706 |
err-list nil |
err-list nil |
707 |
begin (point))) |
begin (point))) |
708 |
;; Goofy s tuff |
;; Goofy stuff |
709 |
(t |
(t |
710 |
(if (get-buffer-window "*Checkdoc Help*") |
(if (get-buffer-window "*Checkdoc Help*") |
711 |
(progn |
(progn |
734 |
(message "Checkdoc: Done.") |
(message "Checkdoc: Done.") |
735 |
returnme)) |
returnme)) |
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 |
|
|
778 |
(defun checkdoc-next-error (enable-fix) |
(defun checkdoc-next-error (enable-fix) |
779 |
"Find and return the next checkdoc error list, or nil. |
"Find and return the next checkdoc error list, or nil. |
780 |
Only documentation strings are checked. |
Only documentation strings are checked. |
781 |
Add error vector is of the form (WARNING . POSITION) where WARNING |
An error list is of the form (WARNING . POSITION) where WARNING is the |
782 |
is the warning text, and POSITION is the point in the buffer where the |
warning text, and POSITION is the point in the buffer where the error |
783 |
error was found. We can use points and not markers because we promise |
was found. We can use points and not markers because we promise not |
784 |
not to edit the buffer before point without re-executing this check. |
to edit the buffer before point without re-executing this check. |
785 |
Argument ENABLE-FIX will enable auto-fixing while looking for the next |
Argument ENABLE-FIX will enable auto-fixing while looking for the next |
786 |
error. This argument assumes that the cursor is already positioned to |
error. This argument assumes that the cursor is already positioned to |
787 |
perform the fix." |
perform the fix." |
1762 |
;; it occurs last. |
;; it occurs last. |
1763 |
(and checkdoc-verb-check-experimental-flag |
(and checkdoc-verb-check-experimental-flag |
1764 |
(save-excursion |
(save-excursion |
1765 |
;; Maybe rebuild the monster-regex |
;; Maybe rebuild the monster-regexp |
1766 |
(checkdoc-create-common-verbs-regexp) |
(checkdoc-create-common-verbs-regexp) |
1767 |
(let ((lim (save-excursion |
(let ((lim (save-excursion |
1768 |
(end-of-line) |
(end-of-line) |
2110 |
(if (or (not checkdoc-spellcheck-documentation-flag) |
(if (or (not checkdoc-spellcheck-documentation-flag) |
2111 |
;; If the user wants no questions or fixing, then we must |
;; If the user wants no questions or fixing, then we must |
2112 |
;; disable spell checking as not useful. |
;; disable spell checking as not useful. |
2113 |
;; FIXME: Somehow, `checkdoc-autofix-flag' is always nil |
(not checkdoc-autofix-flag) |
|
;; when `checkdoc-ispell-docstring-engine' is called to be |
|
|
;; used on a docstring. As a workround, I commented out the |
|
|
;; next line. |
|
|
;; (not checkdoc-autofix-flag) |
|
2114 |
(eq checkdoc-autofix-flag 'never)) |
(eq checkdoc-autofix-flag 'never)) |
2115 |
nil |
nil |
2116 |
(checkdoc-ispell-init) |
(checkdoc-ispell-init) |