unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Klaus Zeitler <kzeitler@lucent.com>
Subject: set-auto-mode ignores interpreter if mode is unknown
Date: Wed, 14 Dec 2005 11:48:31 +0100	[thread overview]
Message-ID: <q5g8xuo0xa8.fsf@lucent.com> (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.

                 reply	other threads:[~2005-12-14 10:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=q5g8xuo0xa8.fsf@lucent.com \
    --to=kzeitler@lucent.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).