emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Context menus and mouse-3


From: Juri Linkov
Subject: Re: Context menus and mouse-3
Date: Mon, 19 Jul 2021 18:55:57 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>> The idea is to define a variable (something like below;
>> poplife-menu-candidates) with list of functions that returns nil or
>> keymap (something like below; poplife-mouse-word-menu).  A function
>> (something like below; poplife-context-menu) will test each of them
>> until it gets keymap.
>
> Note: such a variable should have a name that ends in `-hook` or
> `-functions` and should be manipulated with the usual hook functions,
> e.g. `run-hook-wrapped`.
>
> Note also that the `context-menu-function` already mentioned offers the
> same kind of functionality (except you need to use `add-function`
> instead of `add-hook` and it offers a bit more flexibility at the cost
> of extra work).

For easier customization, 'context-menu-functions' could be more hook-like,
so e.g. when the default value will be defined as

  (defcustom context-menu-functions '(context-menu-region)

then users could easily customize the default value.
More minor modes could add own functions to the global value, e.g.

  (add-hook 'context-menu-functions 'bug-reference-context-menu -5)
  (add-hook 'context-menu-functions 'goto-address-context-menu -10)

Major modes could modify buffer-local values:

  (add-hook 'context-menu-functions 'dired-context-menu nil t)
  (add-hook 'context-menu-functions 'info-context-menu -5 t)
  (add-hook 'context-menu-functions 'dictionary-context-menu -10 t)

Then the user could have the final say by using another option, e.g.

  (defcustom context-menu-filter nil

where a user-defined function (that can be extended using `add-function`)
will accept a menu constructed by context-menu-functions
and return the modified menu with reordered/removed/added items
to user's liking.



reply via email to

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