* set-auto-mode ignores interpreter if mode is unknown
@ 2005-12-14 10:48 Klaus Zeitler
0 siblings, 0 replies; only message in thread
From: Klaus Zeitler @ 2005-12-14 10:48 UTC (permalink / raw)
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: kzeitler@lucent.com |
------------------------------------------
---
The chief cause of problems is solutions.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-12-14 10:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-14 10:48 set-auto-mode ignores interpreter if mode is unknown Klaus Zeitler
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.