[PATCH v2 4/5] emacs: Use the new JSON reply format.
Adam Wolfe Gordon
awg+notmuch at xvx.ca
Wed Jan 18 08:29:08 PST 2012
On Tue, Jan 17, 2012 at 23:54, David Edmondson <dme at dme.org> wrote:
> On Tue, 17 Jan 2012 15:53:37 -0700, Adam Wolfe Gordon <awg+notmuch at xvx.ca> wrote:
>> +(defun notmuch-parts-filter-by-type (parts type)
>> + "Return a list of message parts with the given type"
>> + (let (result)
>> + (dolist (part (append parts nil) result)
>> + (if (string= (cdr (assq 'content-type part)) type)
>> + (setq result (append result (list (cdr (assq 'content part)))))))
>> + result))
>
> I still think that `loop' is easier to read :-) But no objection to this
> code.
I couldn't find the loop construct initially, but after the discussion
of common lisp on IRC yesterday I found the cl package and figured out
how your example worked. With loop and collect figured out, it is
easier to read.
>> +(defun notmuch-mua-insert-part-quoted (part)
>> + (let ((start (point))
>> + limit)
>> + (insert part)
>> + (setq limit (point))
>> + (goto-char start)
>> + (while (re-search-forward "\\(^\\)[^$]" limit 0)
>> + (replace-match "> " nil nil nil 1)
>> + ;; We have added two characters to the quotable region
>> + (setq limit (+ limit 2)))
>> + (set-buffer-modified-p nil)))
>
> You could use a marker for the limit, as it would then move along
> automagically (sorry for not noticing this last time).
Aha! Another trick I didn't know about.
New patch forthcoming.
More information about the notmuch
mailing list