[Top][All Lists]

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

Re: Wrong mode chosen

From: Daniel Pfeiffer
Subject: Re: Wrong mode chosen
Date: Tue, 19 Oct 2004 21:24:11 +0200

Saluton, Moin,

Richard Stallman <address@hidden> skribis:

>     Right now I'm working on ini-mode.el which gives some basic handling,
>     imenu, outline and font-lock for conf files, like
>     var = value
>     var: value
>     var value
>     There are many subtle varieties of these syntaxes and also of file
>     names.  But by far the most *.ini, *.cf, *cfg, *.conf and *.config files
>     are like this. 
> And how would you detect the files written in this mode?

I'm not through with all the odd-named files, but already I have:

(setq auto-mode-alist `(("\\.[iI][nN][iI]\\'" . ini-mode)
                        ;; *.cf, *.cfg, *.conf, 
*.config[.local|.de_DE.UTF8|...], */config
("[/.]c\\(?:on\\)?f\\(?:i?g\\)?\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" .
                        ("\\.desktop\\'" . ini-unix-mode)
                        ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . 
|ns\\|protocols\\|rpc\\|services\\)\\'" . ini-mode)
                        ;; either user's dot-files or under /etc or some such
                        ("/\\.?\\(?:mime\\.types\\|wgetrc\\)\\'" . ini-mode)
                        ;; alas not all ~/.*rc files are like this
layer\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . ini-mode)
. ini-mode)
                        ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . 
                        ("/X11.+app-defaults/" . ini-xdefaults-mode)
                        ("/X11.+locale/.+/Compose\\'" . ini-colon-mode)
                        ;; this contains everything twice, with space and with 
colon :-(
                        ("/X11.+locale/compose\\.dir\\'" . ini-java-mode)

The ini-*-modes are preconfigured for one style, while ini-mode parses the
buffer to find the comment and assignment style.  */.*rc is too unsure, unless
we positively list all that need something else earlier.  But all the *.config
are a pretty sure bet -- if you pick out shell scripts and XML.  This could of
course be done in my parsing, but a general mechanism seems more useful.  And
it would seem strange to say M-x ini-mode and get sh-mode.

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

lerne / learn / apprends / lär dig / ucz się    Esperanto:

reply via email to

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