From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: Tip: tty mode-line popup menus Date: Tue, 10 Dec 2024 14:15:49 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24760"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Emacs Devel To: Stefan Kangas Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 10 14:16:33 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tL06K-0006Kx-VS for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Dec 2024 14:16:33 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tL05k-0003Io-Na; Tue, 10 Dec 2024 08:15:56 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tL05j-0003IS-J9 for emacs-devel@gnu.org; Tue, 10 Dec 2024 08:15:55 -0500 Original-Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tL05h-0000Zl-65 for emacs-devel@gnu.org; Tue, 10 Dec 2024 08:15:55 -0500 Original-Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-434f09d18e2so30768305e9.0 for ; Tue, 10 Dec 2024 05:15:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733836551; x=1734441351; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JNd49pzgJPJ8NDWIlwFx8A2s6P0sw6uFwKAycjfz3TI=; b=i/9aWH9FASMqJ7unDbSfJgt+IZ0GxW5tcj4gLd74SkokRAIhjtNEhf/dW6aeT2Z8f1 RYRswZrbS409j2Mk0HDBCJ6Pgd6Ecd0JZ8HVOx+jhuuU2di5CkmCD5XMqxOkBFsOpjdw el1K264YAbVgQV0fhwjNvA4SmUQskfNz23Rxb9JFMnYFrlHqcKF3/o5xFYBzz5u9AAGl 1TkR0hP6t9akxDZrP9g09MMcaL2FMIWbcq31gdhPNlMCx2rKnRqKC83/MmW3wbBBUxRa 2R9eKmud1E6ch2jKsH9liVqGSm9vE1/dvU3GwBDE7DQaXqFUCZrEHop/6mzO6G4FidQi hS3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733836551; x=1734441351; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=JNd49pzgJPJ8NDWIlwFx8A2s6P0sw6uFwKAycjfz3TI=; b=ZCQ6tLx0WBHTiUef3Q5NMN738EzOOiFBV+xE6ZDr4qFUdHg3aIZtsJzqq+toCBy3K1 cNfpbEbwSILGkYe8AX8uBV4RtdHWz0fHCCoz5I9SUYPGqBweYfg8TVt8qy514anMN2Mr 18Go2j50k3xY0d2IWXi/A+Tx3m/wKynVSC7fklj71i3A3m+k8huiWO5exR2YnNwjjM/p yfwS+TVHVSBFcerMDSh0HF43hAnqQBfr/z13Xze2ER+RIcN3Tfl3vAZdEWiyJ2JGgwAb 9XgyBb8iodKAN2HU+bYcnPM4FFvm+65F6cbWW0659zDq0AVprhRfVkVDVIfsGmtvKFtw PunA== X-Gm-Message-State: AOJu0YzdSqmrb5uDOkLI921UmnHyK1qHo/zYDMlsyJ2lYOInGJcqzNba C85EeG23IYPKCQqJ4NvSbEoSHB1fB27uogAQf1NaTZvSv3rviPb5CpUCDA== X-Gm-Gg: ASbGncvMYzeQCYWOt5eFiNtqNY5L9M94QV6GsTW6vL5maoMRIu5aQ/0P5CVZBixfHrY iFcpOOAaiQ3y9u+6Eg+I2VM5dztGvYXt7hdx8CwhPteTNPYc83P2ACk8Lo4AYny0/0/9Jga3XuU BxgStB7DCuGJprOEWb4Xb/v1KRzr0ojU9JdGPm8FIawnfR8VudIDieKdiOOiqRNCbTFcuTWfsAg k9PKBx9TcKLkcibq40HQM8yj0Luc7ObQeELFBTrP3KR8336pz+lk5os32hwY2ZyOBGBdK/zIfq6 8Pr+bAu7QYJ+fP6XIOpD/bcSoCgLkp3JYJe84GXQopXlDCPX94YFolm7BYDftw0= X-Google-Smtp-Source: AGHT+IHyUIGJNT5ENVTK0esUY0egiZJDJm/UKWgsFfg6q/d785MCoLi6UU1qVMTBFp0EU9X9aPbZ/g== X-Received: by 2002:a05:6000:79d:b0:385:c511:240a with SMTP id ffacd0b85a97d-3862b37c2f8mr13398347f8f.25.1733836550769; Tue, 10 Dec 2024 05:15:50 -0800 (PST) Original-Received: from pro2 (p200300e0b73a150089512521f002ebd0.dip0.t-ipconnect.de. [2003:e0:b73a:1500:8951:2521:f002:ebd0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434f5774454sm83517845e9.13.2024.12.10.05.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Dec 2024 05:15:50 -0800 (PST) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llmann=22'?= =?utf-8?Q?s?= message of "Tue, 10 Dec 2024 11:09:20 +0100") Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=gerd.moellmann@gmail.com; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326284 Archived-At: Gerd M=C3=B6llmann writes: > Gerd M=C3=B6llmann writes: > >> Gerd M=C3=B6llmann writes: >> >>> Stefan Kangas writes: >>> >>>> Gerd M=C3=B6llmann 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 " ")) >>>>> (mouse (kbd " ")) >>>>> (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,=20 >> >> (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 (_) # > Lookup-key does not return that > > (lookup-key mode-line-major-mode-keymap (kbd " "= )) > =3D> (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. And finally, the following works for me, FWIW. (defun my-lookup-down-mouse (map) (cl-flet ((lookup (event map) (catch 'found (map-keymap (lambda (e d) (when (eq event e) (throw 'found d))) map)))) (let* ((mode-line (lookup 'mode-line map))) (when mode-line (lookup 'down-mouse-1 mode-line))))) (defun my-fix-mode-line-map (map) (let* ((down-mouse (kbd " ")) (mouse (kbd " ")) (def (my-lookup-down-mouse map))) (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)