emacs-devel
[Top][All Lists]
Advanced

[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: Fri, 24 Jan 2025 00:25:07 +0100

Hi Eli:

I have a patch that actually works with margins (extremely simple now
BTW).

However, I am trying to get the same with fringes, but I don't find any
documentation on how to add a 'keymap property to a fringe. Is it even
possible?

I am starting with this code from the manual:

(overlay-put
 (make-overlay (point) (point))
 'before-string (propertize
                 "x" 'display
                 `(left-fringe right-arrow warning)))

But so far I can specify a face only.

Jury:

Attached the WIP patch.
Best,
Ergus


On Thu, Jan 23, 2025 at 01:04:50PM +0200, Eli Zaretskii wrote:
Date: Tue, 21 Jan 2025 18:37:59 +0100
From: Ergus <spacibba@aol.com>
CC: juri@linkov.net, sbaugh@janestreet.com

In one of my previous emails I shared this code:

```
(defun margin-command ()
(interactive)
(message "Clicked!!"))

(defvar-keymap margin-keymap
:doc "Keymap margin."
"<mouse-1>" #'margin-command)

(progn
(setq left-margin-width 1)
(dolist (win (get-buffer-window-list))
(set-window-buffer win (current-buffer)))

(defvar margin-overlay (make-overlay (point) (point)))

(move-overlay margin-overlay (point) (point))
(overlay-put margin-overlay 'before-string
(propertize " " 'display
(list '(margin left-margin)
(propertize "b"
'face 'error
'mouse-face 'highlight
'help-echo "HEE error message"
'keymap margin-keymap)))))

```

Is this enough?

Yes, thanks.

AFAICT, your key binding is incorrect: you need to use
"<left-margin> <mouse-1>" instead.  IOW, the below works for me:

 (defun margin-command ()
 (interactive)
 (message "Clicked!!"))

 (defvar-keymap margin-keymap
 :doc "Keymap margin."
 "<left-margin> <mouse-1>" #'margin-command)

 (progn
 (setq left-margin-width 1)
 (dolist (win (get-buffer-window-list))
 (set-window-buffer win (current-buffer)))


 (defvar margin-overlay (make-overlay (point) (point)))

 (move-overlay margin-overlay (point) (point))
 (overlay-put margin-overlay 'before-string
           (propertize " " 'display
                           (list '(margin left-margin)
                                   (propertize "b"
                                           'face 'error
                                           'mouse-face 'highlight
                                           'help-echo "HEE error message"
                                           'keymap margin-keymap)))))

Attachment: flymake-indicator-margin-click.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]