From 85cd27138ded36c6f60bc0f50dbde2028f213b5c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 14 Dec 2016 13:40:00 +0000 Subject: [PATCH] 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 --- rc/base/file.kak | 7 +++---- rc/base/html.kak | 14 +++++++------- rc/base/mail.kak | 4 ---- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/rc/base/file.kak b/rc/base/file.kak index 89442fa9..0b7f60d2 100644 --- a/rc/base/file.kak +++ b/rc/base/file.kak @@ -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 } } diff --git a/rc/base/html.kak b/rc/base/html.kak index 0621160a..fb32a4c4 100644 --- a/rc/base/html.kak +++ b/rc/base/html.kak @@ -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 } diff --git a/rc/base/mail.kak b/rc/base/mail.kak index 9eb3894d..8eb8085a 100644 --- a/rc/base/mail.kak +++ b/rc/base/mail.kak @@ -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