rc mail: enable jumping from inline diff to source file

This allows to jump from a mail buffer that contains an inline diff
to the source files (most accurate when the patch has been applied
locally).

This makes the diff module a mandatory dependency; we could relax that.
This commit is contained in:
Johannes Altmanninger 2021-12-31 09:26:49 +01:00
parent 90b070034d
commit 3843163e2e

View File

@ -4,6 +4,10 @@ hook global BufCreate .+\.eml %{
hook global WinSetOption filetype=mail %{
require-module mail
map buffer normal <ret> %{: diff-jump<ret>}
hook -once -always window WinSetOption filetype=.* %{
unmap buffer normal <ret> %{: diff-jump<ret>}
}
}
hook -group mail-highlight global WinSetOption filetype=mail %{
@ -14,6 +18,8 @@ hook -group mail-highlight global WinSetOption filetype=mail %{
provide-module mail %{
require-module diff
add-highlighter shared/mail group
add-highlighter shared/mail/ regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To|References|Date):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute
add-highlighter shared/mail/ regex <[^@>]+@.*?> 0:string