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: poplife-mode Date: Sun, 12 Nov 2017 13:06:56 -0500 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1510510042 10742 195.159.176.226 (12 Nov 2017 18:07:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 12 Nov 2017 18:07:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 12 19:07:19 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 1eDwf7-0002MT-3F for ged-emacs-devel@m.gmane.org; Sun, 12 Nov 2017 19:07:17 +0100 Original-Received: from localhost ([::1]:50877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDwfB-0001NF-57 for ged-emacs-devel@m.gmane.org; Sun, 12 Nov 2017 13:07:21 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eDwf4-0001Mz-77 for emacs-devel@gnu.org; Sun, 12 Nov 2017 13:07:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eDwez-0004ea-8s for emacs-devel@gnu.org; Sun, 12 Nov 2017 13:07:14 -0500 Original-Received: from [195.159.176.226] (port=41076 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eDwez-0004cc-1g for emacs-devel@gnu.org; Sun, 12 Nov 2017 13:07:09 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eDweo-0001cZ-2e for emacs-devel@gnu.org; Sun, 12 Nov 2017 19:06:58 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 63 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:4F/0gmXoaVQh6hAn/8LJ27cluQs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:220100 Archived-At: > I think this should actually be provided in core: down-mouse-3 should be > bound to a command implementing this, with some standardized way to find > a contextual menu (looking at local char-properties, and if not > found, buffer-local variable). Maybe with something like the patch below. Stefan diff --git a/lisp/mouse.el b/lisp/mouse.el index 5eeee1ec52..90357806a1 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -50,10 +49,15 @@ mouse-drag-copy-region This affects `mouse-save-then-kill' (\\[mouse-save-then-kill]) in addition to mouse drags." :type 'boolean - :version "24.1" - :group 'mouse) + :version "24.1") + +(defcustom mouse-long-click-time 450 + "Time after which a click is considered long.") -(defcustom mouse-1-click-follows-link 450 +(defcustom mouse-1-click-follows-link + ;; FIXME: Maybe values 1 and -1 should be used to mean + ;; "use mouse-long-click-time". + mouse-long-click-time "Non-nil means that clicking Mouse-1 on a link follows the link. With the default setting, an ordinary Mouse-1 click on a link @@ -2455,12 +2451,22 @@ function-key-map (if (not (eq system-type 'ms-dos)) (global-set-key [S-down-mouse-1] 'mouse-appearance-menu)) ;; C-down-mouse-2 is bound in facemenu.el. -(global-set-key [C-down-mouse-3] - `(menu-item ,(purecopy "Menu Bar") ignore - :filter (lambda (_) - (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0)) - (mouse-menu-bar-map) - (mouse-menu-major-mode-map))))) +(let ((default-context-menu + `(menu-item ,(purecopy "Menu Bar") ignore + :filter (lambda (_) + (if (zerop (or (frame-parameter nil 'menu-bar-lines) 0)) + (mouse-menu-bar-map) + (mouse-menu-major-mode-map)))))) + (global-set-key [C-down-mouse-3] default-context-menu) + (global-set-key [context-menu] default-context-menu)) + +(global-set-key [down-mouse-3] #'mouse-maybe-context-menu) +(defun mouse-maybe-context-menu (event) + "Bring up a context menu for a long click. +See `mouse-long-click-time' and `mouse-context-menu-function'." + (interactive "@e") + (if (sit-for (/ mouse-long-click-time 1000.0)) + (push (cons 'context-menu (cdr event)) unread-command-events))) ;; Binding mouse-1 to mouse-select-window when on mode-, header-, or ;; vertical-line prevents Emacs from signaling an error when the mouse