ERC: Sync version 5.3, release candidate 1.
[bpt/emacs.git] / lisp / generic-x.el
index e0fb811..3310c38 100644 (file)
@@ -1,6 +1,7 @@
 ;;; generic-x.el --- A collection of generic modes
 
-;; Copyright (C) 1997, 1998, 2003, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2001, 2002, 2003, 2004,
+;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author:  Peter Breton <pbreton@cs.umb.edu>
 ;; Created: Tue Oct 08 1996
@@ -10,7 +11,7 @@
 
 ;; GNU Emacs 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)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 
 ;; 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.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 ;;
-;; This file contains a collection generic modes.
+;; This file contains a collection of generic modes.
 ;;
 ;; INSTALLATION:
 ;;
@@ -220,6 +221,7 @@ This hook will be installed if the variable
     etc-modules-conf-generic-mode
     etc-passwd-generic-mode
     etc-services-generic-mode
+    etc-sudoers-generic-mode
     fvwm-generic-mode
     inetd-conf-generic-mode
     mailagent-rules-generic-mode
@@ -243,7 +245,7 @@ This hook will be installed if the variable
   (memq system-type '(windows-nt ms-dos))
   "*Non-nil means the modes in `generic-mswindows-modes' will be defined.
 This is a list of MS-Windows specific generic modes.  This variable
-only effects the default value of `generic-extras-enable-list'."
+only affects the default value of `generic-extras-enable-list'."
   :group 'generic-x
   :type 'boolean
   :version "22.1")
@@ -253,7 +255,7 @@ only effects the default value of `generic-extras-enable-list'."
   (not (memq system-type '(windows-nt ms-dos)))
   "*Non-nil means the modes in `generic-unix-modes' will be defined.
 This is a list of Unix specific generic modes.  This variable only
-effects the default value of `generic-extras-enable-list'."
+affects the default value of `generic-extras-enable-list'."
   :group 'generic-x
   :type 'boolean
   :version "22.1")
@@ -316,7 +318,7 @@ your changes into effect."
      (2 font-lock-variable-name-face)))
   '("access_log\\'")
   nil
-  "Mode for Apache log files"))
+  "Mode for Apache log files."))
 
 ;;; Samba
 (when (memq 'samba-generic-mode generic-extras-enable-list)
@@ -382,6 +384,10 @@ your changes into effect."
   "Generic mode for HOSTS files."))
 
 ;;; Windows INF files
+
+;; If i-g-m-f-f-h is defined, then so is i-g-m.
+(declare-function ini-generic-mode "generic-x")
+
 (when (memq 'inf-generic-mode generic-extras-enable-list)
 
 (define-generic-mode inf-generic-mode
@@ -432,7 +438,7 @@ like an INI file.  You can add this hook to `find-file-hook'."
 (define-generic-mode reg-generic-mode
   '(?\;)
   '("key" "classes_root" "REGEDIT" "REGEDIT4")
-  '(("\\(\\[.*]\\)"          1 font-lock-constant-face)
+  '(("\\(\\[.*\\]\\)"        1 font-lock-constant-face)
     ("^\\([^\n\r]*\\)\\s-*=" 1 font-lock-variable-name-face))
   '("\\.[rR][eE][gG]\\'")
   (list
@@ -442,6 +448,8 @@ like an INI file.  You can add this hook to `find-file-hook'."
            '((nil "^\\s-*\\(.*\\)\\s-*=" 1))))))
   "Generic mode for MS-Windows Registry files."))
 
+(declare-function w32-shell-name "w32-fns" ())
+
 ;;; DOS/Windows BAT files
 (when (memq 'bat-generic-mode generic-extras-enable-list)
 
@@ -492,7 +500,7 @@ like an INI file.  You can add this hook to `find-file-hook'."
        "MD"        "md"         "Md"
        "PATH"      "path"       "Path"
        "PAUSE"     "pause"      "Pause"
-       "PROMPT"            "prompt"     "Prompt"
+       "PROMPT"    "prompt"     "Prompt"
        "RD"        "rd"         "Rd"
        "REN"       "ren"        "Ren"
        "SET"       "set"        "Set"
@@ -511,16 +519,17 @@ like an INI file.  You can add this hook to `find-file-hook'."
        (1 font-lock-builtin-face)
        (2 font-lock-variable-name-face t t))))
   '("\\.[bB][aA][tT]\\'"
+    "\\.[cC][mM][dD]\\'"
     "\\`[cC][oO][nN][fF][iI][gG]\\."
     "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
   '(generic-bat-mode-setup-function)
