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 at 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