aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch-lib.el
diff options
context:
space:
mode:
authorGravatar Mark Walters <markwalters1009@gmail.com>2013-01-07 21:07:20 +0000
committerGravatar David Bremner <bremner@debian.org>2013-02-18 20:13:19 -0400
commit3901bbca2eb3f24dd8ffa628a2c057ec1a28a1d0 (patch)
treecafe03af33674c303a782ca387177452549d432f /emacs/notmuch-lib.el
parentc34effad9a65c2f2c6d4d25c508c201bad7a07f6 (diff)
emacs: show: make buttons select window
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.
Diffstat (limited to 'emacs/notmuch-lib.el')
-rw-r--r--emacs/notmuch-lib.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index d78bcf80..270e3dc6 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -97,6 +97,21 @@ For example, if you wanted to remove an \"inbox\" tag and add an
:group 'notmuch-search
:group 'notmuch-show)
+;; By default clicking on a button does not select the window
+;; containing the button (as opposed to clicking on a widget which
+;; does). This means that the button action is then executed in the
+;; current selected window which can cause problems if the button
+;; changes the buffer (e.g., id: links) or moves point.
+;;
+;; This provides a button type which overrides mouse-action so that
+;; the button's window is selected before the action is run. Other
+;; notmuch buttons can get the same behaviour by inheriting from this
+;; button type.
+(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