From 6d6e095a73514fe865581d4cb94bd4f78dc7414d Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Wed, 28 Dec 2011 17:10:11 +0000 Subject: [PATCH] el/dot-emacs.el: Shell-mode hacking for non-Bourne shells. This is surprisingly grim. The rc support botches fontification of backquotes surprisingly badly. And it's really hard to force the use of a particular shell for a given file because local variables get set after the mode is chosen. --- el/dot-emacs.el | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/el/dot-emacs.el b/el/dot-emacs.el index 76cda19..f28b288 100644 --- a/el/dot-emacs.el +++ b/el/dot-emacs.el @@ -2203,6 +2203,42 @@ strip numbers instead." (setq sh-shell-file "/bin/sh") +;; Awful hacking to override the shell detection for particular scripts. +(defmacro define-custom-shell-mode (name shell) + `(defun ,name () + (interactive) + (set (make-local-variable 'sh-shell-file) ,shell) + (sh-mode))) +(define-custom-shell-mode bash-mode "/bin/bash") +(define-custom-shell-mode rc-mode "/usr/bin/rc") +(put 'sh-shell-file 'permanent-local t) + +;; Hack the rc syntax table. Backquotes aren't paired in rc. +(eval-after-load "sh-script" + '(or (assq 'rc sh-mode-syntax-table-input) + (let ((frag '(nil + ?# "<" + ?\n ">#" + ?\" "\"\"" + ?\' "\"\'" + ?$ "'" + ?\` "." + ?! "_" + ?% "_" + ?. "_" + ?^ "_" + ?~ "_" + ?, "_" + ?= "." + ?< "." + ?> ".")) + (assoc (assq 'rc sh-mode-syntax-table-input))) + (if assoc + (rplacd assoc frag) + (setq sh-mode-syntax-table-input + (cons (cons 'rc frag) + sh-mode-syntax-table-input)))))) + ;;;-------------------------------------------------------------------------- ;;; Emacs shell mode. -- 2.11.0