From: Mark Walters Date: Sat, 5 Apr 2014 21:24:25 +0000 (+0100) Subject: [PATCH 5/5] emacs: Add a sort-order option to saved-searches X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=09a9629df253ce31038a02105d370e0492eaf88c;p=notmuch-archives.git [PATCH 5/5] emacs: Add a sort-order option to saved-searches --- diff --git a/ce/3dfe25d90e6a4b6a965aad6a142162f270c876 b/ce/3dfe25d90e6a4b6a965aad6a142162f270c876 new file mode 100644 index 000000000..edf79783e --- /dev/null +++ b/ce/3dfe25d90e6a4b6a965aad6a142162f270c876 @@ -0,0 +1,130 @@ +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 BF996431FAF + for ; Sat, 5 Apr 2014 14:25:06 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + 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 QgKJ6--b3H4W for ; + Sat, 5 Apr 2014 14:24:58 -0700 (PDT) +Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com + [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id AEDA0431FC7 + for ; Sat, 5 Apr 2014 14:24:52 -0700 (PDT) +Received: by mail-wi0-f174.google.com with SMTP id d1so3104996wiv.7 + for ; Sat, 05 Apr 2014 14:24:51 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:in-reply-to:references; + bh=ZGtKMQzv/4fXbY06ReixlWCJwNjbLNz3AM8G7l5IpwE=; + b=Vk18QOPt+KK+z7PkOH4xX9YPhUeDsByobolUOmQ7i9NFHOwfri0zDADd9oT7kBjZXz + Jtpsia0+/f6mM0TqBHcRD7ChzXbgROtSMCSCWqp3fazxQPJFg/Nj8mqe2FOyoe1X9TTW + iOZk3feNxIrrGH4B2gnRmRnMG4dmb31Mp5gMnF/zSupaMjtrGK3x9Nb7mjs29m8f6ppy + Bf69hohyJ/ZEXaIK8QmpUl2BymPUiYY6ISDsAEzejgwUxUCzdvhr5r0m/WCgBJ5x0RI5 + JqBWIfu3o40UOdcxV85XXLfbZ5/BWHiiiLKGG43vH2qRbs+wDVM3Sk9i7sGci745OUMg + AXWw== +X-Received: by 10.180.96.200 with SMTP id du8mr14433808wib.43.1396733091623; + Sat, 05 Apr 2014 14:24:51 -0700 (PDT) +Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31]) + by mx.google.com with ESMTPSA id gi8sm6779580wib.8.2014.04.05.14.24.50 + for + (version=TLSv1.2 cipher=RC4-SHA bits=128/128); + Sat, 05 Apr 2014 14:24:51 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 5/5] emacs: Add a sort-order option to saved-searches +Date: Sat, 5 Apr 2014 22:24:25 +0100 +Message-Id: <1396733065-32602-6-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.10.4 +In-Reply-To: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> +References: <1396733065-32602-1-git-send-email-markwalters1009@gmail.com> +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, 05 Apr 2014 21:25:07 -0000 + +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))) + (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" ++ (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")) +-- +1.7.10.4 +