(mapcar
(lambda (l)
(cons (purecopy (car l)) (cdr l)))
- '(("perl" . perl-mode)
- ("perl5" . perl-mode)
- ("miniperl" . perl-mode)
- ("wish" . tcl-mode)
- ("wishx" . tcl-mode)
- ("tcl" . tcl-mode)
- ("tclsh" . tcl-mode)
- ("expect" . tcl-mode)
- ("scm" . scheme-mode)
- ("ash" . sh-mode)
- ("bash" . sh-mode)
- ("bash2" . sh-mode)
- ("csh" . sh-mode)
- ("dtksh" . sh-mode)
- ("es" . sh-mode)
- ("itcsh" . sh-mode)
- ("jsh" . sh-mode)
- ("ksh" . sh-mode)
- ("oash" . sh-mode)
- ("pdksh" . sh-mode)
- ("rbash" . sh-mode)
- ("rc" . sh-mode)
- ("rpm" . sh-mode)
- ("sh" . sh-mode)
- ("sh5" . sh-mode)
- ("tcsh" . sh-mode)
- ("wksh" . sh-mode)
- ("wsh" . sh-mode)
- ("zsh" . sh-mode)
- ("tail" . text-mode)
- ("more" . text-mode)
- ("less" . text-mode)
- ("pg" . text-mode)
- ("make" . makefile-gmake-mode) ; Debian uses this
- ("guile" . scheme-mode)
- ("clisp" . lisp-mode)
- ("emacs" . emacs-lisp-mode)))
+ '(("\\`\\(mini\\)?perl5?\\'" . perl-mode)
+ ("\\`wishx?\\'" . tcl-mode)
+ ("\\`tcl\\(sh\\)?\\'" . tcl-mode)
+ ("\\`expect\\'" . tcl-mode)
+ ("\\`scm\\'" . scheme-mode)
+ ("\\`[acjkwz]sh\\'" . sh-mode)
+ ("\\`bash2?\\'" . sh-mode)
+ ("\\`dtksh\\'" . sh-mode)
+ ("\\`es\\'" . sh-mode)
+ ("\\`itcsh\\'" . sh-mode)
+ ("\\`oash\\'" . sh-mode)
+ ("\\`pdksh\\'" . sh-mode)
+ ("\\`rbash\\'" . sh-mode)
+ ("\\`rc\\'" . sh-mode)
+ ("\\`rpm\\'" . sh-mode)
+ ("\\`sh5?\\'" . sh-mode)
+ ("\\`tcsh\\'" . sh-mode)
+ ("\\`wksh\\'" . sh-mode)
+ ("\\`tail\\'" . text-mode)
+ ("\\`more\\'" . text-mode)
+ ("\\`less\\'" . text-mode)
+ ("\\`pg\\'" . text-mode)
+ ("\\`make\\'" . makefile-gmake-mode) ; Debian uses this
+ ("\\`guile\\'" . scheme-mode)
+ ("\\`clisp\\'" . lisp-mode)
+ ("\\`emacs\\'" . emacs-lisp-mode)))
"Alist mapping interpreter names to major modes.
This is used for files whose first lines match `auto-mode-interpreter-regexp'.
-Each element looks like (INTERPRETER . MODE).
-If INTERPRETER matches the name of the interpreter specified in the first line
-of a script, mode MODE is enabled.
+Each element looks like (REGEXP . MODE).
+If REGEXP matches the name (minus any directory part) of the interpreter
+specified in the first line of a script, enable major mode MODE.
+
+Emacs versions earlier than 24.4 treat the car of each element as a
+literal string that must match the entire name, rather than a regexp.
+For backwards compatibility, any REGEXP that does not begin with \"\\\\\"
+continues to be treated in this way. This behavior may be removed in
+future and should not be relied upon.
See also `auto-mode-alist'.")
;; If we didn't, look for an interpreter specified in the first line.
;; As a special case, allow for things like "#!/bin/env perl", which
;; finds the interpreter anywhere in $PATH.
- (unless done
- (setq mode (save-excursion
- (goto-char (point-min))
- (if (looking-at auto-mode-interpreter-regexp)
- (match-string 2)
- ""))
- ;; Map interpreter name to a mode, signaling we're done at the
- ;; same time.
- done (assoc (file-name-nondirectory mode)
- interpreter-mode-alist))
- ;; If we found an interpreter mode to use, invoke it now.
- (if done
- (set-auto-mode-0 (cdr done) keep-mode-if-same)))
+ (and (not done)
+ (setq mode (save-excursion
+ (goto-char (point-min))
+ (if (looking-at auto-mode-interpreter-regexp)
+ (match-string 2))))
+ ;; Map interpreter name to a mode, signaling we're done at the
+ ;; same time.
+ (setq done (assoc-default
+ (file-name-nondirectory mode)
+ ;; Backwards compat: if car of i-m-alist does not start
+ ;; with "\\", treat as literal string.
+ (mapcar (lambda (e)
+ (if (string-match-p "\\`\\\\" (car e))
+ e
+ (cons
+ (format "\\`%s\\'" (regexp-quote (car e)))
+ (cdr e))))
+ interpreter-mode-alist)
+ #'string-match-p))
+ ;; If we found an interpreter mode to use, invoke it now.
+ (set-auto-mode-0 done keep-mode-if-same))
;; Next try matching the buffer beginning against magic-mode-alist.
(unless done
(if (setq done (save-excursion
(cons "Pike" (c-lang-const c-mode-menu pike)))
;;;###autoload (add-to-list 'auto-mode-alist '("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode))
-;;;###autoload (add-to-list 'interpreter-mode-alist '("pike" . pike-mode))
+;;;###autoload (add-to-list 'interpreter-mode-alist '("\\`pike\\'" . pike-mode))
;;;###autoload
(define-derived-mode pike-mode prog-mode "Pike"
;; Support for AWK
;;;###autoload (add-to-list 'auto-mode-alist '("\\.awk\\'" . awk-mode))
-;;;###autoload (add-to-list 'interpreter-mode-alist '("awk" . awk-mode))
-;;;###autoload (add-to-list 'interpreter-mode-alist '("mawk" . awk-mode))
-;;;###autoload (add-to-list 'interpreter-mode-alist '("nawk" . awk-mode))
-;;;###autoload (add-to-list 'interpreter-mode-alist '("gawk" . awk-mode))
+;;;###autoload (add-to-list 'interpreter-mode-alist '("\\`[gmn]?awk\\'" . awk-mode))
(c-define-abbrev-table 'awk-mode-abbrev-table
'(("else" "else" c-electric-continued-statement 0)
controls whether to query about making the visited file executable.
Calls the value of `sh-set-shell-hook' if set."
- (interactive (list (completing-read (format "Shell \(default %s\): "
- sh-shell-file)
- interpreter-mode-alist
- (lambda (x) (eq (cdr x) 'sh-mode))
- nil nil nil sh-shell-file)
+ (interactive (list (completing-read
+ (format "Shell \(default %s\): "
+ sh-shell-file)
+ ;; This used to use interpreter-mode-alist, but that is
+ ;; no longer appropriate now that uses regexps.
+ ;; Maybe there could be a separate variable that lists
+ ;; the shells, used here and to construct i-mode-alist.
+ ;; But the following is probably good enough:
+ (append (mapcar (lambda (e) (symbol-name (car e)))
+ sh-ancestor-alist)
+ '("csh" "rc" "sh"))
+ nil nil nil nil sh-shell-file)
(eq executable-query 'function)
t))
(if (string-match "\\.exe\\'" shell)