[PATCH 6/7] emacs: search: use orig-tags in search

Austin Clements amdragon at MIT.EDU
Tue Feb 11 17:30:48 PST 2014


On Sat, 18 Jan 2014, Mark Walters <markwalters1009 at gmail.com> wrote:
> This uses the recent functionality to show the tag changes in the
> search buffer. Currently this is only used to show changes the search
> buffer makes itself: i.e., it does not make display any changes
> reflecting tagging done by other notmuch-buffers.
> ---
>  emacs/notmuch.el |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> index 1436e5a..f0ea5d4 100644
> --- a/emacs/notmuch.el
> +++ b/emacs/notmuch.el
> @@ -753,14 +753,20 @@ non-authors is found, assume that all of the authors match."
>       format-string (notmuch-sanitize (plist-get result :authors))))
>  
>     ((string-equal field "tags")
> -    (let ((tags (plist-get result :tags)))
> -      (insert (format format-string (notmuch-tag-format-tags tags tags)))))))
> +    (let ((tags (plist-get result :tags))
> +	  (orig-tags (plist-get result :orig-tags)))
> +      (insert (format format-string (notmuch-tag-format-tags tags orig-tags)))))))
>  
>  (defun notmuch-search-show-result (result &optional pos)
>    "Insert RESULT at POS or the end of the buffer if POS is null."
>    ;; Ignore excluded matches
>    (unless (= (plist-get result :matched) 0)
> -    (let ((beg (or pos (point-max))))
> +    (let ((beg (or pos (point-max)))
> +	  ;; If we are inserting the result for the first time POS
> +	  ;; will be nil and we should set orig-tags.
> +	  (result (if pos
> +		      result
> +		    (plist-put result :orig-tags (plist-get result :tags)))))

This seems rather obtuse.  I'd prefer a little wrapper that sits between
`notmuch-sexp-parse-partial-list' and `notmuch-search-show-result' that
adds :orig-tags.  The wrapper could also pass (point-max) for pos and
pos could be made a required argument.  E.g.,

(defun notmuch-search-process-result (result)
  ;; Record original tags of this message
  (setq result (plist-put result :orig-tags (plist-get result :tags)))
  ;; Append the result to the search buffer
  (notmuch-search-show-result result (point-max)))

>        (save-excursion
>  	(goto-char beg)
>  	(dolist (spec notmuch-search-result-format)
> -- 
> 1.7.9.1
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list