all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: Augusto Stoffel <arstoffel@gmail.com>
Cc: 62250@debbugs.gnu.org
Subject: bug#62250: 29.0.60; Allow context menu from text properties to not override everything
Date: Sun, 19 Mar 2023 19:43:28 +0200	[thread overview]
Message-ID: <86fsa0r60v.fsf@mail.linkov.net> (raw)
In-Reply-To: <87cz55rjir.fsf@gmail.com> (Augusto Stoffel's message of "Sat, 18 Mar 2023 19:39:40 +0100")

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

>> I already envisioned such request
>
> All right.  Just for the record, this would be useful to create a
> context menu for images.

The patch below will allow using the text property like

  'context-menu-functions '(image-context-menu)

> Also, I could take advantage of it to slightly
> simplify the context menu of jit-spell.

Actually, flyspell was the reason why the text property
`context-menu-function' overrides everything:

1. `make-flyspell-overlay' puts an overlay property

   (overlay-put overlay 'context-menu-function 'flyspell-context-menu)

2. `flyspell-context-menu' returns `flyspell-correct-word'

3. `context-menu-map' should return this symbol unmodified

4. at the end, the symbol `flyspell-correct-word' is executed
   as a command from the menu binding in `context-menu-entry'
   or from `context-menu-open':

    (if (commandp map)
        (call-interactively map)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: context-menu-functions.patch --]
[-- Type: text/x-diff, Size: 1216 bytes --]

diff --git a/lisp/mouse.el b/lisp/mouse.el
index 6b9accd6758..2cd2840bad9 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -368,9 +368,10 @@ context-menu-map
 the function `context-menu-filter-function'."
   (let* ((menu (make-sparse-keymap (propertize "Context Menu" 'hide t)))
          (click (or click last-input-event))
-         (window (posn-window (event-start click)))
-         (fun (mouse-posn-property (event-start click)
-                                   'context-menu-function)))
+         (start (event-start click))
+         (window (posn-window start))
+         (fun (mouse-posn-property start 'context-menu-function))
+         (funs (mouse-posn-property start 'context-menu-functions)))
 
     (unless (eq (selected-window) window)
       (select-window window))
@@ -380,7 +381,9 @@ context-menu-map
       (run-hook-wrapped 'context-menu-functions
                         (lambda (fun)
                           (setq menu (funcall fun menu click))
-                          nil)))
+                          nil))
+      (dolist (fun funs)
+        (setq menu (funcall fun menu click))))
 
     ;; Remove duplicate separators as well as ones at the beginning or
     ;; end of the menu.

  reply	other threads:[~2023-03-19 17:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18  7:51 bug#62250: 29.0.60; Allow context menu from text properties to not override everything Augusto Stoffel
2023-03-18  8:31 ` Eli Zaretskii
2023-03-18 11:19   ` Augusto Stoffel
2023-03-18 11:24     ` Eli Zaretskii
2023-03-18 11:29       ` Augusto Stoffel
2023-03-18 11:33         ` Eli Zaretskii
2023-03-18 18:10     ` Juri Linkov
2023-03-18 18:44       ` Augusto Stoffel
2023-03-19 17:40         ` Juri Linkov
2023-03-19 18:10           ` Augusto Stoffel
2023-03-20 18:29             ` Juri Linkov
2023-03-18 18:08 ` Juri Linkov
2023-03-18 18:39   ` Augusto Stoffel
2023-03-19 17:43     ` Juri Linkov [this message]
2023-03-19 18:21       ` Augusto Stoffel
2023-03-20 18:34         ` Juri Linkov
2023-04-02 16:35       ` Juri Linkov
2024-03-05 16:51         ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86fsa0r60v.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=62250@debbugs.gnu.org \
    --cc=arstoffel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.