all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: dkcombs@panix.com (David Combs)
To: help-gnu-emacs@gnu.org
Subject: Re: How to open a file in sh-mode
Date: Thu, 11 Sep 2008 01:35:55 +0000 (UTC)	[thread overview]
Message-ID: <ga9slr$9uh$1@reader1.panix.com> (raw)
In-Reply-To: 64d8ebaf-0c89-4e9d-9aee-86b4e9414449@o40g2000prn.googlegroups.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2848 bytes --]

In article <64d8ebaf-0c89-4e9d-9aee-86b4e9414449@o40g2000prn.googlegroups.com>,
Xah  <xahlee@gmail.com> wrote:
>On Aug 14, 12:53 am, "Francis Moreau" <francis.m...@gmail.com> wrote:
>> Hello,
>>
>> I'm trying to open a file with emacs automatically set on sh-mode.
>> The file name can't be used to guess that emacs should be in sh-mode
>> when opening it.
>
>If the file content's first line starts with “#!”, then you could use
>the magic-mode-alist.
>
Xah -- question about the characters in your posts:

If I or someone sees eg a url in one of your posts, and
wants to go to that url (because you've suggested doing that,
maybe), it's a little difficult to just cut-n-paste your string,
what with all the extra control or whatever they are characters
mixed in.

What is that stuff, why is it there, and is it really necessary
for you to include it.

Thanks,

David




>-----------------------------------
>How Emacs Choose Modes
>
>Emacs determines what mode to use primarily by 2 mechanisms, in order:
>(1) Check the first line in the file, using “magic-mode-alist”. (2)
>Check the file name's suffix, using “auto-mode-alist”.
>
>The “magic-mode-alist” is a list that emacs use to match the first
>line of a file with a mode. For example, if you want files that begin
>with the line “<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...” to
>always use nxml-mode, then add the following to your “.emacs”:
>
>(add-to-list
> 'magic-mode-alist
> '("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0" . nxml-mode))
>
>The magic-mode-alist is a list. In the above example, the string with
>the “DOCTYPE” is a regex, used to match the first line of a file.
>
>If emacs goes thru magic-mode-alist and didn't find any match, then
>it'll use auto-mode-alist to check on file name suffix. The “auto-mode-
>alist” associates a file name suffix with a mode. For example, if you
>want files ending in “.js” to always open with js2-mode, then do:
>
>(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
>
>Note: The double backslash in the string “\\.js\\'” is used to escape
>the backslash. So, the regex engine just got “\.js\'”. The “\.” is to
>match a period. The “\'” is one of emacs special regex syntax, to
>match end of a string. (See also: Text Pattern Matching in Emacs)
>
>Reference: Elisp Manual: Regexp-Backslash.
>
>You can see what are the values of magic-mode-alist or auto-mode-alist
>by typing “Alt+x describe-variable”.
>
>There are few minor details about how emacs determines what mode to
>load, but the above should cover vast majority of needs. For detail,
>see emacs manual.
>
>Reference: (info "(emacs)Choosing Modes").
>
>--------------------------------------------
>above from:
>http://xahlee.org/emacs/emacs_installing_packages.html
>
>  Xah
>∑ http://xahlee.org/
>
>☄




  reply	other threads:[~2008-09-11  1:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.16658.1218700648.18990.help-gnu-emacs@gnu.org>
2008-08-14  8:28 ` How to open a file in sh-mode Sebastian Kaps
2008-08-14 10:29 ` Xah
2008-09-11  1:35   ` David Combs [this message]
2008-09-11 22:58     ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
2008-09-14 22:35       ` David Combs
2008-09-15 16:28         ` unicode encoding and curly quotes Nikolaj Schumacher
2008-09-15 19:09         ` unicode encoding and curly quotes [was: How to open a file in sh-mode] Xah
2008-09-22 20:17           ` David Combs
2008-08-14  7:53 How to open a file in sh-mode Francis Moreau
2008-08-14  8:16 ` Henrik Austad
2008-08-14  9:03   ` Francis Moreau
2008-08-14 10:03     ` Henrik Austad
2008-08-14 10:06       ` Francis Moreau
2008-08-14 11:17         ` David Hansen
2008-08-14 11:36         ` Henrik Austad
2008-08-14 11:51           ` Francis Moreau
2008-08-14 11:57             ` Lennart Borgman (gmail)
     [not found]       ` <mailman.16667.1218708430.18990.help-gnu-emacs@gnu.org>
2008-08-14 12:24         ` Giorgos Keramidas
2008-08-14 13:01           ` Francis Moreau
2008-08-14 13:27             ` Giorgos Keramidas
2008-08-14 13:48               ` Francis Moreau
2008-08-14 14:23                 ` Giorgos Keramidas
2008-08-14  8:26 ` David Hansen
2008-08-14  9:04   ` Francis Moreau
2008-08-14  9:23     ` Thierry Volpiatto
2008-08-14  9:34       ` Francis Moreau
2008-08-14 10:58     ` Peter Dyballa
2008-08-14 11:02       ` Francis Moreau
2008-08-14 11:20         ` Lennart Borgman (gmail)
2008-08-14 11:36           ` Francis Moreau
2008-08-14 11:46             ` Lennart Borgman (gmail)
2008-08-14 12:06         ` Peter Dyballa
2008-08-14 12:22           ` Francis Moreau

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

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

  git send-email \
    --in-reply-to='ga9slr$9uh$1@reader1.panix.com' \
    --to=dkcombs@panix.com \
    --cc=help-gnu-emacs@gnu.org \
    /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 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.