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 475A8431FB6 for ; Sat, 5 Apr 2014 22:31:42 -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 E76VSXFl6Bnk for ; Sat, 5 Apr 2014 22:31:36 -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 27677431FAF for ; Sat, 5 Apr 2014 22:31:36 -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 1WWfg3-0003UT-Jz; Sun, 06 Apr 2014 06:31:31 +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 1WWfg3-0003R7-5q; Sun, 06 Apr 2014 06:31:31 +0100 From: Mark Walters To: Austin Clements Subject: Re: [PATCH 4/5] emacs: hello: switch notmuch-hello-insert-buttons to plists In-Reply-To: <20140406012425.GF15472@mit.edu> References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> <1396733065-32602-5-git-send-email-markwalters1009@gmail.com> <20140406012425.GF15472@mit.edu> User-Agent: Notmuch/0.15.2+615~g78e3a93 (http://notmuchmail.org) Emacs/23.4.1 (x86_64-pc-linux-gnu) Date: Sun, 06 Apr 2014 06:31:29 +0100 Message-ID: <87vbunuiq6.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-Geographic: According to ripencc, this message was delivered by a machine in Britain (UK) (GB). X-QM-SPAM-Info: Sender has good ham record. :) X-QM-Body-MD5: c74662a89db8d8693277a51c71d49895 (of first 20000 bytes) X-SpamAssassin-Score: 0.0 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.0 points. Summary of the scoring: * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider * (markwalters1009[at]gmail.com) * 0.0 AWL AWL: From: address is in the auto white-list X-QM-Scan-Virus: ClamAV says the message is clean 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: Sun, 06 Apr 2014 05:31:42 -0000 Hello >> @@ -455,23 +457,26 @@ (defun notmuch-hello-query-counts (query-list &rest options) >> #'identity >> (mapcar >> (lambda (elem) >> - (let ((name (notmuch-saved-search-get elem :name)) >> - (search-query (notmuch-saved-search-get elem :query)) >> - (message-count (prog1 (read (current-buffer)) >> + (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem)) >> + (search-query (plist-get elem-plist :query)) >> + (filtered-query (notmuch-hello-filtered-query >> + search-query (plist-get options :filter))) >> + (message-count (prog1 (read (current-buffer)) >> (forward-line 1)))) >> (and (or (plist-get options :show-empty-searches) (> message-count 0)) >> - (list name (notmuch-hello-filtered-query >> - search-query (plist-get options :filter)) >> - message-count)))) >> + (setq elem-plist (plist-put elem-plist :query filtered-query)) > > This technically works, but `setq' is a strange thing to see in an > `and'. But the problem isn't the `setq'; it's that crazy `and'. I'd > replace the `and' with `when', keep the `setq' and `plist-put' in the > body, and squint a lot less at this code. This was actually a bug on my part: the filtered query can be nil (which is used to mean hide this search); in earlier versions having a setq inside the `and' achieved this but obviously not in this plist form. I have switched to the when as suggested and added a test for filtered-query being nil. Best wishes Mark