From f0ef83d97c74eaedc877d7df0d57b0a3496f846b Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 15 Jul 2012 15:50:03 +2000 Subject: [PATCH] Re: [PATCH v2 4/7] emacs: Use result text properties for search result iteration --- b3/43579aed710cbd3bba409725909808d27677e6 | 136 ++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 b3/43579aed710cbd3bba409725909808d27677e6 diff --git a/b3/43579aed710cbd3bba409725909808d27677e6 b/b3/43579aed710cbd3bba409725909808d27677e6 new file mode 100644 index 000000000..94ed978e4 --- /dev/null +++ b/b3/43579aed710cbd3bba409725909808d27677e6 @@ -0,0 +1,136 @@ +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 25A75431FC3 + for ; Sat, 14 Jul 2012 12:50:07 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 LJUYhY2cVAj5 for ; + Sat, 14 Jul 2012 12:50:06 -0700 (PDT) +Received: from dmz-mailsec-scanner-1.mit.edu (DMZ-MAILSEC-SCANNER-1.MIT.EDU + [18.9.25.12]) + by olra.theworths.org (Postfix) with ESMTP id 8119C431FBC + for ; Sat, 14 Jul 2012 12:50:06 -0700 (PDT) +X-AuditID: 1209190c-b7f806d000006b87-3f-5001cd6d3c9b +Received: from mailhub-auth-1.mit.edu ( [18.9.21.35]) + by dmz-mailsec-scanner-1.mit.edu (Symantec Messaging Gateway) with SMTP + id 2E.3C.27527.D6DC1005; Sat, 14 Jul 2012 15:50:05 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q6EJo4WJ003195; + Sat, 14 Jul 2012 15:50:05 -0400 +Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6EJo3qX023524 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Sat, 14 Jul 2012 15:50:04 -0400 (EDT) +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77) + (envelope-from ) + id 1Sq8Lr-0003bK-57; Sat, 14 Jul 2012 15:50:03 -0400 +Date: Sat, 14 Jul 2012 15:50:03 -0400 +From: Austin Clements +To: Jameson Graef Rollins +Subject: Re: [PATCH v2 4/7] emacs: Use result text properties for search + result iteration +Message-ID: <20120714195003.GF31670@mit.edu> +References: <1342140319-19859-1-git-send-email-amdragon@mit.edu> + <1342237406-32507-1-git-send-email-amdragon@mit.edu> + <1342237406-32507-5-git-send-email-amdragon@mit.edu> + <87d33yf8bi.fsf@servo.finestructure.net> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <87d33yf8bi.fsf@servo.finestructure.net> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFmpkleLIzCtJLcpLzFFi42IR4hRV1s09yxhg8HGKpcWefV4W12/OZHZg + 8rh7msvj2apbzAFMUVw2Kak5mWWpRfp2CVwZlzp+Mhf0CFfcWTmXrYHxCl8XIyeHhICJRNfT + bewQtpjEhXvr2UBsIYF9jBLnjgd1MXIB2RsYJX62zGGEcE4ySVzYNZ8JwlnCKPGvez5zFyMH + B4uAqsSjudog3WwCGhLb9i9nBLFFBMwker78AbOZBaQlvv1uZgKxhQWiJXp654Jt4xXQkWif + u5sNYuZNRolLy95AJQQlTs58wgLRrCVx499LJpBdIIOW/+MACXMKmErc33IabL6ogIrElJPb + 2CYwCs1C0j0LSfcshO4FjMyrGGVTcqt0cxMzc4pTk3WLkxPz8lKLdA31cjNL9FJTSjcxgkNa + kmcH45uDSocYBTgYlXh40/0ZAoRYE8uKK3MPMUpyMCmJ8rqeZAwQ4kvKT6nMSCzOiC8qzUkt + PsQowcGsJMLL3wmU401JrKxKLcqHSUlzsCiJ815OuekvJJCeWJKanZpakFoEk5Xh4FCS4J10 + BqhRsCg1PbUiLTOnBCHNxMEJMpwHaPhWkBre4oLE3OLMdIj8KUZFKXHeFSAJAZBERmkeXC8s + 5bxiFAd6RZj3KEgVDzBdwXW/AhrMBDR41s9//kCDSxIRUlINjCpqf098aJ67+UISZ+OxQ/Ld + vfcKMmNfm649v0DTvNt0zSEnhnL9Hu8dMw5dXSm//+3sXc23KmceMnUxviMbFl9SIHvF8ryN + /Z58I/1ZD6f/O5xYZXvq6ebgJbzqqZ1NFV92KUU5/Di+eVmxaORlNmPLZ+V5T6oCnqo+uPpz + Rf3K3Qcf/+1gElNiKc5INNRiLipOBACRbAabFAMAAA== +Cc: notmuch@notmuchmail.org +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: Sat, 14 Jul 2012 19:50:07 -0000 + +Quoth Jameson Graef Rollins on Jul 14 at 12:31 pm: +> On Fri, Jul 13 2012, Austin Clements wrote: +> > Coincidentally, this also essentially enables multi-line search result +> > formats; the only remaining non-multi-line-capable functions are +> > notmuch-search-{next,previous}-thread, which are only used +> > interactively. +> +> So I tried to experiment with multi-line search results with this patch +> series, but it didn't work. I tried adding a '\n' in one of the +> formatter fields, but I got a series of errors for each result insertion +> in the buffer. What's the way to get multi-line to work? + +That's strange. What was the error? + +I've been testing with + (("date" . "%12s ") + ("count" . "%-7s ") + ("authors" . "%-20s ") + ("subject" . "\n%s ") + ("tags" . "(%s)")) +But maybe there are other cases it doesn't handle correctly? + +> > +(defmacro notmuch-search-do-results (beg end pos-sym &rest body) +> > + "Invoke BODY for each result between BEG and END. +> > + +> > +POS-SYM will be bound to the point at the beginning of the +> > +current result." +> > + (declare (indent 3)) +> > + (let ((end-sym (make-symbol "end")) +> > + (first-sym (make-symbol "first"))) +> > + `(let ((,pos-sym (notmuch-search-result-beginning ,beg)) +> > + ;; End must be a marker in case body changes the text +> > + (,end-sym (copy-marker ,end)) +> > + ;; Make sure we examine one result, even if (= beg end) +> > + (,first-sym t)) +> > + ;; We have to be careful if the region extends beyond the +> > + ;; results. In this case, pos could be null or there could be +> > + ;; no result at pos. +> > + (while (and ,pos-sym (or (< ,pos-sym ,end-sym) ,first-sym)) +> > + (when (notmuch-search-get-result ,pos-sym) +> > + ,@body) +> > + (setq ,pos-sym (notmuch-search-result-end ,pos-sym) +> > + ,first-sym nil))))) +> +> Austin, can you explain why you use a defmacro here? I'm honestly have +> a hard time parsing what's going on here. I understand in principle how +> elisp macros work, but I don't see why it's needed here. +> +> I'm also trying to understand what the commas are doing +> (e.g. ",pos-sym"). Are they doing some sort of escaping? +> +> Some sophisticated elisp here! + +I did this as a macro to parallel things like dolist and loop, I'll +try this out with a higher-order procedure and see if the results are +less opaque. -- 2.26.2