summaryrefslogtreecommitdiff
path: root/lisp/progmodes/flymake-proc.el
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2017-09-06 16:03:24 +0100
committerJoão Távora <joaotavora@gmail.com>2017-10-03 13:49:04 +0100
commit1c30f9fc08649649676ed812f1579f0948558ceb (patch)
tree27150682706ea3cbf2f86def567e4c5083b8813d /lisp/progmodes/flymake-proc.el
parentbb8b663d327e79eb271b467317c283cc884106ac (diff)
downloademacs-1c30f9fc08649649676ed812f1579f0948558ceb.tar.gz
Flymake diagnostics now apply to arbitrary buffer regions
Make Flymake UI some 150 lines lighter Strip away much of the original implementation's complexity in manipulating objects representing diagnostics as well as creating and navigating overlays. Lay some groundwork for a more flexible approach that allows for different classes of diagnostics, not necessarily line-based. Importantly, one overlay per diagnostic is created, whereas the original implementation had one per line, and on it it concatenated the results of errors and warnings. This means that currently, an error and warning on the same line are problematic and the warning might be overlooked but this will soon be fixed by setting appropriate priorities. Since diagnostics can highlight arbitrary regions, not just lines, the faces were renamed. Tests pass and backward compatibility with interactive functions is maintained, but probably any third-party extension or customization relying on more than a trivial set of flymake.el internals has stopped working. * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use new flymake-ler-make constructor syntax. * lisp/progmodes/flymake.el (flymake-ins-after) (flymake-set-at, flymake-er-make-er, flymake-er-get-line) (flymake-er-get-line-err-info-list, flymake-ler-set-file) (flymake-ler-set-full-file, flymake-ler-set-line) (flymake-get-line-err-count, flymake-get-err-count) (flymake-highlight-err-lines, flymake-overlay-p) (flymake-make-overlay, flymake-region-has-flymake-overlays) (flymake-find-err-info) (flymake-line-err-info-is-less-or-equal) (flymake-add-line-err-info, flymake-add-err-info) (flymake-get-first-err-line-no) (flymake-get-last-err-line-no, flymake-get-next-err-line-no) (flymake-get-prev-err-line-no, flymake-skip-whitespace) (flymake-goto-line, flymake-goto-next-error) (flymake-goto-prev-error, flymake-patch-err-text): Delete functions no longer used. (flymake-goto-next-error, flymake-goto-prev-error): Rewrite. (flymake-report): Rewrite. (flymake-popup-current-error-menu): Rewrite. (flymake--highlight-line): Rename from flymake-highlight-line. Call `flymake--place-overlay. (flymake--place-overlay): New function. (flymake-ler-errorp): New predicate. (flymake-ler): Simplify. (flymake-error): Rename from flymake-errline. (flymake-warning): Rename from flymake-warnline. (flymake-warnline, flymake-errline): Obsoletion aliases. * test/lisp/progmodes/flymake-tests.el (warning-predicate-rx-gcc) (warning-predicate-function-gcc, warning-predicate-rx-perl) (warning-predicate-function-perl): Use face `flymake-warning'.
Diffstat (limited to 'lisp/progmodes/flymake-proc.el')
-rw-r--r--lisp/progmodes/flymake-proc.el54
1 files changed, 31 insertions, 23 deletions
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index bdfdf9afcb4..0395fff3224 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -395,33 +395,41 @@ Create parent directories as needed."
(defun flymake-proc--diagnostics-for-pattern (proc pattern)
(condition-case err
- (pcase-let ((`(,regexp ,file-idx ,line-idx ,_col-idx ,message-idx)
+ (pcase-let ((`(,regexp ,file-idx ,line-idx ,col-idx ,message-idx)
pattern)
(retval))
(while (search-forward-regexp regexp nil t)
- (let ((fname (and file-idx (match-string file-idx)))
- (message (and message-idx (match-string message-idx)))
- (line-number (and line-idx (string-to-number
- (match-string line-idx)))))
+ (let* ((fname (and file-idx (match-string file-idx)))
+ (message (and message-idx (match-string message-idx)))
+ (line-string (and line-idx (match-string line-idx)))
+ (line-number (and line-string
+ (string-to-number line-string)))
+ (col-string (and col-idx (match-string col-idx)))
+ (col-number (and col-string
+ (string-to-number col-string))))
(with-current-buffer (process-buffer proc)
- (push (flymake-ler-make-ler
- fname
- line-number
- (if (and message
- (cond ((stringp flymake-proc-warning-predicate)
- (string-match flymake-proc-warning-predicate
- message))
- ((functionp flymake-proc-warning-predicate)
- (funcall flymake-proc-warning-predicate
- message))))
- "w"
- "e")
- message
- (and fname
- (funcall (flymake-proc--get-real-file-name-function
- fname)
- fname)))
- retval))))
+ (push
+ (flymake-ler-make
+ :file fname
+ :line line-number
+ :col col-number
+ :type (if (and
+ message
+ (cond ((stringp flymake-proc-warning-predicate)
+ (string-match flymake-proc-warning-predicate
+ message))
+ ((functionp flymake-proc-warning-predicate)
+ (funcall flymake-proc-warning-predicate
+ message))))
+ "w"
+ "e")
+ :text message
+ :full-file (and fname
+ (funcall
+ (flymake-proc--get-real-file-name-function
+ fname)
+ fname)))
+ retval))))
retval)
(error
(flymake-log 1 "Error parsing process output for pattern %s: %s"