[PATCH v2] emacs: display tags in notmuch-show with links
Ethan Glasser-Camp
ethan.glasser.camp at gmail.com
Tue Nov 13 18:03:44 PST 2012
Damien Cassou <damien.cassou at gmail.com> writes:
> +(defun notmuch-tagger-present-tags (tags &optional headerline)
> + "Return a property list which nicely presents all TAGS.
> +
> +If HEADERLINE is non-nil the returned list will be ready for
> +inclusion in the buffer's header-line. HEADERLINE must be nil in
> +all other cases."
> + (list
> + "("
> + (notmuch-tagger-separate-elems (notmuch-tagger-format-tags tags headerline) " ")
> + ")"))
It is kind of appalling that it takes 128 lines just to do this. It
seems like there has to be an easier way, or several easier
ways. Unfortunately, I don't see any.
> diff --git a/test/emacs b/test/emacs
> index 44f641e..ecdc841 100755
> --- a/test/emacs
> +++ b/test/emacs
> @@ -820,5 +820,66 @@ Date: Fri, 05 Jan 2001 15:43:57 +0000
> EOF
> test_expect_equal_file OUTPUT EXPECTED
>
> +test_begin_subtest "Extracting all tags from a thread"
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 1"'
> +parent=${gen_msg_id}
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 2"' \
> + "[in-reply-to]=\<$parent\>"
> +add_message \
> + '[subject]="Extracting all tags from a thread"' \
> + '[body]="body 3"' \
> + "[in-reply-to]=\<$parent\>"
> +latest=${gen_msg_id}
> +# Extract the thread-id from one of the emails
> +thread_id=$(notmuch search id:${latest} | sed -e "s/thread:\([a-f0-9]*\).*/\1/")
I think the accepted idiom is to use "notmuch search
--output=threads". This will output just a string like
"thread:00000000000000b9", so if you really need just the ID, you could
still use sed here...
> +# Add tag "mytagfoo" to one of the emails
> +notmuch tag +mytagfoo id:${latest}
> +test_emacs_expect_t \
> + "(notmuch-show \"thread:${thread_id}\")
... but it seems like "thread:..." is good enough for you.
> + (error \"We must be in notmch-show at this point but we are in %s.\" major-mode))
> + (push-button) ;; simulate a press on the RET key
> + (if (eq major-mode 'notmuch-search-mode)
> + t
> + (format \"We must be in notmch-search at this point but we are in %s.\" major-mode))"
s/notmch/notmuch/ here.
Otherwise I think the code looks fine. I think the design concerns
raised by Mark Walters are probably valid, though.
Ethan
More information about the notmuch
mailing list