emacs/lisp/progmodes/flymake.el

873 lines
34 KiB
EmacsLisp
Raw Normal View History

;;; flymake.el --- A universal on-the-fly syntax checker -*- lexical-binding: t; -*-
2004-05-29 12:55:24 +00:00
;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
2004-05-29 12:55:24 +00:00
;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
;; Maintainer: Leo Liu <sdl.web@gmail.com>
2004-05-29 12:55:24 +00:00
;; Version: 0.3
;; Keywords: c languages tools
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
2004-05-29 12:55:24 +00:00
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
2004-05-29 12:55:24 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
2004-05-29 12:55:24 +00:00
;;; Commentary:
;;
;; Flymake is a minor Emacs mode performing on-the-fly syntax checks.
;;
;; This file contains the UI for displaying and interacting with the
;; results of such checks, as well as entry points for backends to
;; hook on to. Backends are sources of diagnostic info.
;;
2004-05-29 12:55:24 +00:00
;;; Code:
(require 'cl-lib)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(require 'thingatpt) ; end-of-thing
(require 'warnings) ; warning-numeric-level, display-warning
(require 'compile) ; for some faces
(eval-when-compile (require 'subr-x)) ; when-let*, if-let*, hash-table-keys
(defgroup flymake nil
"Universal on-the-fly syntax checker."
:version "23.1"
:link '(custom-manual "(flymake) Top")
:group 'tools)
(defcustom flymake-error-bitmap '(flymake-double-exclamation-mark
compilation-error)
"Bitmap (a symbol) used in the fringe for indicating errors.
The value may also be a list of two elements where the second
element specifies the face for the bitmap. For possible bitmap
symbols, see `fringe-bitmaps'. See also `flymake-warning-bitmap'.
The option `flymake-fringe-indicator-position' controls how and where
this is used."
:group 'flymake
:version "24.3"
:type '(choice (symbol :tag "Bitmap")
(list :tag "Bitmap and face"
(symbol :tag "Bitmap")
(face :tag "Face"))))
(defcustom flymake-warning-bitmap '(exclamation-mark compilation-warning)
"Bitmap (a symbol) used in the fringe for indicating warnings.
The value may also be a list of two elements where the second
element specifies the face for the bitmap. For possible bitmap
symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
The option `flymake-fringe-indicator-position' controls how and where
this is used."
:group 'flymake
:version "24.3"
:type '(choice (symbol :tag "Bitmap")
(list :tag "Bitmap and face"
(symbol :tag "Bitmap")
(face :tag "Face"))))
(defcustom flymake-note-bitmap '(exclamation-mark compilation-info)
"Bitmap (a symbol) used in the fringe for indicating info notes.
The value may also be a list of two elements where the second
element specifies the face for the bitmap. For possible bitmap
symbols, see `fringe-bitmaps'. See also `flymake-error-bitmap'.
The option `flymake-fringe-indicator-position' controls how and where
this is used."
:group 'flymake
:version "26.1"
:type '(choice (symbol :tag "Bitmap")
(list :tag "Bitmap and face"
(symbol :tag "Bitmap")
(face :tag "Face"))))
(defcustom flymake-fringe-indicator-position 'left-fringe
"The position to put flymake fringe indicator.
The value can be nil (do not use indicators), `left-fringe' or `right-fringe'.
See `flymake-error-bitmap' and `flymake-warning-bitmap'."
:group 'flymake
:version "24.3"
:type '(choice (const left-fringe)
(const right-fringe)
(const :tag "No fringe indicators" nil)))
(defcustom flymake-start-syntax-check-on-newline t
"Start syntax check if newline char was added/removed from the buffer."
:group 'flymake
:type 'boolean)
(defcustom flymake-no-changes-timeout 0.5
"Time to wait after last change before starting compilation."
:group 'flymake
:type 'number)
(defcustom flymake-gui-warnings-enabled t
"Enables/disables GUI warnings."
:group 'flymake
:type 'boolean)
(make-obsolete-variable 'flymake-gui-warnings-enabled
"it no longer has any effect." "26.1")
(defcustom flymake-start-syntax-check-on-find-file t
"Start syntax check on find file."
:group 'flymake
:type 'boolean)
(defcustom flymake-log-level -1
"Obsolete and ignored variable."
:type 'integer)
(make-obsolete-variable 'flymake-log-level
"it is superseded by `warning-minimum-log-level.'"
"26.1")
(defcustom flymake-wrap-around t
"If non-nil, moving to errors wraps around buffer boundaries."
:group 'flymake :type 'boolean)
(define-fringe-bitmap 'flymake-double-exclamation-mark
(vector #b00000000
#b00000000
#b00000000
#b00000000
#b01100110
#b01100110
#b01100110
#b01100110
#b01100110
#b01100110
#b01100110
#b01100110
#b00000000
#b01100110
#b00000000
#b00000000
#b00000000))
(defvar-local flymake-timer nil
"Timer for starting syntax check.")
(defvar-local flymake-last-change-time nil
"Time of last buffer change.")
(defvar-local flymake-check-start-time nil
"Time at which syntax check was started.")
(defun flymake--log-1 (level sublog msg &rest args)
"Do actual work for `flymake-log'."
(let (;; never popup the log buffer
(warning-minimum-level :emergency)
(warning-type-format
(format " [%s %s]"
(or sublog 'flymake)
(current-buffer))))
(display-warning (list 'flymake sublog)
(apply #'format-message msg args)
(if (numberp level)
(or (nth level
'(:emergency :error :warning :debug :debug) )
:error)
level)
"*Flymake log*")))
;;;###autoload
(defmacro flymake-log (level msg &rest args)
"Log, at level LEVEL, the message MSG formatted with ARGS.
LEVEL is passed to `display-warning', which is used to display
the warning. If this form is included in a byte-compiled file,
the generated warning contains an indication of the file that
generated it."
(let* ((compile-file (and (boundp 'byte-compile-current-file)
(symbol-value 'byte-compile-current-file)))
(sublog (if (and
compile-file
(not load-file-name))
(intern
(file-name-nondirectory
(file-name-sans-extension compile-file))))))
`(flymake--log-1 ,level ',sublog ,msg ,@args)))
(defun flymake-error (text &rest args)
"Format TEXT with ARGS and signal an error for flymake."
(let ((msg (apply #'format-message text args)))
(flymake-log :error msg)
(error (concat "[Flymake] " msg))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(cl-defstruct (flymake--diag
(:constructor flymake--diag-make))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
buffer beg end type text backend)
(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 (flymake-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")
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(cl-defun flymake--overlays (&key beg end filter compare key)
"Get flymake-related overlays.
If BEG is non-nil and END is nil, consider only `overlays-at'
BEG. Otherwise consider `overlays-in' the region comprised by BEG
and END, defaulting to the whole buffer. Remove all that do not
verify FILTER, sort them by COMPARE (using KEY)."
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'.
2017-09-06 16:03:24 +01:00
(cl-remove-if-not
(lambda (ov)
(and (overlay-get ov 'flymake-overlay)
(or (not filter)
(cond ((functionp filter) (funcall filter ov))
((symbolp filter) (overlay-get ov filter))))))
(save-restriction
(widen)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(let ((ovs (if (and beg (null end))
(overlays-at beg t)
(overlays-in (or beg (point-min))
(or end (point-max))))))
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'.
2017-09-06 16:03:24 +01:00
(if compare
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(cl-sort ovs compare :key (or key
#'identity))
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'.
2017-09-06 16:03:24 +01:00
ovs)))))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(defun flymake-delete-own-overlays (&optional filter)
"Delete all flymake overlays in BUFFER."
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(mapc #'delete-overlay (flymake--overlays :filter filter)))
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'.
2017-09-06 16:03:24 +01:00
(defface flymake-error
'((((supports :underline (:style wave)))
:underline (:style wave :color "Red1"))
(t
:inherit error))
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'.
2017-09-06 16:03:24 +01:00
"Face used for marking error regions."
:version "24.4"
:group 'flymake)
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'.
2017-09-06 16:03:24 +01:00
(defface flymake-warning
'((((supports :underline (:style wave)))
:underline (:style wave :color "deep sky blue"))
(t
:inherit warning))
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'.
2017-09-06 16:03:24 +01:00
"Face used for marking warning regions."
:version "24.4"
:group 'flymake)
(defface flymake-note
'((((supports :underline (:style wave)))
:underline (:style wave :color "yellow green"))
(t
:inherit warning))
"Face used for marking note regions."
:version "26.1"
:group 'flymake)
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'.
2017-09-06 16:03:24 +01:00
(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1")
(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1")
Fix three Flymake bugs when checking C header files The first of these problems is longstanding: if an error-less B.h is included from error-ridden A.h, flymake's legacy parser will panic (and disable itself) since it sees a non-zero exit for a clean file. To fix this, recommend returning 'true' in the documentation for the check-syntax target. Another problem was introduced by the parser rewrite. For error patterns spanning more than one line, point may be left in the middle of a line and thus render other patterns useless. Those patterns were written for the old line-by-line parser. To make them useful again, move to the beginning of line in those situations. The third problem was also longstanding and happened on newer GCC's: The "In file included from" prefix confused flymake-proc-get-real-file-name. Fix this. Also updated flymake--diag-region to fallback to highlighting a full line less often. Add automatic tests to check this. * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Fix bug when patterns accidentally spans more than one line. Don't create diagnostics without error messages. (flymake-proc-real-file-name-considering-includes): New helper. (flymake-proc-allowed-file-name-masks): Use it. * lisp/progmodes/flymake.el (flymake-diag-region): Make COL argument explicitly optional. Only fall back to full line in extreme cases. * test/lisp/progmodes/flymake-tests.el (included-c-header-files): New test. (different-diagnostic-types): Update. * test/lisp/progmodes/flymake-resources/Makefile (check-syntax): Always return success (0) error code. (CC_OPTS): Add -Wextra * test/lisp/progmodes/flymake-resources/errors-and-warnings.c (main): Rewrite comments. * test/lisp/progmodes/flymake-resources/errors-and-warnings.c: Include some dummy header files. * test/lisp/progmodes/flymake-resources/no-problems.h: New file. * test/lisp/progmodes/flymake-resources/some-problems.h: New file. * doc/misc/flymake.texi (Example---Configuring a tool called via make): Recommend adding "|| true" to the check-syntax target.
2017-09-28 12:06:56 +01:00
(defun flymake-diag-region (line &optional col)
"Compute region (BEG . END) corresponding to LINE and COL.
Fix three Flymake bugs when checking C header files The first of these problems is longstanding: if an error-less B.h is included from error-ridden A.h, flymake's legacy parser will panic (and disable itself) since it sees a non-zero exit for a clean file. To fix this, recommend returning 'true' in the documentation for the check-syntax target. Another problem was introduced by the parser rewrite. For error patterns spanning more than one line, point may be left in the middle of a line and thus render other patterns useless. Those patterns were written for the old line-by-line parser. To make them useful again, move to the beginning of line in those situations. The third problem was also longstanding and happened on newer GCC's: The "In file included from" prefix confused flymake-proc-get-real-file-name. Fix this. Also updated flymake--diag-region to fallback to highlighting a full line less often. Add automatic tests to check this. * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Fix bug when patterns accidentally spans more than one line. Don't create diagnostics without error messages. (flymake-proc-real-file-name-considering-includes): New helper. (flymake-proc-allowed-file-name-masks): Use it. * lisp/progmodes/flymake.el (flymake-diag-region): Make COL argument explicitly optional. Only fall back to full line in extreme cases. * test/lisp/progmodes/flymake-tests.el (included-c-header-files): New test. (different-diagnostic-types): Update. * test/lisp/progmodes/flymake-resources/Makefile (check-syntax): Always return success (0) error code. (CC_OPTS): Add -Wextra * test/lisp/progmodes/flymake-resources/errors-and-warnings.c (main): Rewrite comments. * test/lisp/progmodes/flymake-resources/errors-and-warnings.c: Include some dummy header files. * test/lisp/progmodes/flymake-resources/no-problems.h: New file. * test/lisp/progmodes/flymake-resources/some-problems.h: New file. * doc/misc/flymake.texi (Example---Configuring a tool called via make): Recommend adding "|| true" to the check-syntax target.
2017-09-28 12:06:56 +01:00
If COL is nil, return a region just for LINE.
Return nil if the region is invalid."
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(condition-case-unless-debug _err
(let ((line (min (max line 1)
(line-number-at-pos (point-max) 'absolute))))
(save-excursion
(goto-char (point-min))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(forward-line (1- line))
(cl-flet ((fallback-bol
() (progn (back-to-indentation) (point)))
(fallback-eol
(beg)
(progn
(end-of-line)
(skip-chars-backward " \t\f\t\n" beg)
(if (eq (point) beg)
(line-beginning-position 2)
(point)))))
Fix three Flymake bugs when checking C header files The first of these problems is longstanding: if an error-less B.h is included from error-ridden A.h, flymake's legacy parser will panic (and disable itself) since it sees a non-zero exit for a clean file. To fix this, recommend returning 'true' in the documentation for the check-syntax target. Another problem was introduced by the parser rewrite. For error patterns spanning more than one line, point may be left in the middle of a line and thus render other patterns useless. Those patterns were written for the old line-by-line parser. To make them useful again, move to the beginning of line in those situations. The third problem was also longstanding and happened on newer GCC's: The "In file included from" prefix confused flymake-proc-get-real-file-name. Fix this. Also updated flymake--diag-region to fallback to highlighting a full line less often. Add automatic tests to check this. * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Fix bug when patterns accidentally spans more than one line. Don't create diagnostics without error messages. (flymake-proc-real-file-name-considering-includes): New helper. (flymake-proc-allowed-file-name-masks): Use it. * lisp/progmodes/flymake.el (flymake-diag-region): Make COL argument explicitly optional. Only fall back to full line in extreme cases. * test/lisp/progmodes/flymake-tests.el (included-c-header-files): New test. (different-diagnostic-types): Update. * test/lisp/progmodes/flymake-resources/Makefile (check-syntax): Always return success (0) error code. (CC_OPTS): Add -Wextra * test/lisp/progmodes/flymake-resources/errors-and-warnings.c (main): Rewrite comments. * test/lisp/progmodes/flymake-resources/errors-and-warnings.c: Include some dummy header files. * test/lisp/progmodes/flymake-resources/no-problems.h: New file. * test/lisp/progmodes/flymake-resources/some-problems.h: New file. * doc/misc/flymake.texi (Example---Configuring a tool called via make): Recommend adding "|| true" to the check-syntax target.
2017-09-28 12:06:56 +01:00
(if (and col (cl-plusp col))
(let* ((beg (progn (forward-char (1- col))
(point)))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(sexp-end (ignore-errors (end-of-thing 'sexp)))
Fix three Flymake bugs when checking C header files The first of these problems is longstanding: if an error-less B.h is included from error-ridden A.h, flymake's legacy parser will panic (and disable itself) since it sees a non-zero exit for a clean file. To fix this, recommend returning 'true' in the documentation for the check-syntax target. Another problem was introduced by the parser rewrite. For error patterns spanning more than one line, point may be left in the middle of a line and thus render other patterns useless. Those patterns were written for the old line-by-line parser. To make them useful again, move to the beginning of line in those situations. The third problem was also longstanding and happened on newer GCC's: The "In file included from" prefix confused flymake-proc-get-real-file-name. Fix this. Also updated flymake--diag-region to fallback to highlighting a full line less often. Add automatic tests to check this. * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Fix bug when patterns accidentally spans more than one line. Don't create diagnostics without error messages. (flymake-proc-real-file-name-considering-includes): New helper. (flymake-proc-allowed-file-name-masks): Use it. * lisp/progmodes/flymake.el (flymake-diag-region): Make COL argument explicitly optional. Only fall back to full line in extreme cases. * test/lisp/progmodes/flymake-tests.el (included-c-header-files): New test. (different-diagnostic-types): Update. * test/lisp/progmodes/flymake-resources/Makefile (check-syntax): Always return success (0) error code. (CC_OPTS): Add -Wextra * test/lisp/progmodes/flymake-resources/errors-and-warnings.c (main): Rewrite comments. * test/lisp/progmodes/flymake-resources/errors-and-warnings.c: Include some dummy header files. * test/lisp/progmodes/flymake-resources/no-problems.h: New file. * test/lisp/progmodes/flymake-resources/some-problems.h: New file. * doc/misc/flymake.texi (Example---Configuring a tool called via make): Recommend adding "|| true" to the check-syntax target.
2017-09-28 12:06:56 +01:00
(end (or (and sexp-end
(not (= sexp-end beg))
sexp-end)
(ignore-errors (goto-char (1+ beg)))))
(safe-end (or end
(fallback-eol beg))))
(cons (if end beg (fallback-bol))
safe-end))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(let* ((beg (fallback-bol))
(end (fallback-eol beg)))
(cons beg end))))))
(error (flymake-error "Invalid region line=%s col=%s" line col))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(defvar flymake-diagnostic-functions nil
"List of flymake backends i.e. sources of flymake diagnostics.
This variable holds an arbitrary number of \"backends\" or
\"checkers\" providing the flymake UI's \"frontend\" with
information about where and how to annotate problems diagnosed in
a buffer.
Backends are lisp functions sharing a common calling
convention. Whenever flymake decides it is time to re-check the
buffer, each backend is called with a single argument, a
REPORT-FN callback, detailed below. Backend functions are first
expected to quickly and inexpensively announce the feasibility of
checking the buffer (i.e. they aren't expected to immediately
start checking the buffer):
* If the backend function returns nil, flymake forgets about this
backend for the current check, but will call it again the next
time;
* If the backend function returns non-nil, flymake expects this backend to
check the buffer and call its REPORT-FN callback function. If
the computation involved is inexpensive, the backend function
may do so synchronously before returning. If it is not, it may
do so after retuning, using idle timers, asynchronous
processes or other asynchronous mechanisms.
* If the backend function signals an error, it is disabled, i.e. flymake
will not attempt it again for this buffer until `flymake-mode'
is turned off and on again.
When calling REPORT-FN, the first argument passed to it decides
how to proceed. Recognized values are:
* A (possibly empty) list of objects created with
`flymake-make-diagnostic', causing flymake to annotate the
buffer with this information and consider the backend has
having finished its check normally.
* The symbol `:progress', signalling that the backend is still
working and will call REPORT-FN again in the future.
* The symbol `:panic', signalling that the backend has
encountered an exceptional situation and should be disabled.
In the latter cases, it is also possible to provide REPORT-FN
with a string as the keyword argument `:explanation'. The string
should give human-readable details of the situation.")
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(defvar flymake-diagnostic-types-alist
`((:error
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
. ((flymake-category . flymake-error)))
(:warning
. ((flymake-category . flymake-warning)))
(:note
. ((flymake-category . flymake-note))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
"Alist ((KEY . PROPS)*) of properties of flymake error types.
KEY can be anything passed as `:type' to `flymake-diag-make'.
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
PROPS is an alist of properties that are applied, in order, to
the diagnostics of each type. The recognized properties are:
* Every property pertaining to overlays, except `category' and
`evaporate' (see Info Node `(elisp)Overlay Properties'), used
affect the appearance of Flymake annotations.
* `bitmap', an image displayed in the fringe according to
`flymake-fringe-indicator-position'. The value actually
follows the syntax of `flymake-error-bitmap' (which see). It
is overriden by any `before-string' overlay property.
* `severity', a non-negative integer specifying the diagnostic's
severity. The higher, the more serious. If the overlay
priority `priority' is not specified, `severity' is used to set
it and help sort overlapping overlays.
* `flymake-category', a symbol whose property list is considered
as a default for missing values of any other properties. This
is useful to backend authors when creating new diagnostic types
that differ from an existing type by only a few properties.")
(put 'flymake-error 'face 'flymake-error)
(put 'flymake-error 'bitmap 'flymake-error-bitmap)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(put 'flymake-error 'severity (warning-numeric-level :error))
(put 'flymake-error 'mode-line-face 'compilation-error)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(put 'flymake-warning 'face 'flymake-warning)
(put 'flymake-warning 'bitmap 'flymake-warning-bitmap)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(put 'flymake-warning 'severity (warning-numeric-level :warning))
(put 'flymake-warning 'mode-line-face 'compilation-warning)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(put 'flymake-note 'face 'flymake-note)
(put 'flymake-note 'bitmap 'flymake-note-bitmap)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(put 'flymake-note 'severity (warning-numeric-level :debug))
(put 'flymake-note 'mode-line-face 'compilation-info)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(defun flymake--lookup-type-property (type prop &optional default)
"Look up PROP for TYPE in `flymake-diagnostic-types-alist'.
If TYPE doesn't declare PROP in either
`flymake-diagnostic-types-alist' or in the symbol of its
associated `flymake-category' return DEFAULT."
(let ((alist-probe (assoc type flymake-diagnostic-types-alist)))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(cond (alist-probe
(let* ((alist (cdr alist-probe))
(prop-probe (assoc prop alist)))
(if prop-probe
(cdr prop-probe)
(if-let* ((cat (assoc-default 'flymake-category alist))
(plist (and (symbolp cat)
(symbol-plist cat)))
(cat-probe (plist-member plist prop)))
(cadr cat-probe)
default))))
(t
default))))
(defun flymake--fringe-overlay-spec (bitmap &optional recursed)
(if (and (symbolp bitmap)
(boundp bitmap)
(not recursed))
(flymake--fringe-overlay-spec
(symbol-value bitmap) t)
(and flymake-fringe-indicator-position
bitmap
(propertize "!" 'display
(cons flymake-fringe-indicator-position
(if (listp bitmap)
bitmap
(list bitmap)))))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
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'.
2017-09-06 16:03:24 +01:00
(defun flymake--highlight-line (diagnostic)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
"Highlight buffer with info in DIAGNOSTIC."
(when-let* ((ov (make-overlay
(flymake--diag-beg diagnostic)
(flymake--diag-end diagnostic))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
;; First set `category' in the overlay, then copy over every other
;; property.
;;
(let ((alist (assoc-default (flymake--diag-type diagnostic)
flymake-diagnostic-types-alist)))
(overlay-put ov 'category (assoc-default 'flymake-category alist))
(cl-loop for (k . v) in alist
unless (eq k 'category)
do (overlay-put ov k v)))
;; Now ensure some essential defaults are set
;;
(cl-flet ((default-maybe
(prop value)
(unless (or (plist-member (overlay-properties ov) prop)
(let ((cat (overlay-get ov
'flymake-category)))
(and cat
(plist-member (symbol-plist cat) prop))))
(overlay-put ov prop value))))
(default-maybe 'bitmap 'flymake-error-bitmap)
(default-maybe 'face 'flymake-error)
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
(default-maybe 'before-string
(flymake--fringe-overlay-spec
(overlay-get ov 'bitmap)))
(default-maybe 'help-echo
(lambda (_window _ov pos)
(mapconcat
(lambda (ov)
(let ((diag (overlay-get ov 'flymake--diagnostic)))
(flymake--diag-text diag)))
(flymake--overlays :beg pos)
"\n")))
(default-maybe 'severity (warning-numeric-level :error))
(default-maybe 'priority (+ 100 (overlay-get ov 'severity))))
;; Some properties can't be overriden
;;
(overlay-put ov 'evaporate t)
(overlay-put ov 'flymake-overlay t)
(overlay-put ov 'flymake--diagnostic diagnostic)))
(defun flymake-on-timer-event (buffer)
"Start a syntax check for buffer BUFFER if necessary."
(when (buffer-live-p buffer)
(with-current-buffer buffer
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(when (and (not (flymake-is-running))
flymake-last-change-time
(> (- (float-time) flymake-last-change-time)
flymake-no-changes-timeout))
(setq flymake-last-change-time nil)
(flymake-log :debug "starting syntax check after no changes for some time")
(flymake-start)))))
;; Nothing in flymake uses this at all any more, so this is just for
;; third-party compatibility.
(define-obsolete-function-alias 'flymake-display-warning 'message-box "26.1")
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(defvar-local flymake--running-backends nil
"List of currently active flymake backends.
An active backend is a member of `flymake-diagnostic-functions'
that has been invoked but hasn't reported any final status yet.")
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(defvar-local flymake--disabled-backends nil
"List of currently disabled flymake backends.
A backend is disabled if it reported `:panic'.")
(defvar-local flymake--diagnostics-table nil
"Hash table of all diagnostics indexed by backend.")
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(defun flymake-is-running ()
"Tell if flymake has running backends in this buffer"
flymake--running-backends)
(defun flymake--disable-backend (backend action &optional explanation)
(cl-pushnew backend flymake--disabled-backends)
(flymake-log :warning "Disabled the backend %s due to reports of %s (%s)"
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
backend action explanation))
(cl-defun flymake--handle-report (backend action &key explanation force)
"Handle reports from flymake backend identified by BACKEND.
BACKEND, ACTION and EXPLANATION conform to the calling convention
described in `flymake-diagnostic-functions' (which see). Optional
FORCE says to handle a report even if it was not expected."
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(cond
((and (not (memq backend flymake--running-backends))
(not force))
(flymake-error "Ignoring unexpected report from backend %s" backend))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
((eq action :progress)
(flymake-log 3 "Backend %s reports progress: %s" backend explanation))
((eq :panic action)
(flymake--disable-backend backend action explanation))
((listp action)
(let ((diagnostics action))
(save-restriction
(widen)
(flymake-delete-own-overlays
(lambda (ov)
(eq backend
(flymake--diag-backend
(overlay-get ov 'flymake--diagnostic)))))
(puthash backend diagnostics flymake--diagnostics-table)
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(mapc (lambda (diag)
(flymake--highlight-line diag)
(setf (flymake--diag-backend diag) backend))
diagnostics)
(when flymake-check-start-time
(flymake-log 2 "backend %s reported %d diagnostics in %.2f second(s)"
backend
(length diagnostics)
(- (float-time) flymake-check-start-time))))))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(t
(flymake--disable-backend "?"
:strange
(format "unknown action %s (%s)"
action explanation))))
(unless (eq action :progress)
(flymake--stop-backend backend)))
(defun flymake-make-report-fn (backend)
"Make a suitable anonymous report function for BACKEND.
BACKEND is used to help flymake distinguish diagnostic
sources."
(lambda (&rest args)
(apply #'flymake--handle-report backend args)))
(defun flymake--stop-backend (backend)
"Stop the backend BACKEND."
(setq flymake--running-backends (delq backend flymake--running-backends)))
(defun flymake--run-backend (backend)
"Run the backend BACKEND."
(push backend flymake--running-backends)
(remhash backend flymake--diagnostics-table)
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
;; FIXME: Should use `condition-case-unless-debug'
;; here, but that won't let me catch errors during
;; testing where `debug-on-error' is always t
(condition-case err
(unless (funcall backend
(flymake-make-report-fn backend))
(flymake--stop-backend backend))
(error
(flymake--disable-backend backend :error
err)
(flymake--stop-backend backend))))
(defun flymake-start (&optional deferred interactive)
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
"Start a syntax check.
Start it immediately, or after current command if DEFERRED is
non-nil. With optional INTERACTIVE or interactively, clear any
stale information about running and automatically disabled
backends."
(interactive (list nil t))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(cl-labels
((start
()
(remove-hook 'post-command-hook #'start 'local)
(setq flymake-check-start-time (float-time))
(when interactive
(setq flymake--diagnostics-table (make-hash-table)
flymake--running-backends nil
flymake--disabled-backends nil))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(dolist (backend flymake-diagnostic-functions)
(cond ((memq backend flymake--running-backends)
(flymake-log :debug "Backend %s still running, not restarting"
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
backend))
((memq backend flymake--disabled-backends)
(flymake-log :debug "Backend %s is disabled, not starting"
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
backend))
(t
(flymake--run-backend backend))))))
(if (and deferred
this-command)
(add-hook 'post-command-hook #'start 'append 'local)
(start))))
;;;###autoload
(define-minor-mode flymake-mode nil
:group 'flymake :lighter flymake--mode-line-format
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(setq flymake--running-backends nil
flymake--disabled-backends nil)
(cond
;; Turning the mode ON.
(flymake-mode
(cond
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
((not flymake-diagnostic-functions)
(flymake-error "No backends to check buffer %s" (buffer-name)))
(t
(add-hook 'after-change-functions 'flymake-after-change-function nil t)
(add-hook 'after-save-hook 'flymake-after-save-hook nil t)
(add-hook 'kill-buffer-hook 'flymake-kill-buffer-hook nil t)
(setq flymake-timer
(run-at-time nil 1 'flymake-on-timer-event (current-buffer)))
(setq flymake--diagnostics-table (make-hash-table))
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(when flymake-start-syntax-check-on-find-file
(flymake-start)))))
;; Turning the mode OFF.
(t
(remove-hook 'after-change-functions 'flymake-after-change-function t)
(remove-hook 'after-save-hook 'flymake-after-save-hook t)
(remove-hook 'kill-buffer-hook 'flymake-kill-buffer-hook t)
;;+(remove-hook 'find-file-hook (function flymake-find-file-hook) t)
(flymake-delete-own-overlays)
(when flymake-timer
(cancel-timer flymake-timer)
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(setq flymake-timer nil)))))
;;;###autoload
(defun flymake-mode-on ()
"Turn flymake mode on."
(flymake-mode 1))
;;;###autoload
(defun flymake-mode-off ()
"Turn flymake mode off."
(flymake-mode 0))
(defun flymake-after-change-function (start stop _len)
"Start syntax check for current buffer if it isn't already running."
(let((new-text (buffer-substring start stop)))
(when (and flymake-start-syntax-check-on-newline (equal new-text "\n"))
(flymake-log :debug "starting syntax check as new-line has been seen")
(flymake-start 'deferred))
(setq flymake-last-change-time (float-time))))
(defun flymake-after-save-hook ()
(when flymake-mode
(flymake-log :debug "starting syntax check as buffer was saved")
(flymake-start)))
(defun flymake-kill-buffer-hook ()
(when flymake-timer
(cancel-timer flymake-timer)
(setq flymake-timer nil)))
;;;###autoload
(defun flymake-find-file-hook ()
New Flymake API variable flymake-diagnostic-functions Lay groundwork for multiple active backends in the same buffer. Backends are lisp functions called when flymake-mode sees fit. They are responsible for examining the current buffer and telling flymake.el, via return value, if they can syntax check it. Backends should return quickly and inexpensively, but they are also passed a REPORT-FN argument which they may or may not call asynchronously after performing more expensive work. REPORT-FN's calling convention stipulates that a backend calls it with a list of diagnostics as argument, or, alternatively, with a symbol denoting an exceptional situation, usually some panic resulting from a misconfigured backend. In keeping with legacy behaviour, flymake.el's response to a panic is to disable the issuing backend. The flymake--diag object representing a diagnostic now also keeps information about its source backend. Among other uses, this allows flymake to selectively cleanup overlays based on which backend is updating its diagnostics. * lisp/progmodes/flymake-proc.el (flymake-proc--report-fn): New dynamic variable. (flymake-proc--process): New variable. (flymake-can-syntax-check-buffer): Remove. (flymake-proc--process-sentinel): Simplify. Use unwind-protect. Affect flymake-proc--processes here. Bind flymake-proc--report-fn. (flymake-proc--process-filter): Bind flymake-proc--report-fn. (flymake-proc--post-syntax-check): Delete (flymake-proc-start-syntax-check): Take mandatory report-fn. Rewrite. Bind flymake-proc--report-fn. (flymake-proc--process-sentinel): Rewrite and simplify. (flymake-proc--panic): New helper. (flymake-proc--start-syntax-check-process): Record report-fn in process. Use flymake-proc--panic. (flymake-proc-stop-all-syntax-checks): Use mapc. Don't affect flymake-proc--processes here. Record interruption reason. (flymake-proc--init-find-buildfile-dir) (flymake-proc--init-create-temp-source-and-master-buffer-copy): Use flymake-proc--panic. (flymake-diagnostic-functions): Add flymake-proc-start-syntax-check. (flymake-proc-compile): Call flymake-proc-stop-all-syntax-checks with a reason. * lisp/progmodes/flymake.el (flymake-backends): Delete. (flymake-check-was-interrupted): Delete. (flymake--diag): Add backend slot. (flymake-delete-own-overlays): Take optional filter arg. (flymake-diagnostic-functions): New user-visible variable. (flymake--running-backends, flymake--disabled-backends): New buffer-local variables. (flymake-is-running): Now a function, not a variable. (flymake-mode-line, flymake-mode-line-e-w) (flymake-mode-line-status): Delete. (flymake-lighter): flymake's minor-mode "lighter". (flymake-report): Delete. (flymake--backend): Delete. (flymake--can-syntax-check-buffer): Delete. (flymake--handle-report, flymake--disable-backend) (flymake--run-backend, flymake--run-backend): New helpers. (flymake-make-report-fn): Make a lambda. (flymake--start-syntax-check): Iterate flymake-diagnostic-functions. (flymake-mode): Use flymake-lighter. Simplify. Initialize flymake--running-backends and flymake--disabled-backends. (flymake-find-file-hook): Simplify. * test/lisp/progmodes/flymake-tests.el (flymake-tests--call-with-fixture): Use flymake-is-running the function. Check if flymake-mode already active before activating it. Add a thorough test for flymake multiple backends * lisp/progmodes/flymake.el (flymake--start-syntax-check): Don't use condition-case-unless-debug, use condition-case * test/lisp/progmodes/flymake-tests.el (flymake-tests--assert-set): New helper macro. (dummy-backends): New test.
2017-09-26 00:45:46 +01:00
(unless (or flymake-mode
(null flymake-diagnostic-functions))
(flymake-mode)
(flymake-log :warning "Turned on in `flymake-find-file-hook'")))
(defun flymake-goto-next-error (&optional n filter interactive)
"Go to Nth next flymake error in buffer matching FILTER.
FILTER is a list of diagnostic types found in
`flymake-diagnostic-types-alist', or nil, if no filter is to be
applied.
Interactively, always goes to the next error. Also
interactively, FILTER is determined by the prefix arg. With no
prefix arg, don't use a filter, otherwise only consider
diagnostics of type `:error' and `:warning'."
(interactive (list 1
(if current-prefix-arg
'(:error :warning))
t))
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'.
2017-09-06 16:03:24 +01:00
(let* ((n (or n 1))
(ovs (flymake--overlays :filter
(lambda (ov)
(let ((diag (overlay-get
ov
'flymake--diagnostic)))
(and diag
(or (not filter)
(memq (flymake--diag-type diag)
filter)))))
New Flymake variable flymake-diagnostic-types-alist and much cleanup A new user-visible variable is introduced where different diagnostic types can be categorized. Flymake backends can also contribute to this variable. Anything that doesn’t match an existing error type is considered. The variable’s alists are used to propertize the overlays pertaining to each error type. The user can override the built-in properties by either by modifying the alist, or by modifying the properties of a special "category" symbol, named by the `flymake-category' entry in the alist. The `flymake-category' entry is especially useful for, say, the author of foo-flymake-backend, who issues diagnostics of type :foo-note, that should behave like notes, except with no fringe bitmap: (add-to-list 'flymake-diagnostic-types-alist '(:foo-note . ((flymake-category . flymake-note) (bitmap . nil)))) For essential properties like `severity', `priority', etc, a default value is produced. Some properties like `evaporate' cannot be overriden. * lisp/progmodes/flymake.el (flymake--diag): Rename from flymake-ler. (flymake-ler-make): Obsolete alias for flymake-diagnostic-make (flymake-ler-errorp): Rewrite using flymake--severity. (flymake--place-overlay): Delete. (flymake--overlays): Now a cl-defun with &key args. Document. Use `overlays-at' if BEG is non-nil and END is nil. (flymake--lookup-type-property): New helper. (flymake--highlight-line): Rewrite. (flymake-diagnostic-types-alist): New API variable. (flymake--diag-region) (flymake--severity, flymake--face) (flymake--fringe-overlay-spec): New helper. (flymake-popup-current-error-menu): Use new flymake-overlays. (flymake-popup-current-error-menu, flymake-report): Use flymake--diag-errorp. (flymake--fix-line-numbers): Use flymake--diag-line. (flymake-goto-next-error): Pass :key to flymake-overlays * lisp/progmodes/flymake-proc.el (flymake-proc--diagnostics-for-pattern): Use flymake-diagnostic-make.
2017-09-07 15:13:39 +01:00
:compare (if (cl-plusp n) #'< #'>)
:key #'overlay-start))
(tail (cl-member-if (lambda (ov)
(if (cl-plusp n)
(> (overlay-start ov)
(point))
(< (overlay-start ov)
(point))))
ovs))
(chain (if flymake-wrap-around
(if tail
(progn (setcdr (last tail) ovs) tail)
(and ovs (setcdr (last ovs) ovs)))
tail))
(target (nth (1- n) chain)))
(cond (target
(goto-char (overlay-start target))
(when interactive
(message
(funcall (overlay-get target 'help-echo)
nil nil (point)))))
(interactive
(user-error "No more flymake errors%s"
(if filter
(format " of types %s" filter)
""))))))
(defun flymake-goto-prev-error (&optional n filter interactive)
"Go to Nth previous flymake error in buffer matching FILTER.
FILTER is a list of diagnostic types found in
`flymake-diagnostic-types-alist', or nil, if no filter is to be
applied.
Interactively, always goes to the previous error. Also
interactively, FILTER is determined by the prefix arg. With no
prefix arg, don't use a filter, otherwise only consider
diagnostics of type `:error' and `:warning'."
(interactive (list 1 (if current-prefix-arg
'(:error :warning))
t))
(flymake-goto-next-error (- (or n 1)) filter interactive))
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'.
2017-09-06 16:03:24 +01:00
;;; Mode-line fanciness
;;;
(defvar flymake--mode-line-format `(:eval (flymake--mode-line-format)))
(put 'flymake--mode-line-format 'risky-local-variable t)
(defun flymake--mode-line-format ()
"Produce a pretty minor mode indicator."
(let ((running flymake--running-backends)
(reported (hash-table-keys flymake--diagnostics-table)))
`((:propertize " Flymake"
mouse-face mode-line-highlight
,@(when (not reported)
`(face compilation-mode-line-fail))
help-echo
,(concat (format "%s registered backends\n"
(length flymake-diagnostic-functions))
(format "%s running\n"
(length running))
(format "%s disabled\n"
(length flymake--disabled-backends))
"mouse-1: go to log buffer ")
keymap
,(let ((map (make-sparse-keymap)))
(define-key map [mode-line mouse-1]
(lambda (_event)
(interactive "e")
(switch-to-buffer "*Flymake log*")))
map))
,@(when running
`(":" (:propertize "Run"
face compilation-mode-line-run
help-echo
,(format "%s running backends"
(length running)))))
,@(when reported
(let ((by-type (make-hash-table)))
(maphash (lambda (_backend diags)
(mapc (lambda (diag)
(push diag
(gethash (flymake--diag-type diag)
by-type)))
diags))
flymake--diagnostics-table)
(cl-loop
for (type . severity)
in (cl-sort (mapcar (lambda (type)
(cons type (flymake--lookup-type-property
type
'severity
(warning-numeric-level :error))))
(cl-union (hash-table-keys by-type)
'(:error :warning)))
#'>
:key #'cdr)
for diags = (gethash type by-type)
for face = (flymake--lookup-type-property type
'mode-line-face
'compilation-error)
when (or diags
(>= severity (warning-numeric-level :warning)))
collect `(:propertize
,(format "%d" (length diags))
face ,face
mouse-face mode-line-highlight
keymap
,(let ((map (make-sparse-keymap))
(type type))
(define-key map [mode-line mouse-4]
(lambda (_event)
(interactive "e")
(flymake-goto-prev-error 1 (list type) t)))
(define-key map [mode-line mouse-5]
(lambda (_event)
(interactive "e")
(flymake-goto-next-error 1 (list type) t)))
map)
help-echo
,(concat (format "%s diagnostics of type %s\n"
(propertize (format "%d"
(length diags))
'face face)
(propertize (format "%s" type)
'face face))
"mouse-4/mouse-5: previous/next of this type\n"))
into forms
finally return
`((:propertize "[")
,@(cl-loop for (a . rest) on forms by #'cdr
collect a when rest collect
'(:propertize " "))
(:propertize "]"))))))))
(provide 'flymake)
(require 'flymake-proc)
(require 'flymake-elisp)
2004-05-29 12:55:24 +00:00
;;; flymake.el ends here