From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id UMF7MWyRc2IZZAEAbAwnHQ (envelope-from ) for ; Thu, 05 May 2022 10:57:16 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id EF1IMWyRc2IdRAEA9RJhRA (envelope-from ) for ; Thu, 05 May 2022 10:57:16 +0200 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (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 95A0A1771 for ; Thu, 5 May 2022 10:57:16 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id AA9D85F753; Thu, 5 May 2022 08:57:13 +0000 (UTC) Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050:0:465::201]) by mail.notmuchmail.org (Postfix) with ESMTPS id 877E65F74D for ; Thu, 5 May 2022 08:57:11 +0000 (UTC) Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Kv6yZ2ZQLz9sS9; Thu, 5 May 2022 10:57:10 +0200 (CEST) From: Leo Okawa Ericson To: notmuch@notmuchmail.org Subject: [PATCH v3] emacs: Make notmuch-show-next-thread return nil on failure Date: Thu, 5 May 2022 10:56:07 +0200 Message-Id: <20220505085605.8224-1-git@relevant-information.com> MIME-Version: 1.0 Message-ID-Hash: Y24RKZVY3AASIDWLEIKTXTISJQL46RZS X-Message-ID-Hash: Y24RKZVY3AASIDWLEIKTXTISJQL46RZS X-MailFrom: sourcehut@relevant-information.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 CC: Leo Okawa Ericson X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1651741036; 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:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=qcncxweow6NI0TiRXtXDSWq/BvxE+Ir0zLNOkaExvgQ=; b=FZzeA2RXsTW+Sr6ABJOrZ3QOWUtFDd4WHtAWNYshcNTlztxeAedM6cZzUbs9IiLjzCK4sJ TYb6JucbJBtEW2Jr7jtLhCRlP0q+hFro1KVR+Y3Qhn+sI/N/N3y2pNyKLsORf6oAECw2fI 51pmgjc+Z9eMmJRQXtr6+TMEQsPoTY/EBAu3Ol2N5wGWOh/gfMlKbi0+arYmwuBfIHve3+ geMOwUWvHW9Hvyx4oYAhKgOg/RTdy5njVoxCNVX5PK+z0SB3ulCSMAvBAeMGKHEs8Mp1g7 6uX4cnMePbrZUIvBA8txj5Bw3+8zHkZbA8TuiEC7N6sTC02pPRVfGxW2V6sUbA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651741036; a=rsa-sha256; cv=none; b=ufFB6TJs2TW+JcxFItg1FOfPpb+9e+B9wVQHZ34lhclBZNt2ModqMxxKA5+0Pu1fI6ze3h TjF28VeLe/ac81UB7lOcijqe7AuElDyKCyigeXQDrYpS0VhnTM0RHTaRmmZ/cygxkewHkw iUEloum29SdfjZrSCw6OWvKNndt9+OwPxR2dkWl8k04Aj4WAP+6wfn2KOFi77geTjYXpu5 xkRarINxcYbnFcPm0ayFo1lkp0zEvj85uTj4uAs8HgOJ1QPWU4Nhm25F3M/wJRTp4z10rc MkPSVl9SGUmR9SrAzkLX0gJ91iOnF+sn8Pcm2KTqVLIdI7+0qMm7SUu+ZBSAzQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.55 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 95A0A1771 X-Spam-Score: -1.55 X-Migadu-Scanner: scn0.migadu.com X-TUID: tDAhRyp4GmLm Having notmuch-show-next-thread return non-nil on success and nil on failure makes it easier for users to interact with notmuch via elisp. This commit changes notmuch-search-show-thread too since the return value of notmuch-show-next-thread depends on notmuch-search-show-thread. --- I removed the indentation commit because it was plain wrong. Otherwise it's the same as the previous patch series. Previous patch message id: id:20220502151849.6364-1-git@relevant-information.com emacs/notmuch-show.el | 4 +++- emacs/notmuch.el | 7 +++++-- test/T450-emacs-show.sh | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 7c1f02c9..5a2bbe5c 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -2205,7 +2205,9 @@ (defun notmuch-show-next-thread (&optional show previous) If SHOW is non-nil, open the next item in a show buffer. Otherwise just highlight the next item in the search buffer. If PREVIOUS is non-nil, move to the previous item in the -search results instead." +search results instead. + +Return non-nil on success." (interactive "P") (let ((parent-buffer notmuch-show-parent-buffer)) (notmuch-bury-or-kill-this-buffer) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c9cf80dc..01a92997 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -520,7 +520,9 @@ (defun notmuch-search-show-thread (&optional elide-toggle) With a prefix argument, invert the default value of `notmuch-show-only-matching-messages' when displaying the -thread." +thread. + +Return non-nil on success." (interactive "P") (let ((thread-id (notmuch-search-find-thread-id))) (if thread-id @@ -532,7 +534,8 @@ (defun notmuch-search-show-thread (&optional elide-toggle) (format "*%s*" (truncate-string-to-width (notmuch-search-find-subject) 30 nil nil t))) - (message "End of search results.")))) + (message "End of search results.") + nil))) (defun notmuch-tree-from-search-current-query () "Tree view of current query." diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 057ad37e..ee25a403 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -62,6 +62,22 @@ test_emacs '(let ((notmuch-crypto-process-mime nil)) (test-visible-output))' test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT +test_begin_subtest "notmuch-search-show-thread returns non-nil on success" +test_emacs_expect_t '(notmuch-search "id:20091117203301.GV3165@dottiness.seas.harvard.edu") + (when (notmuch-search-show-thread) + (error "Expected non-nil when successfully showing a thread")) + (when (notmuch-show-next-thread) + (error "Expected nil when there are no more threads")) + t' + +test_begin_subtest "notmuch-show-next-thread returns non-nil on success" +test_emacs_expect_t '(notmuch-search "id:20091117203301.GV3165@dottiness.seas.harvard.edu") + (when (notmuch-show-next-thread) + (error "Expected non-nil when successfully showing a thread")) + (when (notmuch-show-next-thread) + (error "Expected nil when there are no more threads")) + t)' + test_begin_subtest "notmuch-show: don't elide non-matching messages" test_emacs '(let ((notmuch-show-only-matching-messages nil)) (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"") base-commit: b2eb0547e172dd766ccbc062319faa90a9500518 -- 2.36.0