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: Mon, 20 Jan 2025 17:22:10 +0100

Hi Jury:

On Mon, Jan 20, 2025 at 09:42:47AM +0200, Juri Linkov wrote:

Thanks, this is much better.


Maybe it doesn't work because flymake-mode still uses an old map,
But the map value seems to be right. And if I set some other binding it seems 
to work there.

The real problem is that this change requires substantial refactoring
of flymake.el to be able to compile the change above.  You need to add
a setter-function like 'flymake-indicator-type--set' defined before
the defcustom flymake-indicator-type.  But all variables that it uses
(flymake-fringe-indicator-position, flymake-margin-indicator-position,
flymake-mode-map) should be defined earlier, etc.

But this is not the right thing to do anyway.  Then maybe you could use
a keymap filter with the condition that checks flymake-indicator-type?

That's way beyond my elisp capabilities ;)

You can see an example in outline-minor-mode-cycle--bind.
A keymap :filter could help to avoid refactoring.


What would happen when you delete the char with the 'keymap' property?
The indicator will go away?  This doesn't look right.

I don't get what you mean or maybe I didn't explain myself properly.

I thought to make clickable the !  or !! characters in the margins.
The user does not remove that char, flymake does.  If the char goes
away it means that the error is gone so, the action is not needed.

I meant to make the !! a clickable text itself so (for example) we
could make that a click on one of those goes directly to that error in
the list.

Sorry, I thought about the 'keymap' property on a char in the buffer,
not in the margin.  So adding the property on a char in the margin
would be an improvement.

I would prefer to implement this one, but for some reason it doesn't
work.

Try this code snippet:

```
(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)))))

```

When I move the mouse over the 'b' letter in the margin I can see: "My
error", but when I click (mouse-1) I don't get the "Clicked!!"
message but an error message: "<left-margin> <mouse-1> is undefined".

Is this intended?

Best,
Ergus




reply via email to

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