From: Austin Clements Date: Sun, 6 Apr 2014 01:30:29 +0000 (+2000) Subject: Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7a31011a2bef9a999d2a6d05d63c92b8c05386db;p=notmuch-archives.git Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches --- diff --git a/89/192aed06b8dd66d6598954b09aa5fa45e2a76f b/89/192aed06b8dd66d6598954b09aa5fa45e2a76f new file mode 100644 index 000000000..68f35c21a --- /dev/null +++ b/89/192aed06b8dd66d6598954b09aa5fa45e2a76f @@ -0,0 +1,156 @@ +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 18F19431FB6 + for ; Sat, 5 Apr 2014 18:30:41 -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 pVckcPazvs9W for ; + Sat, 5 Apr 2014 18:30:33 -0700 (PDT) +Received: from dmz-mailsec-scanner-3.mit.edu (dmz-mailsec-scanner-3.mit.edu + [18.9.25.14]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 7827D431FAF + for ; Sat, 5 Apr 2014 18:30:33 -0700 (PDT) +X-AuditID: 1209190e-f79ee6d000000c40-08-5340ae385e56 +Received: from mailhub-auth-2.mit.edu ( [18.7.62.36]) + (using TLS with cipher AES256-SHA (256/256 bits)) + (Client did not present a certificate) + by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP + id 45.3B.03136.83EA0435; Sat, 5 Apr 2014 21:30:32 -0400 (EDT) +Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11]) + by mailhub-auth-2.mit.edu (8.13.8/8.9.2) with ESMTP id s361UVBQ024227; + Sat, 5 Apr 2014 21:30:32 -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.8/8.12.4) with ESMTP id s361UTjV021355 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); + Sat, 5 Apr 2014 21:30:30 -0400 +Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.80) + (envelope-from ) + id 1WWbun-0007BH-Fo; Sat, 05 Apr 2014 21:30:29 -0400 +Date: Sat, 5 Apr 2014 21:30:29 -0400 +From: Austin Clements +To: Mark Walters +Subject: Re: [PATCH 5/5] emacs: Add a sort-order option to saved-searches +Message-ID: <20140406013029.GG15472@mit.edu> +References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> + <1396733065-32602-6-git-send-email-markwalters1009@gmail.com> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +Content-Disposition: inline +In-Reply-To: <1396733065-32602-6-git-send-email-markwalters1009@gmail.com> +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFvrPIsWRmVeSWpSXmKPExsUixG6nomuxziHYYM0WVYvVc3ksrt+cyezA + 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZdzbaVAwX7Li9dM77A2MB4S7GDk5JARMJJ4v + 7WCGsMUkLtxbzwZiCwnMZpK4P9eii5ELyN7AKNH7cCEzhHOKSeLGnOdQzhJGiWNP7zN1MXJw + sAioSJzZHg/SzSagIbFt/3JGEFtEQEfi9qEF7CA2s4C0xLffzUwgtrCAp8Sjty2sIK28QDVN + G+whFncySmztcQGxeQUEJU7OfMIC0aolcePfS7BNIGOW/+MACXMKeEm867sIViIKdMCUk9vY + JjAKzULSPQtJ9yyE7gWMzKsYZVNyq3RzEzNzilOTdYuTE/PyUot0jfVyM0v0UlNKNzGCwplT + km8H49eDSocYBTgYlXh4L+Y5BAuxJpYVV+YeYpTkYFIS5e2aARTiS8pPqcxILM6ILyrNSS0+ + xCjBwawkwvskCCjHm5JYWZValA+TkuZgURLnfWttFSwkkJ5YkpqdmlqQWgSTleHgUJLgdVkL + 1ChYlJqeWpGWmVOCkGbi4AQZzgM0/NUakOHFBYm5xZnpEPlTjIpS4ryCIM0CIImM0jy4Xli6 + ecUoDvSKMK8OSBUPMFXBdb8CGswENLghzA5kcEkiQkqqgZFfp8HyssWE8wlyXHsy9x66ac// + JvKTHfsMmZb87f+iVD+lH8if8CC2fmn2supJlnuad0pH8PqLy/bKVNYVX36zT+3VhTUTOLnr + k8QNz53/Exbm/zKh5XXd0y3v652r+iv5JVY7FCSUl/P3C7vI73hV2/e/1VPRdqvJthvTv8Ur + +otX7by3UImlOCPRUIu5qDgRALxS48sSAwAA +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 01:30:41 -0000 + +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)) + +> (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!) + +> + (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"))