Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1881F431FD7 for ; Mon, 27 May 2013 00:35:32 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.098 X-Spam-Level: X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0pPOMqxPcs9Z for ; Mon, 27 May 2013 00:35:23 -0700 (PDT) Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 81915431FAE for ; Mon, 27 May 2013 00:35:23 -0700 (PDT) Received: from smtp.qmul.ac.uk ([138.37.6.40]) by mail2.qmul.ac.uk with esmtp (Exim 4.71) (envelope-from ) id 1Ugrxh-0007Bp-D5; Mon, 27 May 2013 08:35:22 +0100 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost) by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71) (envelope-from ) id 1Ugrxh-0002la-26; Mon, 27 May 2013 08:35:21 +0100 From: Mark Walters To: David Bremner , notmuch@notmuchmail.org Subject: Re: [PATCH 1/2] contrib: pick: add thread based utility functions In-Reply-To: <87fvxswgff.fsf@zancas.localnet> References: <1354970914-18342-1-git-send-email-markwalters1009@gmail.com> <1354970914-18342-2-git-send-email-markwalters1009@gmail.com> <87fvxswgff.fsf@zancas.localnet> User-Agent: Notmuch/0.14+255~gff3cc55 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) Date: Mon, 27 May 2013 08:35:18 +0100 Message-ID: <878v30kh8p.fsf@qmul.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Sender-Host-Address: 93.97.24.31 X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: cb557fcb22de4c19ba253139540d261a (of first 20000 bytes) X-SpamAssassin-Score: -0.1 X-SpamAssassin-SpamBar: / X-SpamAssassin-Report: The QM spam filters have analysed this message to determine if it is spam. We require at least 5.0 points to mark a message as spam. This message scored -0.1 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * -0.1 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 May 2013 07:35:32 -0000 Hi David Bremner writes: > Mark Walters 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)