help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Some questions of a newbie


From: Kai Grossjohann
Subject: Re: Some questions of a newbie
Date: Mon, 23 Apr 2007 14:37:39 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.97 (gnu/linux)

Cecil Westerhof <dummy@dummy.nl> writes:

> I added org-mode and nxml-mode.
> The first uses:
>   (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
> the second uses:
>   (setq auto-mode-alist
>     (cons '("\\.\\(xml\\|xsl\\|rng\\|xhtml\\)\\'" . nxml-mode)
>       auto-mode-alist))
>
> Is there a reason for this, or is it just what the creator liked? If the
> second is the reason, then I prefer the first way and will change the way
> of nxml.

It is a matter of style and taste.  I prefer to use add-to-list over
the setq-cons combination because it creates simpler-looking code.
(add-to-list also checks if the entry is already present, the
setq-cons combination shown there might add dupes.)

However, the two variants also differ in that the former uses $ and
the latter uses \\'.  $ matches at end of line or end of string,
whereas \\' only matches at end of string.

So if you had a file named foo.org\nbla where \n stands for a newline
character, then the regex "\\.org$" would match.  "\\.org\\'" wouldn't
match.

Since file names with newlines in them are rare, this difference has
little practical relevance.  Yet, I can't resist to use \\' just
because it's *right* :-)

Kai






reply via email to

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