unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Tomi Ollila <tomi.ollila@iki.fi>
To: David Bremner <david@tethera.net>,
	David Bremner <david@tethera.net>,
	notmuch@notmuchmail.org
Subject: Re: [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags
Date: Sun, 13 Nov 2022 20:11:35 +0200	[thread overview]
Message-ID: <y387pwy.b06rn4-too@iki.fi> (raw)
In-Reply-To: <20221111214831.46716-3-david@tethera.net>

On Fri, Nov 11 2022, David Bremner wrote:

> 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)))))))

Series looks good to me (as much as I understand it)

This last changed line got me checking docstring of (line-end-position),
which says:

 -- line-end-position is a built-in function in ‘C source code’.
 -- Probably introduced at or before Emacs version 20.4.
 -- This function does not change global state, including the match data.

and then grepping thru notmuch source code:

notmuch-tree.el:497:      (delete-region (point) (1+ (line-end-position)))

-- it looks to me this could be simpler and faster alternative.

Tomi

PS: something that is nasty but probably does not hit here (there is
newline always)

(delete-region (line-end-position) 1000000)
-> Debugger entered--Lisp error: (args-out-of-range #<buffer *scratch*> 215 1000000

>  
>  (defun notmuch-clean-address (address)
>    "Try to clean a single email ADDRESS for display. Return a cons
> -- 
> 2.35.1
>
> _______________________________________________
> notmuch mailing list -- notmuch@notmuchmail.org
> To unsubscribe send an email to notmuch-leave@notmuchmail.org\r

  reply	other threads:[~2022-11-13 18:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 21:26 [PATCH] emacs: fix notmuch-show-update-tags to support duplicate files Tomi Ollila
2022-11-05 17:45 ` David Bremner
2022-11-06 14:08   ` Tomi Ollila
2022-11-11 21:48     ` [PATCH 1/3] emacs/show: use plist to pass message info to n-s-insert-headerline David Bremner
2022-11-11 21:48       ` [PATCH 2/3] emacs/show: add optional orig-tags argument to n-s-i-headerline David Bremner
2022-11-11 21:48       ` [PATCH 3/3] emacs/show: use n-s-i-headerline to update tags David Bremner
2022-11-13 18:11         ` Tomi Ollila [this message]
2022-11-15 11:59           ` David Bremner
2022-11-15 14:01             ` Tomi Ollila

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=y387pwy.b06rn4-too@iki.fi \
    --to=tomi.ollila@iki.fi \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).