From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eLnsDhEu/GFkSAEAgWs5BA (envelope-from ) for ; Thu, 03 Feb 2022 20:33:37 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id +MaeCxEu/GFLKAAAauVa8A (envelope-from ) for ; Thu, 03 Feb 2022 20:33:37 +0100 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 C78863B639 for ; Thu, 3 Feb 2022 20:33:36 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id E36C05F705; Thu, 3 Feb 2022 19:33:31 +0000 (UTC) X-Greylist: delayed 568 seconds by postgrey-1.36 at yantan; Thu, 03 Feb 2022 19:18:46 UTC Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by mail.notmuchmail.org (Postfix) with ESMTPS id 894345F6F1 for ; Thu, 3 Feb 2022 19:18:46 +0000 (UTC) Date: Thu, 03 Feb 2022 20:09:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lobber.eu; s=key1; t=1643915357; 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; bh=Orpqw+KUaeCOXaUmZjrBJhHnbwkb/ayrJSEHl7O52Bo=; b=U/FIbOJhG954uRNlR87OjZSIcV1F8ub98B4ytyPLXA08SWm83sILztSImbsxMP0pbRTsuU H/8krAoPpeNP4F6GtliT/MZt68DTIAn5BDqAZuqa8E5UMp4YtLpN0sS43YVH2BxEqujZY4 u/Nvu9pYxmXhh1vBa3wsZtP32GKrxY4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Miguel Bernabeu To: notmuch@notmuchmail.org, David Bremner Subject: Re: [RFC PATCH v2 09/12] emacs: add notmuch-tag-undo In-Reply-To: <20220203143254.3344753-10-david@tethera.net> References: <20220203143254.3344753-1-david@tethera.net> <20220203143254.3344753-10-david@tethera.net> Message-ID: <2622A6E4-DA2B-459F-B8D5-30070CDF1697@lobber.eu> MIME-Version: 1.0 X-MailFrom: miguel.bernabeu@lobber.eu 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 Message-ID-Hash: QCVTEMZSBNIC7NGBPCAKDNN243OP4IA6 X-Message-ID-Hash: QCVTEMZSBNIC7NGBPCAKDNN243OP4IA6 X-Mailman-Approved-At: Thu, 03 Feb 2022 19:33:30 +0000 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-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643916816; 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:dkim-signature; bh=gvpInohjFGD4D01XGu/A8DXoRkwOcENJN8GaYzF16SQ=; b=hvBHoKpqymqDvqiMvJhUs8CSHAosbyrvWjU4ElwfmZ9yZ71yQuUpiNnTC72piAb2Ys/clr xAiBNKDtMax08pf7SSnvJ554j+hUlUe/wcKr4jrccoQSti9ca5PPyvs6aJkoa/vfI6A2eP 3DE03DldEmrafG9tkqFjP9hS5jYMi8Ir8JhyScfpgO6QnmwcwzLNJ1ZsA0pIDiea0vndda ZR5kwzf0dv2oIokmXrT3rdf6KiYEFgqqXiPj2Iy8m75QBlfKkjm70/NA9Hp2YyJ3knJ9NR bJw7TizldLwHNDstOZPQW1lsEHOSoZp9xjoMNUjLOdGJUfssEpx7uXM17ION6w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643916816; a=rsa-sha256; cv=none; b=lx8MM3OHwHSFfUSdxhYvVbFK1AoPm+BHh/m6NA762vIN4AoVYVEIRdywqcnphxoHEGcLyl 4EhVN8g3cHw45f0SpjA8Ciz9xzw7ytSPTLGeRCpzvcvtisw7jaqHE952u/5Bqv54BM7nnd 9GdQ+POImowPO1wbbm5jtjph1Y3sIqxrSl8YfXb24b/1JeN9zRzDK6gLf/gxofejlwZPIy n2dwdrMO4jY2pgoyWgEkDdv4nMmFjtPKJWjVYsajkVgpqbzjIl82McDYhsCb/HB2T0h3rN 6jISNtGuge5qhUbeu2pwkOy2cQcDUWl6EVpQ2BehAANbnAjQ0WJ6vu4RBbDPFg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=lobber.eu header.s=key1 header.b="U/FIbOJh"; 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.35 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=lobber.eu header.s=key1 header.b="U/FIbOJh"; 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: C78863B639 X-Spam-Score: -1.35 X-Migadu-Scanner: scn1.migadu.com X-TUID: neQ9HprRPViL Just a typo that jumped to my eye. Sorry, I'm not proficient in elisp to validate the rest. On February 3, 2022 3:32:51 PM GMT+01:00, David Bremner wrote: >Keybindings are deferred to a future commit. >--- > doc/notmuch-emacs.rst | 15 +++++++++++ > emacs/notmuch-tag.el | 14 ++++++++++ > test/T315-emacs-tagging.sh | 52 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 81 insertions(+) > >diff --git a/doc/notmuch-emacs.rst b/doc/notmuch-emacs.rst >index f2667de1..670d2925 100644 >--- a/doc/notmuch-emacs.rst >+++ b/doc/notmuch-emacs.rst >@@ -383,6 +383,21 @@ operations specified in ``notmuch-tagging-keys``; i.e. each > > |docstring::notmuch-tagging-keys| > >+.. _notmuch-tag-undo: >+ >+notmuch-tag-undo >+---------------- >+ >+Each each notmuch buffer supporting tagging operations (i.e buffers in Duplicated `each`. >+:any:`notmuch-show`, :any:`notmuch-search`, :any:`notmuch-tree`, and >+:any:`notmuch-unthreaded` mode) keeps a local stack of tagging >+operations. These can be undone via ``notmuch-tag-undo``. By default >+this is bound to the usual emacs keys for undo. >+ >+:index:`notmuch-tag-undo` >+ >+ |docstring::notmuch-tag-undo| >+ > Buffer navigation > ================= > >diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el >index 4c974679..95977881 100644 >--- a/emacs/notmuch-tag.el >+++ b/emacs/notmuch-tag.el >@@ -278,6 +278,7 @@ This can be used with `notmuch-tag-format-image-data'." > ;;; track history of tag operations > (defvar-local notmuch-tag-history nil > "Buffer local history of `notmuch-tag' function.") >+(put 'notmuch-tag-history 'permanent-local t) > > ;;; Format Handling > >@@ -502,6 +503,19 @@ notmuch-after-tag-hook will be run." > (query query)) > (run-hooks 'notmuch-after-tag-hook))) > >+(defun notmuch-tag-undo () >+ "Undo the previous tagging operation in the current buffer. Uses >+buffer local variable `notmuch-tag-history' to determine what >+that operation was." >+ (interactive) >+ (when (null notmuch-tag-history) >+ (error "no further notmuch undo information")) >+ (let* ((action (pop notmuch-tag-history)) >+ (query (plist-get action :query)) >+ (changes (notmuch-tag-change-list (plist-get action :tag-changes) t))) >+ (notmuch-tag query changes t)) >+ (notmuch-refresh-this-buffer)) >+ > (defun notmuch-tag-change-list (tags &optional reverse) > "Convert TAGS into a list of tag changes. > >diff --git a/test/T315-emacs-tagging.sh b/test/T315-emacs-tagging.sh >index 02fd3d27..d76b5ab8 100755 >--- a/test/T315-emacs-tagging.sh >+++ b/test/T315-emacs-tagging.sh >@@ -103,5 +103,57 @@ test_emacs '(notmuch-search "subject:\"search race test\" -subject:two") > output=$(notmuch search --output=messages 'tag:search-global-race-tag') > test_expect_equal "$output" "id:$gen_msg_id_1" > >+test_begin_subtest "undo with empty history is an error" >+test_emacs "(let ((notmuch-tag-history nil)) >+ (test-log-error >+ (notmuch-tag-undo))) >+ " >+cat < EXPECTED >+(error no further notmuch undo information) >+EOF >+test_expect_equal_file EXPECTED MESSAGES >+ >+for mode in search show tree unthreaded; do >+ test_begin_subtest "undo tagging in $mode mode" >+ test_emacs "(let ((notmuch-tag-history nil)) >+ (notmuch-$mode \"$os_x_darwin_thread\") >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+tag-to-be-undone-$mode\") >+ (notmuch-tag-undo))" >+ count=$(notmuch count "tag:tag-to-be-undone-$mode") >+ test_expect_equal "$count" "0" >+ >+ test_begin_subtest "undo tagging in $mode mode (multiple operations)" >+ test_emacs "(let ((notmuch-tag-history nil)) >+ (notmuch-$mode \"$os_x_darwin_thread\") >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+one-$mode\") >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+two-$mode\") >+ (notmuch-test-wait) >+ (notmuch-tag-undo) >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+three-$mode\"))" >+ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) >+ notmuch tag "-one-$mode" "-three-$mode" $os_x_darwin_thread >+ test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox one-$mode three-$mode unread)" >+ >+ test_begin_subtest "undo tagging in $mode mode (multiple undo)" >+ test_emacs "(let ((notmuch-tag-history nil)) >+ (notmuch-$mode \"$os_x_darwin_thread\") >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+one-$mode\") >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+two-$mode\") >+ (notmuch-tag-undo) >+ (notmuch-test-wait) >+ (notmuch-tag-undo) >+ (notmuch-test-wait) >+ (execute-kbd-macro \"+three-$mode\"))" >+ output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize) >+ notmuch tag "-one-$mode" "-three-$mode" $os_x_darwin_thread >+ test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox three-$mode unread)" >+done >+ > > test_done