From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: step Newsgroups: gmane.emacs.help Subject: Re: about auto-mode-alist Date: Thu, 29 Nov 2007 18:41:17 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <1a72b8a8-1a18-46a8-b336-e746f33c643f@e10g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1196394041 5774 80.91.229.12 (30 Nov 2007 03:40:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 30 Nov 2007 03:40:41 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Nov 30 04:40:48 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IxwkB-0001bj-Tg for geh-help-gnu-emacs@m.gmane.org; Fri, 30 Nov 2007 04:40:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ixwjw-0001OH-1Q for geh-help-gnu-emacs@m.gmane.org; Thu, 29 Nov 2007 22:40:32 -0500 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!i12g2000prf.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 67 Original-NNTP-Posting-Host: 210.32.174.48 Original-X-Trace: posting.google.com 1196390477 28330 127.0.0.1 (30 Nov 2007 02:41:17 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Fri, 30 Nov 2007 02:41:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i12g2000prf.googlegroups.com; posting-host=210.32.174.48; posting-account=36-j9AoAAAC2cBASboXsNT86-OhbxFJB User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061010 Firefox/2.0,gzip(gfe),gzip(gfe) Content-Disposition: inline Original-Xref: shelby.stanford.edu gnu.emacs.help:154285 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:49713 Archived-At: On 11=D4=C230=C8=D5, =C9=CF=CE=E710=CA=B138=B7=D6, step w= rote: > On 11=D4=C230=C8=D5, =C9=CF=CE=E710=CA=B113=B7=D6, Billy O'Connor wrote: > > > > > step 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 '("<=A3=DC=A3=DC?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.