From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WNvaAMfn+2G9AAEAgWs5BA (envelope-from ) for ; Thu, 03 Feb 2022 15:33:43 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id qBUEOcbn+2E/ZAAAauVa8A (envelope-from ) for ; Thu, 03 Feb 2022 15:33:42 +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 06E593A241 for ; Thu, 3 Feb 2022 15:33:41 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 3ECD35F72C; Thu, 3 Feb 2022 14:33:09 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id A69535F716 for ; Thu, 3 Feb 2022 14:33:05 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 251A95FBD6; Thu, 3 Feb 2022 09:33:04 -0500 (EST) Received: (nullmailer pid 3348416 invoked by uid 1000); Thu, 03 Feb 2022 14:32:56 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC PATCH v2 08/12] emacs/tag: keep tag history Date: Thu, 3 Feb 2022 10:32:50 -0400 Message-Id: <20220203143254.3344753-9-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203143254.3344753-1-david@tethera.net> References: <20220203143254.3344753-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: RVB6GZJ5NG5WFS5EKXYQOCOT3V3MSB2V X-Message-ID-Hash: RVB6GZJ5NG5WFS5EKXYQOCOT3V3MSB2V 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=1643898821; 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=TB7jRDR33NFUB6r9BSSjQncdq4ZEtAJ9G3K8hpFTYpw=; b=PDS7ulI2TanH1IXejvU1AC9NOUZyH2DfLkDNCzQ32qugGd0km2zLYTPzCVtNatBYldtKNx rAqqalzVz26LgZL7KYciMZcG1RzL+9beFQ/7qU3som7tnncj23WtpOwVtlG6GYPdOWkrKC cmIaJ8240eyxLJOwQ+cXOLOKTREfK41gFrLJ/YPcxUlhUHoAaR6m7elS06RPHOJDrtlIgq ReEPjL9FM3yw0VcXtadXhBFKo+cLwEb75eymTndNsLchRPl+GrxxtUPeY093F3Ak7eUrQi OedKsQj3Ulx0JLgRj8LNAcQkV2BuBZLLqotgyT2oX9eyS4kmKOMyWKyAQ/Y2Eg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643898821; a=rsa-sha256; cv=none; b=fjTVzE1lszaudp5UT+EqsbkZev41fY+LzqWK0LpsC7duHt1J11+jSORTCgnes2xma1sqKU pvGCgyoYXkkc8EKiav7p/PmQG06kpVQQQXB+7WtMl4ucOZxuFgYOq07pn/KzUQo3Mtu0sN a12fljjCrYuanVI7ln15ci4N+cf7m/bln60pWsTSSxKEUjt2V1uo3hRhp2fmpo8/M3ni0R zfVdOtl3Ti3DSVC7DXTI0wdkTiqjeDL00WPvErKeOjM1ykwEtLB+ARENJqflq6FvZ4r1h6 QmwZbfkl/BSPAGXi4z3pISAnvBpfMLi4V56KqyLaorjaWKW0DCu2osak76ajGA== 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.35 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: 06E593A241 X-Spam-Score: -1.35 X-Migadu-Scanner: scn1.migadu.com X-TUID: cYHjYgjp8O2h This buffer local list will be used to provide an undo facility for tagging operations. The new arguments are for the use of a future undo function. --- 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