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 WJgVO0XDbmMOIQAAbAwnHQ (envelope-from ) for ; Fri, 11 Nov 2022 22:48:54 +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 QAwtO0XDbmNTLQEA9RJhRA (envelope-from ) for ; Fri, 11 Nov 2022 22:48:53 +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 C602F38022 for ; Fri, 11 Nov 2022 22:48:53 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 4EB505FA53; Fri, 11 Nov 2022 21:48:50 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 807675F9A8 for ; Fri, 11 Nov 2022 21:48:47 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id EBD9B5FBC0; Fri, 11 Nov 2022 16:48:46 -0500 (EST) Received: (nullmailer pid 46743 invoked by uid 1000); Fri, 11 Nov 2022 21:48:37 -0000 From: David Bremner To: Tomi Ollila , David Bremner , notmuch@notmuchmail.org Subject: [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags Date: Fri, 11 Nov 2022 16:48:31 -0500 Message-Id: <20221111214831.46716-3-david@tethera.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221111214831.46716-1-david@tethera.net> References: <20221111214831.46716-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: 7VB2ULYKFBBPNHA6O2TJ7ZXJEE36P52O X-Message-ID-Hash: 7VB2ULYKFBBPNHA6O2TJ7ZXJEE36P52O 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=1668203333; 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=kcsBgNUas4OgIFrbWsiNmx/T0535eTuzjq7D7QmWX/Y=; b=QM57yMfRKh0L/GUCkwkpnvn+XLYjIL46CD3GzBb6kc4qmfHSiMPBTz0berW8RFANxvYlHO XadKUsPxnXWsAmYs0rdEVo/xndK+FIZjcRu/CRV0wAIX5EG0dD6jDrOOhpdx/B3zTxZZYg yfigjDBt1r1KL5dEnrrTp9u5hfhAc9u3eFvvmIR2fQ6OwNTMimUgssrqEhZdHC27FLkqja nH37KvdcSYYPKgMC24SDCTRYfqjcKzpEeEkY7LinwPz0VIqTwh3edQp/YXhidos+Q6BfSv OfxYB1hp3q2BzuCxK+HBOPB8VBgKZo4a1XNOMcs4Ft2920gipEOeTs6YaW2Lmg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1668203333; a=rsa-sha256; cv=none; b=Kjh6B91OyNaLelbuIApqzpWXTU82MQVdlRfRnF1iPI+tNGy21+mTk+LYRQRjsqplnMWtor aQvSak/0lB05RvnHtSsfSZrXeg4XwbztX4vDq3ITP7Qoa/AcYborJBoOOY10QvWjlL91ZM jSYdFqYyW87SezIMMbKXks3JaJqoe/YTLJUmBPGnpshOSa7bcz4imdAqJklt6gj4Sgy6Os Up+8kIDRC6rWA3j1PlIdMTsmnVo/PzGnuO12yUE079bn9e1Yl13o8nS2JxLhacvSrWNoly n80hj7t0b3y7ScQUHg02VE851mtmc/ZZywdNGANnivcFtvfelkv6TlM5Tjht8g== 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: -0.20 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: C602F38022 X-Spam-Score: -0.20 X-Migadu-Scanner: scn1.migadu.com X-TUID: U3hP4sKZttYg Although this has more steps than the previous regular expression search and replace, it should be more robust against changes in the headerline format, such as the inclusion of duplicate numbers (which broke the previous version). --- emacs/notmuch-show.el | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 5fb5ab31..c4e88be2 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -452,14 +452,20 @@ operation on the contents of the current buffer." (defun notmuch-show-update-tags (tags) "Update the displayed tags of the current message." (save-excursion - (goto-char (notmuch-show-message-top)) - (when (re-search-forward "(\\([^()]*\\))$" (line-end-position) t) - (let ((inhibit-read-only t)) - (replace-match (concat "(" - (notmuch-tag-format-tags - tags - (notmuch-show-get-prop :orig-tags)) - ")")))))) + (let ((inhibit-read-only t) + (start (notmuch-show-message-top)) + (depth (notmuch-show-get-prop :depth)) + (orig-tags (notmuch-show-get-prop :orig-tags)) + (props (notmuch-show-get-message-properties)) + (extent (notmuch-show-message-extent))) + (goto-char start) + (notmuch-show-insert-headerline props depth tags orig-tags) + (put-text-property start (1+ start) + :notmuch-message-properties props) + (put-text-property (car extent) (cdr extent) :notmuch-message-extent extent) + ;; delete original headerline, but do not save to kill ring + (delete-region + (point) (save-excursion (end-of-line nil) (1+ (point))))))) (defun notmuch-clean-address (address) "Try to clean a single email ADDRESS for display. Return a cons -- 2.35.1