Re: emacs-notmuch: notmuch-show-hook runs too early

Subject: Re: emacs-notmuch: notmuch-show-hook runs too early

Date: Tue, 29 Dec 2020 16:03:31 +0100

To: notmuch@notmuchmail.org

Cc:

From: yoctocell


On Tue, Dec 29 2020, yoctocell wrote:

> I am using a package called gnus-article-treat-patch[0] which colorizes
> patches in emails. It works expected when I manually call
> `ft/gnus-article-treat-patch` in a notmuch-show buffer, but it doesn't
> work when I add it as a hook.
>
> (add-hook 'notmuch-show-hook 'ft/gnus-article-treat-patch)
>
> `notmuch-show-hook` seems to be called too early so
> `ft/gnus-article-treat-patch` isn't able to read the contents of the
> message and apply any highlighting.
>
> I managed to get it to work with the following patch.
>
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index 056c4e30..f9f3bdb1 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -1317,11 +1317,11 @@ If no messages match the query return NIL."
>  				      (notmuch-sanitize
>  				       (notmuch-show-strip-re
>  					(notmuch-show-get-subject)))))
> -      (run-hooks 'notmuch-show-hook)
>        (if state
>  	  (notmuch-show-apply-state state)
>  	;; With no state to apply, just go to the first message.
> -	(notmuch-show-goto-first-wanted-message)))
> +	(notmuch-show-goto-first-wanted-message))
> +      (run-hooks 'notmuch-show-hook))
>      ;; Report back to the caller whether any messages matched.
>      forest))
>
> -- 
> yoctocell
> 8B88 2502 31D7 03B1 68BC  2691 3851 020D 7E61 BBC2

Sorry, forgot the provide the link.

[0]: https://github.com/velkyel/gnus-article-treat-patch
signature.asc (application/pgp-signature)
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: