[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 de4e13a 17/3
From: |
João Távora |
Subject: |
[Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 de4e13a 17/39: More Flymake cleanup before advancing to backend redesign |
Date: |
Mon, 2 Oct 2017 20:12:23 -0400 (EDT) |
branch: scratch/flymake-refactor-cleaner-for-emacs-26
commit de4e13ac088a29b38fc94e9ca3aed6f24f6b12aa
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
More Flymake cleanup before advancing to backend redesign
Diagnostics are reported for buffers, not necessarily files. It’s the
backend’s responsibility to compute the buffer where the diagnostic is
applicable. For now, this has to match the buffer where flymake-mode
is active and which is at the origin of the backend call.
flymake.el knows nothing about line/column diagnostics (except for
backward-compatible flymake-ler-make-ler, which must yet be tested).
It’s also the backend’s reponsibility to compute a BEG and END
positions for the diagnostic in the relevant buffer.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Convert LINE/COL to
region here. Check file buffer here.
(flymake-proc--process-sentinel): Don’t kill output buffer if
high enough log level.
* lisp/progmodes/flymake.el (flymake-diag-region): Make this a utility
function. (flymake--highlight-line): Diagnostic has region now.
(flymake-popup-current-error-menu): Don’t add file and line numbers to
already this silly menu. (flymake--fix-line-numbers): Remove.
(flymake-report): No need to fix diagnostics here.
---
lisp/progmodes/flymake-proc.el | 33 ++++++++++++--------
lisp/progmodes/flymake.el | 68 ++++++++++++++++++++----------------------
2 files changed, 53 insertions(+), 48 deletions(-)
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 2e593bd..05f2cab 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -423,18 +423,24 @@ Create parent directories as needed."
for col-string = (and col-idx (match-string col-idx))
for col-number = (and col-string
(string-to-number col-string))
- collect (with-current-buffer (process-buffer proc)
- (flymake-make-diagnostic
- :file fname
- :line line-number
- :col col-number
- :type (guess-type flymake-proc-diagnostic-type-pred
message)
- :text message
- :full-file (and fname
- (funcall
- (flymake-proc--get-real-file-name-function
- fname)
- fname)))))
+ for full-file = (with-current-buffer (process-buffer proc)
+ (and fname
+ (funcall
+ (flymake-proc--get-real-file-name-function
+ fname)
+ fname)))
+ for buffer = (and full-file
+ (find-buffer-visiting full-file))
+ if (eq buffer (process-buffer proc))
+ collect (with-current-buffer buffer
+ (pcase-let ((`(,beg . ,end)
+ (flymake-diag-region line-number col-number)))
+ (flymake-make-diagnostic
+ buffer beg end
+ (guess-type flymake-proc-diagnostic-type-pred message)
+ message)))
+ else
+ do (flymake-log 2 "No buffer found for diagnosed file %s" fname))
(error
(flymake-log 1 "Error parsing process output for pattern %s: %s"
pattern err)
@@ -486,7 +492,8 @@ Create parent directories as needed."
(flymake-log 2 "process %d exited with code %d"
(process-id process) exit-status)
- (kill-buffer (process-get process 'flymake-proc--output-buffer))
+ (unless (> flymake-log-level 2)
+ (kill-buffer (process-get process 'flymake-proc--output-buffer)))
(condition-case err
(progn
(flymake-log 3 "cleaning up using %s" cleanup-f)
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index cbe917e..dba69eb 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -139,10 +139,29 @@ are the string substitutions (see the function `format')."
(message "%s" msg))))
(cl-defstruct (flymake--diag
- (:constructor flymake-make-diagnostic))
- file line col type text full-file)
-(define-obsolete-function-alias 'flymake-ler-make 'flymake-make-diagnostic
"26.1"
- "Constructor for objects of type `flymake--diag'")
+ (:constructor flymake--diag-make))
+ buffer beg end type text)
+
+(defun flymake-make-diagnostic (buffer
+ beg
+ end
+ type
+ text)
+ "Mark BUFFER's region from BEG to END with a flymake diagnostic.
+TYPE is a key to `flymake-diagnostic-types-alist' and TEXT is a
+description of the problem detected in this region."
+ (flymake--diag-make :buffer buffer :beg beg :end end :type type :text text))
+
+(defun flymake-ler-make-ler (file line type text &optional full-file)
+ (let* ((file (or full-file file))
+ (buf (find-buffer-visiting file)))
+ (unless buf (error "No buffer visiting %s" file))
+ (pcase-let* ((`(,beg . ,end)
+ (with-current-buffer buf
+ (flymake-diag-region line nil))))
+ (flymake-make-diagnostic buf beg end type text))))
+
+(make-obsolete 'flymake-ler-make-ler 'flymake-make-diagnostic "26.1")
(cl-defun flymake--overlays (&key beg end filter compare key)
"Get flymake-related overlays.
@@ -201,15 +220,14 @@ verify FILTER, sort them by COMPARE (using KEY)."
(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1")
(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1")
-(defun flymake--diag-region (diagnostic)
- "Return the region (BEG . END) for DIAGNOSTIC.
+(defun flymake-diag-region (line col)
+ "Compute region (BEG . END) corresponding to LINE and COL.
Or nil if the region is invalid."
- ;; FIXME: make this a generic function
(condition-case-unless-debug _err
- (save-excursion
- (goto-char (point-min))
- (let ((line (flymake--diag-line diagnostic))
- (col (flymake--diag-col diagnostic)))
+ (let ((line (min (max line 1)
+ (line-number-at-pos (point-max) 'absolute))))
+ (save-excursion
+ (goto-char (point-min))
(forward-line (1- line))
(cl-flet ((fallback-bol
() (progn (back-to-indentation) (point)))
@@ -316,8 +334,9 @@ If TYPE doesn't declare PROP in either
(defun flymake--highlight-line (diagnostic)
"Highlight buffer with info in DIAGNOSTIC."
- (when-let* ((region (flymake--diag-region diagnostic))
- (ov (make-overlay (car region) (cdr region))))
+ (when-let* ((ov (make-overlay
+ (flymake--diag-beg diagnostic)
+ (flymake--diag-end diagnostic))))
;; First set `category' in the overlay, then copy over every other
;; property.
;;
@@ -388,12 +407,7 @@ If TYPE doesn't declare PROP in either
(user-error "No flymake problem for current line")))
(menu (mapcar (lambda (ov)
(let ((diag (overlay-get ov 'flymake--diagnostic)))
- (cons (format "%s - %s(%s)"
- (flymake--diag-text diag)
- (or (flymake--diag-file diag)
- "(no file)")
- (or (flymake--diag-line diag)
- "?"))
+ (cons (flymake--diag-text diag)
ov)))
diag-overlays))
(event (if (mouse-event-p event)
@@ -445,26 +459,10 @@ If TYPE doesn't declare PROP in either
(flymake-log 0 "switched OFF Flymake mode for buffer %s due to fatal status
%s, warning %s"
(buffer-name) status warning))
-(defun flymake--fix-line-numbers (diagnostic)
- "Ensure DIAGNOSTIC has sensible error lines"
- (setf (flymake--diag-line diagnostic)
- (min (max (flymake--diag-line diagnostic)
- 1)
- (line-number-at-pos (point-max) 'absolute))))
-
(defun flymake-report (diagnostics)
(save-restriction
(widen)
(flymake-delete-own-overlays)
- (setq diagnostics
- (cl-remove-if-not
- (lambda (diag)
- (let ((ff (flymake--diag-full-file diag)))
- (and ff
- (equal (expand-file-name ff)
- (expand-file-name (buffer-file-name))))))
- diagnostics))
- (mapc #'flymake--fix-line-numbers diagnostics)
(mapc #'flymake--highlight-line diagnostics)
(let ((err-count (cl-count-if #'flymake--diag-errorp diagnostics))
(warn-count (cl-count-if-not #'flymake--diag-errorp diagnostics)))
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4ae24d7 20/39: Flymake's flymake-proc.el backend slightly easier to debug, (continued)
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4ae24d7 20/39: Flymake's flymake-proc.el backend slightly easier to debug, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4d6d56d 27/39: Remove old flymake-display-err-menu-for-current-line, it's useless, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 ef67227 29/39: Explicitly add a(n empty) keymap for Flymake, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2b735b4 08/39: New Flymake variable flymake-diagnostic-types-alist and much cleanup, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 2971cd0 38/39: Minimal tweak as an attempt to future-proof Flymake API, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 c1661fc 36/39: Hook Flymake onto proper checkdoc and byte-compile interfaces, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 38fdbd6 34/39: Capitalize "Flymake" in docstrings and comments, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b80d29d 39/39: Start rewriting Flymake manual, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 b4099cb 18/39: New Flymake API variable flymake-diagnostic-functions, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 a506cc6 25/39: Fix three Flymake bugs when checking C header files, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 de4e13a 17/39: More Flymake cleanup before advancing to backend redesign,
João Távora <=
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 fd9e32c 15/39: Flymake highlights GCC info/notes as detected by flymake-proc.el, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 be9dd4c 32/39: Improve use of flymake-no-changes-timeout, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 8f0f9cc 28/39: Flymake uses some new fringe bitmaps, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 3ecfe98 35/39: Tweak Flymake autoloads and dependencies, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 26ac964 23/39: A couple of Flymake backends for emacs-lisp-mode, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 fbc6359 31/39: Flymake variable flymake-diagnostic-functions now a special hook, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 4a110bf 22/39: Fancy Flymake mode-line construct displays status, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 fc30b6b 19/39: Simplify Flymake logging and erroring, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 6a5e6ad 05/39: Flymake diagnostics now apply to arbitrary buffer regions, João Távora, 2017/10/02
- [Emacs-diffs] scratch/flymake-refactor-cleaner-for-emacs-26 3169bd9 37/39: Integrate elisp checkers into elisp-mode.el directly, João Távora, 2017/10/02