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 ms0.migadu.com with LMTPS id mExiBJIYCGLFqAAAgWs5BA (envelope-from ) for ; Sat, 12 Feb 2022 21:29:06 +0100 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 sN/DAZIYCGLnwQAA9RJhRA (envelope-from ) for ; Sat, 12 Feb 2022 21:29:06 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (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 C37452BDDA for ; Sat, 12 Feb 2022 21:29:05 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id E7E585F73E; Sat, 12 Feb 2022 20:28:55 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4C61F5F723 for ; Sat, 12 Feb 2022 20:28:53 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 88C755FBD4; Sat, 12 Feb 2022 15:28:52 -0500 (EST) Received: (nullmailer pid 2577363 invoked by uid 1000); Sat, 12 Feb 2022 20:27:56 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH v4 07/11] emacs/tag: keep tag history Date: Sat, 12 Feb 2022 16:27:38 -0400 Message-Id: <20220212202742.2577237-8-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220212202742.2577237-1-david@tethera.net> References: <20220212202742.2577237-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: KBAMABAFZ7WIZ3J7NKIFQRTQITCP6GPF X-Message-ID-Hash: KBAMABAFZ7WIZ3J7NKIFQRTQITCP6GPF X-MailFrom: bremner@tethera.net 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; digests; suspicious-header 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=1644697745; 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=8nr8z/FRwUUu4oumPo9UamDK5vs1Ooim4nd6euSnaro=; b=MRvoCT2HhC5pV9iI4YI0I+XWte2sFeGGFeSaf9ZwlAokatQltHM4TZ7DG1iElaL+1rI7ZZ 6XgI/snDzFK2+FycJVLsSoMcTPonKevRJHhax5ZwLvKLgyQarAdBauEvhzi1IPgoxyDke8 1YihvO77fLSxsfDfUDM+VqAvhEaarjTRVjPmZrz9MevfSmJs9bpHeLcND244pkZc6J7bw2 oHl+p1H/cXXnj1C7617AXwcBrfbCEtd2DS1QKbUm276SP/zd8NSesuAB7gV6vzcEayuCct wn9jp/76dkx2S5Lpy1PSvLWKecbKAlbEJNPLW5of8ahbMctmXEP7DHGrdVRlRg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1644697745; a=rsa-sha256; cv=none; b=aEe+gSY0TKrC2YHC9uxPjGid4HonjwWjGHGzjDmtPgheV/MbeXvTQdAd5Bo/Sa47ObVj/P W5o3rC8pBPp56VOhnWRItypDxRLH652hdC78yAm2mOc+d5RYUJ1b4ZVi92l5XM48AzR1Ua vdS6hUkM4557/BEAmQXUy0WGBwAHOUjgA1sdP/KSRYJiSGVfHVvKR9IJry7Hpmnm/9SrqS pBDi/jELSCBKjCx6Zxm2T13wEoAiIqOiu2+gfoh2GrCfl0JJqoYasfh+INlg/a5TirPe5E Gu1m2+0yLkHcRX+nr51Py1xuWrNPk6TaiYpxUn7jos3ubODE+r3V0zFflicujA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.34 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: C37452BDDA X-Spam-Score: -1.34 X-Migadu-Scanner: scn1.migadu.com X-TUID: fdhXptxI/SJq This buffer local list will be used to provide an undo facility for tagging operations. Keeping history can be disabled with the new OMIT-HIST option. --- emacs/notmuch-tag.el | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index ad0cb1c1..4c974679 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -275,6 +275,10 @@ 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.") + ;;; Format Handling (defvar notmuch-tag--format-cache (make-hash-table :test 'equal) @@ -464,12 +468,13 @@ NOTE: this variable is no longer used.") (make-obsolete-variable 'notmuch-tag-argument-limit nil "notmuch 0.36") -(defun notmuch-tag (query tag-changes) +(defun notmuch-tag (query tag-changes &optional omit-hist) "Add/remove tags in TAG-CHANGES to messages matching QUERY. QUERY should be a string containing the search-terms. -TAG-CHANGES is a list of strings of the form \"+tag\" or -\"-tag\" to add or remove tags, respectively. +TAG-CHANGES is a list of strings of the form \"+tag\" or \"-tag\" +to add or remove tags, respectively. OMIT-HIST disables history +tracking if non-nil. Note: Other code should always use this function to alter tags of messages instead of running (notmuch-call-notmuch-process \"tag\" ..) @@ -485,13 +490,17 @@ notmuch-after-tag-hook will be run." (notmuch-dlet ((tag-changes tag-changes) (query query)) (run-hooks 'notmuch-before-tag-hook)) - ;; Use batch tag mode to avoid argument length limitations - (let ((batch-op (concat (mapconcat #'notmuch-hex-encode tag-changes " ") - " -- " query))) - (notmuch-call-notmuch-process :stdin-string batch-op "tag" "--batch"))) + (with-temp-buffer + (insert (concat (mapconcat #'notmuch-hex-encode tag-changes " ") " -- " query)) + (unless (= 0 + (notmuch--call-process-region + (point-min) (point-max) notmuch-command t t nil "tag" "--batch")) + (notmuch-logged-error "notmuch tag failed" (buffer-string)))) + (unless omit-hist + (push (list :query query :tag-changes tag-changes) notmuch-tag-history))) (notmuch-dlet ((tag-changes tag-changes) - (query query)) - (run-hooks 'notmuch-after-tag-hook))) + (query query)) + (run-hooks 'notmuch-after-tag-hook))) (defun notmuch-tag-change-list (tags &optional reverse) "Convert TAGS into a list of tag changes. -- 2.34.1