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 A6B8E431FD4 for ; Mon, 19 Nov 2012 21:32:21 -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 SBjQ5qZr9bbq for ; Mon, 19 Nov 2012 21:32:20 -0800 (PST) Received: from dmz-mailsec-scanner-5.mit.edu (DMZ-MAILSEC-SCANNER-5.MIT.EDU [18.7.68.34]) by olra.theworths.org (Postfix) with ESMTP id 997CB431E64 for ; Mon, 19 Nov 2012 21:32:19 -0800 (PST) X-AuditID: 12074422-b7f746d0000008cc-82-50ab15e390eb Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) by dmz-mailsec-scanner-5.mit.edu (Symantec Messaging Gateway) with SMTP id C5.CF.02252.3E51BA05; Tue, 20 Nov 2012 00:32:19 -0500 (EST) Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id qAK5WIiP010654; Tue, 20 Nov 2012 00:32:19 -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 qAK5WHKk001271 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Tue, 20 Nov 2012 00:32:18 -0500 (EST) Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) (envelope-from ) id 1TagRU-0000Kh-Rq; Tue, 20 Nov 2012 00:32:16 -0500 Date: Tue, 20 Nov 2012 00:32:16 -0500 From: Austin Clements To: Damien Cassou Subject: Re: [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable Message-ID: <20121120053216.GG22284@mit.edu> References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com> <1353266322-20318-4-git-send-email-damien.cassou@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1353266322-20318-4-git-send-email-damien.cassou@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmplleLIzCtJLcpLzFFi42IRYrdT0X0sujrAYMoDLotdd7cyWVy/OZPZ gclj56y77B7PVt1iDmCK4rJJSc3JLEst0rdL4MqY9OsSe8EE+YrDE/awNDAel+hi5OSQEDCR +LjnKhOELSZx4d56ti5GLg4hgX2MEkt3bGCBcDYwSlxsmc0K4ZxkkuiY9pYZwlnCKDH9QRMb SD+LgKrEzQkLmEFsNgENiW37lzOC2CIC2hJvlnawgtjMAkYS93dMB6sRFgiW+Hu7hwXE5hXQ kbi0bR47xNBWRomPd7awQSQEJU7OfMIC0awlcePfS6BjOYBsaYnl/zhAwpwCHhJ9i96B/SAq oCIx5eQ2tgmMQrOQdM9C0j0LoXsBI/MqRtmU3Crd3MTMnOLUZN3i5MS8vNQiXVO93MwSvdSU 0k2M4NB2UdrB+POg0iFGAQ5GJR7eBwmrAoRYE8uKK3MPMUpyMCmJ8m4QXh0gxJeUn1KZkVic EV9UmpNafIhRgoNZSYS3qRyonDclsbIqtSgfJiXNwaIkznst5aa/kEB6YklqdmpqQWoRTFaG g0NJgne3CNBQwaLU9NSKtMycEoQ0EwcnyHAeoOGnQGp4iwsSc4sz0yHypxgVpcR5H4AkBEAS GaV5cL2w1POKURzoFWHeryBVPMC0Bdf9CmgwE9DgawHLQQaXJCKkpBoYZU46yuVZPNk7T+Oj 3aHf9gqqzjpSK7bWyL9TPqXGaFh4pF26z+rWfNMvT+7XqkVzP7j+Wlpm0r7Tjv+qmq4dfr94 4ev9iwIW8Hgkp55Kn+l3J/+4oFADs0oHw16T4xX7Y39Jv9sjPXOP4+Zpx05lbjWRPvqCqZj9 5UxLJrXJ3989lZ02eY7SeSWW4oxEQy3mouJEAEU3EvIYAwAA Cc: notmuch mailing list 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: Tue, 20 Nov 2012 05:32:22 -0000 Quoth Damien Cassou on Nov 18 at 8:18 pm: > Signed-off-by: Damien Cassou > --- > emacs/notmuch-show.el | 9 +++++---- > emacs/notmuch-tagger.el | 33 +++++++++++++++++++++++++++++++++ > 2 files changed, 38 insertions(+), 4 deletions(-) > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > index 988e27c..379c8cd 100644 > --- a/emacs/notmuch-show.el > +++ b/emacs/notmuch-show.el > @@ -431,10 +431,11 @@ message at DEPTH in the current thread." > (notmuch-show-clean-address (plist-get headers :From)) > " (" > date > - ") (" > - (propertize (mapconcat 'identity tags " ") > - 'face 'notmuch-tag-face) > - ")\n") > + ") " > + (propertize > + (format-mode-line (notmuch-tagger-present-tags tags)) > + 'face 'notmuch-tag-face) > + "\n") > (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) > > (defun notmuch-show-insert-header (header header-value) > diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el > index 19a6c7e..379a905 100644 > --- a/emacs/notmuch-tagger.el > +++ b/emacs/notmuch-tagger.el > @@ -53,12 +53,21 @@ test if the library is present before calling this function." > (let ((tag (header-button-get button 'notmuch-tagger-tag))) > (notmuch-tagger-goto-target tag))) > > +(defun notmuch-tagger-body-button-action (button) > + "Open `notmuch-search' for the tag referenced by BUTTON." > + (let ((tag (button-get button 'notmuch-tagger-tag))) > + (notmuch-tagger-goto-target tag))) > + > (eval-after-load "header-button" > '(define-button-type 'notmuch-tagger-header-button-type > 'supertype 'header > 'action #'notmuch-tagger-header-button-action > 'follow-link t)) > > +(define-button-type 'notmuch-tagger-body-button-type > + 'action #'notmuch-tagger-body-button-action > + 'follow-link t) > + > (defun notmuch-tagger-really-make-header-link (tag) > "Return a property list that presents a link to TAG. > > @@ -82,6 +91,19 @@ if not." > (notmuch-tagger-really-make-header-link tag) > tag)) > > +(defun notmuch-tagger-make-body-link (tag) > + "Return a property list that presents a link to TAG. > +The returned property list will work everywhere except in the > +header-line. For a link that works on the header-line, prefer > +`notmuch-tagger-make-header-link'." > + (let ((button (copy-sequence tag))) > + (make-text-button > + button nil > + 'type 'notmuch-tagger-body-button-type > + 'notmuch-tagger-tag tag > + 'help-echo (format "%s: Search other messages like this" tag)) > + button)) > + > (defun notmuch-tagger-present-tags-header-line (tags) > "Return a property list to present TAGS in emacs header-line." > (list > @@ -91,6 +113,17 @@ if not." > " ") > ")")) > > +(defun notmuch-tagger-present-tags (tags) notmuch-tagger-format-tags? > + "Return a property list to present TAGS in emacs. Same comment about the comment as in patch 1. Though is this really the right interface? Is it useful to return a mode-line-format template from this, given that it can't be used in the mode-line or header-line since the buttons won't work? Should this just return a string that can be inserted into a buffer? Something like (untested), (defun notmuch-tagger-format-tags (tags) "Format TAGS as a string suitable for insertion in a buffer." (concat "(" (mapconcat #'notmuch-tagger-make-body-link tags " ") ")")) > +If tags the result of this function is to be used within the > +header-line, prefer `notmuch-tagger-present-tags-header-line' > +instead of this function." > + (list > + "(" > + (notmuch-tagger-separate-elems > + (mapcar #'notmuch-tagger-make-body-link tags) > + " ") > + ")")) > > (provide 'notmuch-tagger) > ;;; notmuch-tagger.el ends here