Re: [PATCH v2 4/7] emacs: Use result text properties for search result iteration
authorAustin Clements <amdragon@MIT.EDU>
Sat, 14 Jul 2012 19:50:03 +0000 (15:50 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:18 +0000 (09:48 -0800)
b3/43579aed710cbd3bba409725909808d27677e6 [new file with mode: 0644]

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