From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EHW2HtNs12AddQAAgWs5BA (envelope-from ) for ; Sat, 26 Jun 2021 20:07:15 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id QE5rGtNs12DBZAAAB5/wlQ (envelope-from ) for ; Sat, 26 Jun 2021 18:07:15 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DF98F11047 for ; Sat, 26 Jun 2021 20:07:14 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 114DD290DF; Sat, 26 Jun 2021 14:07:03 -0400 (EDT) Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by mail.notmuchmail.org (Postfix) with ESMTPS id 8DBA62904D for ; Sat, 26 Jun 2021 14:06:55 -0400 (EDT) Received: from fencepost.gnu.org ([2001:470:142:3::e]:35636) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lxChj-0003N7-86; Sat, 26 Jun 2021 14:06:55 -0400 Received: from cpc103048-sgyl39-2-0-cust502.18-2.cable.virginm.net ([92.233.85.247]:46268 helo=osgiliath.local) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lxChi-0000I6-W8; Sat, 26 Jun 2021 14:06:55 -0400 From: jao To: notmuch@notmuchmail.org Subject: [PATCH 3/5] emacs/hello: honouring :sort-order in threaded queries Date: Sat, 26 Jun 2021 19:06:48 +0100 Message-Id: <20210626180650.342569-4-jao@gnu.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210626180650.342569-1-jao@gnu.org> References: <20210626022846.233052-1-jao@gnu.org> <20210626180650.342569-1-jao@gnu.org> MIME-Version: 1.0 Message-ID-Hash: SHYRG6TRPY3HUBJMDXB7NQEPRXE4GKXT X-Message-ID-Hash: SHYRG6TRPY3HUBJMDXB7NQEPRXE4GKXT X-MailFrom: jao@gnu.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: jao X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624730835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ERhfQTpewma9jiStYUmEvIBF6YlaqvI5G75noFEUKJg=; b=Cc919gZdwvgYuKkRaniI+m1aqpwZKtU2WlAlNwHCc6Zp+KHJ92NauoYMvsKAvQtFKSd6VR pMAha0LgTUMP9kywqkkEh+YWEarKtdpJzCVhZV7MozfQ4S5Gvi+9ss91DnTRmvl0AsKprS wrucMNPnuUvXYB2UfMgRzz0KQdo04jLAyv+83Yz3MzWSpt1rN3G6wTv/Rj6QN5SNW1b68R UnvmF7kKWjbNEh/W263h5Teg72IDpQGOtXP4rxViT5qR9JQZx0ZhBbWrAuvFM7viXdM/ur cxIdLlGfFvQ9mqy/CvWQTEtM7V307GeeK/zRXDZ6gt85QXIDJWfyKu+2o4MbpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624730835; a=rsa-sha256; cv=none; b=moXoPJzbXdhkMUKm6YlWsnhd3OKb1yveT2G/55jRiHvL+Xba3jdnEBGAo2sYrQfo4YOKVq SRSt6MNmXHB0coumlWPNjrd9f8910KdKpbAXNsHagsRB2GOniK+V7F6cqeqPeXUJBAwZT+ 7LHSKytkwCHA35g1xNBDx+tccEZpeJbLkJFIrUPRZurHULINNrlDBPrg09cJk5tjvq63Hy jYeW04y1inVD0HOSCAgU2lZYvvJWy/3llFS3Dz2VfEiNeP4OqeYP8j//u1zbArDOKTkCQB 8pr+o5gViyHqacKE0VbFRFZYVMBT9Wl7sqolVh9Dqp8EjvYDTFGs7ZKKxd/Mkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gnu.org (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.96 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gnu.org (policy=none); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: DF98F11047 X-Spam-Score: -0.96 X-Migadu-Scanner: scn0.migadu.com X-TUID: 5cTPjjQjwyOt Now that notmuch show accepts --sort, we can, on the emacs side, use it according to the value of :sort-order in the definition of saved queries. --- emacs/notmuch-hello.el | 4 +++- emacs/notmuch-tree.el | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 531f209d..5e1ff5fe 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -484,7 +484,9 @@ diagonal." (defun notmuch-hello-widget-search (widget &rest _ignore) (cl-case (widget-get widget :notmuch-search-type) (tree - (notmuch-tree (widget-get widget :notmuch-search-terms))) + (notmuch-tree (widget-get widget :notmuch-search-terms) + nil nil nil nil nil nil + (widget-get widget :notmuch-search-oldest-first))) (unthreaded (notmuch-unthreaded (widget-get widget :notmuch-search-terms))) (t diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 00ee78d6..6ef8e439 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1062,7 +1062,8 @@ Complete list of currently available key bindings: (notmuch-sexp-parse-partial-list 'notmuch-tree-insert-forest-thread results-buf))))) -(defun notmuch-tree-worker (basic-query &optional query-context target open-target unthreaded) +(defun notmuch-tree-worker (basic-query &optional query-context target + open-target unthreaded oldest-first) "Insert the tree view of the search in the current buffer. This is is a helper function for notmuch-tree. The arguments are @@ -1088,6 +1089,7 @@ the same as for the function notmuch-tree." (let* ((search-args (concat basic-query (and query-context (concat " and (" query-context ")")))) + (sort-arg (if oldest-first "--sort=oldest-first" "--sort=newest-first")) (message-arg (if unthreaded "--unthreaded" "--entire-thread"))) (when (equal (car (process-lines notmuch-command "count" search-args)) "0") (setq search-args basic-query)) @@ -1095,7 +1097,7 @@ the same as for the function notmuch-tree." (let ((proc (notmuch-start-notmuch "notmuch-tree" (current-buffer) #'notmuch-tree-process-sentinel "show" "--body=false" "--format=sexp" "--format-version=4" - message-arg search-args)) + sort-arg message-arg search-args)) ;; Use a scratch buffer to accumulate partial output. ;; This buffer will be killed by the sentinel, which ;; should be called no matter how the process dies. @@ -1114,7 +1116,7 @@ the same as for the function notmuch-tree." notmuch-tree-basic-query)) (defun notmuch-tree (&optional query query-context target buffer-name - open-target unthreaded parent-buffer) + open-target unthreaded parent-buffer oldest-first) "Display threads matching QUERY in tree view. The arguments are: @@ -1143,7 +1145,7 @@ The arguments are: (pop-to-buffer-same-window buffer)) ;; Don't track undo information for this buffer (setq buffer-undo-list t) - (notmuch-tree-worker query query-context target open-target unthreaded) + (notmuch-tree-worker query query-context target open-target unthreaded oldest-first) (setq notmuch-tree-parent-buffer parent-buffer) (setq truncate-lines t)) -- 2.32.0