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

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

Ini mode


From: Daniel Pfeiffer
Subject: Ini mode
Date: Sun, 10 Oct 2004 10:56:16 +0200

Under Windows Ini files are wide-spread.  They follow the schema

; comment
[section]
var maybe with spaces = value

On Unix they are also used.  But except for Wine and ported stuff, comments
are mostly with `#'.  There are also many where the schema is

# coment
var: value

or

var value

And .Xdefaults has comments with `!'.  Java properties top it all, with three
different comment syntaxes and three assigment syntaxes at once:

# comment
// comment
/* comment */
var = value
var: value
var value

Aside from these variations, they're all alike.  So it makes sence to have one
mode for them.  There are two candidates in the net, Aurélien Tisné's generic
one and Robert Fitzgerald's one, which only works when set up for the allowed
sections and vars per file.  This latter feature can be good as an add-on, so
I'm in discussion with Bob as to how the two approaches can be integrated.

In the meanwhile I have spiffied up Aurélien's mode to cover all the above
syntaxes.  I've added an alignment function which improves the readability
tremendously.

The major head-ache is automatic set up of this.  Files may be named x.ini,
x.cfg, x.conf, ~/.xrc or anything else.  Not all that have the same suffix
follow the same schema.  And indeed not all config files with these names, are
inis at all (.bashrc, .sawfishrc).  This would lead to huge regexps to cover
it all correctly.  Here's some of what I've found:

(setq auto-mode-alist `(;; ntfs & smbfs mounts
                        ("\\`/windows/.*\\.[iI][nN][iI]\\'" . ini-windows-mode)
                        ("\\.[iI][nN][iI]\\'" . ini-mode)
                        ("/\\.opera/.*\\.ini\\'" . ini-windows-mode)
                        ("/\\.wine/config\\'" . ini-windows-mode)
                        ("/smb\\.conf\\'" . ini-unix-mode)
                        ("\\.desktop\\'" . ini-unix-mode)
                        ("\\.properties\\(?:\\.[a-z_]+\\)\\'" . ini-java-mode)
                        ("/\\.?mime\\.types\\'" . ini-space-mode)
                        ("/\\.X\\(?:default\\|resource\\)s\\'" . 
ini-xdefaults-mode)
                        ("/X11/locale/compose\\.dir\\'" . ini-space-mode)
                        ("/X11/locale/.*/Compose\\'" . ini-colon-mode)
                
("/\\.\\(?:enigma\\|gltron\\|hxplayer\\|kde\\|realplayer\\|scummvm\\|sversion
\\|wget\\)rc\\'" . ini-mode)
                        ,@auto-mode-alist))

Unlike Bob's mode this does not follow all guidelines.  But I'm publishing it
to get some more discussion going.  This is in the goal of making it part of
Emacs.

Bummer, for some reason T-online provider thinks that gnu.emacs.sources
doesn't take attachments, so pick this up from

http://dapfy.bei.t-online.de/ini-mode.el

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]