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 5F155431FD7 for ; Sat, 14 Jul 2012 12:31:52 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -2.29 X-Spam-Level: X-Spam-Status: No, score=-2.29 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_MED=-2.3, T_MIME_NO_TEXT=0.01] 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 j5dQuSuBn-OL for ; Sat, 14 Jul 2012 12:31:52 -0700 (PDT) Received: from outgoing-mail.its.caltech.edu (outgoing-mail.its.caltech.edu [131.215.239.19]) by olra.theworths.org (Postfix) with ESMTP id E924C431FBC for ; Sat, 14 Jul 2012 12:31:51 -0700 (PDT) Received: from earth-doxen.imss.caltech.edu (localhost [127.0.0.1]) by earth-doxen-postvirus (Postfix) with ESMTP id 9AF1566E00D3; Sat, 14 Jul 2012 12:31:51 -0700 (PDT) X-Spam-Scanned: at Caltech-IMSS on earth-doxen by amavisd-new Received: from finestructure.net (unknown [76.89.192.57]) (Authenticated sender: jrollins) by earth-doxen-submit (Postfix) with ESMTP id C0E4966E00AE; Sat, 14 Jul 2012 12:31:48 -0700 (PDT) Received: by finestructure.net (Postfix, from userid 1000) id 5CFFD73E; Sat, 14 Jul 2012 12:31:48 -0700 (PDT) From: Jameson Graef Rollins To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH v2 4/7] emacs: Use result text properties for search result iteration In-Reply-To: <1342237406-32507-5-git-send-email-amdragon@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> User-Agent: Notmuch/0.13.2+82~gd0a8b58 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sat, 14 Jul 2012 12:31:45 -0700 Message-ID: <87d33yf8bi.fsf@servo.finestructure.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" 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:31:52 -0000 --=-=-= Content-Transfer-Encoding: quoted-printable 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? > +(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 (=3D 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?=20=20 Some sophisticated elisp here! jamie. --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCAAGBQJQAckiAAoJEO00zqvie6q8npUP/0BHgS9V1uRn9POipVtZM6CQ eR4Y3QTJf7gn1JGcvAnrWtbVrobWu3sW3eKdsZaNdxQ+BWZPhuoSihjDSOAgK157 Mr7dj9s5Qj7FctvS4TNKWhcpr6L7NECngKQnulPIqK51tyVKqgueeBko0+x/xC5o JKtDWEeONdBpvEV7FlPR9kDvpIv6CFLlllTrRokmsFS2t11ueOP3iSyAD7vxtRUG WSs0uBtr0v2CXcKtJW1FT/KcW3r4k6/AOM0Zp10AUfQVkz+yt8+AqdY1eD/Py06o tyUdmtmuMqWhUxuw4dQEUKMJvxzmoj8uq9Y+a60FQJKD3VyhZgkJs3WDylMokUjE CbhdBehaEa5fFqFhI9pWixQ8EeSVYgVAID2XVuITUeWYQ/KZlEArQgksqyMOx8BM lzmyT8kvJ9qD78D131v9HFe98stzoqz88q67xTGww+1ySd2vyI8DoaIIMS74PlR8 bn6+FE2C0PDuvhJYqdmf+vVV0HaPENc+KI+hzsBm+KcVEcUqjouiSXCM3ocVmgPJ zhvGOE7Uw9W8vb+eG+by+NMkZ1vyto3tKzZTlYDdUWGfE1OlU6ch1V6SXLiCciLZ se4QDQy2xw+ZVUHVShxsvDl5npRnMImxTDli+9A7eELfyy2Ae9arcFo9DxBjM1pJ 2QsFRFnNIs3y0FIcPG5M =JQX1 -----END PGP SIGNATURE----- --=-=-=--