unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
Subject: Re: [PATCH 1/2] contrib: pick: add thread based utility functions
Date: Mon, 27 May 2013 08:35:18 +0100	[thread overview]
Message-ID: <878v30kh8p.fsf@qmul.ac.uk> (raw)
In-Reply-To: <87fvxswgff.fsf@zancas.localnet>


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!.\b@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)

  reply	other threads:[~2013-05-27  7:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-08 12:48 [PATCH 0/2] Add some thread based actions to pick Mark Walters
2012-12-08 12:48 ` [PATCH 1/2] contrib: pick: add thread based utility functions Mark Walters
2013-05-12 12:06   ` David Bremner
2013-05-27  7:35     ` Mark Walters [this message]
2013-06-01 12:36       ` David Bremner
2012-12-08 12:48 ` [PATCH 2/2] contrib: pick: thread tagging (including archiving) implemented Mark Walters
2013-06-01 19:48   ` David Bremner
2013-06-01 21:45     ` Mark Walters

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878v30kh8p.fsf@qmul.ac.uk \
    --to=markwalters1009@gmail.com \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).