comparison lisp/emacs-lisp/checkdoc.el @ 89909:68c22ea6027c

Sync to HEAD
author Kenichi Handa <handa@m17n.org>
date Fri, 16 Apr 2004 12:51:06 +0000
parents 375f2633d815
children 4c90ffeb71c5
comparison
equal deleted inserted replaced
89908:ee1402f7b568 89909:68c22ea6027c
1 ;;; checkdoc.el --- check documentation strings for style requirements 1 ;;; checkdoc.el --- check documentation strings for style requirements
2 2
3 ;;; Copyright (C) 1997, 1998, 2001 Free Software Foundation 3 ;;; Copyright (C) 1997, 1998, 2001, 2004 Free Software Foundation
4 4
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> 5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; Version: 0.6.2 6 ;; Version: 0.6.2
7 ;; Keywords: docs, maint, lisp 7 ;; Keywords: docs, maint, lisp
8 8
651 (progn 651 (progn
652 (message "A Fix was not available.") 652 (message "A Fix was not available.")
653 (sit-for 2)) 653 (sit-for 2))
654 (setq err-list (cdr err-list)))) 654 (setq err-list (cdr err-list))))
655 (beginning-of-defun) 655 (beginning-of-defun)
656 (let ((pe (car err-list)) 656 (let ((ne (funcall findfunc nil)))
657 (ne (funcall findfunc nil)))
658 (if ne 657 (if ne
659 (setq err-list (cons ne err-list)) 658 (setq err-list (cons ne err-list))
660 (cond ((not err-list) 659 (cond ((not err-list)
661 (message "No More Stylistic Errors.") 660 (message "No More Stylistic Errors.")
662 (sit-for 2)) 661 (sit-for 2))
898 "Find the next doc string in the current buffer which has a style error. 897 "Find the next doc string in the current buffer which has a style error.
899 Prefix argument TAKE-NOTES means to continue through the whole buffer and 898 Prefix argument TAKE-NOTES means to continue through the whole buffer and
900 save warnings in a separate buffer. Second optional argument START-POINT 899 save warnings in a separate buffer. Second optional argument START-POINT
901 is the starting location. If this is nil, `point-min' is used instead." 900 is the starting location. If this is nil, `point-min' is used instead."
902 (interactive "P") 901 (interactive "P")
903 (let ((wrong nil) (msg nil) (errors nil) 902 (let ((wrong nil) (msg nil)
904 ;; Assign a flag to spellcheck flag 903 ;; Assign a flag to spellcheck flag
905 (checkdoc-spellcheck-documentation-flag 904 (checkdoc-spellcheck-documentation-flag
906 (car (memq checkdoc-spellcheck-documentation-flag 905 (car (memq checkdoc-spellcheck-documentation-flag
907 '(buffer t)))) 906 '(buffer t))))
908 (checkdoc-autofix-flag (if take-notes 'never 907 (checkdoc-autofix-flag (if take-notes 'never
2596 (if checkdoc-output-mode-map 2595 (if checkdoc-output-mode-map
2597 nil 2596 nil
2598 (setq checkdoc-output-mode-map (make-sparse-keymap)) 2597 (setq checkdoc-output-mode-map (make-sparse-keymap))
2599 (if (not (string-match "XEmacs" emacs-version)) 2598 (if (not (string-match "XEmacs" emacs-version))
2600 (define-key checkdoc-output-mode-map [mouse-2] 2599 (define-key checkdoc-output-mode-map [mouse-2]
2601 'checkdoc-find-error-mouse)) 2600 'checkdoc-find-error))
2602 (define-key checkdoc-output-mode-map "\C-c\C-c" 'checkdoc-find-error) 2601 (define-key checkdoc-output-mode-map "\C-c\C-c" 'checkdoc-find-error)
2603 (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error)) 2602 (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error))
2604 2603
2605 (defun checkdoc-output-mode () 2604 (defun checkdoc-output-mode ()
2606 "Create and setup the buffer used to maintain checkdoc warnings. 2605 "Create and setup the buffer used to maintain checkdoc warnings.
2607 \\<checkdoc-output-mode-map>\\[checkdoc-find-error] - Go to this error location 2606 \\<checkdoc-output-mode-map>\\[checkdoc-find-error] - Go to this error location."
2608 \\[checkdoc-find-error-mouse] - Goto the error clicked on."
2609 (if (get-buffer checkdoc-diagnostic-buffer) 2607 (if (get-buffer checkdoc-diagnostic-buffer)
2610 (get-buffer checkdoc-diagnostic-buffer) 2608 (get-buffer checkdoc-diagnostic-buffer)
2611 (save-excursion 2609 (save-excursion
2612 (set-buffer (get-buffer-create checkdoc-diagnostic-buffer)) 2610 (set-buffer (get-buffer-create checkdoc-diagnostic-buffer))
2613 (kill-all-local-variables) 2611 (kill-all-local-variables)
2617 '((checkdoc-output-font-lock-keywords) t t ((?- . "w") (?_ . "w")))) 2615 '((checkdoc-output-font-lock-keywords) t t ((?- . "w") (?_ . "w"))))
2618 (use-local-map checkdoc-output-mode-map) 2616 (use-local-map checkdoc-output-mode-map)
2619 (run-hooks 'checkdoc-output-mode-hook) 2617 (run-hooks 'checkdoc-output-mode-hook)
2620 (current-buffer)))) 2618 (current-buffer))))
2621 2619
2622 (defun checkdoc-find-error-mouse (e) 2620 (defalias 'checkdoc-find-error-mouse 'checkdoc-find-error)
2623 ;; checkdoc-params: (e) 2621 (defun checkdoc-find-error (&optional event)
2624 "Call `checkdoc-find-error' where the user clicks the mouse."
2625 (interactive "e")
2626 (mouse-set-point e)
2627 (checkdoc-find-error))
2628
2629 (defun checkdoc-find-error ()
2630 "In a checkdoc diagnostic buffer, find the error under point." 2622 "In a checkdoc diagnostic buffer, find the error under point."
2631 (interactive) 2623 (interactive (list last-input-event))
2624 (if event (posn-set-point (event-end e)))
2632 (beginning-of-line) 2625 (beginning-of-line)
2633 (if (looking-at "\\(\\(\\w+\\|\\s_\\)+\\.el\\):\\([0-9]+\\):") 2626 (if (looking-at "\\(\\(\\w+\\|\\s_\\)+\\.el\\):\\([0-9]+\\):")
2634 (let ((l (string-to-int (match-string 3))) 2627 (let ((l (string-to-int (match-string 3)))
2635 (f (match-string 1))) 2628 (f (match-string 1)))
2636 (if (not (get-file-buffer f)) 2629 (if (not (get-file-buffer f))
2655 (defun checkdoc-error (point msg) 2648 (defun checkdoc-error (point msg)
2656 "Store POINT and MSG as errors in the checkdoc diagnostic buffer." 2649 "Store POINT and MSG as errors in the checkdoc diagnostic buffer."
2657 (setq checkdoc-pending-errors t) 2650 (setq checkdoc-pending-errors t)
2658 (checkdoc-output-to-error-buffer 2651 (checkdoc-output-to-error-buffer
2659 "\n" (checkdoc-buffer-label) ":" 2652 "\n" (checkdoc-buffer-label) ":"
2660 (int-to-string (count-lines (point-min) (or point 1))) ": " 2653 (int-to-string (count-lines (point-min) (or point (point-min)))) ": "
2661 msg)) 2654 msg))
2662 2655
2663 (defun checkdoc-output-to-error-buffer (&rest text) 2656 (defun checkdoc-output-to-error-buffer (&rest text)
2664 "Place TEXT into the checkdoc diagnostic buffer." 2657 "Place TEXT into the checkdoc diagnostic buffer."
2665 (save-excursion 2658 (save-excursion
2690 (custom-add-option 'emacs-lisp-mode-hook 2683 (custom-add-option 'emacs-lisp-mode-hook
2691 (lambda () (checkdoc-minor-mode 1))) 2684 (lambda () (checkdoc-minor-mode 1)))
2692 2685
2693 (add-to-list 'debug-ignored-errors 2686 (add-to-list 'debug-ignored-errors
2694 "Argument `.*' should appear (as .*) in the doc string") 2687 "Argument `.*' should appear (as .*) in the doc string")
2688 (add-to-list 'debug-ignored-errors
2689 "Lisp symbol `.*' should appear in quotes")
2695 (add-to-list 'debug-ignored-errors "Disambiguate .* by preceding .*") 2690 (add-to-list 'debug-ignored-errors "Disambiguate .* by preceding .*")
2696 2691
2697 (provide 'checkdoc) 2692 (provide 'checkdoc)
2698 2693
2694 ;;; arch-tag: c49a7ec8-3bb7-46f2-bfbc-d5f26e033b26
2699 ;;; checkdoc.el ends here 2695 ;;; checkdoc.el ends here