2017-08-17 15:38:12 +01:00
|
|
|
|
;;; flymake.el --- A universal on-the-fly syntax checker -*- lexical-binding: t; -*-
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
2017-01-01 03:14:01 +00:00
|
|
|
|
;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
2006-11-25 13:29:40 +00:00
|
|
|
|
;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
|
Clean up flymake.el
* lisp/progmodes/flymake.el (flymake, flymake-error-bitmap)
(flymake-warning-bitmap, flymake-fringe-indicator-position)
(flymake-compilation-prevents-syntax-check)
(flymake-start-syntax-check-on-newline)
(flymake-no-changes-timeout, flymake-gui-warnings-enabled)
(flymake-start-syntax-check-on-find-file, flymake-log-level)
(flymake-xml-program, flymake-master-file-dirs)
(flymake-master-file-count-limit)
(flymake-allowed-file-name-masks): Relocate.
(flymake-makehash, flymake-float-time)
(flymake-replace-regexp-in-string, flymake-split-string)
(flymake-get-temp-dir): Remove.
(flymake-popup-menu, flymake-nop, flymake-make-xemacs-menu)
(flymake-current-row, flymake-selected-frame)
(flymake-get-point-pixel-pos): Remove xemacs compatibity and
related functions.
Fixes: debbugs:16077
2013-12-08 11:35:32 +08:00
|
|
|
|
;; 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.
|
|
|
|
|
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; 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
|
2008-05-06 07:25:26 +00:00
|
|
|
|
;; 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
|
2017-08-17 15:38:12 +01:00
|
|
|
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
2004-05-29 12:55:24 +00:00
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
;;
|
2017-08-17 15:38:12 +01:00
|
|
|
|
;; Flymake is a minor Emacs mode performing on-the-fly syntax checks.
|
|
|
|
|
;;
|
2017-10-01 01:24:31 +01:00
|
|
|
|
;; Flymake collects diagnostic information for multiple sources,
|
|
|
|
|
;; called backends, and visually annotates the relevant portions in
|
|
|
|
|
;; the buffer.
|
|
|
|
|
;;
|
2017-08-17 15:38:12 +01:00
|
|
|
|
;; This file contains the UI for displaying and interacting with the
|
2017-10-01 01:24:31 +01:00
|
|
|
|
;; results produced by these backends, as well as entry points for
|
|
|
|
|
;; backends to hook on to.
|
|
|
|
|
;;
|
|
|
|
|
;; The main entry points are `flymake-mode' and `flymake-start'
|
|
|
|
|
;;
|
2017-10-03 16:04:30 -07:00
|
|
|
|
;; The docstrings of these variables are relevant to understanding how
|
2017-10-01 01:24:31 +01:00
|
|
|
|
;; Flymake works for both the user and the backend programmer:
|
|
|
|
|
;;
|
|
|
|
|
;; * `flymake-diagnostic-functions'
|
|
|
|
|
;; * `flymake-diagnostic-types-alist'
|
2017-08-17 15:38:12 +01:00
|
|
|
|
;;
|
2004-05-29 12:55:24 +00:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2017-08-23 02:23:41 +01:00
|
|
|
|
(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
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(require 'warnings) ; warning-numeric-level, display-warning
|
2017-09-27 02:31:58 +01:00
|
|
|
|
(require 'compile) ; for some faces
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(require 'subr-x) ; when-let*, if-let*, hash-table-keys, hash-table-values
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
|
|
|
|
(defgroup flymake nil
|
|
|
|
|
"Universal on-the-fly syntax checker."
|
|
|
|
|
:version "23.1"
|
|
|
|
|
:link '(custom-manual "(flymake) Top")
|
|
|
|
|
:group 'tools)
|
|
|
|
|
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(defcustom flymake-error-bitmap '(flymake-double-exclamation-mark
|
|
|
|
|
compilation-error)
|
2017-09-27 22:35:49 +01:00
|
|
|
|
"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."
|
|
|
|
|
:version "24.3"
|
|
|
|
|
:type '(choice (symbol :tag "Bitmap")
|
|
|
|
|
(list :tag "Bitmap and face"
|
|
|
|
|
(symbol :tag "Bitmap")
|
|
|
|
|
(face :tag "Face"))))
|
|
|
|
|
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(defcustom flymake-warning-bitmap '(exclamation-mark compilation-warning)
|
2017-09-27 22:35:49 +01:00
|
|
|
|
"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."
|
|
|
|
|
:version "24.3"
|
|
|
|
|
:type '(choice (symbol :tag "Bitmap")
|
|
|
|
|
(list :tag "Bitmap and face"
|
|
|
|
|
(symbol :tag "Bitmap")
|
|
|
|
|
(face :tag "Face"))))
|
|
|
|
|
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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."
|
|
|
|
|
:version "26.1"
|
|
|
|
|
:type '(choice (symbol :tag "Bitmap")
|
|
|
|
|
(list :tag "Bitmap and face"
|
|
|
|
|
(symbol :tag "Bitmap")
|
|
|
|
|
(face :tag "Face"))))
|
|
|
|
|
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(defcustom flymake-fringe-indicator-position 'left-fringe
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"The position to put Flymake fringe indicator.
|
2017-09-27 22:35:49 +01:00
|
|
|
|
The value can be nil (do not use indicators), `left-fringe' or `right-fringe'.
|
|
|
|
|
See `flymake-error-bitmap' and `flymake-warning-bitmap'."
|
|
|
|
|
: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."
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom flymake-no-changes-timeout 0.5
|
2017-09-30 10:45:48 +01:00
|
|
|
|
"Time to wait after last change before automatically checking buffer.
|
|
|
|
|
If nil, never start checking buffer automatically like this."
|
2017-09-27 22:35:49 +01:00
|
|
|
|
:type 'number)
|
|
|
|
|
|
|
|
|
|
(defcustom flymake-gui-warnings-enabled t
|
|
|
|
|
"Enables/disables GUI warnings."
|
|
|
|
|
: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."
|
|
|
|
|
:type 'boolean)
|
|
|
|
|
|
|
|
|
|
(defcustom flymake-log-level -1
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
"Obsolete and ignored variable."
|
2017-09-27 22:35:49 +01:00
|
|
|
|
:type 'integer)
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(make-obsolete-variable 'flymake-log-level
|
|
|
|
|
"it is superseded by `warning-minimum-log-level.'"
|
|
|
|
|
"26.1")
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(defcustom flymake-wrap-around t
|
|
|
|
|
"If non-nil, moving to errors wraps around buffer boundaries."
|
2017-09-29 11:02:36 +01:00
|
|
|
|
:type 'boolean)
|
2017-09-27 12:42:20 +01:00
|
|
|
|
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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))
|
|
|
|
|
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(defvar-local flymake-timer nil
|
|
|
|
|
"Timer for starting syntax check.")
|
|
|
|
|
|
|
|
|
|
(defvar-local flymake-check-start-time nil
|
|
|
|
|
"Time at which syntax check was started.")
|
|
|
|
|
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(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*")))
|
|
|
|
|
|
2017-10-05 02:42:01 +01:00
|
|
|
|
(defun flymake-switch-to-log-buffer ()
|
|
|
|
|
"Go to the *Flymake log* buffer."
|
|
|
|
|
(interactive)
|
|
|
|
|
(switch-to-buffer "*Flymake log*"))
|
|
|
|
|
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
;;;###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))))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
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
|
2017-09-23 18:15:40 +01:00
|
|
|
|
(: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)
|
2017-09-23 18:15:40 +01:00
|
|
|
|
|
2017-10-01 01:24:31 +01:00
|
|
|
|
;;;###autoload
|
2017-09-23 18:15:40 +01:00
|
|
|
|
(defun flymake-make-diagnostic (buffer
|
|
|
|
|
beg
|
|
|
|
|
end
|
|
|
|
|
type
|
|
|
|
|
text)
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Make a Flymake diagnostic for BUFFER's region from BEG to END.
|
2017-09-23 18:15:40 +01:00
|
|
|
|
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))
|
|
|
|
|
|
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
|
2017-09-29 11:02:36 +01:00
|
|
|
|
verify FILTER, a function, and sort them by COMPARE (using KEY)."
|
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
(let ((ovs (cl-remove-if-not
|
|
|
|
|
(lambda (ov)
|
|
|
|
|
(and (overlay-get ov 'flymake)
|
|
|
|
|
(or (not filter)
|
|
|
|
|
(funcall filter ov))))
|
|
|
|
|
(if (and beg (null 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
|
|
|
|
(overlays-at beg t)
|
|
|
|
|
(overlays-in (or beg (point-min))
|
2017-09-29 11:02:36 +01:00
|
|
|
|
(or end (point-max)))))))
|
|
|
|
|
(if compare
|
|
|
|
|
(cl-sort ovs compare :key (or key
|
|
|
|
|
#'identity))
|
|
|
|
|
ovs))))
|
2017-09-27 22:35:49 +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
|
|
|
|
(defun flymake-delete-own-overlays (&optional filter)
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"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
|
2017-09-27 22:35:49 +01:00
|
|
|
|
'((((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."
|
2017-09-29 11:02:36 +01:00
|
|
|
|
:version "24.4")
|
2017-09-27 22:35:49 +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
|
|
|
|
(defface flymake-warning
|
2017-09-27 22:35:49 +01:00
|
|
|
|
'((((supports :underline (:style wave)))
|
2017-09-20 19:09:10 +01:00
|
|
|
|
:underline (:style wave :color "deep sky blue"))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(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."
|
2017-09-29 11:02:36 +01:00
|
|
|
|
:version "24.4")
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
2017-09-21 14:44:13 +01:00
|
|
|
|
(defface flymake-note
|
|
|
|
|
'((((supports :underline (:style wave)))
|
|
|
|
|
:underline (:style wave :color "yellow green"))
|
|
|
|
|
(t
|
|
|
|
|
:inherit warning))
|
|
|
|
|
"Face used for marking note regions."
|
2017-09-29 11:02:36 +01:00
|
|
|
|
:version "26.1")
|
2017-09-21 14:44:13 +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
|
|
|
|
(define-obsolete-face-alias 'flymake-warnline 'flymake-warning "26.1")
|
|
|
|
|
(define-obsolete-face-alias 'flymake-errline 'flymake-error "26.1")
|
|
|
|
|
|
2017-10-05 02:42:01 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun flymake-diag-region (buffer line &optional col)
|
|
|
|
|
"Compute BUFFER's region (BEG . END) corresponding to LINE and COL.
|
|
|
|
|
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
|
2017-10-05 02:42:01 +01:00
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(let ((line (min (max line 1)
|
|
|
|
|
(line-number-at-pos (point-max) 'absolute))))
|
|
|
|
|
(save-excursion
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line (1- line))
|
|
|
|
|
(cl-flet ((fallback-bol
|
|
|
|
|
() (progn (back-to-indentation) (point)))
|
|
|
|
|
(fallback-eol
|
|
|
|
|
(beg)
|
|
|
|
|
(progn
|
|
|
|
|
(end-of-line)
|
|
|
|
|
(skip-chars-backward " \t\f\t\n" beg)
|
|
|
|
|
(if (eq (point) beg)
|
|
|
|
|
(line-beginning-position 2)
|
|
|
|
|
(point)))))
|
|
|
|
|
(if (and col (cl-plusp col))
|
|
|
|
|
(let* ((beg (progn (forward-char (1- col))
|
|
|
|
|
(point)))
|
|
|
|
|
(sexp-end (ignore-errors (end-of-thing 'sexp)))
|
|
|
|
|
(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))
|
|
|
|
|
(let* ((beg (fallback-bol))
|
|
|
|
|
(end (fallback-eol beg)))
|
|
|
|
|
(cons beg end)))))))
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(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
|
2017-10-02 13:28:18 +01:00
|
|
|
|
"Special hook of Flymake backends that check a 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
|
|
|
|
|
2017-09-29 12:18:30 +01:00
|
|
|
|
The functions in this hook diagnose problems in a buffer’s
|
2017-10-02 13:28:18 +01:00
|
|
|
|
contents and provide information to the Flymake user interface
|
2017-09-29 12:18:30 +01:00
|
|
|
|
about where and how to annotate problems diagnosed in a 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
|
|
|
|
|
2017-09-29 12:18:30 +01:00
|
|
|
|
Whenever Flymake or the user decides to re-check the buffer, each
|
2017-10-02 13:28:18 +01:00
|
|
|
|
function is called with an arbitrary number of arguments:
|
|
|
|
|
|
|
|
|
|
* the first argument is always REPORT-FN, a callback function
|
|
|
|
|
detailed below;
|
|
|
|
|
|
|
|
|
|
* the remaining arguments are keyword-value pairs in the
|
|
|
|
|
form (:KEY VALUE :KEY2 VALUE2...). Currently, Flymake provides
|
|
|
|
|
no such arguments, but backend functions must be prepared to
|
|
|
|
|
accept to accept and possibly ignore any number of them.
|
|
|
|
|
|
|
|
|
|
Backend functions are expected to initiate the buffer check, but
|
|
|
|
|
aren't required to complete it check before exiting: if the
|
|
|
|
|
computation involved is expensive, especially for large buffers,
|
|
|
|
|
that task can be scheduled for the future using asynchronous
|
|
|
|
|
processes or other asynchronous mechanisms.
|
2017-09-30 17:32:53 +01:00
|
|
|
|
|
|
|
|
|
In any case, backend functions are expected to return quickly or
|
|
|
|
|
signal an error, in which case the backend is disabled. Flymake
|
|
|
|
|
will not try disabled backends again for any future checks of
|
|
|
|
|
this buffer. Certain commands, like turning `flymake-mode' off
|
|
|
|
|
and on again, reset the list of disabled backends.
|
|
|
|
|
|
|
|
|
|
If the function returns, Flymake considers the backend to be
|
|
|
|
|
\"running\". If it has not done so already, the backend is
|
|
|
|
|
expected to call the function REPORT-FN with a single argument
|
2017-10-02 13:28:18 +01:00
|
|
|
|
REPORT-ACTION also followed by an optional list of keyword-value
|
|
|
|
|
pairs in the form (:REPORT-KEY VALUE :REPORT-KEY2 VALUE2...).
|
2017-09-29 11:02:36 +01:00
|
|
|
|
|
2017-10-02 13:28:18 +01:00
|
|
|
|
Currently accepted values for REPORT-ACTION are:
|
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
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
* A (possibly empty) list of diagnostic objects created with
|
2017-09-29 12:18:30 +01:00
|
|
|
|
`flymake-make-diagnostic', causing Flymake to annotate the
|
2017-09-30 17:32:53 +01:00
|
|
|
|
buffer with this information.
|
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
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
A backend may call REPORT-FN repeatedly in this manner, but
|
|
|
|
|
only until Flymake considers that the most recently requested
|
|
|
|
|
buffer check is now obsolete because, say, buffer contents have
|
|
|
|
|
changed in the meantime. The backend is only given notice of
|
|
|
|
|
this via a renewed call to the backend function. Thus, to
|
|
|
|
|
prevent making obsolete reports and wasting resources, backend
|
|
|
|
|
functions should first cancel any ongoing processing from
|
|
|
|
|
previous calls.
|
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
|
|
|
|
|
2017-10-03 16:04:30 -07:00
|
|
|
|
* The symbol `:panic', signaling that the backend has encountered
|
|
|
|
|
an exceptional situation and should be disabled.
|
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
|
|
|
|
|
2017-10-02 13:28:18 +01:00
|
|
|
|
Currently accepted REPORT-KEY arguments are:
|
2017-09-29 11:02:36 +01:00
|
|
|
|
|
|
|
|
|
* ‘:explanation’: value should give user-readable details of
|
|
|
|
|
the situation encountered, if any.
|
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
* ‘:force’: value should be a boolean suggesting that the Flymake
|
|
|
|
|
considers the report even if was somehow unexpected.")
|
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
|
|
|
|
|
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
|
2017-09-21 14:44:13 +01:00
|
|
|
|
`((: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)))
|
2017-09-21 14:44:13 +01:00
|
|
|
|
(:warning
|
|
|
|
|
. ((flymake-category . flymake-warning)))
|
|
|
|
|
(:note
|
|
|
|
|
. ((flymake-category . flymake-note))))
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Alist ((KEY . PROPS)*) of properties of Flymake error types.
|
2017-09-21 14:44:13 +01:00
|
|
|
|
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
|
2017-10-03 16:04:30 -07:00
|
|
|
|
is overridden by any `before-string' overlay property.
|
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
|
|
|
|
|
|
|
|
|
* `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)
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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))
|
2017-09-27 02:31:58 +01:00
|
|
|
|
(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)
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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))
|
2017-09-27 02:31:58 +01:00
|
|
|
|
(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)
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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))
|
2017-09-27 02:31:58 +01:00
|
|
|
|
(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
|
2017-09-27 02:31:58 +01:00
|
|
|
|
`flymake-diagnostic-types-alist' or in the symbol of its
|
|
|
|
|
associated `flymake-category' return DEFAULT."
|
2017-09-21 14:44:13 +01:00
|
|
|
|
(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))))
|
|
|
|
|
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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."
|
2017-09-23 18:15:40 +01:00
|
|
|
|
(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))))
|
2017-09-28 14:17:27 +01:00
|
|
|
|
(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))))
|
2017-10-03 16:04:30 -07:00
|
|
|
|
;; Some properties can't be overridden.
|
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
|
|
|
|
;;
|
|
|
|
|
(overlay-put ov 'evaporate t)
|
2017-09-29 11:02:36 +01:00
|
|
|
|
(overlay-put ov 'flymake t)
|
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
|
|
|
|
(overlay-put ov 'flymake--diagnostic diagnostic)))
|
|
|
|
|
|
2017-09-30 18:04:45 +01:00
|
|
|
|
;; Nothing in Flymake uses this at all any more, so this is just for
|
2017-09-27 22:35:49 +01:00
|
|
|
|
;; third-party compatibility.
|
|
|
|
|
(define-obsolete-function-alias 'flymake-display-warning 'message-box "26.1")
|
|
|
|
|
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(defvar-local flymake--backend-state nil
|
|
|
|
|
"Buffer-local hash table of a Flymake backend's state.
|
|
|
|
|
The keys to this hash table are functions as found in
|
|
|
|
|
`flymake-diagnostic-functions'. The values are structures
|
|
|
|
|
of the type `flymake--backend-state', with these slots
|
|
|
|
|
|
|
|
|
|
`running', a symbol to keep track of a backend's replies via its
|
|
|
|
|
REPORT-FN argument. A backend is running if this key is
|
|
|
|
|
present. If the key is absent if the backend isn't expecting any
|
|
|
|
|
replies from the backend.
|
|
|
|
|
|
|
|
|
|
`diags', a (possibly empty) list of diagnostic objects created
|
|
|
|
|
with `flymake-make-diagnostic'. This key is absent if the
|
|
|
|
|
backend hasn't reported anything yet.
|
|
|
|
|
|
|
|
|
|
`reported-p', a boolean indicating if the backend has replied
|
|
|
|
|
since it last was contacted.
|
|
|
|
|
|
|
|
|
|
`disabled', a string with the explanation for a previous
|
|
|
|
|
exceptional situation reported by the backend. If this key is
|
|
|
|
|
present the backend is disabled.")
|
|
|
|
|
|
|
|
|
|
(cl-defstruct (flymake--backend-state
|
|
|
|
|
(:constructor flymake--make-backend-state))
|
|
|
|
|
running reported-p disabled diags)
|
|
|
|
|
|
|
|
|
|
(defmacro flymake--with-backend-state (backend state-var &rest body)
|
|
|
|
|
"Bind BACKEND's STATE-VAR to its state, run BODY."
|
|
|
|
|
(declare (indent 2) (debug (sexp sexp &rest form)))
|
|
|
|
|
(let ((b (make-symbol "b")))
|
|
|
|
|
`(let* ((,b ,backend)
|
|
|
|
|
(,state-var
|
|
|
|
|
(or (gethash ,b flymake--backend-state)
|
|
|
|
|
(puthash ,b (flymake--make-backend-state)
|
|
|
|
|
flymake--backend-state))))
|
|
|
|
|
,@body)))
|
2017-09-27 02:31:58 +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
|
|
|
|
(defun flymake-is-running ()
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Tell if Flymake has running backends in this buffer"
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake-running-backends))
|
|
|
|
|
|
2017-10-02 13:28:18 +01:00
|
|
|
|
(cl-defun flymake--handle-report (backend token report-action
|
|
|
|
|
&key explanation force
|
|
|
|
|
&allow-other-keys)
|
2017-09-30 17:32:53 +01:00
|
|
|
|
"Handle reports from BACKEND identified by TOKEN.
|
|
|
|
|
|
2017-10-02 13:28:18 +01:00
|
|
|
|
BACKEND, REPORT-ACTION and EXPLANATION, and FORCE conform to the calling
|
2017-09-30 17:32:53 +01:00
|
|
|
|
convention described in `flymake-diagnostic-functions' (which
|
|
|
|
|
see). Optional FORCE says to handle a report even if TOKEN was
|
|
|
|
|
not expected."
|
|
|
|
|
(let* ((state (gethash backend flymake--backend-state))
|
|
|
|
|
(first-report (not (flymake--backend-state-reported-p state))))
|
|
|
|
|
(setf (flymake--backend-state-reported-p state) t)
|
|
|
|
|
(let (expected-token
|
|
|
|
|
new-diags)
|
|
|
|
|
(cond
|
|
|
|
|
((null state)
|
|
|
|
|
(flymake-error
|
|
|
|
|
"Unexpected report from unknown backend %s" backend))
|
|
|
|
|
((flymake--backend-state-disabled state)
|
|
|
|
|
(flymake-error
|
|
|
|
|
"Unexpected report from disabled backend %s" backend))
|
|
|
|
|
((progn
|
|
|
|
|
(setq expected-token (flymake--backend-state-running state))
|
|
|
|
|
(null expected-token))
|
|
|
|
|
;; should never happen
|
|
|
|
|
(flymake-error "Unexpected report from stopped backend %s" backend))
|
|
|
|
|
((and (not (eq expected-token token))
|
|
|
|
|
(not force))
|
|
|
|
|
(flymake-error "Obsolete report from backend %s with explanation %s"
|
|
|
|
|
backend explanation))
|
2017-10-02 13:28:18 +01:00
|
|
|
|
((eq :panic report-action)
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake--disable-backend backend explanation))
|
2017-10-02 13:28:18 +01:00
|
|
|
|
((not (listp report-action))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(flymake--disable-backend backend
|
2017-10-02 13:28:18 +01:00
|
|
|
|
(format "Unknown action %S" report-action))
|
|
|
|
|
(flymake-error "Expected report, but got unknown key %s" report-action))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(t
|
2017-10-02 13:28:18 +01:00
|
|
|
|
(setq new-diags report-action)
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(save-restriction
|
|
|
|
|
(widen)
|
|
|
|
|
;; only delete overlays if this is the first report
|
|
|
|
|
(when first-report
|
|
|
|
|
(flymake-delete-own-overlays
|
|
|
|
|
(lambda (ov)
|
|
|
|
|
(eq backend
|
|
|
|
|
(flymake--diag-backend
|
|
|
|
|
(overlay-get ov 'flymake--diagnostic))))))
|
|
|
|
|
(mapc (lambda (diag)
|
|
|
|
|
(flymake--highlight-line diag)
|
|
|
|
|
(setf (flymake--diag-backend diag) backend))
|
|
|
|
|
new-diags)
|
|
|
|
|
(setf (flymake--backend-state-diags state)
|
|
|
|
|
(append new-diags (flymake--backend-state-diags state)))
|
|
|
|
|
(when flymake-check-start-time
|
|
|
|
|
(flymake-log :debug "backend %s reported %d diagnostics in %.2f second(s)"
|
|
|
|
|
backend
|
|
|
|
|
(length new-diags)
|
|
|
|
|
(- (float-time) flymake-check-start-time)))))))))
|
|
|
|
|
|
|
|
|
|
(defun flymake-make-report-fn (backend &optional token)
|
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
|
|
|
|
"Make a suitable anonymous report function for BACKEND.
|
2017-09-30 18:04:45 +01:00
|
|
|
|
BACKEND is used to help Flymake distinguish different diagnostic
|
|
|
|
|
sources. If provided, TOKEN helps Flymake distinguish between
|
2017-09-30 17:32:53 +01:00
|
|
|
|
different runs of the same backend."
|
|
|
|
|
(let ((buffer (current-buffer)))
|
|
|
|
|
(lambda (&rest args)
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(apply #'flymake--handle-report backend token args))))))
|
|
|
|
|
|
|
|
|
|
(defun flymake--collect (fn)
|
|
|
|
|
(let (retval)
|
|
|
|
|
(maphash (lambda (backend state)
|
|
|
|
|
(when (funcall fn state) (push backend retval)))
|
|
|
|
|
flymake--backend-state)
|
|
|
|
|
retval))
|
|
|
|
|
|
|
|
|
|
(defun flymake-running-backends ()
|
|
|
|
|
"Compute running Flymake backends in current buffer."
|
|
|
|
|
(flymake--collect #'flymake--backend-state-running))
|
|
|
|
|
|
|
|
|
|
(defun flymake-disabled-backends ()
|
|
|
|
|
"Compute disabled Flymake backends in current buffer."
|
|
|
|
|
(flymake--collect #'flymake--backend-state-disabled))
|
|
|
|
|
|
|
|
|
|
(defun flymake-reporting-backends ()
|
|
|
|
|
"Compute reporting Flymake backends in current buffer."
|
|
|
|
|
(flymake--collect #'flymake--backend-state-reported-p))
|
|
|
|
|
|
|
|
|
|
(defun flymake--disable-backend (backend &optional explanation)
|
|
|
|
|
"Disable BACKEND because EXPLANATION.
|
|
|
|
|
If is is running also stop it."
|
|
|
|
|
(flymake-log :warning "Disabling backend %s because %s" backend explanation)
|
|
|
|
|
(flymake--with-backend-state backend state
|
|
|
|
|
(setf (flymake--backend-state-running state) nil
|
|
|
|
|
(flymake--backend-state-disabled state) explanation
|
|
|
|
|
(flymake--backend-state-reported-p state) 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
|
|
|
|
|
|
|
|
|
(defun flymake--run-backend (backend)
|
2017-09-30 17:32:53 +01:00
|
|
|
|
"Run the backend BACKEND, reenabling if necessary."
|
|
|
|
|
(flymake-log :debug "Running backend %s" backend)
|
|
|
|
|
(let ((run-token (cl-gensym "backend-token")))
|
|
|
|
|
(flymake--with-backend-state backend state
|
|
|
|
|
(setf (flymake--backend-state-running state) run-token
|
|
|
|
|
(flymake--backend-state-disabled state) nil
|
|
|
|
|
(flymake--backend-state-diags state) nil
|
|
|
|
|
(flymake--backend-state-reported-p state) nil))
|
|
|
|
|
;; FIXME: Should use `condition-case-unless-debug' here, for don't
|
|
|
|
|
;; for two reasons: (1) that won't let me catch errors from inside
|
|
|
|
|
;; `ert-deftest' where `debug-on-error' appears to be always
|
|
|
|
|
;; t. (2) In cases where the user is debugging elisp somewhere
|
|
|
|
|
;; else, and using flymake, the presence of a frequently
|
|
|
|
|
;; misbehaving backend in the global hook (most likely the legacy
|
|
|
|
|
;; backend) will trigger an annoying backtrace.
|
|
|
|
|
;;
|
|
|
|
|
(condition-case err
|
|
|
|
|
(funcall backend
|
|
|
|
|
(flymake-make-report-fn backend run-token))
|
|
|
|
|
(error
|
|
|
|
|
(flymake--disable-backend backend err)))))
|
|
|
|
|
|
|
|
|
|
(defun flymake-start (&optional deferred force)
|
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
|
2017-09-30 17:32:53 +01:00
|
|
|
|
non-nil. With optional FORCE run even disabled backends.
|
|
|
|
|
|
|
|
|
|
Interactively, with a prefix arg, FORCE is t."
|
|
|
|
|
(interactive (list nil current-prefix-arg))
|
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))
|
2017-09-29 12:18:30 +01:00
|
|
|
|
(run-hook-wrapped
|
|
|
|
|
'flymake-diagnostic-functions
|
|
|
|
|
(lambda (backend)
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(cond
|
|
|
|
|
((and (not force)
|
|
|
|
|
(flymake--with-backend-state backend state
|
|
|
|
|
(flymake--backend-state-disabled state)))
|
|
|
|
|
(flymake-log :debug "Backend %s is disabled, not starting"
|
|
|
|
|
backend))
|
|
|
|
|
(t
|
|
|
|
|
(flymake--run-backend backend)))
|
2017-09-29 12:18:30 +01:00
|
|
|
|
nil))))
|
2017-09-22 01:31:23 +01:00
|
|
|
|
(if (and deferred
|
|
|
|
|
this-command)
|
|
|
|
|
(add-hook 'post-command-hook #'start 'append 'local)
|
|
|
|
|
(start))))
|
|
|
|
|
|
2017-09-28 14:57:01 +01:00
|
|
|
|
(defvar flymake-mode-map
|
2017-10-01 01:24:31 +01:00
|
|
|
|
(let ((map (make-sparse-keymap))) map)
|
|
|
|
|
"Keymap for `flymake-mode'")
|
2017-09-28 14:57:01 +01:00
|
|
|
|
|
2017-09-27 22:35:49 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(define-minor-mode flymake-mode nil
|
2017-09-28 14:57:01 +01:00
|
|
|
|
:group 'flymake :lighter flymake--mode-line-format :keymap flymake-mode-map
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(cond
|
|
|
|
|
;; Turning the mode ON.
|
|
|
|
|
(flymake-mode
|
2017-10-06 00:07:53 +01:00
|
|
|
|
(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--backend-state (make-hash-table))
|
|
|
|
|
|
|
|
|
|
(when flymake-start-syntax-check-on-find-file
|
|
|
|
|
(flymake-start)))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
|
|
|
|
;; 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)))))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
2017-09-30 10:45:48 +01:00
|
|
|
|
(defun flymake--schedule-timer-maybe ()
|
|
|
|
|
"(Re)schedule an idle timer for checking the buffer.
|
|
|
|
|
Do it only if `flymake-no-changes-timeout' is non-nil."
|
|
|
|
|
(when flymake-timer (cancel-timer flymake-timer))
|
|
|
|
|
(when flymake-no-changes-timeout
|
|
|
|
|
(setq
|
|
|
|
|
flymake-timer
|
|
|
|
|
(run-with-idle-timer
|
|
|
|
|
(seconds-to-time flymake-no-changes-timeout)
|
|
|
|
|
nil
|
|
|
|
|
(lambda (buffer)
|
|
|
|
|
(when (buffer-live-p buffer)
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(when (and flymake-mode
|
|
|
|
|
flymake-no-changes-timeout)
|
|
|
|
|
(flymake-log
|
|
|
|
|
:debug "starting syntax check after idle for %s seconds"
|
|
|
|
|
flymake-no-changes-timeout)
|
|
|
|
|
(flymake-start))
|
|
|
|
|
(setq flymake-timer nil))))
|
|
|
|
|
(current-buffer)))))
|
|
|
|
|
|
2017-09-27 22:35:49 +01:00
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun flymake-mode-on ()
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Turn Flymake mode on."
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(flymake-mode 1))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
|
|
|
|
;;;###autoload
|
|
|
|
|
(defun flymake-mode-off ()
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Turn Flymake mode off."
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(flymake-mode 0))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
2017-09-29 11:02:36 +01:00
|
|
|
|
(make-obsolete 'flymake-mode-on 'flymake-mode "26.1")
|
|
|
|
|
(make-obsolete 'flymake-mode-off 'flymake-mode "26.1")
|
|
|
|
|
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(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"))
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(flymake-log :debug "starting syntax check as new-line has been seen")
|
2017-09-27 17:47:14 +01:00
|
|
|
|
(flymake-start 'deferred))
|
2017-09-30 10:45:48 +01:00
|
|
|
|
(flymake--schedule-timer-maybe)))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
|
|
|
|
(defun flymake-after-save-hook ()
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(when flymake-mode
|
|
|
|
|
(flymake-log :debug "starting syntax check as buffer was saved")
|
2017-09-27 17:47:14 +01:00
|
|
|
|
(flymake-start)))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
|
|
|
|
(defun flymake-kill-buffer-hook ()
|
|
|
|
|
(when flymake-timer
|
|
|
|
|
(cancel-timer flymake-timer)
|
|
|
|
|
(setq flymake-timer nil)))
|
|
|
|
|
|
|
|
|
|
(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
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(null flymake-diagnostic-functions))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
(flymake-mode)
|
Simplify Flymake logging and erroring
Use display-warning and a dedicated *Flymake log* buffer.
To ease readability, flymake log messages are now prefixed with a
common prefix and the buffer that originated them.
Some situations of over-zealous logging are fixed.
Use byte-compiler info, if available, to determine whence the
flymake-related log message is coming.
* lisp/progmodes/flymake-proc.el
(flymake-proc--diagnostics-for-pattern): Improve log message.
(flymake-proc--panic): Always flymake-log an error
(flymake-proc--safe-delete-file)
(flymake-proc--safe-delete-directory):
Downgrade warning
(flymake-proc-start-syntax-check): Simplify slightly.
(flymake-proc--start-syntax-check-process): Simplify.
(flymake-proc--init-find-buildfile-dir)
(flymake-proc--init-create-temp-source-and-master-buffer-copy):
No need to warn twice.
* lisp/progmodes/flymake.el (flymake-log): Convert to macro.
(flymake--log-1): New helper.
(flymake-log-level): Deprecate.
(flymake-error): New helper.
(flymake-ler-make-ler, flymake--handle-report, flymake-mode):
Use flymake-error.
(flymake-on-timer-event)
(flymake--handle-report, flymake--disable-backend)
(flymake--run-backend, flymake-start, flymake-mode-on)
(flymake-mode-off, flymake-after-change-function)
(flymake-after-save-hook, flymake-find-file-hook): Adjust
flymake-log calls.
* test/lisp/progmodes/flymake-tests.el
(flymake-tests--call-with-fixture): Only log errors.
2017-09-26 01:35:43 +01:00
|
|
|
|
(flymake-log :warning "Turned on in `flymake-find-file-hook'")))
|
2017-09-27 22:35:49 +01:00
|
|
|
|
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(defun flymake-goto-next-error (&optional n filter interactive)
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Go to Nth next Flymake error in buffer matching FILTER.
|
2017-09-29 11:02:36 +01:00
|
|
|
|
|
|
|
|
|
Interactively, always move to the next error. Interactively, and
|
|
|
|
|
with a prefix arg, skip any diagnostics with a severity less than
|
|
|
|
|
‘:warning’.
|
|
|
|
|
|
|
|
|
|
If ‘flymake-wrap-around’ is non-nil, resumes search from top
|
|
|
|
|
at end of buffer.
|
|
|
|
|
|
2017-09-27 12:42:20 +01:00
|
|
|
|
FILTER is a list of diagnostic types found in
|
|
|
|
|
`flymake-diagnostic-types-alist', or nil, if no filter is to be
|
2017-09-29 11:02:36 +01:00
|
|
|
|
applied."
|
|
|
|
|
;; TODO: let filter be a number, a severity below which diags are
|
|
|
|
|
;; skipped.
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(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))
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(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))
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(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))
|
2017-09-21 14:20:22 +01:00
|
|
|
|
(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
|
2017-09-30 18:04:45 +01:00
|
|
|
|
(user-error "No more Flymake errors%s"
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(if filter
|
|
|
|
|
(format " of types %s" filter)
|
|
|
|
|
""))))))
|
|
|
|
|
|
|
|
|
|
(defun flymake-goto-prev-error (&optional n filter interactive)
|
2017-09-30 18:04:45 +01:00
|
|
|
|
"Go to Nth previous Flymake error in buffer matching FILTER.
|
2017-09-29 11:02:36 +01:00
|
|
|
|
|
|
|
|
|
Interactively, always move to the previous error. Interactively,
|
|
|
|
|
and with a prefix arg, skip any diagnostics with a severity less
|
|
|
|
|
than ‘:warning’.
|
|
|
|
|
|
|
|
|
|
If ‘flymake-wrap-around’ is non-nil, resumes search from top
|
|
|
|
|
at end of buffer.
|
|
|
|
|
|
2017-09-27 12:42:20 +01:00
|
|
|
|
FILTER is a list of diagnostic types found in
|
|
|
|
|
`flymake-diagnostic-types-alist', or nil, if no filter is to be
|
2017-09-29 11:02:36 +01:00
|
|
|
|
applied."
|
2017-09-27 12:42:20 +01:00
|
|
|
|
(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
|
|
|
|
|
2017-09-27 02:31:58 +01:00
|
|
|
|
|
2017-10-05 02:42:01 +01:00
|
|
|
|
;;; Mode-line and menu
|
2017-09-27 02:31:58 +01:00
|
|
|
|
;;;
|
2017-10-05 02:42:01 +01:00
|
|
|
|
(easy-menu-define flymake-menu flymake-mode-map "Flymake"
|
|
|
|
|
`("Flymake"
|
|
|
|
|
[ "Go to next error" flymake-goto-next-error t ]
|
|
|
|
|
[ "Go to previous error" flymake-goto-prev-error t ]
|
|
|
|
|
[ "Check now" flymake-start t ]
|
|
|
|
|
[ "Go to log buffer" flymake-switch-to-log-buffer t ]
|
|
|
|
|
"--"
|
|
|
|
|
[ "Turn off Flymake" flymake-mode t ]))
|
|
|
|
|
|
2017-09-27 02:31:58 +01:00
|
|
|
|
(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."
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(let* ((known (hash-table-keys flymake--backend-state))
|
|
|
|
|
(running (flymake-running-backends))
|
|
|
|
|
(disabled (flymake-disabled-backends))
|
|
|
|
|
(reported (flymake-reporting-backends))
|
|
|
|
|
(diags-by-type (make-hash-table))
|
|
|
|
|
(all-disabled (and disabled (null running)))
|
|
|
|
|
(some-waiting (cl-set-difference running reported)))
|
|
|
|
|
(maphash (lambda (_b state)
|
|
|
|
|
(mapc (lambda (diag)
|
|
|
|
|
(push diag
|
|
|
|
|
(gethash (flymake--diag-type diag)
|
|
|
|
|
diags-by-type)))
|
|
|
|
|
(flymake--backend-state-diags state)))
|
|
|
|
|
flymake--backend-state)
|
2017-09-27 02:31:58 +01:00
|
|
|
|
`((:propertize " Flymake"
|
|
|
|
|
mouse-face mode-line-highlight
|
|
|
|
|
help-echo
|
2017-09-30 17:32:53 +01:00
|
|
|
|
,(concat (format "%s known backends\n" (length known))
|
|
|
|
|
(format "%s running\n" (length running))
|
|
|
|
|
(format "%s disabled\n" (length disabled))
|
2017-09-27 02:31:58 +01:00
|
|
|
|
"mouse-1: go to log buffer ")
|
|
|
|
|
keymap
|
|
|
|
|
,(let ((map (make-sparse-keymap)))
|
2017-10-05 02:42:01 +01:00
|
|
|
|
(define-key map [mode-line down-mouse-1]
|
|
|
|
|
flymake-menu)
|
2017-09-27 02:31:58 +01:00
|
|
|
|
map))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
,@(pcase-let ((`(,ind ,face ,explain)
|
|
|
|
|
(cond ((null known)
|
|
|
|
|
`("?" mode-line "No known backends"))
|
|
|
|
|
(some-waiting
|
|
|
|
|
`("Wait" compilation-mode-line-run
|
2017-10-05 02:42:01 +01:00
|
|
|
|
,(format "Waiting for %s running backend(s)"
|
|
|
|
|
(length some-waiting))))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
(all-disabled
|
|
|
|
|
`("!" compilation-mode-line-run
|
|
|
|
|
"All backends disabled"))
|
|
|
|
|
(t
|
|
|
|
|
`(nil nil nil)))))
|
|
|
|
|
(when ind
|
|
|
|
|
`((":"
|
|
|
|
|
(:propertize ,ind
|
|
|
|
|
face ,face
|
2017-10-05 02:42:01 +01:00
|
|
|
|
help-echo ,explain
|
|
|
|
|
keymap
|
|
|
|
|
,(let ((map (make-sparse-keymap)))
|
|
|
|
|
(define-key map [mode-line mouse-1]
|
|
|
|
|
'flymake-switch-to-log-buffer)
|
|
|
|
|
map))))))
|
2017-09-30 17:32:53 +01:00
|
|
|
|
,@(unless (or all-disabled
|
|
|
|
|
(null known))
|
|
|
|
|
(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 diags-by-type)
|
|
|
|
|
'(:error :warning)))
|
|
|
|
|
#'>
|
|
|
|
|
:key #'cdr)
|
|
|
|
|
for diags = (gethash type diags-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 "]")))))))
|
2017-09-27 02:31:58 +01:00
|
|
|
|
|
2004-11-25 16:33:53 +00:00
|
|
|
|
(provide 'flymake)
|
2017-08-17 15:38:12 +01:00
|
|
|
|
|
|
|
|
|
(require 'flymake-proc)
|
2017-10-01 01:24:31 +01:00
|
|
|
|
|
2004-05-29 12:55:24 +00:00
|
|
|
|
;;; flymake.el ends here
|