unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Gerd Möllmann" <gerd.moellmann@gmail.com>
To: Stefan Kangas <stefankangas@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Tip: tty mode-line popup menus
Date: Tue, 10 Dec 2024 11:09:20 +0100	[thread overview]
Message-ID: <m27c87kfxr.fsf@gmail.com> (raw)
In-Reply-To: <m2seqvzxwl.fsf@gmail.com> ("Gerd Möllmann"'s message of "Tue, 10 Dec 2024 10:32:10 +0100")

Gerd Möllmann <gerd.moellmann@gmail.com> writes:

> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>
>> Stefan Kangas <stefankangas@gmail.com> writes:
>>
>>> Gerd Möllmann <gerd.moellmann@gmail.com> writes:
>>>
>>>> I don't like the tty behavior. It is fiddly with a track pad, which I
>>>> normally use, leading to inadvertent menu selections. Furthermore,
>>>> keyboard operation of the menu seems impossible.
>>>>
>>>> To fix this, I've added this in my init.el:
>>>>
>>>>   (defun my-fix-mode-line-map (map)
>>>>     (let* ((down-mouse (kbd "<mode-line> <down-mouse-1>"))
>>>> 	   (mouse (kbd "<mode-line> <mouse-1>"))
>>>> 	   (def (lookup-key map down-mouse)))
>>>>       (when def
>>>> 	(define-key map down-mouse nil)
>>>> 	(define-key map mouse def))))
>>>>
>>>>   (my-fix-mode-line-map mode-line-major-mode-keymap)
>>>>   (my-fix-mode-line-map mode-line-minor-mode-keymap)
>>>
>>> How about adding a defcustom for this behavior?
>>
>> Maybe, don't know. One problem is that I don't know where else something
>> similar is done. I know only the two places above plus one in the
>> Minions package, which probably simply mimicked what Emacs does in
>> bindings.el. Or in other words, I don't have enough of an overview to
>> design something that's really useful.
>>
>>> I guess many users are on laptops with trackpads these days, and would
>>> find that convenient.
>>
>> I guess so, especially if they use tap-to-click like I do.
>
> BTW, 
>
>    (my-fix-mode-line-map mode-line-major-mode-keymap)
>
> in combination with using the persistent-scratch package somehow seems
> to mess up the major-mode mode-line menu. I don't yet understand how, so
> be warned.

Resorting to logic sometimes helps. The problem is pretty simple:

Original definition in mode-line-major-mode-keymap looks like

	    (down-mouse-1 menu-item "Menu Bar" ignore :filter
			  #f(compiled-function (_) #<bytecode

Lookup-key does not return that

(lookup-key mode-line-major-mode-keymap (kbd "<mode-line> <down-mouse-1>"))
=> (keymap "IELM Mode" keymap
	(keymap
	 (ielm menu-item "IELM"
	       (keymap "IELM"
               ...

And setting that with define-key is not the right thing, obviously. One
would need a function returning the "raw" entry of a key in a keymap,
No idea if Emacs has such a function. If it does, I can't find it.

In essence, I have to retract that tip. It doesn't work as expected.



  reply	other threads:[~2024-12-10 10:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09  8:01 Tip: tty mode-line popup menus Gerd Möllmann
2024-12-09 10:40 ` Jean Louis
2024-12-09 14:58   ` Eli Zaretskii
2024-12-09 14:45 ` Eli Zaretskii
2024-12-09 15:15   ` Gerd Möllmann
2024-12-09 16:24     ` Eli Zaretskii
2024-12-09 21:54 ` Petteri Hintsanen
2024-12-10  3:32   ` Gerd Möllmann
2024-12-09 22:59 ` Stefan Kangas
2024-12-10  6:14   ` Gerd Möllmann
2024-12-10  9:32     ` Gerd Möllmann
2024-12-10 10:09       ` Gerd Möllmann [this message]
2024-12-10 13:15         ` Gerd Möllmann

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=m27c87kfxr.fsf@gmail.com \
    --to=gerd.moellmann@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=stefankangas@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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).