[PATCH] emacs: show: make buttons select window
authorMark Walters <markwalters1009@gmail.com>
Mon, 7 Jan 2013 18:24:51 +0000 (18:24 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:53:01 +0000 (09:53 -0800)
97/a27d919a76527f92c98a34d51d3bee606c49a5 [new file with mode: 0644]

diff --git a/97/a27d919a76527f92c98a34d51d3bee606c49a5 b/97/a27d919a76527f92c98a34d51d3bee606c49a5
new file mode 100644 (file)
index 0000000..76427d0
--- /dev/null
@@ -0,0 +1,175 @@
+Return-Path: <markwalters1009@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 51D60431FBD\r
+       for <notmuch@notmuchmail.org>; Mon,  7 Jan 2013 10:24:58 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 2.7\r
+X-Spam-Level: **\r
+X-Spam-Status: No, score=2.7 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       FREEMAIL_REPLY=2.499, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id 75ewR6QrtQe5 for <notmuch@notmuchmail.org>;\r
+       Mon,  7 Jan 2013 10:24:57 -0800 (PST)\r
+Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com\r
+ [74.125.82.51])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 88FC9431FAE   for <notmuch@notmuchmail.org>; Mon,  7 Jan 2013 10:24:57 -0800\r
+ (PST)\r
+Received: by mail-wg0-f51.google.com with SMTP id gg4so9759772wgb.6\r
+       for <notmuch@notmuchmail.org>; Mon, 07 Jan 2013 10:24:56 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=x-received:from:to:cc:subject:date:message-id:x-mailer;\r
+       bh=0QhrGc8tRuE6pGATW64rY1lUqwSIRFJ5U5Yng7veCPw=;\r
+       b=xpT+KMr2pX4XPnQRY66uHquDP7kauVp7CLu5n0lrBtOWhFWJPOR5sMcIXnSpnC56Jo\r
+       i2NuudrpfCZGDC3Lkfk/1mMteDCeTEW4EMBGB/V/zdBS2Y4JusNIBg0eEkMcA70q2NOJ\r
+       NmDUGkxatniXJ7DaGdmApGfJkijVn+IennYWbm6VjwqAWlb5O+D3MEKGbHAvD+Gh+vBk\r
+       KYfkFm6pS8uVF6kOOu0rj1iHNBFpIjKFA1NG7tDsEkadE1EaEMmiEyFLVo2xikUA0KIa\r
+       nGv9Kl+U1+t73xNVduniMtqYEmcvexe+bNZcTYbYukjNcxV7olSbjaKUXSCGoqzq7nLJ\r
+       8eRg==\r
+X-Received: by 10.180.73.202 with SMTP id n10mr10768193wiv.17.1357583095041;\r
+       Mon, 07 Jan 2013 10:24:55 -0800 (PST)\r
+Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])\r
+       by mx.google.com with ESMTPS id df2sm13248748wib.0.2013.01.07.10.24.53\r
+       (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+       Mon, 07 Jan 2013 10:24:53 -0800 (PST)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: show: make buttons select window\r
+Date: Mon,  7 Jan 2013 18:24:51 +0000\r
+Message-Id: <1357583091-28738-1-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Mon, 07 Jan 2013 18:24:58 -0000\r
+\r
+Emacs has two button type objects: widgets (as used for saved searches\r
+in notmuch-hello) and buttons as used by parts/citations and id links\r
+in notmuch-show. These two behave subtly differently when clicked with\r
+the mouse: widgets select the window clicked before running the\r
+action, buttons do not.\r
+\r
+This patch makes all of these behave the same: clicking always selects\r
+the clicked window. It does this by defining a notmuch-button-type\r
+supertype that the other notmuch buttons can inherit from. This\r
+supertype binds the mouse-action to select the window and then\r
+activate the button.\r
+---\r
+\r
+This is a new patch attempting to do the same as\r
+id:1355958602-16752-1-git-send-email-markwalters1009@gmail.com\r
+\r
+This version changes all notmuch buttons to select the appropriate\r
+window before applying the action. This brings the buttons in line\r
+with widgets (as used in notmuch hello) and whatever is used for\r
+http:// links.\r
+\r
+I think that buttons should at least run the action in the clicked\r
+window: whether point should remain there is less clear. This version\r
+does leave point there as this is what widgets and links do (but this\r
+would be easy to change).\r
+\r
+I don't know whether we want to do this for 0.15: the change for id\r
+links would be nice, the other cases are less important. If preferred\r
+I can provide a patch fixing that single instance.\r
+\r
+Finally, if anyone who uses the crypto stuff could check that it works\r
+for crypto buttons that would be nice as I do not have crypto setup.\r
+\r
+Best wishes\r
+\r
+Mark\r
+\r
+\r
+\r
+\r
+ emacs/notmuch-crypto.el |    3 ++-\r
+ emacs/notmuch-lib.el    |    5 +++++\r
+ emacs/notmuch-show.el   |    4 +++-\r
+ emacs/notmuch-wash.el   |    3 ++-\r
+ 4 files changed, 12 insertions(+), 3 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el\r
+index 83e5d37..173a3e7 100644\r
+--- a/emacs/notmuch-crypto.el\r
++++ b/emacs/notmuch-crypto.el\r
+@@ -76,7 +76,8 @@ mode."\r
+ (define-button-type 'notmuch-crypto-status-button-type\r
+   'action (lambda (button) (message (button-get button 'help-echo)))\r
+   'follow-link t\r
+-  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts.")\r
++  'help-echo "Set notmuch-crypto-process-mime to process cryptographic mime parts."\r
++  :supertype 'notmuch-button-type)\r
\r
+ (defun notmuch-crypto-insert-sigstatus-button (sigstatus from)\r
+   (let* ((status (plist-get sigstatus :status))\r
+diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el\r
+index 0407f8a..1573e32 100644\r
+--- a/emacs/notmuch-lib.el\r
++++ b/emacs/notmuch-lib.el\r
+@@ -97,6 +97,11 @@ For example, if you wanted to remove an \"inbox\" tag and add an\r
+   :group 'notmuch-search\r
+   :group 'notmuch-show)\r
\r
++(define-button-type 'notmuch-button-type\r
++  'mouse-action (lambda (button)\r
++                (select-window (posn-window (event-start last-input-event)))\r
++                (button-activate button)))\r
++\r
+ (defun notmuch-version ()\r
+   "Return a string with the notmuch version number."\r
+   (let ((long-string\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 5751d98..059194d 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -469,7 +469,8 @@ message at DEPTH in the current thread."\r
+   'action 'notmuch-show-part-button-default\r
+   'keymap 'notmuch-show-part-button-map\r
+   'follow-link t\r
+-  'face 'message-mml)\r
++  'face 'message-mml\r
++  :supertype 'notmuch-button-type)\r
\r
+ (defvar notmuch-show-part-button-map\r
+   (let ((map (make-sparse-keymap)))\r
+@@ -1075,6 +1076,7 @@ buttons for a corresponding notmuch search."\r
+       ;; Remove the overlay created by goto-address-mode\r
+       (remove-overlays (first link) (second link) 'goto-address t)\r
+       (make-text-button (first link) (second link)\r
++                        :type 'notmuch-button-type\r
+                         'action `(lambda (arg)\r
+                                    (notmuch-show ,(third link)))\r
+                         'follow-link t\r
+diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el\r
+index d6db4fa..826b6f4 100644\r
+--- a/emacs/notmuch-wash.el\r
++++ b/emacs/notmuch-wash.el\r
+@@ -115,7 +115,8 @@ lower).")\r
+ (define-button-type 'notmuch-wash-button-invisibility-toggle-type\r
+   'action 'notmuch-wash-toggle-invisible-action\r
+   'follow-link t\r
+-  'face 'font-lock-comment-face)\r
++  'face 'font-lock-comment-face\r
++  :supertype 'notmuch-button-type)\r
\r
+ (define-button-type 'notmuch-wash-button-citation-toggle-type\r
+   'help-echo "mouse-1, RET: Show citation"\r
+-- \r
+1.7.9.1\r
+\r