From 901d5ea1be8c97cc461554253b63ea13a08fcdee Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 21 Feb 2013 13:36:25 +0100 Subject: [PATCH] Add mail.kak for mail file highlighting --- src/Makefile | 2 +- src/rc/mail.kak | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/rc/mail.kak diff --git a/src/Makefile b/src/Makefile index b2b0ea14e..05be05993 100644 --- a/src/Makefile +++ b/src/Makefile @@ -23,6 +23,6 @@ XDG_CONFIG_HOME ?= $(HOME)/.config userconfig: mkdir -p $(XDG_CONFIG_HOME)/kak/autoload - ln -s $(CURDIR)/rc/{asciidoc,client,cpp,diff,git,grep,kakrc,make,sh}.kak $(XDG_CONFIG_HOME)/kak/autoload/ + ln -s $(CURDIR)/rc/{asciidoc,client,cpp,diff,git,grep,kakrc,make,sh,mail}.kak $(XDG_CONFIG_HOME)/kak/autoload/ .PHONY: tags userconfig diff --git a/src/rc/mail.kak b/src/rc/mail.kak new file mode 100644 index 000000000..d0603fec0 --- /dev/null +++ b/src/rc/mail.kak @@ -0,0 +1,17 @@ +hook global BufOpen .* %{ %sh{ + mimetype="$(file -b --mime-type ${kak_bufname})" + if [[ "${mimetype}" == "message/rfc822" ]]; then + echo setb filetype mail; + fi +} } + +hook global WinSetOption filetype=mail %~ + addhl group mail-highlight + addhl -group mail-highlight regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute + addhl -group mail-highlight regex <[^@>]+@.*?> 0:string + addhl -group mail-highlight regex ^>.*?$ 0:comment +~ + +hook global WinSetOption filetype=(?!mail).* %{ + rmhl mail-highlight +}