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