lang/sh: improve zsh buffer detection

This commit is contained in:
Henrik Lissner 2017-06-20 16:18:27 +02:00
parent 02bfb73264
commit f4e3080432
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -35,7 +35,11 @@
;; sh-mode has file extensions checks for other shells, but not zsh, so...
(defun +sh|detect-zsh ()
(when (and buffer-file-name (string-match-p "\\.zsh\\'" buffer-file-name))
(when (or (and buffer-file-name
(string-match-p "\\.zsh\\'" buffer-file-name))
(save-excursion
(goto-char (point-min))
(looking-at-p "^#!.+zsh[$\\s-]")))
(sh-set-shell "zsh")))
(add-hook 'sh-mode-hook #'+sh|detect-zsh))