From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Changing default mouse bindings Date: Fri, 17 Nov 2017 10:28:52 -0500 Message-ID: References: <0ad9af94-11cc-4dae-841f-f2918342d1bf@default> <7f5a496c-1ea7-4f0c-a2f5-4e5307d7ee82@default> <87fu9heq03.fsf_-_@gmail.com> <86y3n83183.fsf@misasa.okayama-u.ac.jp> <86lgj54xpd.fsf@misasa.okayama-u.ac.jp> <838tf5id1e.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1510932552 1319 195.159.176.226 (17 Nov 2017 15:29:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Nov 2017 15:29:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: charles@aurox.ch, johnw@gnu.org, emacs-devel@gnu.org, Tak Kunihiro , agrambot@gmail.com, drew.adams@oracle.com To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Nov 17 16:29:07 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eFiZg-000899-NM for ged-emacs-devel@m.gmane.org; Fri, 17 Nov 2017 16:29:00 +0100 Original-Received: from localhost ([::1]:46471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFiZn-0004kF-QY for ged-emacs-devel@m.gmane.org; Fri, 17 Nov 2017 10:29:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40431) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFiZh-0004jy-6U for emacs-devel@gnu.org; Fri, 17 Nov 2017 10:29:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFiZg-0005tC-BV for emacs-devel@gnu.org; Fri, 17 Nov 2017 10:29:01 -0500 Original-Received: from pmta11.teksavvy.com ([76.10.157.34]:42611) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1eFiZa-0005jP-UT; Fri, 17 Nov 2017 10:28:55 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2EFFQB0/w5a/3HQSC1cHAEBAQQBAQoBA?= =?us-ascii?q?YM8gVKOLI8+gX2Yc4VFAoRnQxQBAQEBAQEBAQEDaCiFIAEEAXkFCwsNJxIUGDE?= =?us-ascii?q?uigIIrDohAopeAQEBBwImgzSCB4ZpixMFkwiPNqB/KIcxl2w2I4F0NCEIMkmCZ?= =?us-ascii?q?YR8I4sMAQEB?= X-IPAS-Result: =?us-ascii?q?A2EFFQB0/w5a/3HQSC1cHAEBAQQBAQoBAYM8gVKOLI8+gX2?= =?us-ascii?q?Yc4VFAoRnQxQBAQEBAQEBAQEDaCiFIAEEAXkFCwsNJxIUGDEuigIIrDohAopeA?= =?us-ascii?q?QEBBwImgzSCB4ZpixMFkwiPNqB/KIcxl2w2I4F0NCEIMkmCZYR8I4sMAQEB?= X-IronPort-AV: E=Sophos;i="5.44,410,1505793600"; d="scan'208";a="9619408" Original-Received: from unknown (HELO pastel.home) ([45.72.208.113]) by smtp.teksavvy.com with ESMTP; 17 Nov 2017 10:28:52 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 86D08607D3; Fri, 17 Nov 2017 10:28:52 -0500 (EST) In-Reply-To: <838tf5id1e.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Nov 2017 09:23:41 +0200") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 76.10.157.34 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:220249 Archived-At: >> (global-set-key [mouse-3] 'mouse-context-menu) >> (defun mouse-context-menu (event) >> (interactive "e") >> (or (poplife-mouse-dir-menu event) ; DIR menu >> (poplife-mouse-url-menu event) ; URL menu >> (mouse3-region-menu event) ; region menu >> (mouse-context-menu-default event))) ; default menu <<<<< > I don't think binding this to mouse-3 by default can fly, because it > contradicts the usual GUI meaning of that button related to > selections, something that is honored by all well-behaving GUI > applications in the X world. It would be unwise for Emacs not to > comply. Indeed, I think we should first focus on the command itself, and leave the discussion about where to bind it to for later. I don't think we want the command to hardcode things like dir-menu, region-menu, ..., so we'll want to have a hook where we can add a function that gives the region-part of the menu, and another for the dir-part of a menu, ... Maybe we could do something like the code below. The intention is to make it reasonably easy to add functions to the hook that add a few elements to the menu, and to also make it possible to add functions that completely override the default menu (e.g. for flyspell's context menu). This sample solution doesn't provide any direct way to specify the context-menu from text-properties, so maybe we'd want to add to the default definition of mouse-context-menu-function some function which looks up some `context-menu` text-property, tho maybe we don't need that and we can let packages add their own function to lookup their own text-properties instead. Stefan (defvar mouse-context-menu-function #'mouse-default-context-menu "Function that builds the context-menu. Takes one argument (the EVENT that requests the menu) and should return a list of menu items.") (defun mouse-context-menu (event) "Open up the context menu." (interactive "@e") (let* ((menu-items (funcall mouse-context-menu-function event)) (keymap `(keymap ,(apply #'vector menu-items)))) (popup-menu leymap event)))