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

[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._-]+\\)?\\'" .
ini-mode)
                        ("\\.desktop\\'" . ini-unix-mode)
                        ("\\.properties\\(?:\\.[a-zA-Z0-9._-]+\\)?\\'" . 
ini-java-mode)
                        
("\\`/etc/\\(?:aliases\\|DIR_COLORS\\|ethers\\|.?fstab\\|gnokiirc\\|.*hosts\\
|kde3rc\\|ksysguarddrc\\|lesskey\\|login\\.defs\\|mtab\\|opera6rc\\|permissio
|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
                
("/\\.\\(?:enigma\\|gltron\\|hxplayer\\|kde\\|net\\|neverball\\|qt/.+\\|realp
layer\\|scummvm\\|sversion\\|sylpheed/.+\\|xmp\\)rc\\'" . ini-mode)
                
("/\\.\\(?:gdbtkinit\\|grip\\|orbital/.+txt\\|rhosts\\|tuxracer/options\\)\\'"
. ini-mode)
                        ("/\\.?X\\(?:default\\|resource\\|re\\)s\\>" . 
ini-xdefaults-mode)
                        ("/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)
                        ,@auto-mode-alist))

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
varieties
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:
                              http://lernu.net/




reply via email to

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