[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Fix mouse click on flymake
From: |
Ergus |
Subject: |
Re: [PATCH] Fix mouse click on flymake |
Date: |
Sun, 19 Jan 2025 12:25:52 +0100 |
Hi Juri:
On Sun, Jan 19, 2025 at 09:47:53AM +0200, Juri Linkov wrote:
Flymake with fringe indicator supports an action to click in the fringe
and show the buffer diagnostics.
This was only working on gui just because the map action was not
set. Not sure if that was intended.
No, this was not intended.
The attached patch attempts to fix that; If you thing it is correct,
please, push it.
Thanks.
(defvar flymake-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map `[,flymake-fringe-indicator-position mouse-1]
+ (define-key map `[,(pcase flymake-indicator-type
+ ('fringes flymake-fringe-indicator-position)
+ ('margins flymake-margin-indicator-position))
+ mouse-1]
What would happen when the user changes the value of flymake-indicator-type?
The keybinding is not updated? What if the value is nil?
Maybe better to bind both 'fringes' and 'margins'?
Or update keybindings when flymake-indicator-type is customized?
My first attempt for this fix was actually this patch
```
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index 9dda53713f5..25482f70b35 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -200,8 +200,20 @@ flymake-indicator-type
See Info node `Fringes' and Info node `(elisp)Display Margins'."
:version "30.1"
:type '(choice (const :tag "Use Fringes" fringes)
- (const :tag "Use Margins "margins)
- (const :tag "No indicators" nil)))
+ (const :tag "Use Margins " margins)
+ (const :tag "No indicators" nil))
+ :set (lambda (sym val)
+ ;; TODO: Maybe add a condition here using last value of sym
+ (keymap-unset flymake-mode-map "<left-margin> <mouse-1>" t)
+ (keymap-unset flymake-mode-map "<left-fringe> <mouse-1>" t)
+ (set-default sym val)
+ (when val
+ (keymap-set flymake-mode-map
+ (key-description `[,(pcase flymake-indicator-type
+ ('fringes flymake-fringe-indicator-position)
+ ('margins
flymake-margin-indicator-position))
+ mouse-1])
+ #'flymake-show-buffer-diagnostics))))
(defcustom flymake-margin-indicators-string
'((error "!!" compilation-error)
@@ -1369,11 +1381,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'.")
```
But for some reason it didn't work. The entry is in the map:
```
flymake-mode-map is a keymap variable defined in ‘flymake.el’.
Documentation:
Keymap for ‘flymake-mode’.
Key Binding
<left-margin> <mouse-1> flymake-show-buffer-diagnostics
...
```
But the click action didn't work.
If you see my error, feel free to fix it and push.
BTW!! When I haven't seen the code yet, I was actually looking for a
property in the margin char, I thought that the char in the
fringe/margin had a 'keymap property that made it clickable.
That would give more fine grained actions and will allow a more precise
action. I tried to do that but it didn't work, apparently the action is
associated with the whole margin.
Is this also intended?
WDYT?
Best,
Ergus
- [PATCH] Fix mouse click on flymake, Ergus, 2025/01/18
- Re: [PATCH] Fix mouse click on flymake, Eli Zaretskii, 2025/01/19
- Re: [PATCH] Fix mouse click on flymake, Juri Linkov, 2025/01/19
- Re: [PATCH] Fix mouse click on flymake,
Ergus <=
- Re: [PATCH] Fix mouse click on flymake, Juri Linkov, 2025/01/19
- Re: [PATCH] Fix mouse click on flymake, Ergus, 2025/01/19
- Message not available
- Re: [PATCH] Fix mouse click on flymake, Ergus, 2025/01/20
- Re: [PATCH] Fix mouse click on flymake, Juri Linkov, 2025/01/20
- Re: [PATCH] Fix mouse click on flymake, Ergus, 2025/01/20
- Re: [PATCH] Fix mouse click on flymake, Eli Zaretskii, 2025/01/21
- Re: [PATCH] Fix mouse click on flymake, Ergus, 2025/01/21
- Re: [PATCH] Fix mouse click on flymake, Eli Zaretskii, 2025/01/23
- Re: [PATCH] Fix mouse click on flymake, Ergus, 2025/01/23
- Re: [PATCH] Fix mouse click on flymake, Eli Zaretskii, 2025/01/24