From: Austin Clements Date: Mon, 7 Jan 2013 21:20:08 +0000 (+1900) Subject: Re: [PATCH v2] emacs: show: make buttons select window X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=dce7771a0c24f92322e086a3abed6295d2017998;p=notmuch-archives.git Re: [PATCH v2] emacs: show: make buttons select window --- diff --git a/cd/5f1ea1ad5d923c7bf9413dd3c8aa9794706741 b/cd/5f1ea1ad5d923c7bf9413dd3c8aa9794706741 new file mode 100644 index 000000000..99bae12ce --- /dev/null +++ b/cd/5f1ea1ad5d923c7bf9413dd3c8aa9794706741 @@ -0,0 +1,196 @@ +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 28F2E431FAF + for ; Mon, 7 Jan 2013 13:20:19 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[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 L1q3r1sDa6+T for ; + Mon, 7 Jan 2013 13:20:18 -0800 (PST) +Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU + [18.9.25.12]) + by olra.theworths.org (Postfix) with ESMTP id 4524C431FAE + for ; Mon, 7 Jan 2013 13:20:18 -0800 (PST) +X-AuditID: 1209190c-b7fa86d000001d37-9e-50eb3c111241 +Received: from mailhub-auth-3.mit.edu ( [18.9.21.43]) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id 81.8E.07479.11C3BE05; Mon, 7 Jan 2013 16:20:17 -0500 (EST) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-3.mit.edu (8.13.8/8.9.2) with ESMTP id r07LKAZK029031; + Mon, 7 Jan 2013 16:20:11 -0500 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id r07LK8PD003845 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Mon, 7 Jan 2013 16:20:09 -0500 (EST) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1TsK76-00010G-Go; Mon, 07 Jan 2013 16:20:08 -0500 +Date: Mon, 7 Jan 2013 16:20:08 -0500 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH v2] emacs: show: make buttons select window +Message-ID: <20130107212008.GM17581@mit.edu> +References: <20130107202221.GL17581@mit.edu> + <1357592840-31155-1-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1357592840-31155-1-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFvrHIsWRmVeSWpSXmKPExsUixCmqrSto8zrA4PgjA4vVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZTTuWMFUsEa14tGh3UwNjHPkuhg5OSQETCR2 + Xm1mgbDFJC7cW88GYgsJ7GOUODzHG8Jezyjx5JUNhH2BSeLZFYUuRi4gewmjxK6lPawgCRYB + FYlNv68ygdhsAhoS2/YvZwSxRQR0JG4fWsAOYjMLSEt8+90MVMPBISxgL/H2gy5ImBeoZOf6 + 2+wgYSGBHInVDyogwoISJ2c+YYHo1JK48e8lWCfIlOX/OEDCnAJeEjMuHgK7WBTogCknt7FN + YBSahaR7FpLuWQjdCxiZVzHKpuRW6eYmZuYUpybrFicn5uWlFuka6uVmluilppRuYgQHsyTP + DsY3B5UOMQpwMCrx8F4weBUgxJpYVlyZe4hRkoNJSZR3leXrACG+pPyUyozE4oz4otKc1OJD + jBIczEoivN8eAJXzpiRWVqUW5cOkpDlYlMR5L6fc9BcSSE8sSc1OTS1ILYLJynBwKEnwRloD + DRUsSk1PrUjLzClBSDNxcIIM5wEa3glSw1tckJhbnJkOkT/FqCglztsLkhAASWSU5sH1wpLN + K0ZxoFeEeTNAqniAiQqu+xXQYCagwamPn4MMLklESEk1MHpksziKTV813WV1wE7XH2wscdxf + vjvdTD5oI7sqWCX4MN9fv1T5j0LdL030Z8Ut49NcKb7JZuut14vbpX4dPblCNDp0u37cEqci + 1oOL25vecOuWl9Rvdfx/cpm1v3LM7JyGpv0n1G/Kvtm35danjsbakEmHZvb8bMjV8dow6db/ + KfPmySkW9CqxFGckGmoxFxUnAgB4DGOWEQMAAA== +Cc: notmuch@notmuchmail.org +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 21:20:19 -0000 + +LGTM. + +Quoth Mark Walters on Jan 07 at 9:07 pm: +> 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 versions fixes most of the comments raised by Austin's review. +> The one change I didn't make was changing :supertype to 'supertype. In +> principle I agree with Austin but the : form is used for inheritance +> for other notmuch buttons in wash and crypto. +> +> Best wishes +> +> Mark +> +> +> +> +> emacs/notmuch-crypto.el | 5 ++++- +> emacs/notmuch-lib.el | 15 +++++++++++++++ +> emacs/notmuch-show.el | 4 +++- +> emacs/notmuch-wash.el | 3 ++- +> 4 files changed, 24 insertions(+), 3 deletions(-) +> +> diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el +> index 83e5d37..5233824 100644 +> --- a/emacs/notmuch-crypto.el +> +++ b/emacs/notmuch-crypto.el +> @@ -19,6 +19,8 @@ +> ;; +> ;; Authors: Jameson Rollins +> +> +(require 'notmuch-lib) +> + +> (defcustom notmuch-crypto-process-mime nil +> "Should cryptographic MIME parts be processed? +> +> @@ -76,7 +78,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..6836192 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 +> 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"