From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id yERPHHv2b2LROwEAbAwnHQ (envelope-from ) for ; Mon, 02 May 2022 17:19:23 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id APNoHHv2b2LNugAA9RJhRA (envelope-from ) for ; Mon, 02 May 2022 17:19:23 +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 F1B421FC17 for ; Mon, 2 May 2022 17:19:22 +0200 (CEST) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 703165F70B; Mon, 2 May 2022 15:19:20 +0000 (UTC) Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [IPv6:2001:67c:2050:0:465::202]) by mail.notmuchmail.org (Postfix) with ESMTPS id 1812C5F6C9 for ; Mon, 2 May 2022 15:19:18 +0000 (UTC) Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (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-202.mailbox.org (Postfix) with ESMTPS id 4KsRZq1PKBz9srS for ; Mon, 2 May 2022 17:19:15 +0200 (CEST) From: Leo Okawa Ericson To: notmuch@notmuchmail.org Subject: [PATCH v2 2/2] emacs: Make notmuch-show-next-thread return nil on failure Date: Mon, 2 May 2022 17:18:50 +0200 Message-Id: <20220502151849.6364-2-git@relevant-information.com> In-Reply-To: <20220502151849.6364-1-git@relevant-information.com> References: <20220502151849.6364-1-git@relevant-information.com> MIME-Version: 1.0 Message-ID-Hash: 7MAX2DLRTBDF6OVI7223YFLP7L2JDZC2 X-Message-ID-Hash: 7MAX2DLRTBDF6OVI7223YFLP7L2JDZC2 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 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=1651504763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to: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-owner:list-unsubscribe:list-subscribe:list-post; bh=O3QR3brPzY/fiYWLVvKUUVN8RdEx7xakCdghF6C4lz8=; b=NjzQD0MN7+t7Cyb+bOWSLOUr91MJ8Z/lhntNNBfnKUFUoYa5+2pNhLB5WDGoIJ8eVvnd4T KavcPmHgD65bUx0hB14mvPJg+dxfL7qC04/dHXDPFJOO1w+tcOZfE1vat6yC1ZKz2JGBHc x85VKGqr5Wula8h1HaY7s0nzepCCGl9KZUbibB2+HDVt2GMPIBdM0+2CawVCnv1WkHWEHA LeeSZVHBg/MpLZR86Nf8f/gTo0xMPjquvmHUHrOf7sDJ4I1RXf0+8+g2Zp50arGcF4fmJw j9TXh5YNUg1TJLDB5JHjhMN8LU8SJ7wpWtE0D/6Xrew0VEmKhvGLrsStSSxing== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1651504763; a=rsa-sha256; cv=none; b=li3ymHg38VYsjfAimZjHTCE452/73wngp9LFHfub/tweK+/vaZFdj1NZZ+gD2B9OSeY8eP zfbkMwVY6ilHWqNzN7kwKR02otQUvOP5bZsJ76bnNdRXTCyVfZwLbsY7/OU5JnW0iOpy7t vSl08F2wng5p/Fhu0SzsrXk1+TlI/+8MFFA+m6hruTaymhkmobwQNTjz8W1sicxx3UK4HW K+2WZXmIAdL2RAklFujJ1ASuh/2HCiM58Ye1YZP18OqCODkCHSoys/pfJ5okNf5k/iAkfa 0Jlkil28EJamFVKaTVjuwcs+JGkeFxI+1PjxANNDXNpX4IyPgD8Q6pZnIUi+AA== 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.04 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: F1B421FC17 X-Spam-Score: -1.04 X-Migadu-Scanner: scn1.migadu.com X-TUID: RpwxlLcjjlbc 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've added docstrings and tests, but I'm not sure if the location I put the tests in is appropriate. 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 c1ddb06b..a87d416a 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\"") -- 2.36.0