[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
set-auto-mode ignores interpreter if mode is unknown
From: |
Klaus Zeitler |
Subject: |
set-auto-mode ignores interpreter if mode is unknown |
Date: |
Wed, 14 Dec 2005 11:48:31 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (usg-unix-v) |
Not sure if this is a bug or a feature. One of my colleagues looked at
one of my ksh scripts that contained a mode instruction for a mode
that was unknown in his emacs session. To his (and my) amazement the buffer
was in fundamental mode and not in sh-mode.
Here's an example. Paste the following 2 lines in a file (but filename
without an extension that is known to auto-mode-alist) and load it in
emacs.
--- cut ---
#! /usr/bin/ksh
# -*- unknown -*-
--- cut ---
CVS emacs will set the mode to fundamental-mode, whereas emacs 21 will set
it to sh-mode.
I looked at the code of set-auto-mode and it could easily be changed so that
it would check the interpreter, if no valid mode instruction can be found.
*** /vol/freeware/cvs/emacs/head/emacs/lisp/files.el Mon Dec 12 10:31:47 2005
--- /vol/freeware/cvs/emacs/head/emacs/lisp/files.el.~1.796.~ Thu Dec 8
08:38:06 2005
***************
*** 2098,2105 ****
(setq done t)
(or (set-auto-mode-0 mode keep-mode-if-same)
;; continuing would call minor modes again, toggling them off
! (throw 'nop nil))))))
! (unless done
;; 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.
--- 2098,2104 ----
(setq done t)
(or (set-auto-mode-0 mode keep-mode-if-same)
;; continuing would call minor modes again, toggling them off
! (throw 'nop nil)))))
;; 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.
Klaus
--
------------------------------------------
| Klaus Zeitler Lucent Technologies |
| Email: address@hidden |
------------------------------------------
---
The chief cause of problems is solutions.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- set-auto-mode ignores interpreter if mode is unknown,
Klaus Zeitler <=