From: David Bremner Date: Sun, 12 May 2013 12:06:44 +0000 (+2100) Subject: Re: [PATCH 1/2] contrib: pick: add thread based utility functions X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6a0c3c006c34c0e3d46384aa8234dd726b513249;p=notmuch-archives.git Re: [PATCH 1/2] contrib: pick: add thread based utility functions --- diff --git a/a9/864bee84df629d8ae81e7ecaef177e98ba8a84 b/a9/864bee84df629d8ae81e7ecaef177e98ba8a84 new file mode 100644 index 000000000..4136f5f4b --- /dev/null +++ b/a9/864bee84df629d8ae81e7ecaef177e98ba8a84 @@ -0,0 +1,117 @@ +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 B21E0431FBC + for ; Sun, 12 May 2013 05:06:59 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.3 +X-Spam-Level: +X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5 + tests=[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 dVVtz3OaBkTL for ; + Sun, 12 May 2013 05:06:53 -0700 (PDT) +Received: from tempo.its.unb.ca (tempo.its.unb.ca [131.202.1.21]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 5A3A1431FAF + for ; Sun, 12 May 2013 05:06:53 -0700 (PDT) +Received: from tesseract.cs.unb.ca (tesseract.cs.unb.ca [131.202.240.238]) + by tempo.its.unb.ca (8.13.8/8.13.8) with ESMTP id r4CC6pYY001308; + Sun, 12 May 2013 09:06:51 -0300 +Received: from fctnnbsc30w-156034082078.dhcp-dynamic.fibreop.nb.bellaliant.net + ([156.34.82.78] helo=zancas.localnet) + by tesseract.cs.unb.ca with esmtpsa + (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) + (envelope-from ) + id 1UbV3C-0003Sk-JK; Sun, 12 May 2013 09:06:51 -0300 +Received: from bremner by zancas.localnet with local (Exim 4.80) + (envelope-from ) + id 1UbV37-00064F-0l; Sun, 12 May 2013 09:06:45 -0300 +From: David Bremner +To: Mark Walters , notmuch@notmuchmail.org +Subject: Re: [PATCH 1/2] contrib: pick: add thread based utility functions +In-Reply-To: <1354970914-18342-2-git-send-email-markwalters1009@gmail.com> +References: <1354970914-18342-1-git-send-email-markwalters1009@gmail.com> + <1354970914-18342-2-git-send-email-markwalters1009@gmail.com> +User-Agent: Notmuch/0.15.2+84~g12d5e4e (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-pc-linux-gnu) +Date: Sun, 12 May 2013 09:06:44 -0300 +Message-ID: <87fvxswgff.fsf@zancas.localnet> +MIME-Version: 1.0 +Content-Type: text/plain +Content-Transfer-Encoding: 8bit +X-Spam_bar: / +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: Sun, 12 May 2013 12:06:59 -0000 + +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. + +More importantly, in emacs 24.3 I get an infinite loop when trying to +evaluate the update notmuch-pick.el. + +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)