Hi David Bremner <david@tethera.net> writes: > Mark Walters <markwalters1009@gmail.com> writes: > >> Previously notmuch-pick had no thread based functionality. This adds a >> macro to iterate through all messages in a thread. To simplify this it >> adds a text-property marker to the first message of each thread. > > >> +(defun notmuch-pick-get-messages-ids-thread () >> + "Return all id: queries of messages in the current thread." >> + (let ((message-ids)) >> + (notmuch-pick-thread-mapc >> + (lambda () (push (notmuch-pick-get-message-id) message-ids))) >> + message-ids)) > > As a style thing, it seems more idiomatic to me to have a map macro > which returns a sequence, rather than faking it with mapc and push. But > maybe that's a typical common lisp style, I don't know. I think I agree: this is very closely copied from notmuch-show (notmuch-show-mapc and notmuch-show-get-messages-id) so it is probably worth staying the same. > More importantly, in emacs 24.3 I get an infinite loop when trying to > evaluate the update notmuch-pick.el. I think this is just stupidity on my part: it should be a defun rather than a defmacro. Would you be able to test that (or I can send a new version if you prefer)? Also, how are you loading notmuch-pick? In my set up the macro and function work interchangeably. Best wishes Mark > > The backtrace is below. I'm not a macro expert, but seems like too much > is happening at compile/eval time. > > ---------------------------------------------------------------------- > > Debugger entered--Lisp error: (quit) > (save-excursion (beginning-of-line) (get-text-property (point) :notmuch-message-properties)) > notmuch-pick-get-message-properties() > (or props (notmuch-pick-get-message-properties)) > (let ((props (or props (notmuch-pick-get-message-properties)))) (plist-get props prop)) > notmuch-pick-get-prop(:first) > (not (notmuch-pick-get-prop :first)) > (while (not (notmuch-pick-get-prop :first)) (forward-line -1)) > notmuch-pick-thread-top() > (save-excursion (notmuch-pick-thread-top) (progn (while (progn (progn (funcall function) (forward-line)) (and (notmuch-pick-get-message-properties) (not (notmuch-pick-get-prop :first))))) nil)) > (lambda (function) "Iterate through all messages in the current thread\n and call FUNCTION for side effects." (save-excursion (notmuch-pick-thread-top) (progn (while (progn (progn (funcall function) (forward-line)) (and (notmuch-pick-get-message-properties) (not (notmuch-pick-get-prop :first))))) nil)))((lambda nil (push (notmuch-pick-get-message-id) message-ids))) > macroexpand((notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) nil) > macroexp--expand-all((notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids)))) > macroexp--all-forms(((notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) > #[1028 "\300.\300\301.\302\"\303.!.@A#..@#\207" [macroexp--cons macroexp--all-clauses 1 macroexp--all-forms] 10 "\n\n(fn FORM BODY BINDINGS FUN)"](((let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) ((notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids) ((message-ids)) let) > macroexp--expand-all((let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) > macroexp--all-forms((lambda nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) 2) > macroexp--expand-all((function (lambda nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)))) > macroexp--all-forms((defalias (quote notmuch-pick-get-messages-ids-thread) (function (lambda nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)))) 1) > #[514 "\300.\301\"\211\204. > macroexp--expand-all((defun notmuch-pick-get-messages-ids-thread nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids))) > macroexpand-all((defun notmuch-pick-get-messages-ids-thread nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids))) > #[0 " \nB.\303\300!)\207" [(defun notmuch-pick-get-messages-ids-thread nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) load-file-name macroexp--pending-eager-loads macroexpand-all] 2 "\n\n(fn)"]() > funcall(#[0 " \nB.\303\300!)\207" [(defun notmuch-pick-get-messages-ids-thread nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids)) load-file-name macroexp--pending-eager-loads macroexpand-all] 2 "\n\n(fn)"]) > internal-macroexpand-for-load((defun notmuch-pick-get-messages-ids-thread nil "Return all id: queries of messages in the current thread." (let ((message-ids)) (notmuch-pick-thread-mapc (lambda nil (push (notmuch-pick-get-message-id) message-ids))) message-ids))) > eval-current-buffer() > call-interactively(eval-current-buffer record nil) > command-execute(eval-current-buffer record) > execute-extended-command(nil "eval-current-buffer") > call-interactively(execute-extended-command nil nil)