[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/relint 0604fad 43/44: Use a custom mode for the *relint
From: |
Mattias Engdegård |
Subject: |
[elpa] externals/relint 0604fad 43/44: Use a custom mode for the *relint* buffer |
Date: |
Tue, 26 Mar 2019 12:57:32 -0400 (EDT) |
branch: externals/relint
commit 0604faded0efb16f1e6688b851b90335108706b9
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>
Use a custom mode for the *relint* buffer
Using our own mode, a sub-mode to compilation-mode, is mainly so that
we can bind the "g" key to "run the same thing again".
---
relint.el | 53 +++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 41 insertions(+), 12 deletions(-)
diff --git a/relint.el b/relint.el
index 65af095..39a1db8 100644
--- a/relint.el
+++ b/relint.el
@@ -45,6 +45,7 @@
;;; Code:
(require 'xr)
+(require 'compile)
(defconst relint--error-buffer-name "*relint*")
@@ -53,7 +54,7 @@
(or buf
(let ((buf (get-buffer-create relint--error-buffer-name)))
(with-current-buffer buf
- (compilation-mode))
+ (relint-mode))
buf))))
(defvar relint--error-count)
@@ -975,24 +976,52 @@
(when (> relint--error-count errors-before)
(relint--show-errors))))
-(defun relint--init (dir)
+(defvar relint-last-target nil
+ "The last file or directory on which relint was run. Buffer-local.")
+
+(defun relint--init (target)
(if noninteractive
(setq relint--error-count 0)
(with-current-buffer (relint--error-buffer)
(let ((inhibit-read-only t))
(erase-buffer)
- (insert ";; -*- compilation -*-\n"))
- (setq default-directory dir)
+ (insert (format "Relint results for %s\n" target)))
+ (setq relint-last-target target)
+ (setq default-directory
+ (if (file-directory-p target)
+ target
+ (file-name-directory target)))
(setq relint--error-count 0))))
(defun relint--finish ()
- (unless noninteractive
- (relint--add-to-error-buffer "Finished.\n")
- (let ((errors relint--error-count))
- (message "relint: %d error%s found." errors (if (= errors 1) "" "s")))))
-
-(defun relint--scan-files (files cwd)
- (relint--init cwd)
+ (let* ((errors relint--error-count)
+ (msg (format "%d error%s" errors (if (= errors 1) "" "s"))))
+ (unless noninteractive
+ (relint--add-to-error-buffer (format "\nFinished -- %s found.\n" msg)))
+ (message "relint: %s found." msg)))
+
+(defun relint-again ()
+ "Re-run relint on the same file or directory as last time."
+ (interactive)
+ (if (file-directory-p relint-last-target)
+ (relint-directory relint-last-target)
+ (relint-file relint-last-target)))
+
+(defvar relint-mode-map
+ (let ((map (make-sparse-keymap)))
+ (set-keymap-parent map compilation-minor-mode-map)
+ (define-key map "n" 'next-error-no-select)
+ (define-key map "p" 'previous-error-no-select)
+ (define-key map "g" 'relint-again)
+ map)
+ "Keymap for relint buffers.")
+
+(define-compilation-mode relint-mode "Relint"
+ "Mode for relint output."
+ (setq-local relint-last-target nil))
+
+(defun relint--scan-files (files target)
+ (relint--init target)
(dolist (file files)
;;(relint--add-to-error-buffer (format "Scanning %s\n" file))
(relint--single-file file))
@@ -1007,7 +1036,7 @@
(defun relint-file (file)
"Scan FILE, an elisp file, for errors in regexp strings."
(interactive "fRelint elisp file: ")
- (relint--scan-files (list file) (file-name-directory file)))
+ (relint--scan-files (list file) file))
;;;###autoload
- [elpa] branch externals/relint created (now ee70350), Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 0604fad 43/44: Use a custom mode for the *relint* buffer,
Mattias Engdegård <=
- [elpa] externals/relint ee70350 44/44: FSF copyright, URL, and increment version to 1.5, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 0fd1d46 29/44: Rename trawl to relint, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint e882b71 42/44: Detect regexps spliced into [...], Mattias Engdegård, 2019/03/26
- [elpa] externals/relint c1b92cc 36/44: Wrap and evaluate defined functions passed as parameters, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint d4a6d46 37/44: Evaluate some more functions, macros and special forms, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 019f4cf 10/44: Rewrite the partial evaluator and extend coverage, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 365dc91 41/44: Check bad skip-set provenance, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint a1829d7 39/44: Refactor the file scanning and linting code, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint 0f76132 40/44: Add README.org, Mattias Engdegård, 2019/03/26
- [elpa] externals/relint e824db0 38/44: Expand locally defined macros, Mattias Engdegård, 2019/03/26