unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* about auto-mode-alist
@ 2007-11-30  1:38 step
  2007-11-30  2:13 ` Billy O'Connor
       [not found] ` <mailman.4329.1196388926.18990.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: step @ 2007-11-30  1:38 UTC (permalink / raw)
  To: help-gnu-emacs

  hi,i use gnu emacs23 ,when i set the auto-mode-alist, it seems don't
work.
  the elisp i add in the my .emacs file follow:
   (setq auto-mode-alist
  (append '(("\\.css\\'"  . css-mode)
            ("\\.c\\'"    . c-mode)
            ("\\.cc\\'"   . c++-mode)
            ("\\.cpp\\'"  . c++-mode)
            ("\\.cxx\\'"  . c++-mode)
            ("\\.hpp\\'"  . c++-mode)
            ("\\.e\\'"    . eiffel-mode)
            ("\\.hxx\\'"  . c++-mode)
            ("\\.h\\'"    . c-mode)
            ("\\.hh\\'"   . c++-mode)
            ("\\.idl\\'"  . c++-mode)
            ("\\.ipp\\'"  . c++-mode)
            ("\\.java\\'" . java-mode)
            ("\\.lua\\'"   . lua-mode)
            ("\\.pl\\'"   . perl-mode)
            ("\\.pm\\'"   . perl-mode)
            ("\\.rb\\'"   . ruby-mode)
            ("\\.rbw\\'"  . ruby-mode)
            ("\\.t2t\\'"  . t2t-mode)
	    ("\\.txt\\'"  . text-mode)
            ("\\.py\\'"   . python-mode)
     	    ("\\.tex\\'"  . LaTeX-mode)
	    ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
	    )
      auto-mode-alist))
   when i use the C-x C-f create a new .xml file ,it can auto load to
nxml-mode ,but if i open a exist .xml file ,it auto load to sgml-mode
which is the default mode emacs set in the file.el .
   is there somebody konw why? thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: about auto-mode-alist
  2007-11-30  1:38 about auto-mode-alist step
@ 2007-11-30  2:13 ` Billy O'Connor
       [not found] ` <mailman.4329.1196388926.18990.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Billy O'Connor @ 2007-11-30  2:13 UTC (permalink / raw)
  To: help-gnu-emacs

step <fxlzju@gmail.com> writes:

>   hi,i use gnu emacs23 ,when i set the auto-mode-alist, it seems don't
> work.
>   the elisp i add in the my .emacs file follow:
>    (setq auto-mode-alist
>   (append '(("\\.css\\'"  . css-mode)
>             ("\\.c\\'"    . c-mode)
>             ("\\.cc\\'"   . c++-mode)
>             ("\\.cpp\\'"  . c++-mode)
>             ("\\.cxx\\'"  . c++-mode)
>             ("\\.hpp\\'"  . c++-mode)
>             ("\\.e\\'"    . eiffel-mode)
>             ("\\.hxx\\'"  . c++-mode)
>             ("\\.h\\'"    . c-mode)
>             ("\\.hh\\'"   . c++-mode)
>             ("\\.idl\\'"  . c++-mode)
>             ("\\.ipp\\'"  . c++-mode)
>             ("\\.java\\'" . java-mode)
>             ("\\.lua\\'"   . lua-mode)
>             ("\\.pl\\'"   . perl-mode)
>             ("\\.pm\\'"   . perl-mode)
>             ("\\.rb\\'"   . ruby-mode)
>             ("\\.rbw\\'"  . ruby-mode)
>             ("\\.t2t\\'"  . t2t-mode)
> 	    ("\\.txt\\'"  . text-mode)
>             ("\\.py\\'"   . python-mode)
>      	    ("\\.tex\\'"  . LaTeX-mode)
> 	    ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
> 	    )
>       auto-mode-alist))
>    when i use the C-x C-f create a new .xml file ,it can auto load to
> nxml-mode ,but if i open a exist .xml file ,it auto load to sgml-mode
> which is the default mode emacs set in the file.el .
>    is there somebody konw why? thanks!

Your code works for my xml files, both old and new.  Could you have mode
tags at the top of some xml files that are forcing xml mode?

