comparison lisp/emacs-lisp/checkdoc.el @ 55060:4a1324ad659c

(checkdoc-output-mode): Make it a normal major mode. (checkdoc-buffer-label): Make sure the file name is meaningful. (checkdoc-output-to-error-buffer): Remove. (checkdoc-error, checkdoc-start-section): Rewrite.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 21 Apr 2004 20:54:03 +0000
parents bbf96a27b6c5
children 9454ec4dffea
comparison
equal deleted inserted replaced
55059:fa9573e2db2a 55060:4a1324ad659c
2602 (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error)) 2602 (define-key checkdoc-output-mode-map "\C-m" 'checkdoc-find-error))
2603 2603
2604 (defun checkdoc-output-mode () 2604 (defun checkdoc-output-mode ()
2605 "Create and setup the buffer used to maintain checkdoc warnings. 2605 "Create and setup the buffer used to maintain checkdoc warnings.
2606 \\<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."
2607 (if (get-buffer checkdoc-diagnostic-buffer) 2607 (kill-all-local-variables)
2608 (get-buffer checkdoc-diagnostic-buffer) 2608 (setq mode-name "Checkdoc"
2609 (save-excursion 2609 major-mode 'checkdoc-output-mode)
2610 (set-buffer (get-buffer-create checkdoc-diagnostic-buffer)) 2610 (set (make-local-variable 'font-lock-defaults)
2611 (kill-all-local-variables) 2611 '((checkdoc-output-font-lock-keywords) t t ((?- . "w") (?_ . "w"))))
2612 (setq mode-name "Checkdoc" 2612 (use-local-map checkdoc-output-mode-map)
2613 major-mode 'checkdoc-output-mode) 2613 (run-mode-hooks 'checkdoc-output-mode-hook))
2614 (set (make-local-variable 'font-lock-defaults)
2615 '((checkdoc-output-font-lock-keywords) t t ((?- . "w") (?_ . "w"))))
2616 (use-local-map checkdoc-output-mode-map)
2617 (run-hooks 'checkdoc-output-mode-hook)
2618 (current-buffer))))
2619 2614
2620 (defalias 'checkdoc-find-error-mouse 'checkdoc-find-error) 2615 (defalias 'checkdoc-find-error-mouse 'checkdoc-find-error)
2621 (defun checkdoc-find-error (&optional event) 2616 (defun checkdoc-find-error (&optional event)
2622 "In a checkdoc diagnostic buffer, find the error under point." 2617 "In a checkdoc diagnostic buffer, find the error under point."
2623 (interactive (list last-input-event)) 2618 (interactive (list last-input-event))
2632 (goto-line l)))) 2627 (goto-line l))))
2633 2628
2634 (defun checkdoc-buffer-label () 2629 (defun checkdoc-buffer-label ()
2635 "The name to use for a checkdoc buffer in the error list." 2630 "The name to use for a checkdoc buffer in the error list."
2636 (if (buffer-file-name) 2631 (if (buffer-file-name)
2637 (file-name-nondirectory (buffer-file-name)) 2632 (file-relative-name (buffer-file-name))
2638 (concat "#<buffer "(buffer-name) ">"))) 2633 (concat "#<buffer "(buffer-name) ">")))
2639 2634
2640 (defun checkdoc-start-section (check-type) 2635 (defun checkdoc-start-section (check-type)
2641 "Initialize the checkdoc diagnostic buffer for a pass. 2636 "Initialize the checkdoc diagnostic buffer for a pass.
2642 Create the header so that the string CHECK-TYPE is displayed as the 2637 Create the header so that the string CHECK-TYPE is displayed as the
2643 function called to create the messages." 2638 function called to create the messages."
2644 (checkdoc-output-to-error-buffer 2639 (let ((dir default-directory)
2645 "\n\n\C-l\n*** " 2640 (label (checkdoc-buffer-label)))
2646 (checkdoc-buffer-label) ": " check-type " V " checkdoc-version)) 2641 (with-current-buffer (get-buffer-create checkdoc-diagnostic-buffer)
2642 (checkdoc-output-mode)
2643 (setq default-directory dir)
2644 (goto-char (point-max))
2645 (insert "\n\n\C-l\n*** " label ": " check-type " V " checkdoc-version))))
2647 2646
2648 (defun checkdoc-error (point msg) 2647 (defun checkdoc-error (point msg)
2649 "Store POINT and MSG as errors in the checkdoc diagnostic buffer." 2648 "Store POINT and MSG as errors in the checkdoc diagnostic buffer."
2650 (setq checkdoc-pending-errors t) 2649 (setq checkdoc-pending-errors t)
2651 (checkdoc-output-to-error-buffer 2650 (let ((text (list "\n" (checkdoc-buffer-label) ":"
2652 "\n" (checkdoc-buffer-label) ":" 2651 (int-to-string
2653 (int-to-string (count-lines (point-min) (or point (point-min)))) ": " 2652 (count-lines (point-min) (or point (point-min))))
2654 msg)) 2653 ": " msg)))
2655 2654 (with-current-buffer (get-buffer checkdoc-diagnostic-buffer)
2656 (defun checkdoc-output-to-error-buffer (&rest text) 2655 (goto-char (point-max))
2657 "Place TEXT into the checkdoc diagnostic buffer." 2656 (apply 'insert text))))
2658 (save-excursion
2659 (set-buffer (checkdoc-output-mode))
2660 (goto-char (point-max))
2661 (apply 'insert text)))
2662 2657
2663 (defun checkdoc-show-diagnostics () 2658 (defun checkdoc-show-diagnostics ()
2664 "Display the checkdoc diagnostic buffer in a temporary window." 2659 "Display the checkdoc diagnostic buffer in a temporary window."
2665 (if checkdoc-pending-errors 2660 (if checkdoc-pending-errors
2666 (let ((b (get-buffer checkdoc-diagnostic-buffer))) 2661 (let ((b (get-buffer checkdoc-diagnostic-buffer)))