unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Austin Clements <amdragon@MIT.EDU>
To: Damien Cassou <damien.cassou@gmail.com>
Cc: notmuch mailing list <notmuch@notmuchmail.org>
Subject: Re: [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
Date: Tue, 20 Nov 2012 00:32:16 -0500	[thread overview]
Message-ID: <20121120053216.GG22284@mit.edu> (raw)
In-Reply-To: <1353266322-20318-4-git-send-email-damien.cassou@gmail.com>

Quoth Damien Cassou on Nov 18 at  8:18 pm:
> Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
> ---
>  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

  parent reply	other threads:[~2012-11-20  5:32 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-18 19:18 [PATCH v2] emacs: display tags in notmuch-show with links Damien Cassou
2012-11-18 19:18 ` [PATCH 1/4] Add a thread's tags to emacs header-line Damien Cassou
2012-11-20  5:13   ` Austin Clements
2012-11-20  5:32     ` Austin Clements
2012-11-22 18:36       ` Damien Cassou
2012-11-18 19:18 ` [PATCH 2/4] Make tags in header-line clickable Damien Cassou
2012-11-18 19:18 ` [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable Damien Cassou
2012-11-18 23:06   ` Mark Walters
2012-11-22 18:40     ` Damien Cassou
2012-11-22 18:46       ` Mark Walters
2012-11-23  8:02       ` Bernard Hurley
2012-11-23 11:18         ` Tomi Ollila
2012-11-30 16:15         ` Damien Cassou
2012-11-20  5:32   ` Austin Clements [this message]
2012-11-30 16:13     ` Damien Cassou
2012-11-18 19:18 ` [PATCH 4/4] emacs: Add unit-tests for clickable tags in notmuch-show Damien Cassou
2012-11-18 22:59 ` [PATCH v2] emacs: display tags in notmuch-show with links Ethan Glasser-Camp
2012-11-19  0:10   ` Aaron Ecay
2012-11-20  4:23   ` Austin Clements
2012-11-20  4:50     ` Ethan
2012-11-22 18:11   ` Damien Cassou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121120053216.GG22284@mit.edu \
    --to=amdragon@mit.edu \
    --cc=damien.cassou@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).