Remove mimetype option for good

file.kak now is responsible for mapping whatever mimetype file uses
to the filetype that Kakoune uses.

Fixes #975
Fixes #979
This commit is contained in:
Maxime Coste 2016-12-14 13:40:00 +00:00
parent 1bdf26fd6e
commit 85cd27138d
3 changed files with 10 additions and 15 deletions

View File

@ -1,16 +1,15 @@
decl str mimetype
hook global BufOpen .* %{ %sh{
if [ -z "${kak_opt_filetype}" ]; then
mime=$(file -b --mime-type "${kak_buffile}")
case "${mime}" in
application/*+xml) filetype="xml" ;;
message/rfc822) filetype="mail" ;;
text/x-shellscript) filetype="sh" ;;
text/x-*) filetype="${mime#text/x-}" ;;
text/*) filetype="${mime#text/}" ;;
esac
if [ -n "${filetype}" ]; then
printf "set buffer filetype '%s'\n" "${filetype}"
else
printf "set buffer mimetype '%s'\n" "${mime}"
fi
fi
} }

View File

@ -4,12 +4,12 @@
# Detection
# ‾‾‾‾‾‾‾‾‾
hook global BufSetOption mimetype=(text/((x-)?html|xml)|application/((\w+\+)?xml)) %{
hook global BufCreate .*\.html %{
set buffer filetype html
}
hook global BufCreate .*\.(html|xml) %{
set buffer filetype html
hook global BufCreate .*\.xml %{
set buffer filetype xml
}
# Highlighters
@ -63,17 +63,17 @@ def -hidden _html_indent_on_new_line %{
# Initialization
# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾
hook -group html-highlight global WinSetOption filetype=html %{ addhl ref html }
hook -group html-highlight global WinSetOption filetype=(?:html|xml) %{ addhl ref html }
hook global WinSetOption filetype=html %{
hook global WinSetOption filetype=(?:html|xml) %{
hook window InsertEnd .* -group html-hooks _html_filter_around_selections
hook window InsertChar .* -group html-indent _html_indent_on_char
hook window InsertChar \n -group html-indent _html_indent_on_new_line
}
hook -group html-highlight global WinSetOption filetype=(?!html).* %{ rmhl html }
hook -group html-highlight global WinSetOption filetype=(?!html|xml).* %{ rmhl html }
hook global WinSetOption filetype=(?!html).* %{
hook global WinSetOption filetype=(?!html|xml).* %{
rmhooks window html-indent
rmhooks window html-hooks
}

View File

@ -2,10 +2,6 @@ hook global BufCreate .+\.eml %{
set buffer filetype mail
}
hook global BufSetOption mimetype=message/rfc822 %{
set buffer filetype mail
}
addhl -group / group mail
addhl -group /mail regex ^(From|To|Cc|Bcc|Subject|Reply-To|In-Reply-To):([^\n]*(?:\n\h+[^\n]+)*)$ 1:keyword 2:attribute
addhl -group /mail regex <[^@>]+@.*?> 0:string