;;; config-mode.el --- Major mode for configuration files ;; Copyright (C) 2000 Stéphane Levant ;; Author: Stéphane Levant ;; Created: 2000 ;; Keywords: languages ;; Version: 1.1 ;; URL: http://arsunik.free.fr/emacs ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; Config mode, for editing all files where "#" begins a comment. ;; INSTALL: Adds this lines to your .emacs : ;; (autoload 'config-mode "config-mode" "" t) ;; ; add it at the end of the list ! (important for the "/etc/") ;; (setq auto-mode-alist ;; (append auto-mode-alist '(("rc$" . config-mode) ;; ("^/etc/" . config-mode) ;; (".conf$" . config-mode) ;; ("\\.properties$" . config-mode) ;; ("\\.prop$" . config-mode) ;; ("\\.cfg$" . config-mode))) ;; TODO : try to autodect if the file looks like a configuration file and ;; what is the comment char. ;;; Code: (defvar config-mode-hook nil) (defvar config-mode-syntax-table nil) (if config-mode-syntax-table () (setq config-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?# "<" config-mode-syntax-table) (modify-syntax-entry ?\n ">" config-mode-syntax-table)) (defvar config-font-lock-keywords '(( "^###.*$" 0 font-lock-title-face t))) (cond ((not (facep 'font-lock-title-face)) (defvar font-lock-title-face 'font-lock-title-face) (copy-face 'bold 'font-lock-title-face))) ;;;###autoload (defun config-mode () (interactive) "Config mode, for editing all files where \"#\" begins a comment." (kill-all-local-variables) (set-syntax-table config-mode-syntax-table) (make-local-variable 'comment-start) (make-local-variable 'font-lock-defaults) (setq comment-start "#" major-mode 'config-mode mode-name "Config" font-lock-defaults '(config-font-lock-keywords nil nil nil)) (run-hooks 'config-mode-hook)) ;;; config-mode.el ends here