From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Context menus and mouse-3 Date: Tue, 13 Jul 2021 22:14:08 -0400 Message-ID: References: <20200914061111.3trmuzhdvv7nwdcc@Ergus> <87y2acv2tw.fsf@mail.linkov.net> <87sg0jt7bo.fsf@mail.linkov.net> <871r8123jg.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29519"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Richard Stallman , spacibba@aol.com, philipk@posteo.net, emacs-devel@gnu.org, arthur.miller@live.com, dgutov@yandex.ru, ghe@sdf.org, drew.adams@oracle.com To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 14 04:15:15 2021 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 1m3UQd-0007SJ-2h for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Jul 2021 04:15:15 +0200 Original-Received: from localhost ([::1]:35886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3UQc-00011a-0n for ged-emacs-devel@m.gmane-mx.org; Tue, 13 Jul 2021 22:15:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3UPm-0000IS-RR for emacs-devel@gnu.org; Tue, 13 Jul 2021 22:14:23 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:3895) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3UPg-0004fl-5O; Tue, 13 Jul 2021 22:14:17 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 48DD2100201; Tue, 13 Jul 2021 22:14:11 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id EB82D1001F2; Tue, 13 Jul 2021 22:14:09 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1626228849; bh=enF4n70MBnfgcTnrLc0dRDV0woWIyGycNaP+uwem/HE=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=KyFwaHLkmWHjVwjHSDhn7ZKsnEM5QNDbZ5Dy6wwyyOOtNWWmVIYlJTIzCjC7VYqu8 2J4xGgMMOQmYZklhW9i/t0/fHYNtzggBrbvRO3YRMneod6ge+lSg9F6qm5CVxarrUW 00kxJLy199Fee7TrL4GxvB1zlRwbp88FBbxKJFNkudVvw2SYV7t9HE/SJ0O7Y9Fob5 dIThn2CawwLde5H5DUwcGi0Zb0qQGXj00gxeVwq7tJFGeRIFx4MxCL9P8THoT9pwgj ThRGzaoA6JduMMvrVMy/uE/M+Oo8T3gM/QB5kX1Tx+zuk7v+c7UkQ3IQPfBq6fc6jI pwsfGZNjbk5tw== Original-Received: from alfajor (unknown [216.154.29.138]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 93FAC1204BC; Tue, 13 Jul 2021 22:14:09 -0400 (EDT) In-Reply-To: <871r8123jg.fsf@mail.linkov.net> (Juri Linkov's message of "Wed, 14 Jul 2021 02:32:35 +0300") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.23 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" Xref: news.gmane.io gmane.emacs.devel:271207 Archived-At: >>> I tried to override the global [context-menu] with e.g. menu-bar-custom-menu >>> (that later could be replaced with the value returned from mouse-context-menu-function): >>> >>> (let ((map (make-sparse-keymap))) >>> (define-key map [context-menu] menu-bar-custom-menu) >>> (set-transient-map map)) >>> (push (cons 'context-menu (cdr event)) unread-command-events) >>> >>> However, it doesn't override the global [context-menu], but prepends >>> the transient [context-menu] before the global one. >> >> Yes, if the key is bound in various keymaps and all the bindings are to >> a keymap, then those keymaps get merged, as usual for prefix keymaps. >> >> Two ways to solve that: >> - use `mouse-context-menu-function` instead of adding a new local >> key binding for `context-menu`. >> - don't bind `context-menu` to a keymap but to a command (that >> presumably then uses `popup-menu` internally). > > `popup-menu` has the same problems: it doesn't run post/pre-command-hook, etc. That doesn't matter: the command loop does that for us before/after calling the command bound to `context-menu`, so the command bound to `context-menu` doesn't need to do it. The problem with your original call is not the use of `popup-menu` but the fact that it runs it from from a timer. Stefan