-  "Generic mode for MS-Windows BAT files.")
+  "Generic mode for MS-Windows batch files.")
 
 (defvar bat-generic-mode-syntax-table nil
   "Syntax table in use in `bat-generic-mode' buffers.")
 
 (defvar bat-generic-mode-keymap (make-sparse-keymap)
-  "Keymap for bet-generic-mode.")
+  "Keymap for `bat-generic-mode'.")
 
 (defun bat-generic-mode-compile ()
   "Run the current BAT file in a compilation buffer."
@@ -782,7 +791,7 @@ like an INI file.  You can add this hook to `find-file-hook'."
      (2 font-lock-constant-face)))
   '("[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'")
   nil
-  "Mode for Java Manifest files"))
+  "Mode for Java Manifest files."))
 
 ;; Java properties files
 (when (memq 'java-properties-generic-mode generic-extras-enable-list)
@@ -1705,6 +1714,8 @@ like an INI file.  You can add this hook to `find-file-hook'."
     "reiserfs"
     "romfs"
     "smbfs"
+    "cifs"
+    "usbdevfs"
     "sysv"
     "tmpfs"
     "udf"
@@ -1716,7 +1727,7 @@ like an INI file.  You can add this hook to `find-file-hook'."
     "swap"
     "auto"
     "ignore")
-  '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)"
+  '(("^\\([^# \t]+\\)\\s-+\\([^# \t]+\\)"
      (1 font-lock-type-face t)
      (2 font-lock-variable-name-face t)))
   '("/etc/[v]*fstab\\'")
@@ -1724,7 +1735,22 @@ like an INI file.  You can add this hook to `find-file-hook'."
    (function
     (lambda ()
       (setq imenu-generic-expression
-           '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1))))))))
+           '((nil "^\\([^# \t]+\\)\\s-+" 1))))))))
+
+;; /etc/sudoers
+(when (memq 'etc-sudoers-generic-mode generic-extras-enable-list)
+
+(define-generic-mode etc-sudoers-generic-mode
+  '(?#)
+  '("User_Alias" "Runas_Alias" "Host_Alias"  "Cmnd_Alias"
+    "NOPASSWD" "PASSWD" "NOEXEC" "EXEC"
+    "ALL")
+  '(("\\<\\(root\\|su\\)\\>" 1 font-lock-warning-face)
+    ("\\(\\*\\)" 1 font-lock-warning-face)
+    ("\\<\\(%[A-Za-z0-9_]+\\)\\>" 1 font-lock-variable-name-face))
+  '("/etc/sudoers\\'")
+  nil
+  "Generic mode for sudoers configuration files."))
 
 ;; From Jacques Duthen <jacques.duthen@sncf.fr>
 (when (memq 'show-tabs-generic-mode generic-extras-enable-list)
@@ -1733,17 +1759,17 @@ like an INI file.  You can add this hook to `find-file-hook'."
 
 (defconst show-tabs-generic-mode-font-lock-defaults-1
   '(;; trailing spaces must come before...
-    ("[ \t]+$" . 'show-tabs-space-face)
+    ("[ \t]+$" . 'show-tabs-space)
     ;; ...embedded tabs
-    ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face))))
+    ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab))))
 
 (defconst show-tabs-generic-mode-font-lock-defaults-2
   '(;; trailing spaces must come before...
-    ("[ \t]+$" . 'show-tabs-space-face)
+    ("[ \t]+$" . 'show-tabs-space)
     ;; ...tabs
-    ("\t+" . 'show-tabs-tab-face))))
+    ("\t+" . 'show-tabs-tab))))
 
-(defface show-tabs-tab-face
+(defface show-tabs-tab
   '((((class grayscale) (background light)) (:background "DimGray"   :weight bold))
     (((class grayscale) (background dark))  (:background "LightGray" :weight bold))
     (((class color)     (min-colors 88))    (:background "red1"))
@@ -1751,8 +1777,10 @@ like an INI file.  You can add this hook to `find-file-hook'."
     (t (:weight bold)))
   "Font Lock mode face used to highlight TABs."
   :group 'generic-x)
+;; backward-compatibility alias
+(put 'show-tabs-tab-face 'face-alias 'show-tabs-tab)
 
-(defface show-tabs-space-face
+(defface show-tabs-space
   '((((class grayscale) (background light)) (:background "DimGray"   :weight bold))
     (((class grayscale) (background dark))  (:background "LightGray" :weight bold))
     (((class color)     (min-colors 88))    (:background "yellow1"))
@@ -1760,6 +1788,8 @@ like an INI file.  You can add this hook to `find-file-hook'."
     (t (:weight bold)))
   "Font Lock mode face used to highlight spaces."
   :group 'generic-x)
+;; backward-compatibility alias
+(put 'show-tabs-space-face 'face-alias 'show-tabs-space)
 
 (define-generic-mode show-tabs-generic-mode
   nil ;; no comment char
@@ -1768,7 +1798,7 @@ like an INI file.  You can add this hook to `find-file-hook'."
   nil ;; no auto-mode-alist
   ;; '(show-tabs-generic-mode-hook-fun)
   nil
-  "Generic mode to show tabs and trailing spaces"))
+  "Generic mode to show tabs and trailing spaces."))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; DNS modes