emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: magic-mode-alist gets in the way


From: James J. Ramsey
Subject: Re: magic-mode-alist gets in the way
Date: Tue, 4 Jan 2005 15:17:18 -0800 (PST)

--- Richard Stallman <address@hidden> wrote:

>     Trouble is, when it *isn't* what is wanted,
> changing
>     the behavior is tricky.
> 
> It can't be that hard to copy the code from the
> definition of
> magic-mode-alist and change the aspect you want to
> change.

Actually, it may be be unexpectedly tricky because it
would require knowing what the backquote and comma do
in Lisp, something I only learned after working on
patches to PSGML and ispell.el. It also requires
learning where magic-mode-alist is defined, an
internal detail that may change from one Emacs version
to the next. Also, many distributions by default don't
install the .el files for Emacs, only the .elc files,
so finding files.el becomes that much trickier. (In
such a case, the .el files are in a separate package.)

Also, the case has not yet been made for why a unified
auto-mode-alist is such a bad idea. The objection that
I've seen so far is that the entries that match by
file content would be unknowingly overridden by the
entries that match by file extension, but that isn't
always a bad thing, nor always what would happen.

Assume for the sake of argument that there is one
auto-mode-alist, where each alist entry is in one of
two forms:

("regexp-matching-extension" . foo-mode)

or

('magic . "regexp-matching-contents" . foo-mode)

Assume also that entries corresponding to the current
entries of magic-mode-alist are at the top of this
auto-mode-alist.

Now if someone has

(setq auto-mode-alist (cons '("\\.xml\\'" . nxml-mode)
auto-mode-alist))

in his/her ~/.emacs, then files ending in ".xml" will
be edited in nXML mode. What happens if said user
edits a .conf file that happens to be XML in Emacs?
Then the next match in auto-mode-alist will be the
regexp matching the contents of an XML file, and
everything is hunky-dory. What happens when the user
edits a file ending in ".xml.pl"? Same thing that
happens when a user edits a file ending in ".conf"
(because of the "\\'" at the end of the regexp
"\\.xml\\'")

Now if a user has

(setq auto-mode-alist (cons '("\\.html\\'" .
nxml-mode) auto-mode-alist))

in his/her ~/.emacs, then of course files ending in
".html" will be edited in nXML mode, overriding the
entry in auto-mode-alist matching the contents of a
HTML file--which is the behavior the user wants. Does
the user know that the overridden entry in
auto-mode-alist matches the file contents rather than
the file name? Probably not. Should the user care
about that? I can't see why that would matter to a
user.



                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250




reply via email to

[Prev in Thread] Current Thread [Next in Thread]