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 1EA97431FB6 for ; Sat, 5 Apr 2014 22:32:56 -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 Tj9qif13kcsG for ; Sat, 5 Apr 2014 22:32:48 -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 C3FB8431FAF for ; Sat, 5 Apr 2014 22:32:47 -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 1WWfh6-0003kf-DU; Sun, 06 Apr 2014 06:32:45 +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 1WWfh6-0003Ry-36; Sun, 06 Apr 2014 06:32:36 +0100 From: Mark Walters To: Austin Clements Subject: Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches In-Reply-To: <20140406013029.GG15472@mit.edu> References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> <1396733065-32602-6-git-send-email-markwalters1009@gmail.com> <20140406013029.GG15472@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:32:35 +0100 Message-ID: <87sipruioc.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: 95a750182b32e53587c6ff5a3d2ab059 (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:32:56 -0000 Hi On Sun, 06 Apr 2014, Austin Clements wrote: > Quoth Mark Walters on Apr 05 at 10:24 pm: >> This adds a sort-order option to saved-searches, stores it in the >> saved-search buttons (widgets), and uses the stored value when the >> button is pressed. >> >> Storing the sort-order in the widget was suggested by Jani in >> id:4c3876274126985683e888641b29cf18142a5eb8.1391771337.git.jani@nikula.org. >> --- >> emacs/notmuch-hello.el | 11 ++++++++++- >> emacs/notmuch-lib.el | 7 ++++++- >> 2 files changed, 16 insertions(+), 2 deletions(-) >> >> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el >> index aa40e6f..6a28372 100644 >> --- a/emacs/notmuch-hello.el >> +++ b/emacs/notmuch-hello.el >> @@ -364,7 +364,8 @@ (defun notmuch-hello-reflect (list ncols) >> (defun notmuch-hello-widget-search (widget &rest ignore) >> (notmuch-search (widget-get widget >> :notmuch-search-terms) >> - notmuch-search-oldest-first)) >> + (widget-get widget >> + :notmuch-search-oldest-first))) >> >> (defun notmuch-saved-search-count (search) >> (car (process-lines notmuch-command "count" search))) >> @@ -496,12 +497,20 @@ (defun notmuch-hello-insert-buttons (searches) >> (widget-insert (make-string column-indent ? ))) >> (let* ((name (plist-get elem :name)) >> (query (plist-get elem :query)) >> + (oldest-first (cond >> + ((eq (plist-get elem :sort-order) 'newest-first) >> + nil) >> + ((eq (plist-get elem :sort-order) 'oldest-first) >> + t) >> + (t >> + notmuch-search-oldest-first))) > > (case (plist-get elem :sort-order) > (newest-first nil) > (oldest-first t) > (otherwise notmuch-search-oldest-first)) This is much better. > >> (msg-count (plist-get elem :count))) >> (widget-insert (format "%8s " >> (notmuch-hello-nice-number msg-count))) >> (widget-create 'push-button >> :notify #'notmuch-hello-widget-search >> :notmuch-search-terms query >> + :notmuch-search-oldest-first oldest-first >> name) >> (setq column-indent >> (1+ (max 0 (- column-width (length name))))))) >> diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el >> index 8a12f91..8aa8cfc 100644 >> --- a/emacs/notmuch-lib.el >> +++ b/emacs/notmuch-lib.el >> @@ -125,7 +125,12 @@ (define-widget 'notmuch-saved-search-plist 'list >> (group :format "%v" :inline t (const :format " Query: " :query) (string :format "%v"))) >> (checklist :inline t >> :format "%v" >> - (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v"))))) >> + (group :format "%v" :inline t (const :format "Count-Query: " :count-query) (string :format "%v")) >> + (group :format "%v" :inline t (const :format "" :sort-order) >> + (choice :tag " Sort Order" > > Should there be a colon? (I haven't applied the patches and I'm > afraid this is beyond my mental implementation of define-widget!) I think it is OK without: since this is using :tag rather than :format the colon is supplied automatically. Many thanks Mark > >> + (const :tag "Default" nil) >> + (const :tag "Oldest-first" oldest-first) >> + (const :tag "Newest-first" newest-first)))))) >> >> (defcustom notmuch-saved-searches '((:name "inbox" :query "tag:inbox") >> (:name "unread" :query "tag:unread"))