diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 9dda53713f5..d3bbb98a93e 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -748,34 +748,41 @@ flymake--severity (flymake--lookup-type-property type 'severity (warning-numeric-level :error))) -(defun flymake--indicator-overlay-spec (indicator) +(defun flymake--indicator-overlay-spec (type) "Return INDICATOR as propertized string to use in error indicators." - (let* ((value (if (symbolp indicator) + (let* ((indicator (flymake--lookup-type-property + type + (cond ((eq flymake-indicator-type 'fringes) + 'flymake-bitmap) + ((eq flymake-indicator-type 'margins) + 'flymake-margin-string)) + (alist-get 'bitmap (alist-get type ; backward compat + flymake-diagnostic-types-alist)))) + (value (if (symbolp indicator) (symbol-value indicator) indicator)) - (indicator-car (if (listp value) - (car value) - value)) - (indicator-cdr (if (listp value) - (cdr value)))) + (valuelist (if (listp value) + value + (list value))) + (indicator-car (car valuelist))) + (cond ((and (symbolp indicator-car) flymake-fringe-indicator-position) (propertize "!" 'display - (cons flymake-fringe-indicator-position - (if (listp value) - value - (list value))))) + (cons flymake-fringe-indicator-position valuelist))) ((and (stringp indicator-car) flymake-margin-indicator-position) (propertize "!" 'display `((margin ,flymake-margin-indicator-position) - ,(propertize - indicator-car - 'face - `(:inherit (,indicator-cdr - default))))))))) + ,(propertize indicator-car + 'face `(:inherit (,(cdr valuelist) default)) + 'mouse-face 'highlight + 'help-echo "Open Flymake diagnostics" + 'keymap `,(define-keymap + (format "<%s> " flymake-margin-indicator-position) + #'flymake-show-buffer-diagnostics)))))))) (defun flymake--resize-margins (&optional orig-width) "Resize current window margins according to `flymake-margin-indicator-position'. @@ -941,16 +948,7 @@ flymake--highlight-line (overlay-put ov prop (flymake--lookup-type-property type prop value))))) (default-maybe 'face 'flymake-error) - (default-maybe 'before-string - (flymake--indicator-overlay-spec - (flymake--lookup-type-property - type - (cond ((eq flymake-indicator-type 'fringes) - 'flymake-bitmap) - ((eq flymake-indicator-type 'margins) - 'flymake-margin-string)) - (alist-get 'bitmap (alist-get type ; backward compat - flymake-diagnostic-types-alist))))) + (default-maybe 'before-string (flymake--indicator-overlay-spec type)) ;; (default-maybe 'after-string ;; (flymake--diag-text diagnostic)) (default-maybe 'help-echo @@ -1369,11 +1367,7 @@ flymake-start nil))) (flymake--import-foreign-diagnostics)))))) -(defvar flymake-mode-map - (let ((map (make-sparse-keymap))) - (define-key map `[,flymake-fringe-indicator-position mouse-1] - #'flymake-show-buffer-diagnostics) - map) +(defvar flymake-mode-map (make-sparse-keymap) "Keymap for `flymake-mode'.") ;;;###autoload