--
Billy O'Connor

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: about auto-mode-alist
       [not found] ` <mailman.4329.1196388926.18990.help-gnu-emacs@gnu.org>
@ 2007-11-30  2:25   ` step
  2007-11-30  2:38   ` step
  1 sibling, 0 replies; 5+ messages in thread
From: step @ 2007-11-30  2:25 UTC (permalink / raw)
  To: help-gnu-emacs

On 11月30日, 上午10时13分, Billy O'Connor <bill...@gmail.com> wrote:
> step <fxl...@gmail.com> writes:
> >   hi,i use gnu emacs23 ,when i set the auto-mode-alist, it seems don't
> > work.
> >   the elisp i add in the my .emacs file follow:
> >    (setq auto-mode-alist
> >   (append '(("\\.css\\'"  . css-mode)
> >             ("\\.c\\'"    . c-mode)
> >             ("\\.cc\\'"   . c++-mode)
> >             ("\\.cpp\\'"  . c++-mode)
> >             ("\\.cxx\\'"  . c++-mode)
> >             ("\\.hpp\\'"  . c++-mode)
> >             ("\\.e\\'"    . eiffel-mode)
> >             ("\\.hxx\\'"  . c++-mode)
> >             ("\\.h\\'"    . c-mode)
> >             ("\\.hh\\'"   . c++-mode)
> >             ("\\.idl\\'"  . c++-mode)
> >             ("\\.ipp\\'"  . c++-mode)
> >             ("\\.java\\'" . java-mode)
> >             ("\\.lua\\'"   . lua-mode)
> >             ("\\.pl\\'"   . perl-mode)
> >             ("\\.pm\\'"   . perl-mode)
> >             ("\\.rb\\'"   . ruby-mode)
> >             ("\\.rbw\\'"  . ruby-mode)
> >             ("\\.t2t\\'"  . t2t-mode)
> >        ("\\.txt\\'"  . text-mode)
> >             ("\\.py\\'"   . python-mode)
> >                ("\\.tex\\'"  . LaTeX-mode)
> >        ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
> >        )
> >       auto-mode-alist))
> >    when i use the C-x C-f create a new .xml file ,it can auto load to
> > nxml-mode ,but if i open a exist .xml file ,it auto load to sgml-mode
> > which is the default mode emacs set in the file.el .
> >    is there somebody konw why? thanks!
>
> Your code works for my xml files, both old and new.  Could you have mode
> tags at the top of some xml files that are forcing xml mode?
>
> --
> Billy O'Connor

i use this in the xml file header
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://
www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
or the docbook example xml file int /usr/share
<?xml version='1.0'?>
<!DOCTYPE book SYSTEM "/usr/share/xml/docbook/schema/dtd/4.4/
docbookx.dtd">

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: about auto-mode-alist
       [not found] ` <mailman.4329.1196388926.18990.help-gnu-emacs@gnu.org>
  2007-11-30  2:25   ` step
@ 2007-11-30  2:38   ` step
  2007-11-30  2:41     ` step
  1 sibling, 1 reply; 5+ messages in thread
From: step @ 2007-11-30  2:38 UTC (permalink / raw)
  To: help-gnu-emacs

On 11月30日, 上午10时13分, Billy O'Connor <bill...@gmail.com> wrote:
> step <fxl...@gmail.com> writes:
> >   hi,i use gnu emacs23 ,when i set the auto-mode-alist, it seems don't
> > work.
> >   the elisp i add in the my .emacs file follow:
> >    (setq auto-mode-alist
> >   (append '(("\\.css\\'"  . css-mode)
> >             ("\\.c\\'"    . c-mode)
> >             ("\\.cc\\'"   . c++-mode)
> >             ("\\.cpp\\'"  . c++-mode)
> >             ("\\.cxx\\'"  . c++-mode)
> >             ("\\.hpp\\'"  . c++-mode)
> >             ("\\.e\\'"    . eiffel-mode)
> >             ("\\.hxx\\'"  . c++-mode)
> >             ("\\.h\\'"    . c-mode)
> >             ("\\.hh\\'"   . c++-mode)
> >             ("\\.idl\\'"  . c++-mode)
> >             ("\\.ipp\\'"  . c++-mode)
> >             ("\\.java\\'" . java-mode)
> >             ("\\.lua\\'"   . lua-mode)
> >             ("\\.pl\\'"   . perl-mode)
> >             ("\\.pm\\'"   . perl-mode)
> >             ("\\.rb\\'"   . ruby-mode)
> >             ("\\.rbw\\'"  . ruby-mode)
> >             ("\\.t2t\\'"  . t2t-mode)
> >        ("\\.txt\\'"  . text-mode)
> >             ("\\.py\\'"   . python-mode)
> >                ("\\.tex\\'"  . LaTeX-mode)
> >        ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
> >        )
> >       auto-mode-alist))
> >    when i use the C-x C-f create a new .xml file ,it can auto load to
> > nxml-mode ,but if i open a exist .xml file ,it auto load to sgml-mode
> > which is the default mode emacs set in the file.el .
> >    is there somebody konw why? thanks!
>
> Your code works for my xml files, both old and new.  Could you have mode
> tags at the top of some xml files that are forcing xml mode?
>
> --
> Billy O'Connor

ok i konw why this happen,the magic-mode-alist define
i add this
 (setq magic-mode-alist
	  (cons '("<\\?xml " . nxml-mode)
	  magic-mode-alist))
(fset 'xml-mode 'nxml-mode)

 it can work

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: about auto-mode-alist
  2007-11-30  2:38   ` step
