/[emacs]/emacs/lisp/emacs-lisp/checkdoc.el
ViewVC logotype

Diff of /emacs/lisp/emacs-lisp/checkdoc.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.37.4.1 by handa, Fri Apr 16 12:50:13 2004 UTC revision 1.37.4.2 by miles, Mon Jun 28 07:29:45 2004 UTC
# Line 1246  generating a buffered list of errors." Line 1246  generating a buffered list of errors."
1246  With prefix ARG, turn Checkdoc minor mode on iff ARG is positive.  With prefix ARG, turn Checkdoc minor mode on iff ARG is positive.
1247    
1248  In Checkdoc minor mode, the usual bindings for `eval-defun' which is  In Checkdoc minor mode, the usual bindings for `eval-defun' which is
1249  bound to \\<checkdoc-minor-mode-map> \\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include  bound to \\<checkdoc-minor-mode-map>\\[checkdoc-eval-defun] and `checkdoc-eval-current-buffer' are overridden to include
1250  checking of documentation strings.  checking of documentation strings.
1251    
1252  \\{checkdoc-minor-mode-map}"  \\{checkdoc-minor-mode-map}"
# Line 2579  This function will not modify `match-dat Line 2579  This function will not modify `match-dat
2579  ;;; Warning management  ;;; Warning management
2580  ;;  ;;
2581  (defvar checkdoc-output-font-lock-keywords  (defvar checkdoc-output-font-lock-keywords
2582    '(("\\(\\w+\\.el\\): \\(\\w+\\)"    '(("^\\*\\*\\* \\(.+\\.el\\): \\([^ \n]+\\)"
2583       (1 font-lock-function-name-face)       (1 font-lock-function-name-face)
2584       (2 font-lock-comment-face))       (2 font-lock-comment-face)))
     ("^\\(\\w+\\.el\\):" 1 font-lock-function-name-face)  
     (":\\([0-9]+\\):" 1 font-lock-constant-face))  
2585    "Keywords used to highlight a checkdoc diagnostic buffer.")    "Keywords used to highlight a checkdoc diagnostic buffer.")
2586    
2587  (defvar checkdoc-output-mode-map nil  (defvar checkdoc-output-error-regex-alist
2588    "Keymap used in `checkdoc-output-mode'.")    '(("^\\(.+\\.el\\):\\([0-9]+\\): " 1 2)))
2589    
2590  (defvar checkdoc-pending-errors nil  (defvar checkdoc-pending-errors nil
2591    "Non-nil when there are errors that have not been displayed yet.")    "Non-nil when there are errors that have not been displayed yet.")
2592    
2593  (if checkdoc-output-mode-map  (define-derived-mode checkdoc-output-mode compilation-mode "Checkdoc"
2594      nil    "Set up the major mode for the buffer containing the list of errors."
2595    (setq checkdoc-output-mode-map (make-sparse-keymap))    (set (make-local-variable 'compilation-error-regexp-alist)
2596    (if (not (string-match "XEmacs" emacs-version))         checkdoc-output-error-regex-alist)
2597        (define-key checkdoc-output-mode-map [mouse-2]    (set (make-local-variable 'compilation-mode-font-lock-keywords)
2598          'checkdoc-find-error))         checkdoc-output-font-lock-keywords))
   (define-key checkdoc-output-mode-map "\C-c\C-c" 'checkdoc-find-error)  
   (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error))  
   
 (defun checkdoc-output-mode ()  
   "Create and setup the buffer used to maintain checkdoc warnings.  
 \\<checkdoc-output-mode-map>\\[checkdoc-find-error]  - Go to this error location."  
   (if (get-buffer checkdoc-diagnostic-buffer)  
       (get-buffer checkdoc-diagnostic-buffer)  
     (save-excursion  
       (set-buffer (get-buffer-create checkdoc-diagnostic-buffer))  
       (kill-all-local-variables)  
       (setq mode-name "Checkdoc"  
             major-mode 'checkdoc-output-mode)  
       (set (make-local-variable 'font-lock-defaults)  
            '((checkdoc-output-font-lock-keywords) t t ((?- . "w") (?_ . "w"))))  
       (use-local-map checkdoc-output-mode-map)  
       (run-hooks 'checkdoc-output-mode-hook)  
       (current-buffer))))  
   
 (defalias 'checkdoc-find-error-mouse 'checkdoc-find-error)  
 (defun checkdoc-find-error (&optional event)  
   "In a checkdoc diagnostic buffer, find the error under point."  
   (interactive (list last-input-event))  
   (if event (posn-set-point (event-end e)))  
   (beginning-of-line)  
   (if (looking-at "\\(\\(\\w+\\|\\s_\\)+\\.el\\):\\([0-9]+\\):")  
       (let ((l (string-to-int (match-string 3)))  
             (f (match-string 1)))  
         (if (not (get-file-buffer f))  
             (error "Can't find buffer %s" f))  
         (switch-to-buffer-other-window (get-file-buffer f))  
         (goto-line l))))  
2599    
2600  (defun checkdoc-buffer-label ()  (defun checkdoc-buffer-label ()
2601    "The name to use for a checkdoc buffer in the error list."    "The name to use for a checkdoc buffer in the error list."
2602    (if (buffer-file-name)    (if (buffer-file-name)
2603        (file-name-nondirectory (buffer-file-name))        (file-relative-name (buffer-file-name))
2604      (concat "#<buffer "(buffer-name) ">")))      (concat "#<buffer "(buffer-name) ">")))
2605    
2606  (defun checkdoc-start-section (check-type)  (defun checkdoc-start-section (check-type)
2607    "Initialize the checkdoc diagnostic buffer for a pass.    "Initialize the checkdoc diagnostic buffer for a pass.
2608  Create the header so that the string CHECK-TYPE is displayed as the  Create the header so that the string CHECK-TYPE is displayed as the
2609  function called to create the messages."  function called to create the messages."
2610    (checkdoc-output-to-error-buffer    (let ((dir default-directory)
2611     "\n\n\C-l\n*** "          (label (checkdoc-buffer-label)))
2612     (checkdoc-buffer-label) ": " check-type " V " checkdoc-version))      (with-current-buffer (get-buffer-create checkdoc-diagnostic-buffer)
2613          (checkdoc-output-mode)
2614          (setq default-directory dir)
2615          (goto-char (point-max))
2616          (insert "\n\n\C-l\n*** " label ": " check-type " V " checkdoc-version))))
2617    
2618  (defun checkdoc-error (point msg)  (defun checkdoc-error (point msg)
2619    "Store POINT and MSG as errors in the checkdoc diagnostic buffer."    "Store POINT and MSG as errors in the checkdoc diagnostic buffer."
2620    (setq checkdoc-pending-errors t)    (setq checkdoc-pending-errors t)
2621    (checkdoc-output-to-error-buffer    (let ((text (list "\n" (checkdoc-buffer-label) ":"
2622     "\n" (checkdoc-buffer-label) ":"                      (int-to-string
2623     (int-to-string (count-lines (point-min) (or point (point-min)))) ": "                       (count-lines (point-min) (or point (point-min))))
2624     msg))                      ": " msg)))
2625        (with-current-buffer (get-buffer checkdoc-diagnostic-buffer)
2626  (defun checkdoc-output-to-error-buffer (&rest text)        (goto-char (point-max))
2627    "Place TEXT into the checkdoc diagnostic buffer."        (apply 'insert text))))
   (save-excursion  
     (set-buffer (checkdoc-output-mode))  
     (goto-char (point-max))  
     (apply 'insert text)))  
2628    
2629  (defun checkdoc-show-diagnostics ()  (defun checkdoc-show-diagnostics ()
2630    "Display the checkdoc diagnostic buffer in a temporary window."    "Display the checkdoc diagnostic buffer in a temporary window."

Legend:
Removed from v.1.37.4.1  
changed lines
  Added in v.1.37.4.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26