To customize the appearance of error types, the user must set properties on the symbols associated with each diagnostic type.
The three standard diagnostic keyword symbols –
:note – have pre-configured appearances.
However a backend may define more (see Backend functions).
The following properties can be set:
flymake-bitmap, an image displayed in the fringe according to
flymake-fringe-indicator-position. The value actually follows the syntax of
flymake-error-bitmap(see Customizable variables). It is overridden by any
flymake-overlay-control, an alist ((OVPROP . VALUE) ...) of further properties used to affect the appearance of Flymake annotations. With the exception of
evaporate, these properties are applied directly to the created overlay (see Overlay Properties in The Emacs Lisp Reference Manual).
As an example, here’s how to make diagnostics of the type
stand out more prominently:
(push '(face . highlight) (get :note 'flymake-overlay-control))
If you push another alist entry in front, it overrides the previous
one. So this effectively removes the face from
(push '(face . nil) (get :note 'flymake-overlay-control))
To restore the original look for
:note types, empty or remove
(put :note 'flymake-overlay-control '())
flymake-severityis a non-negative integer specifying the diagnostic’s severity. The higher the value, the more serious is the error. If the overlay property
priorityis not specified in
flymake-severityis used to set it and help sort overlapping overlays.
flymake-type-nameis a string used to succinctly name the error type, in case the name of the symbol associated with it is very long.
flymake-categoryis a symbol whose property list is considered the default for missing values of any other properties.
Three default diagnostic types are predefined:
:note. By default, each one of them has a
flymake-category property whose value is, respectively, the
These category symbols’ plist is where the values of customizable
variables and faces (such as
flymake-error-bitmap) are found.
Thus, if you change their plists, Flymake may stop honoring these user
flymake-category special property is especially useful for
backends which create diagnostics objects with non-default types that
differ from an existing type by only a few properties (see Flymake utility functions).
As an example, consider configuring a new diagnostic type
:low-priority-note that behaves much like
without an overlay face.
(put :low-priority-note 'flymake-overlay-control '((face . nil))) (put :low-priority-note 'flymake-category 'flymake-note)
As you might have guessed, Flymake’s annotations are implemented as
overlays (see Overlays in The Emacs Lisp Reference Manual).
Along with the properties that you specify for the specific type of
diagnostic, Flymake adds the property
these overlays, and sets it to the object that the backend created
Since overlays also support arbitrary keymaps, you can use this along
with the functions
flymake-diagnostic-text (see Flymake utility functions) to
create interactive annotations, such as in the following example of
mouse-3 event (middle mouse button click) to an
Internet search for the text of a
(defun my-search-for-message (event) (interactive "e") (let* ((diags (flymake-diagnostics (posn-point (event-start event)))) (topmost-diag (car diags))) (eww-browse-url (concat "https://duckduckgo.com/?q=" (replace-regexp-in-string " " "+" (flymake-diagnostic-text topmost-diag))) t))) (dolist (type '(:warning :error)) (push '(mouse-face . highlight) (get type 'flymake-overlay-control)) (push `(keymap . ,(let ((map (make-sparse-keymap))) (define-key map [mouse-2] 'my-search-for-message) map)) (get type 'flymake-overlay-control)))