@ 2007-11-30  2:41     ` step
  0 siblings, 0 replies; 5+ messages in thread
From: step @ 2007-11-30  2:41 UTC (permalink / raw)
  To: help-gnu-emacs

On 11月30日, 上午10时38分, step <fxl...@gmail.com> wrote:
> On 11月30日, 上午10时13分, Billy O'Connor <bill...@gmail.com> wrote:
>
>
>
> > step <fxl...@gmail.com> writes:
> > >   hi,i use gnu emacs23 ,when i set the auto-mode-alist, it seems don't
> > > work.
> > >   the elisp i add in the my .emacs file follow:
> > >    (setq auto-mode-alist
> > >   (append '(("\\.css\\'"  . css-mode)
> > >             ("\\.c\\'"    . c-mode)
> > >             ("\\.cc\\'"   . c++-mode)
> > >             ("\\.cpp\\'"  . c++-mode)
> > >             ("\\.cxx\\'"  . c++-mode)
> > >             ("\\.hpp\\'"  . c++-mode)
> > >             ("\\.e\\'"    . eiffel-mode)
> > >             ("\\.hxx\\'"  . c++-mode)
> > >             ("\\.h\\'"    . c-mode)
> > >             ("\\.hh\\'"   . c++-mode)
> > >             ("\\.idl\\'"  . c++-mode)
> > >             ("\\.ipp\\'"  . c++-mode)
> > >             ("\\.java\\'" . java-mode)
> > >             ("\\.lua\\'"   . lua-mode)
> > >             ("\\.pl\\'"   . perl-mode)
> > >             ("\\.pm\\'"   . perl-mode)
> > >             ("\\.rb\\'"   . ruby-mode)
> > >             ("\\.rbw\\'"  . ruby-mode)
> > >             ("\\.t2t\\'"  . t2t-mode)
> > >        ("\\.txt\\'"  . text-mode)
> > >             ("\\.py\\'"   . python-mode)
> > >                ("\\.tex\\'"  . LaTeX-mode)
> > >        ("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
> > >        )
> > >       auto-mode-alist))
> > >    when i use the C-x C-f create a new .xml file ,it can auto load to
> > > nxml-mode ,but if i open a exist .xml file ,it auto load to sgml-mode
> > > which is the default mode emacs set in the file.el .
> > >    is there somebody konw why? thanks!
>
> > Your code works for my xml files, both old and new.  Could you have mode
> > tags at the top of some xml files that are forcing xml mode?
>
> > --
> > Billy O'Connor
>
> ok i konw why this happen,the magic-mode-alist define
> i add this
>  (setq magic-mode-alist
>           (cons '("<\\?xml " . nxml-mode)
>           magic-mode-alist))
> (fset 'xml-mode 'nxml-mode)
>
>  it can work

the magic-mode-alist document in help manual:

Alist of buffer beginnings vs. corresponding major mode functions.
Each element looks like (REGEXP . FUNCTION).  After visiting a file,
if REGEXP matches the text at the beginning of the buffer,
`normal-mode' will call FUNCTION rather than allowing `auto-mode-
alist'
to decide the buffer's major mode.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-11-30  2:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-30  1:38 about auto-mode-alist step
2007-11-30  2:13 ` Billy O'Connor
     [not found] ` <mailman.4329.1196388926.18990.help-gnu-emacs@gnu.org>
2007-11-30  2:25   ` step
2007-11-30  2:38   ` step
2007-11-30  2:41     ` step

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).