[PATCH 1/8] emacs: Clean up notmuch-search-show-result

Austin Clements amdragon at MIT.EDU
Wed Jul 4 14:00:30 PDT 2012


Quoth Mark Walters on Jul 04 at  9:47 pm:
> On Tue, 03 Jul 2012, Austin Clements <amdragon at MIT.EDU> wrote:
> > This simplifies the code and makes it no longer cubic in the number of
> > result fields.
> > ---
> >  emacs/notmuch.el |   20 ++++++++++----------
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> >
> > diff --git a/emacs/notmuch.el b/emacs/notmuch.el
> > index c6236db..be217a2 100644
> > --- a/emacs/notmuch.el
> > +++ b/emacs/notmuch.el
> > @@ -707,29 +707,29 @@ non-authors is found, assume that all of the authors match."
> >  	  (overlay-put overlay 'isearch-open-invisible #'delete-overlay)))
> >        (insert padding))))
> >  
> > -(defun notmuch-search-insert-field (field date count authors subject tags)
> > +(defun notmuch-search-insert-field (field format date count authors subject tags)
> >    (cond
> >     ((string-equal field "date")
> > -    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) date)
> > +    (insert (propertize (format format date)
> >  			'face 'notmuch-search-date)))
> >     ((string-equal field "count")
> > -    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) count)
> > +    (insert (propertize (format format count)
> >  			'face 'notmuch-search-count)))
> >     ((string-equal field "subject")
> > -    (insert (propertize (format (cdr (assoc field notmuch-search-result-format)) subject)
> > +    (insert (propertize (format format subject)
> >  			'face 'notmuch-search-subject)))
> >  
> >     ((string-equal field "authors")
> > -    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))
> > +    (notmuch-search-insert-authors format authors))
> >  
> >     ((string-equal field "tags")
> > -    (insert (concat "(" (propertize tags 'font-lock-face 'notmuch-tag-face) ")")))))
> > +    (insert
> > +     (format format (propertize tags 'font-lock-face 'notmuch-tag-face))))))
> 
> Am I missing something or did the search result line previously ignore
> the user's specification for tags and automatically print it with inside
> ()? Now this change does actually obey the user's specification.
> 
> In principle that is a good thing, but the tag update code (when
> changing a tag on a message) seems to rely on the brackets to find
> something and errors out if the user format does not have any
> brackets. (The code has things like "(re-search-backward "(")" in it).

Mm, that's a good point.  For now I should probably just revert the
code to ignoring the user's format specification.  A better solution
would be to remember the result's plist and simply rebuild the whole
line when the tags change, rather than trying to incrementally edit
it.

> Incidentally, patch 8 does change the format slightly by not padding the
> the date field string itself and only printing it padded. This (very
> mildly) breaks things if the user has customised
> notmuch-search-result-format

Yes, that's true.  I could pad out the date to keep this backwards
compatible, but since all of the other fields are variable width, I
think I'd rather switch to the variable size date field and just
mention this in the news.

> Best wishes
> 
> Mark
> 
> 
> 
> >  
> >  (defun notmuch-search-show-result (date count authors subject tags)
> > -  (let ((fields) (field))
> > -    (setq fields (mapcar 'car notmuch-search-result-format))
> > -    (loop for field in fields
> > -	  do (notmuch-search-insert-field field date count authors subject tags)))
> > +  (dolist (format notmuch-search-result-format)
> > +    (notmuch-search-insert-field (car format) (cdr format)
> > +				 date count authors subject tags))
> >    (insert "\n"))
> >  
> >  (defun notmuch-search-process-filter (proc string)


More information about the notmuch mailing list