Re: [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
authorAustin Clements <amdragon@MIT.EDU>
Tue, 20 Nov 2012 05:32:16 +0000 (00:32 +1900)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:46 +0000 (09:50 -0800)
73/cda62f4170459a9c93c3ad445f65469abb13d2 [new file with mode: 0644]

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