I'm trying to use display_filter to colorize messages, but am seeing some strange behaviour. Talking to @flatcap on IRC, he suggested I file a bug report.
I'm aware of the color configuration directives, but I want to have more context around colorization to colorize git patches messages properly. I looked at #394 which was closed as wontfix.
Expected Behaviour
I set
set allow_ansi = yes
set display_filter = "/home/tj/.dotfiles/neomutt/display_filter.sh"
where display_filter.sh is the following:
#!/usr/bin/env sh
awk -f /home/tj/.dotfiles/neomutt/hldiff.awk -
and hldiff.awk is the following script:
# vim: set ft=awk :
BEGIN {
#bright = "\x1B[1m"
#red = "\x1B[31m"
#green = "\x1B[32m"
#cyan = "\x1B[36m"
#reset = "\x1B[0m"
bright = "\033[1m"
red = "\033[31m"
green = "\033[32m"
cyan = "\033[36m"
reset = "\033[0m"
hit_diff = 0
}
{
if (hit_diff == 0) {
# Strip carriage returns from line
gsub(/\r/, "", $0)
if ($0 ~ /^diff /) {
hit_diff = 1;
print bright $0 reset
} else if ($0 ~ /^.*\|.*(\+|-)/) {
left = substr($0, 0, index($0, "|")-1)
right = substr($0, index($0, "|"))
gsub(/-+/, red "&" reset, right)
gsub(/\++/, green "&" reset, right)
print left right
} else {
print $0
}
} else {
# Strip carriage returns from line
gsub(/\r/, "", $0)
if ($0 ~ /^-/) {
print red $0 reset
} else if ($0 ~ /^\+/) {
print green $0 reset
} else if ($0 ~ /^ /) {
print $0
} else if ($0 ~ /^@@ (-[0-9]+,[0-9]+ \+[0-9]+,[0-9]+) @@.*/) {
sub(/^@@ (-[0-9]+,[0-9]+ \+[0-9]+,[0-9]+) @@/, cyan "&" reset)
print $0
} else {
print bright $0 reset
}
}
}
Notice the "diff --git .." line, it is correctly made bold (and it doesn't change), but the other colorized lines are stuck on one color (red, cyan or green) which changes as I scroll through the patch. My understanding is that
Steps to Reproduce
Use the provided display_filter.sh for display_filter
Make sure the hldiff.awk is in the right location
open an email that contains a patch sent with git
I've disabled all color directives in the configuration
How often does this happen?
Always
NeoMutt Version
$ neomutt -v
NeoMutt 20210205
Copyright (C) 1996-2020 Michael R. Elkins and others.
NeoMutt comes with ABSOLUTELY NO WARRANTY; for details type 'neomutt -vv'.
NeoMutt is free software, and you are welcome to redistribute it
under certain conditions; type 'neomutt -vv' for details.
System: Linux 5.12.0 (x86_64)
ncurses: ncurses 6.2.20210619 (compiled with 6.2.20200212)
GPGME: 1.15.1
OpenSSL: OpenSSL 1.1.1l 24 Aug 2021
libnotmuch: 5.3.0
storage: gdbm
compression: zlib
Configure options: --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --docdir=/usr/share/doc/neomutt-20210205-r1 --with-sysroot=/ --libdir=/usr/lib64 CCACHE=none CC_FOR_BUILD=x86_64-pc-linux-gnu-gcc --disable-doc --enable-nls --enable-notmuch --disable-autocrypt --enable-gpgme --disable-pgp --disable-smime --disable-bdb --enable-gdbm --disable-kyotocabinet --disable-qdbm --disable-tokyocabinet --disable-lz4 --enable-zlib --disable-zstd --disable-idn --disable-gss --disable-lmdb --enable-sasl --with-ui=ncurses --sysconfdir=/etc/neomutt --enable-ssl --disable-gnutls --disable-testing
Compilation CFLAGS: -march=native -O2 -pipe -fomit-frame-pointer -std=c99 -fno-delete-null-pointer-checks -D_ALL_SOURCE=1 -D_GNU_SOURCE=1 -D__EXTENSIONS__ -I//usr/include -DNCURSES_WIDECHAR
Default options:
+attach_headers_color +compose_to_sender +compress +cond_date +debug
+encrypt_to_self +forgotten_attachments +forwref +ifdef +imap +index_color
+initials +limit_current_thread +multiple_fcc +nested_if +new_mail +nntp +pop
+progress +quasi_delete +regcomp +reply_with_xorig +sensible_browser +sidebar
+skip_quoted +smtp +status_color +timeout +tls_sni +trash
Compile options:
-autocrypt +bkgdset +color +curs_set +fcntl -flock -fmemopen +futimens
+getaddrinfo -gnutls +gpgme -gss +hcache -homespool -idn +inotify
-locales_hack -lua +meta -mixmaster +nls +notmuch +openssl -pgp +regex +sasl
-smime -sqlite +start_color +sun_attachment +typeahead
MAILPATH="/var/mail"
PKGDATADIR="/usr/share/neomutt"
SENDMAIL="/usr/sbin/sendmail"
SYSCONFDIR="/etc/neomutt"
To learn more about NeoMutt, visit: https://neomutt.org
If you find a bug in NeoMutt, please raise an issue at:
https://github.com/neomutt/neomutt/issues
or send an email to: <neomutt-devel@neomutt.org>
I'm trying to use display_filter to colorize messages, but am seeing some strange behaviour. Talking to @flatcap on IRC, he suggested I file a bug report.
I'm aware of the
color
configuration directives, but I want to have more context around colorization to colorize git patches messages properly. I looked at #394 which was closed as wontfix.Expected Behaviour
I set
where
display_filter.sh
is the following:and
hldiff.awk
is the following script:(source: https://git.sr.ht/~sircmpwn/aerc/tree/master/item/filters/hldiff)
I expected the patch to be properly colorized, which it partly is, but the diff lines are
Actual Behaviour
I recorded the behaviour: https://asciinema.org/a/m9XEZEdKgoHJM65EzZstJty14
Notice the "diff --git .." line, it is correctly made bold (and it doesn't change), but the other colorized lines are stuck on one color (red, cyan or green) which changes as I scroll through the patch. My understanding is that
Steps to Reproduce
color
directives in the configurationHow often does this happen?
NeoMutt Version
Extra Info