Mercurial > emacs
changeset 60774:65f5b049afac
Don't prevent compilation. Don't require generic.
Follow coding conventions. Minor code cleanup.
(etc-fstab-generic-mode): Add some keywords.
author | Lute Kamstra <lute@gnu.org> |
---|---|
date | Mon, 21 Mar 2005 17:10:57 +0000 |
parents | 1771db839aa6 |
children | f36a881a67e2 |
files | lisp/generic-x.el |
diffstat | 1 files changed, 667 insertions(+), 760 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/generic-x.el Mon Mar 21 17:10:06 2005 +0000 +++ b/lisp/generic-x.el Mon Mar 21 17:10:57 2005 +0000 @@ -1,6 +1,6 @@ -;;; generic-x.el --- Extra Modes for generic-mode -*- no-byte-compile: t -*- +;;; generic-x.el --- Extra Modes for generic-mode -;; Copyright (C) 1997, 1998, 2003 Free Software Foundation, Inc. +;; Copyright (C) 1997, 1998, 2003, 2005 Free Software Foundation, Inc. ;; Author: Peter Breton <pbreton@cs.umb.edu> ;; Created: Tue Oct 08 1996 @@ -34,7 +34,7 @@ ;; (require 'generic-x) ;; ;; You can decide which modes to load by setting the variable -;; `generic-extras-enable-list'. Some platform-specific modes are +;; `generic-extras-enable-list'. Some platform-specific modes are ;; affected by the variables `generic-define-mswindows-modes' and ;; `generic-define-unix-modes' (which see). ;; @@ -92,7 +92,6 @@ ;;; Code: -(require 'generic) (require 'font-lock) (defgroup generic-x nil @@ -103,53 +102,52 @@ (defcustom generic-extras-enable-list nil "*List of generic modes to enable by default. -Each entry in the list should be a symbol. -The variables `generic-define-mswindows-modes' and `generic-define-unix-modes' -also affect which generic modes are defined. -Please note that if you set this variable after generic-x is loaded, -you must reload generic-x to enable the specified modes." +Each entry in the list should be a symbol. The variables +`generic-define-mswindows-modes' and `generic-define-unix-modes' +also affect which generic modes are defined. Please note that if +you set this variable after generic-x is loaded, you must reload +generic-x to enable the specified modes." :group 'generic-x - :type '(repeat sexp) - ) + :type '(repeat sexp)) (defcustom generic-define-mswindows-modes - (memq system-type (list 'windows-nt 'ms-dos)) + (memq system-type '(windows-nt ms-dos)) "*If non-nil, some MS-Windows specific generic modes will be defined." :group 'generic-x - :type 'boolean - ) + :type 'boolean) (defcustom generic-define-unix-modes - (not (memq system-type (list 'windows-nt 'ms-dos))) + (not (memq system-type '(windows-nt ms-dos))) "*If non-nil, some Unix specific generic modes will be defined." :group 'generic-x - :type 'boolean - ) + :type 'boolean) (and generic-define-mswindows-modes - (setq generic-extras-enable-list - (append (list 'bat-generic-mode 'ini-generic-mode - 'inf-generic-mode 'rc-generic-mode - 'reg-generic-mode 'rul-generic-mode - 'hosts-generic-mode - 'apache-conf-generic-mode - 'apache-log-generic-mode - ) - generic-extras-enable-list))) + (setq generic-extras-enable-list + (append (list 'bat-generic-mode + 'ini-generic-mode + 'inf-generic-mode + 'rc-generic-mode + 'reg-generic-mode + 'rul-generic-mode + 'hosts-generic-mode + 'apache-conf-generic-mode + 'apache-log-generic-mode) + generic-extras-enable-list))) (and generic-define-unix-modes (setq generic-extras-enable-list (append (list 'apache-conf-generic-mode 'apache-log-generic-mode 'samba-generic-mode - 'hosts-generic-mode 'fvwm-generic-mode + 'hosts-generic-mode + 'fvwm-generic-mode 'x-resource-generic-mode 'alias-generic-mode 'inetd-conf-generic-mode 'etc-services-generic-mode 'etc-passwd-generic-mode - 'etc-fstab-generic-mode - ) + 'etc-fstab-generic-mode) generic-extras-enable-list))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -157,382 +155,345 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; Apache -(and - (memq 'apache-conf-generic-mode generic-extras-enable-list) +(when (memq 'apache-conf-generic-mode generic-extras-enable-list) -(define-generic-mode 'apache-conf-generic-mode - (list ?#) - nil - '(("^\\s-*\\(<.*>\\)" 1 'font-lock-constant-face) - ("^\\s-*\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face)) - (list "srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'") - (list - (function - (lambda () +(define-generic-mode apache-conf-generic-mode + (list ?#) + nil + '(("^\\s-*\\(<.*>\\)" 1 'font-lock-constant-face) + ("^\\s-*\\(\\sw+\\)\\s-" 1 'font-lock-variable-name-face)) + (list "srm\\.conf\\'" "httpd\\.conf\\'" "access\\.conf\\'") + (list + (function + (lambda () (setq imenu-generic-expression '((nil "^\\([-A-Za-z0-9_]+\\)" 1) ("*Directories*" "^\\s-*<Directory\\s-*\\([^>]+\\)>" 1) - ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1) - )) - ))) - "Generic mode for Apache or HTTPD configuration files.")) + ("*Locations*" "^\\s-*<Location\\s-*\\([^>]+\\)>" 1)))))) + "Generic mode for Apache or HTTPD configuration files.")) -(and - (memq 'apache-log-generic-mode generic-extras-enable-list) +(when (memq 'apache-log-generic-mode generic-extras-enable-list) -(define-generic-mode 'apache-log-generic-mode +(define-generic-mode apache-log-generic-mode nil nil ;; Hostname ? user date request return-code number-of-bytes '(("^\\([-a-zA-z0-9.]+\\) - [-A-Za-z]+ \\(\\[.*\\]\\)" (1 font-lock-constant-face) - (2 font-lock-variable-name-face)) - ) + (2 font-lock-variable-name-face))) (list "access_log\\'") nil "Mode for Apache log files")) ;;; Samba -(and - (memq 'samba-generic-mode generic-extras-enable-list) +(when (memq 'samba-generic-mode generic-extras-enable-list) -(define-generic-mode 'samba-generic-mode - (list ?\; ?#) - nil - '( - ("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face) - ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)" - (1 'font-lock-variable-name-face) - (2 'font-lock-type-face)) - ) - (list "smb\\.conf\\'") - (list 'generic-bracket-support) - "Generic mode for Samba configuration files.")) +(define-generic-mode samba-generic-mode + (list ?\; ?#) + nil + '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face) + ("^\\s-*\\(.+\\)=\\([^\r\n]*\\)" + (1 'font-lock-variable-name-face) + (2 'font-lock-type-face))) + (list "smb\\.conf\\'") + (list 'generic-bracket-support) + "Generic mode for Samba configuration files.")) ;;; Fvwm ;; This is pretty basic. Also, modes for other window managers could ;; be defined as well. -(and -(memq 'fvwm-generic-mode generic-extras-enable-list) +(when (memq 'fvwm-generic-mode generic-extras-enable-list) -(define-generic-mode 'fvwm-generic-mode - (list ?#) - (list - "AddToMenu" - "AddToFunc" - "ButtonStyle" - "EndFunction" - "EndPopup" - "Function" - "IconPath" - "Key" - "ModulePath" - "Mouse" - "PixmapPath" - "Popup" - "Style" - ) - nil - (list "\\.fvwmrc\\'" "\\.fvwm2rc\\'") - nil - "Generic mode for FVWM configuration files.")) +(define-generic-mode fvwm-generic-mode + (list ?#) + (list + "AddToMenu" + "AddToFunc" + "ButtonStyle" + "EndFunction" + "EndPopup" + "Function" + "IconPath" + "Key" + "ModulePath" + "Mouse" + "PixmapPath" + "Popup" + "Style") + nil + (list "\\.fvwmrc\\'" "\\.fvwm2rc\\'") + nil + "Generic mode for FVWM configuration files.")) ;;; X Resource ;; I'm pretty sure I've seen an actual mode to do this, but I don't ;; think it's standard with Emacs -(and - (memq 'x-resource-generic-mode generic-extras-enable-list) +(when (memq 'x-resource-generic-mode generic-extras-enable-list) -(define-generic-mode 'x-resource-generic-mode - (list ?!) - nil - '(("^\\([^:\n]+:\\)" 1 'font-lock-variable-name-face)) - (list "\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'") - nil - "Generic mode for X Resource configuration files.")) +(define-generic-mode x-resource-generic-mode + (list ?!) + nil + '(("^\\([^:\n]+:\\)" 1 'font-lock-variable-name-face)) + (list "\\.Xdefaults\\'" "\\.Xresources\\'" "\\.Xenvironment\\'" "\\.ad\\'") + nil + "Generic mode for X Resource configuration files.")) ;;; Hosts -(and - (memq 'hosts-generic-mode generic-extras-enable-list) +(when (memq 'hosts-generic-mode generic-extras-enable-list) -(define-generic-mode 'hosts-generic-mode - (list ?#) - (list "localhost") - '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-constant-face)) - (list "[hH][oO][sS][tT][sS]\\'") - nil - "Generic mode for HOSTS files.")) +(define-generic-mode hosts-generic-mode + (list ?#) + (list "localhost") + '(("\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-constant-face)) + (list "[hH][oO][sS][tT][sS]\\'") + nil + "Generic mode for HOSTS files.")) ;;; Windows INF files -(and - (memq 'inf-generic-mode generic-extras-enable-list) +(when (memq 'inf-generic-mode generic-extras-enable-list) -(define-generic-mode 'inf-generic-mode - (list ?\;) - nil - '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)) - (list "\\.[iI][nN][fF]\\'") - (list 'generic-bracket-support) - "Generic mode for MS-Windows INF files.")) +(define-generic-mode inf-generic-mode + (list ?\;) + nil + '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face)) + (list "\\.[iI][nN][fF]\\'") + (list 'generic-bracket-support) + "Generic mode for MS-Windows INF files.")) ;;; Windows INI files ;; Should define escape character as well! -(and - (memq 'ini-generic-mode generic-extras-enable-list) +(when (memq 'ini-generic-mode generic-extras-enable-list) -(define-generic-mode 'ini-generic-mode - (list ?\;) - nil - '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face) - ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$" - (1 font-lock-function-name-face) - (2 font-lock-variable-name-face))) - (list "\\.[iI][nN][iI]\\'") - (list - (function - (lambda () - (setq imenu-generic-expression - '((nil "^\\[\\(.*\\)\\]" 1) - ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1))) - ))) - "Generic mode for MS-Windows INI files.")) +(define-generic-mode ini-generic-mode + (list ?\;) + nil + '(("^\\(\\[.*\\]\\)" 1 'font-lock-constant-face) + ("^\\([^=\n\r]*\\)=\\([^\n\r]*\\)$" + (1 font-lock-function-name-face) + (2 font-lock-variable-name-face))) + (list "\\.[iI][nN][iI]\\'") + (list + (function + (lambda () + (setq imenu-generic-expression + '((nil "^\\[\\(.*\\)\\]" 1) + ("*Variables*" "^\\s-*\\([^=]+\\)\\s-*=" 1)))))) + "Generic mode for MS-Windows INI files.")) ;;; Windows REG files ;;; Unfortunately, Windows 95 and Windows NT have different REG file syntax! -(and - (memq 'reg-generic-mode generic-extras-enable-list) +(when (memq 'reg-generic-mode generic-extras-enable-list) -(define-generic-mode 'reg-generic-mode - '(?\;) - '("key" "classes_root" "REGEDIT" "REGEDIT4") - '(("\\(\\[.*]\\)" 1 'font-lock-constant-face) - ("^\\([^\n\r]*\\)\\s-*=" 1 'font-lock-variable-name-face)) - '("\\.[rR][eE][gG]\\'") - (list - (function - (lambda () - (setq imenu-generic-expression - '((nil "^\\s-*\\(.*\\)\\s-*=" 1)))))) - "Generic mode for MS-Windows Registry files.")) +(define-generic-mode reg-generic-mode + '(?\;) + '("key" "classes_root" "REGEDIT" "REGEDIT4") + '(("\\(\\[.*]\\)" 1 'font-lock-constant-face) + ("^\\([^\n\r]*\\)\\s-*=" 1 'font-lock-variable-name-face)) + '("\\.[rR][eE][gG]\\'") + (list + (function + (lambda () + (setq imenu-generic-expression + '((nil "^\\s-*\\(.*\\)\\s-*=" 1)))))) + "Generic mode for MS-Windows Registry files.")) ;;; DOS/Windows BAT files -(if (not (memq 'bat-generic-mode generic-extras-enable-list)) - nil -(define-generic-mode 'bat-generic-mode - nil - nil +(when (memq 'bat-generic-mode generic-extras-enable-list) + +(define-generic-mode bat-generic-mode + nil + nil + (list + ;; Make this one first in the list, otherwise comments will + ;; be over-written by other variables + (list "^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 'font-lock-comment-face t) + (list "^[ \t]*\\(::.*\\)" 1 'font-lock-comment-face t) + (list + "^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)" + '(1 font-lock-builtin-face) + '(2 font-lock-constant-face t t)) + ;; Any text (except ON/OFF) following ECHO is a string. + (list + "^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)" + '(1 font-lock-builtin-face) + '(3 font-lock-constant-face t t) + '(5 font-lock-string-face t t)) + ;; These keywords appear as the first word on a line. (Actually, they + ;; can also appear after "if ..." or "for ..." clause, but since they + ;; are frequently used in simple text, we punt.) + ;; In `generic-bat-mode-setup-function' we make the keywords + ;; case-insensitive + (generic-make-keywords-list (list - ;; Make this one first in the list, otherwise comments will - ;; be over-written by other variables - (list "^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 'font-lock-comment-face t) - (list "^[ \t]*\\(::.*\\)" 1 'font-lock-comment-face t) - (list - "^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)" - '(1 font-lock-builtin-face) - '(2 font-lock-constant-face t t)) - ;; Any text (except ON/OFF) following ECHO is a string. - (list - "^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)" - '(1 font-lock-builtin-face) - '(3 font-lock-constant-face t t) - '(5 font-lock-string-face t t)) - ;; These keywords appear as the first word on a line. (Actually, they - ;; can also appear after "if ..." or "for ..." clause, but since they - ;; are frequently used in simple text, we punt.) - ;; In `generic-bat-mode-setup-function' we make the keywords - ;; case-insensitive - (generic-make-keywords-list - (list - "for" - "if" - ) - 'font-lock-keyword-face "^[@ \t]*") - ;; These keywords can be anywhere on a line - ;; In `generic-bat-mode-setup-function' we make the keywords - ;; case-insensitive - (generic-make-keywords-list - (list - "do" - "exist" - "errorlevel" - "goto" - "not" - ) 'font-lock-keyword-face) - ;; These are built-in commands. Only frequently-used ones are listed. - (generic-make-keywords-list - (list - "CALL" "call" "Call" - "CD" "cd" "Cd" - "CLS" "cls" "Cls" - "COPY" "copy" "Copy" - "DEL" "del" "Del" - "ECHO" "echo" "Echo" - "MD" "md" "Md" - "PATH" "path" "Path" - "PAUSE" "pause" "Pause" - "PROMPT" "prompt" "Prompt" - "RD" "rd" "Rd" - "REN" "ren" "Ren" - "SET" "set" "Set" - "START" "start" "Start" - "SHIFT" "shift" "Shift" - ) 'font-lock-builtin-face "[ \t|\n]") - (list "^[ \t]*\\(:\\sw+\\)" 1 'font-lock-function-name-face t) - (list "\\(%\\sw+%\\)" 1 'font-lock-variable-name-face t) - (list "\\(%[0-9]\\)" 1 'font-lock-variable-name-face t) - (list "\\(/[^/ \"\t\n]+\\)" 1 'font-lock-type-face) - (list "[\t ]+\\([+-][^\t\n\" ]+\\)" 1 'font-lock-type-face) - (list "[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?" - '(1 font-lock-keyword-face) - '(2 font-lock-function-name-face nil t)) - (list "[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?" - '(1 font-lock-builtin-face) - '(2 font-lock-variable-name-face t t)) - - ) + "for" + "if") + 'font-lock-keyword-face "^[@ \t]*") + ;; These keywords can be anywhere on a line + ;; In `generic-bat-mode-setup-function' we make the keywords + ;; case-insensitive + (generic-make-keywords-list + (list + "do" + "exist" + "errorlevel" + "goto" + "not") + 'font-lock-keyword-face) + ;; These are built-in commands. Only frequently-used ones are listed. + (generic-make-keywords-list (list - "\\.[bB][aA][tT]\\'" - "\\`[cC][oO][nN][fF][iI][gG]\\." - "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\." ) - (list 'generic-bat-mode-setup-function) - "Generic mode for MS-Windows BAT 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.") + "CALL" "call" "Call" + "CD" "cd" "Cd" + "CLS" "cls" "Cls" + "COPY" "copy" "Copy" + "DEL" "del" "Del" + "ECHO" "echo" "Echo" + "MD" "md" "Md" + "PATH" "path" "Path" + "PAUSE" "pause" "Pause" + "PROMPT" "prompt" "Prompt" + "RD" "rd" "Rd" + "REN" "ren" "Ren" + "SET" "set" "Set" + "START" "start" "Start" + "SHIFT" "shift" "Shift") + 'font-lock-builtin-face "[ \t|\n]") + (list "^[ \t]*\\(:\\sw+\\)" 1 'font-lock-function-name-face t) + (list "\\(%\\sw+%\\)" 1 'font-lock-variable-name-face t) + (list "\\(%[0-9]\\)" 1 'font-lock-variable-name-face t) + (list "\\(/[^/ \"\t\n]+\\)" 1 'font-lock-type-face) + (list "[\t ]+\\([+-][^\t\n\" ]+\\)" 1 'font-lock-type-face) + (list "[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?" + '(1 font-lock-keyword-face) + '(2 font-lock-function-name-face nil t)) + (list "[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?" + '(1 font-lock-builtin-face) + '(2 font-lock-variable-name-face t t))) + (list + "\\.[bB][aA][tT]\\'" + "\\`[cC][oO][nN][fF][iI][gG]\\." + "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\." ) + (list 'generic-bat-mode-setup-function) + "Generic mode for MS-Windows BAT files.") - (defun bat-generic-mode-compile () - "Run the current BAT file in a compilation buffer." - (interactive) - (let ((compilation-buffer-name-function - (function - (lambda(ign) - (concat "*" (buffer-file-name) "*"))) - ) - ) - (compile - (concat (w32-shell-name) " -c " (buffer-file-name))))) +(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.") - (defun bat-generic-mode-run-as-comint () - "Run the current BAT file in a comint buffer." - (interactive) - (require 'comint) - (let* ((file (buffer-file-name)) - (buf-name (concat "*" file "*"))) - (save-excursion - (set-buffer - (get-buffer-create buf-name)) - (erase-buffer) - (comint-mode) - (comint-exec - buf-name - file - (w32-shell-name) - nil - (list - "-c" - file - ) - ) - (display-buffer buf-name)))) - - (define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile) +(defun bat-generic-mode-compile () + "Run the current BAT file in a compilation buffer." + (interactive) + (let ((compilation-buffer-name-function + (function + (lambda(ign) + (concat "*" (buffer-file-name) "*"))))) + (compile + (concat (w32-shell-name) " -c " (buffer-file-name))))) - ;; Make underscores count as words - (if bat-generic-mode-syntax-table - nil - (setq bat-generic-mode-syntax-table (make-syntax-table)) - (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table)) +(defun bat-generic-mode-run-as-comint () + "Run the current BAT file in a comint buffer." + (interactive) + (require 'comint) + (let* ((file (buffer-file-name)) + (buf-name (concat "*" file "*"))) + (save-excursion + (set-buffer + (get-buffer-create buf-name)) + (erase-buffer) + (comint-mode) + (comint-exec + buf-name + file + (w32-shell-name) + nil + (list "-c" file)) + (display-buffer buf-name)))) + +(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile) - ;; bat-generic-mode doesn't use the comment functionality of generic-mode - ;; because it has a three-letter comment-string, so we do it - ;; here manually instead - (defun generic-bat-mode-setup-function () - (make-local-variable 'parse-sexp-ignore-comments) - (make-local-variable 'comment-start) - (make-local-variable 'comment-start-skip) - (make-local-variable 'comment-end) - (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1)) - parse-sexp-ignore-comments t - comment-end "" - comment-start "REM " - comment-start-skip "[Rr][Ee][Mm] *" - ) - (set-syntax-table bat-generic-mode-syntax-table) - ;; Make keywords case-insensitive - (setq font-lock-defaults (list 'generic-font-lock-defaults nil t)) - (use-local-map bat-generic-mode-keymap) - ) - ) +;; Make underscores count as words +(unless bat-generic-mode-syntax-table + (setq bat-generic-mode-syntax-table (make-syntax-table)) + (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table)) + +;; bat-generic-mode doesn't use the comment functionality of generic-mode +;; because it has a three-letter comment-string, so we do it +;; here manually instead +(defun generic-bat-mode-setup-function () + (make-local-variable 'parse-sexp-ignore-comments) + (make-local-variable 'comment-start) + (make-local-variable 'comment-start-skip) + (make-local-variable 'comment-end) + (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1)) + parse-sexp-ignore-comments t + comment-end "" + comment-start "REM " + comment-start-skip "[Rr][Ee][Mm] *") + (set-syntax-table bat-generic-mode-syntax-table) + ;; Make keywords case-insensitive + (setq font-lock-defaults (list 'generic-font-lock-defaults nil t)) + (use-local-map bat-generic-mode-keymap))) ;;; Mailagent ;; Mailagent is a Unix mail filtering program. Anyone wanna do a generic mode ;; for procmail? -(and - (memq 'mailagent-rules-generic-mode generic-extras-enable-list) +(when (memq 'mailagent-rules-generic-mode generic-extras-enable-list) -(define-generic-mode 'mailagent-rules-generic-mode - (list ?#) - (list "SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT") - '(("^\\(\\sw+\\)\\s-*=" 1 'font-lock-variable-name-face) - ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 'font-lock-constant-face)) - (list "\\.rules\\'") - (list 'mailagent-rules-setup-function) - "Mode for Mailagent rules files.") +(define-generic-mode mailagent-rules-generic-mode + (list ?#) + (list "SAVE" "DELETE" "PIPE" "ANNOTATE" "REJECT") + '(("^\\(\\sw+\\)\\s-*=" 1 'font-lock-variable-name-face) + ("\\s-/\\([^/]+\\)/[i, \t\n]" 1 'font-lock-constant-face)) + (list "\\.rules\\'") + (list 'mailagent-rules-setup-function) + "Mode for Mailagent rules files.") (defun mailagent-rules-setup-function () - (make-local-variable 'imenu-generic-expression) - (setq imenu-generic-expression - '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1)))) - ) + (make-local-variable 'imenu-generic-expression) + (setq imenu-generic-expression + '((nil "\\s-/\\([^/]+\\)/[i, \t\n]" 1))))) ;; Solaris/Sys V prototype files -(and - (memq 'prototype-generic-mode generic-extras-enable-list) +(when (memq 'prototype-generic-mode generic-extras-enable-list) -(define-generic-mode 'prototype-generic-mode - (list ?#) - nil - '( - ("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$" - (2 font-lock-constant-face) - (3 font-lock-keyword-face)) - ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" - (1 font-lock-constant-face) - (2 font-lock-keyword-face) - (3 font-lock-variable-name-face)) - ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$" - (1 font-lock-keyword-face) - (3 font-lock-variable-name-face)) - ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$" - (1 font-lock-keyword-face) - (2 font-lock-variable-name-face)) - ) - (list "prototype\\'") - nil - "Mode for Sys V prototype files.")) +(define-generic-mode prototype-generic-mode + (list ?#) + nil + '(("^\\([0-9]\\)?\\s-*\\([a-z]\\)\\s-+\\([A-Za-z_]+\\)\\s-+\\([^\n\r]*\\)$" + (2 font-lock-constant-face) + (3 font-lock-keyword-face)) + ("^\\([a-z]\\) \\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" + (1 font-lock-constant-face) + (2 font-lock-keyword-face) + (3 font-lock-variable-name-face)) + ("^\\(!\\s-*\\(search\\|include\\|default\\)\\)\\s-*\\([^\n\r]*\\)$" + (1 font-lock-keyword-face) + (3 font-lock-variable-name-face)) + ("^\\(!\\s-*\\sw+\\)=\\([^\n\r]*\\)$" + (1 font-lock-keyword-face) + (2 font-lock-variable-name-face))) + (list "prototype\\'") + nil + "Mode for Sys V prototype files.")) ;; Solaris/Sys V pkginfo files -(and - (memq 'pkginfo-generic-mode generic-extras-enable-list) +(when (memq 'pkginfo-generic-mode generic-extras-enable-list) -(define-generic-mode 'pkginfo-generic-mode - (list ?#) - nil - '( - ("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" - (1 font-lock-keyword-face) - (2 font-lock-variable-name-face)) - ) - (list "pkginfo\\'") - nil - "Mode for Sys V pkginfo files.")) +(define-generic-mode pkginfo-generic-mode + (list ?#) + nil + '(("^\\([A-Za-z_]+\\)=\\([^\n\r]*\\)$" + (1 font-lock-keyword-face) + (2 font-lock-variable-name-face))) + (list "pkginfo\\'") + nil + "Mode for Sys V pkginfo files.")) ;; Javascript mode ;; Includes extra keywords from Armando Singer [asinger@MAIL.COLGATE.EDU] -(define-generic-mode 'javascript-generic-mode +(define-generic-mode javascript-generic-mode (list "//" '("/*" . "*/")) (list "break" @@ -594,27 +555,23 @@ "synchronized" "throws" "transient" - "true" - ) + "true") (list (list "^\\s-*function\\s-+\\([A-Za-z0-9_]+\\)" - '(1 font-lock-function-name-face)) - (list "^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)" - '(1 font-lock-variable-name-face)) - ) + '(1 font-lock-function-name-face)) + (list "^\\s-*var\\s-+\\([A-Za-z0-9_]+\\)" + '(1 font-lock-variable-name-face))) (list "\\.js\\'") (list (function (lambda () (setq imenu-generic-expression '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1) - ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1) - )) - ))) + ("*Variables*" "^var\\s-+\\([A-Za-z0-9_]+\\)" 1)))))) "Mode for JavaScript files.") ;; VRML files -(define-generic-mode 'vrml-generic-mode +(define-generic-mode vrml-generic-mode (list ?#) (list "DEF" @@ -644,8 +601,7 @@ "textureTransform" "title" "transparency" - "type" - ) + "type") (list (list "USE\\s-+\\([-A-Za-z0-9_]+\\)" '(1 font-lock-constant-face)) @@ -656,8 +612,7 @@ '(1 font-lock-function-name-face)) (list "^\\s-*\\(geometry\\|appearance\\|material\\)\\s-+\\([-A-Za-z0-9_]+\\)" - '(2 font-lock-variable-name-face)) - ) + '(2 font-lock-variable-name-face))) (list "\\.wrl\\'") (list (function @@ -666,12 +621,11 @@ '((nil "^\\([A-Za-z0-9_]+\\)\\s-*{" 1) ("*Definitions*" "DEF\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([A-Za-z0-9]+\\)\\s-*{" - 1))) - ))) + 1)))))) "Generic Mode for VRML files.") ;; Java Manifests -(define-generic-mode 'java-manifest-generic-mode +(define-generic-mode java-manifest-generic-mode (list ?#) (list "Name" @@ -681,26 +635,23 @@ "Signature-Version" "Magic" "Java-Bean" - "Depends-On" - ) + "Depends-On") '(("^Name:\\s-+\\([^\n\r]*\\)$" (1 font-lock-variable-name-face)) ("^\\(Manifest\\|Required\\|Signature\\)-Version:\\s-+\\([^\n\r]*\\)$" - (2 font-lock-constant-face)) - ) + (2 font-lock-constant-face))) (list "[mM][aA][nN][iI][fF][eE][sS][tT]\\.[mM][fF]\\'") nil "Mode for Java Manifest files") ;; Java properties files -(define-generic-mode 'java-properties-generic-mode +(define-generic-mode java-properties-generic-mode (list ?! ?#) nil (let ((java-properties-key "\\(\\([-A-Za-z0-9_\\./]\\|\\(\\\\[ =:]\\)\\)+\\)") (java-properties-value - "\\([^\r\n]*\\)") - ) + "\\([^\r\n]*\\)")) ;; Property and value can be separated in a number of different ways: ;; * whitespace ;; * an equal sign @@ -711,143 +662,133 @@ (list (concat "^" java-properties-key elt java-properties-value "$") '(1 font-lock-constant-face) - '(4 font-lock-variable-name-face) - ))) + '(4 font-lock-variable-name-face)))) ;; These are the separators - (list ":\\s-*" "\\s-+" "\\s-*=\\s-*") - ) - ) + (list ":\\s-*" "\\s-+" "\\s-*=\\s-*"))) nil (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\([^#! \t\n\r=:]+\\)" 1))) - ))) + '((nil "^\\([^#! \t\n\r=:]+\\)" 1)))))) "Mode for Java properties files.") ;; C shell alias definitions -(and - (memq 'alias-generic-mode generic-extras-enable-list) +(when (memq 'alias-generic-mode generic-extras-enable-list) -(define-generic-mode 'alias-generic-mode +(define-generic-mode alias-generic-mode (list ?#) (list "alias" "unalias") '(("^alias\\s-+\\([-A-Za-z0-9_]+\\)\\s-+" (1 font-lock-variable-name-face)) ("^unalias\\s-+\\([-A-Za-z0-9_]+\\)\\s-*$" - (1 font-lock-variable-name-face)) - ) + (1 font-lock-variable-name-face))) (list "alias\\'") (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2))) - ))) - "Mode for C Shell alias files.") -) + '((nil "^\\(alias\\|unalias\\)\\s-+\\([-a-zA-Z0-9_]+\\)" 2)))))) + "Mode for C Shell alias files.")) ;;; Windows RC files ;; Contributed by ACorreir@pervasive-sw.com (Alfred Correira) -(and - (memq 'rc-generic-mode generic-extras-enable-list) +(when (memq 'rc-generic-mode generic-extras-enable-list) -(define-generic-mode 'rc-generic-mode -;; (list ?\/) - (list "//") - '("ACCELERATORS" - "AUTO3STATE" - "AUTOCHECKBOX" - "AUTORADIOBUTTON" - "BITMAP" - "BOTTOMMARGIN" - "BUTTON" - "CAPTION" - "CHARACTERISTICS" - "CHECKBOX" - "CLASS" - "COMBOBOX" - "CONTROL" - "CTEXT" - "CURSOR" - "DEFPUSHBUTTON" - "DESIGNINFO" - "DIALOG" - "DISCARDABLE" - "EDITTEXT" - "EXSTYLE" - "FONT" - "GROUPBOX" - "GUIDELINES" - "ICON" - "LANGUAGE" - "LEFTMARGIN" - "LISTBOX" - "LTEXT" - "MENUITEM SEPARATOR" - "MENUITEM" - "MENU" - "MOVEABLE" - "POPUP" - "PRELOAD" - "PURE" - "PUSHBOX" - "PUSHBUTTON" - "RADIOBUTTON" - "RCDATA" - "RIGHTMARGIN" - "RTEXT" - "SCROLLBAR" - "SEPARATOR" - "STATE3" - "STRINGTABLE" - "STYLE" - "TEXTINCLUDE" - "TOOLBAR" - "TOPMARGIN" - "VERSIONINFO" - "VERSION" - ) - ;; the choice of what tokens go where is somewhat arbitrary, - ;; as is the choice of which value tokens are included, as - ;; the choice of face for each token group - (list - (eval-when-compile - (generic-make-keywords-list - (list - "FILEFLAGSMASK" - "FILEFLAGS" - "FILEOS" - "FILESUBTYPE" - "FILETYPE" - "FILEVERSION" - "PRODUCTVERSION" - ) 'font-lock-type-face)) - (eval-when-compile - (generic-make-keywords-list - (list - "BEGIN" - "BLOCK" - "END" - "VALUE" - ) 'font-lock-function-name-face)) - '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face) - '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face) - '("^#[ \t]*\\(elif\\|if\\)\\>" - ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil - (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t))) - '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" +(define-generic-mode rc-generic-mode + ;; (list ?\/) + (list "//") + '("ACCELERATORS" + "AUTO3STATE" + "AUTOCHECKBOX" + "AUTORADIOBUTTON" + "BITMAP" + "BOTTOMMARGIN" + "BUTTON" + "CAPTION" + "CHARACTERISTICS" + "CHECKBOX" + "CLASS" + "COMBOBOX" + "CONTROL" + "CTEXT" + "CURSOR" + "DEFPUSHBUTTON" + "DESIGNINFO" + "DIALOG" + "DISCARDABLE" + "EDITTEXT" + "EXSTYLE" + "FONT" + "GROUPBOX" + "GUIDELINES" + "ICON" + "LANGUAGE" + "LEFTMARGIN" + "LISTBOX" + "LTEXT" + "MENUITEM SEPARATOR" + "MENUITEM" + "MENU" + "MOVEABLE" + "POPUP" + "PRELOAD" + "PURE" + "PUSHBOX" + "PUSHBUTTON" + "RADIOBUTTON" + "RCDATA" + "RIGHTMARGIN" + "RTEXT" + "SCROLLBAR" + "SEPARATOR" + "STATE3" + "STRINGTABLE" + "STYLE" + "TEXTINCLUDE" + "TOOLBAR" + "TOPMARGIN" + "VERSIONINFO" + "VERSION") + ;; the choice of what tokens go where is somewhat arbitrary, + ;; as is the choice of which value tokens are included, as + ;; the choice of face for each token group + (list + (eval-when-compile + (generic-make-keywords-list + (list + "FILEFLAGSMASK" + "FILEFLAGS" + "FILEOS" + "FILESUBTYPE" + "FILETYPE" + "FILEVERSION" + "PRODUCTVERSION") + 'font-lock-type-face)) + (eval-when-compile + (generic-make-keywords-list + (list + "BEGIN" + "BLOCK" + "END" + "VALUE") + 'font-lock-function-name-face)) + '("^#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" 1 font-lock-string-face) + '("^#[ \t]*define[ \t]+\\(\\sw+\\)(" 1 font-lock-function-name-face) + '("^#[ \t]*\\(elif\\|if\\)\\>" + ("\\<\\(defined\\)\\>[ \t]*(?\\(\\sw+\\)?" nil nil (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t))) - (list "\\.[rR][cC]$") - nil - "Generic mode for MS-Windows Resource files.")) + '("^#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" + (1 font-lock-constant-face) (2 font-lock-variable-name-face nil t))) + (list "\\.[rR][cC]$") + nil + "Generic mode for MS-Windows Resource files.")) ;; InstallShield RUL files ;; Contributed by Alfred.Correira@Pervasive.Com ;; Bugfixes by "Rolf Sandau" <Rolf.Sandau@marconi.com> -(and -(memq 'rul-generic-mode generic-extras-enable-list) +(when (memq 'rul-generic-mode generic-extras-enable-list) + ;;; build the regexp strings using regexp-opt (defvar installshield-statement-keyword-list (list @@ -882,8 +823,7 @@ "typedef" "until" "void" - "while" - ) + "while") "Statement keywords used in InstallShield 3 and 5.") (defvar installshield-system-functions-list @@ -907,39 +847,39 @@ "ChangeDirectory" "CloseFile" "CmdGetHwndDlg" - "ComponentAddItem" ; differs between IS3 and IS5 - "ComponentCompareSizeRequired" ; IS5 only + "ComponentAddItem" ; differs between IS3 and IS5 + "ComponentCompareSizeRequired" ; IS5 only "ComponentDialog" - "ComponentError" ; IS5 only - "ComponentFileEnum" ; IS5 only - "ComponentFileInfo" ; IS5 only - "ComponentFilterLanguage" ; IS5 only - "ComponentFilterOS" ; IS5 only - "ComponentGetData" ; IS5 only - "ComponentGetItemInfo" ; IS3 only - "ComponentGetItemSize" ; differs between IS3 and IS5 - "ComponentIsItemSelected" ; differs between IS3 and IS5 + "ComponentError" ; IS5 only + "ComponentFileEnum" ; IS5 only + "ComponentFileInfo" ; IS5 only + "ComponentFilterLanguage" ; IS5 only + "ComponentFilterOS" ; IS5 only + "ComponentGetData" ; IS5 only + "ComponentGetItemInfo" ; IS3 only + "ComponentGetItemSize" ; differs between IS3 and IS5 + "ComponentIsItemSelected" ; differs between IS3 and IS5 "ComponentListItems" - "ComponentMoveData" ; IS5 only - "ComponentSelectItem" ; differs between IS3 and IS5 - "ComponentSetData" ; IS5 only - "ComponentSetItemInfo" ; IS3 only - "ComponentSetTarget" ; IS5 only - "ComponentSetupTypeEnum" ; IS5 only - "ComponentSetupTypeGetData" ; IS5 only - "ComponentSetupTypeSet" ; IS5 only + "ComponentMoveData" ; IS5 only + "ComponentSelectItem" ; differs between IS3 and IS5 + "ComponentSetData" ; IS5 only + "ComponentSetItemInfo" ; IS3 only + "ComponentSetTarget" ; IS5 only + "ComponentSetupTypeEnum" ; IS5 only + "ComponentSetupTypeGetData" ; IS5 only + "ComponentSetupTypeSet" ; IS5 only "ComponentTotalSize" - "ComponentValidate" ; IS5 only - "CompressAdd" ; IS3 only - "CompressDel" ; IS3 only - "CompressEnum" ; IS3 only - "CompressGet" ; IS3 only - "CompressInfo" ; IS3 only + "ComponentValidate" ; IS5 only + "CompressAdd" ; IS3 only + "CompressDel" ; IS3 only + "CompressEnum" ; IS3 only + "CompressGet" ; IS3 only + "CompressInfo" ; IS3 only "CopyFile" "CreateDir" "CreateFile" "CreateProgramFolder" - "DeinstallSetReference" ; IS5 only + "DeinstallSetReference" ; IS5 only "DeinstallStart" "Delay" "DeleteDir" @@ -965,12 +905,12 @@ "FileDeleteLine" "FileGrep" "FileInsertLine" - "FileSetBeginDefine" ; IS3 only - "FileSetEndDefine" ; IS3 only - "FileSetPerformEz" ; IS3 only - "FileSetPerform" ; IS3 only - "FileSetReset" ; IS3 only - "FileSetRoot" ; IS3 only + "FileSetBeginDefine" ; IS3 only + "FileSetEndDefine" ; IS3 only + "FileSetPerformEz" ; IS3 only + "FileSetPerform" ; IS3 only + "FileSetReset" ; IS3 only + "FileSetRoot" ; IS3 only "FindAllDirs" "FindAllFiles" "FindFile" @@ -1024,7 +964,7 @@ "Path" "PlaceBitmap" "PlaceWindow" - "PlayMMedia" ; IS5 only + "PlayMMedia" ; IS5 only "ProgDefGroupType" "RegDBCreateKeyEx" "RegDBDeleteValue" @@ -1084,7 +1024,7 @@ "SdSelectFolder" "SdSetSequentialItems" "SdSetStatic" - "SdSetupTypeEx" ; IS5 only + "SdSetupTypeEx" ; IS5 only "SdSetupType" "SdShowAnyDialog" "SdShowDlgEdit1" @@ -1101,14 +1041,14 @@ "SetColor" "SetFont" "SetDialogTitle" - "SetDisplayEffect" ; IS5 only + "SetDisplayEffect" ; IS5 only "SetFileInfo" "SetForegroundWindow" "SetStatusWindow" "SetTitle" "SetupType" "ShowProgramFolder" - "Split" ; IS3 only + "Split" ; IS3 only "SprintfBox" "Sprintf" "StatusUpdate" @@ -1129,8 +1069,7 @@ "Welcome" "WriteLine" "WriteProfString" - "XCopyFile" - ) + "XCopyFile") "System functions defined in InstallShield 3 and 5.") (defvar installshield-system-variables-list @@ -1163,8 +1102,7 @@ "WINDISK" "WINMAJOR" "WINSYSDIR" - "WINSYSDISK" - ) + "WINSYSDISK") "System variables used in InstallShield 3 and 5.") (defvar installshield-types-list @@ -1186,8 +1124,7 @@ "RGB" "SHORT" "STRINGLIST" - "STRING" - ) + "STRING") "Type keywords used in InstallShield 3 and 5.") ;;; some might want to skip highlighting these to improve performance @@ -1397,111 +1334,104 @@ "WINMINOR" "WIN32SINSTALLED" "WIN32SMAJOR" - "WIN32SMINOR" - ) + "WIN32SMINOR") "Function argument constants used in InstallShield 3 and 5.") -(progn - (defvar rul-generic-mode-syntax-table nil - "Syntax table to use in rul-generic-mode buffers.") +(defvar rul-generic-mode-syntax-table nil + "Syntax table to use in rul-generic-mode buffers.") + +(setq rul-generic-mode-syntax-table + (make-syntax-table c++-mode-syntax-table)) - (setq rul-generic-mode-syntax-table - (make-syntax-table c++-mode-syntax-table)) +(modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table) +(modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table) - (modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table) - (modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table) - - (modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table) - (modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table) +(modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table) +(modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table) - ;; here manually instead - (defun generic-rul-mode-setup-function () - (make-local-variable 'parse-sexp-ignore-comments) - (make-local-variable 'comment-start) - (make-local-variable 'comment-start-skip) - (make-local-variable 'comment-end) - (setq imenu-generic-expression - '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)) - parse-sexp-ignore-comments t - comment-end "*/" - comment-start "/*" -;; comment-end "" -;; comment-start "//" -;; comment-start-skip "" - ) -;; (set-syntax-table rul-generic-mode-syntax-table) - (setq font-lock-syntax-table rul-generic-mode-syntax-table) - ) +;; here manually instead +(defun generic-rul-mode-setup-function () + (make-local-variable 'parse-sexp-ignore-comments) + (make-local-variable 'comment-start) + (make-local-variable 'comment-start-skip) + (make-local-variable 'comment-end) + (setq imenu-generic-expression + '((nil "^function\\s-+\\([A-Za-z0-9_]+\\)" 1)) + parse-sexp-ignore-comments t + comment-end "*/" + comment-start "/*" +;;; comment-end "" +;;; comment-start "//" +;;; comment-start-skip "" + ) + ;; (set-syntax-table rul-generic-mode-syntax-table) + (setq font-lock-syntax-table rul-generic-mode-syntax-table)) - ;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan - (define-generic-mode 'rul-generic-mode - ;; Using "/*" and "*/" doesn't seem to be working right - (list "//" '("/*" . "*/" )) - installshield-statement-keyword-list - (list - ;; preprocessor constructs - '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" - 1 font-lock-string-face) - '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" - (1 font-lock-reference-face) - (2 font-lock-variable-name-face nil t)) - ;; indirect string constants - '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face) - ;; gotos - '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face) - '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?" - (1 font-lock-keyword-face) - (2 font-lock-reference-face nil t)) - ;; system variables - (generic-make-keywords-list - installshield-system-variables-list - 'font-lock-variable-name-face "[^_]" "[^_]") - ;; system functions - (generic-make-keywords-list - installshield-system-functions-list - 'font-lock-function-name-face "[^_]" "[^_]") - ;; type keywords - (generic-make-keywords-list - installshield-types-list - 'font-lock-type-face "[^_]" "[^_]") - ;; function argument constants - (generic-make-keywords-list - installshield-funarg-constants-list - 'font-lock-variable-name-face "[^_]" "[^_]") ; is this face the best choice? - ) - (list "\\.[rR][uU][lL]$") - (list 'generic-rul-mode-setup-function) - "Generic mode for InstallShield RUL files.") -) +;; moved mode-definition behind defun-definition to be warning-free - 15.11.02/RSan +(define-generic-mode rul-generic-mode + ;; Using "/*" and "*/" doesn't seem to be working right + (list "//" '("/*" . "*/" )) + installshield-statement-keyword-list + (list + ;; preprocessor constructs + '("#[ \t]*include[ \t]+\\(<[^>\"\n]+>\\)" + 1 font-lock-string-face) + '("#[ \t]*\\(\\sw+\\)\\>[ \t]*\\(\\sw+\\)?" + (1 font-lock-reference-face) + (2 font-lock-variable-name-face nil t)) + ;; indirect string constants + '("\\(@[A-Za-z][A-Za-z0-9_]+\\)" 1 font-lock-builtin-face) + ;; gotos + '("[ \t]*\\(\\sw+:\\)" 1 font-lock-reference-face) + '("\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?" + (1 font-lock-keyword-face) + (2 font-lock-reference-face nil t)) + ;; system variables + (generic-make-keywords-list + installshield-system-variables-list + 'font-lock-variable-name-face "[^_]" "[^_]") + ;; system functions + (generic-make-keywords-list + installshield-system-functions-list + 'font-lock-function-name-face "[^_]" "[^_]") + ;; type keywords + (generic-make-keywords-list + installshield-types-list + 'font-lock-type-face "[^_]" "[^_]") + ;; function argument constants + (generic-make-keywords-list + installshield-funarg-constants-list + 'font-lock-variable-name-face "[^_]" "[^_]")) ; is this face the best choice? + (list "\\.[rR][uU][lL]$") + (list 'generic-rul-mode-setup-function) + "Generic mode for InstallShield RUL files.") + (define-skeleton rul-if - "Insert an if statement." - "condition: " - "if(" str ") then" \n - > _ \n - ( "other condition, %s: " - > "elseif(" str ") then" \n - > \n) - > "else" \n - > \n - resume: - > "endif;" - ) + "Insert an if statement." + "condition: " + "if(" str ") then" \n + > _ \n + ( "other condition, %s: " + > "elseif(" str ") then" \n + > \n) + > "else" \n + > \n + resume: + > "endif;") (define-skeleton rul-function "Insert a function statement." "function: " "function " str " ()" \n ( "local variables, %s: " - > " " str ";" \n) + > " " str ";" \n) > "begin" \n > _ \n resume: - > "end;") - -) + > "end;")) ;; Additions by ACorreir@pervasive-sw.com (Alfred Correira) -(define-generic-mode 'mailrc-generic-mode +(define-generic-mode mailrc-generic-mode (list ?#) (list "alias" @@ -1512,8 +1442,7 @@ "ignore" "set" "source" - "unset" - ) + "unset") '(("^\\s-*\\(alias\\|group\\)\\s-+\\([-A-Za-z0-9_]+\\)\\s-+\\([^\n\r#]*\\)\\(#.*\\)?$" (2 font-lock-constant-face) (3 font-lock-variable-name-face)) ("^\\s-*\\(unset\\|set\\|ignore\\)\\s-+\\([-A-Za-z0-9_]+\\)=?\\([^\n\r#]*\\)\\(#.*\\)?$" @@ -1525,10 +1454,9 @@ "Mode for mailrc files.") ;; Inetd.conf -(and - (memq 'inetd-conf-generic-mode generic-extras-enable-list) +(when (memq 'inetd-conf-generic-mode generic-extras-enable-list) -(define-generic-mode 'inetd-conf-generic-mode +(define-generic-mode inetd-conf-generic-mode (list ?#) (list "stream" @@ -1537,142 +1465,139 @@ "udp" "wait" "nowait" - "internal" - ) - '( - ("^\\([-A-Za-z0-9_]+\\)" - 1 'font-lock-type-face) - ) + "internal") + '(("^\\([-A-Za-z0-9_]+\\)" + 1 'font-lock-type-face)) '("/etc/inetd.conf\\'") (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\([-A-Za-z0-9_]+\\)" 1))) - ))) - ) -) + '((nil "^\\([-A-Za-z0-9_]+\\)" 1)))))))) ;; Services -(and - (memq 'etc-services-generic-mode generic-extras-enable-list) +(when (memq 'etc-services-generic-mode generic-extras-enable-list) -(define-generic-mode 'etc-services-generic-mode +(define-generic-mode etc-services-generic-mode (list ?#) (list "tcp" "udp" - "ddp" - ) - '( - ("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/" + "ddp") + '(("^\\([-A-Za-z0-9_]+\\)\\s-+\\([0-9]+\\)/" (1 'font-lock-type-face) - (2 'font-lock-variable-name-face) - ) - ) + (2 'font-lock-variable-name-face))) '("/etc/services\\'") (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\([-A-Za-z0-9_]+\\)" 1))) - ))) - ) -) + '((nil "^\\([-A-Za-z0-9_]+\\)" 1)))))))) ;; Password and Group files -(and - (memq 'etc-passwd-generic-mode generic-extras-enable-list) +(when (memq 'etc-passwd-generic-mode generic-extras-enable-list) -(define-generic-mode 'etc-passwd-generic-mode +(define-generic-mode etc-passwd-generic-mode nil ;; No comment characters (list "root") ;; Only one keyword (list - (list - (concat - "^" - ;; User name -- Never blank! - "\\([^:]+\\)" - ":" - ;; Password, UID and GID - (mapconcat - 'identity - (make-list 3 "\\([^:]+\\)") - ":" - ) - ":" - ;; GECOS/Name -- might be blank - "\\([^:]*\\)" - ":" - ;; Home directory and shell - "\\([^:]+\\)" - ":?" - "\\([^:]*\\)" - "$" - ) - '(1 'font-lock-type-face) - '(5 'font-lock-variable-name-face) - '(6 'font-lock-constant-face) - '(7 'font-lock-warning-face) - ) - '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$" - (1 'font-lock-type-face) - (4 'font-lock-variable-name-face) - ) - ) + (list + (concat + "^" + ;; User name -- Never blank! + "\\([^:]+\\)" + ":" + ;; Password, UID and GID + (mapconcat + 'identity + (make-list 3 "\\([^:]+\\)") + ":") + ":" + ;; GECOS/Name -- might be blank + "\\([^:]*\\)" + ":" + ;; Home directory and shell + "\\([^:]+\\)" + ":?" + "\\([^:]*\\)" + "$") + '(1 'font-lock-type-face) + '(5 'font-lock-variable-name-face) + '(6 'font-lock-constant-face) + '(7 'font-lock-warning-face)) + '("^\\([^:]+\\):\\([^:]*\\):\\([0-9]+\\):\\(.*\\)$" + (1 'font-lock-type-face) + (4 'font-lock-variable-name-face))) '("/etc/passwd\\'" "/etc/group\\'") (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\([-A-Za-z0-9_]+\\):" 1))) - ))) - ) -) + '((nil "^\\([-A-Za-z0-9_]+\\):" 1)))))))) ;; Fstab -(and - (memq 'etc-fstab-generic-mode generic-extras-enable-list) +(when (memq 'etc-fstab-generic-mode generic-extras-enable-list) -(define-generic-mode 'etc-fstab-generic-mode +(define-generic-mode etc-fstab-generic-mode (list ?#) (list + "adfs" + "affs" + "autofs" + "coda" + "coherent" + "cramfs" + "devpts" + "efs" "ext2" - "fd" + "ext3" + "hfs" + "hpfs" "iso9660" + "jfs" + "minix" + "msdos" + "ncpfs" "nfs" + "ntfs" "proc" - "swap" + "qnx4" + "reiserfs" + "romfs" + "smbfs" + "sysv" + "tmpfs" + "udf" "ufs" - ) - '( - ("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)" + "umsdos" + "vfat" + "xenix" + "xfs" + "swap" + "auto" + "ignore") + '(("^\\([/-A-Za-z0-9_]+\\)\\s-+\\([/-A-Za-z0-9_]+\\)" (1 'font-lock-type-face) - (2 'font-lock-variable-name-face) - ) - ) + (2 'font-lock-variable-name-face))) '("/etc/[v]*fstab\\'") (list (function (lambda () (setq imenu-generic-expression - '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1))) - ))) - ) -) + '((nil "^\\([/-A-Za-z0-9_]+\\)\\s-+" 1)))))))) ;; From Jacques Duthen <jacques.duthen@sncf.fr> (defvar show-tabs-generic-mode-font-lock-defaults-1 - '( ;; trailing spaces must come before... - ("[ \t]+$" . 'show-tabs-space-face) - ;; ...embedded tabs - ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face)))) + '( ;; trailing spaces must come before... + ("[ \t]+$" . 'show-tabs-space-face) + ;; ...embedded tabs + ("[^\n\t]\\(\t+\\)" (1 'show-tabs-tab-face)))) (defvar show-tabs-generic-mode-font-lock-defaults-2 - '( ;; trailing spaces must come before... - ("[ \t]+$" . 'show-tabs-space-face) - ;; ...tabs - ("\t+" . 'show-tabs-tab-face))) + '( ;; trailing spaces must come before... + ("[ \t]+$" . 'show-tabs-space-face) + ;; ...tabs + ("\t+" . 'show-tabs-tab-face))) (defface show-tabs-tab-face '((((class grayscale) (background light)) (:foreground "LightGray" :weight bold)) @@ -1692,10 +1617,10 @@ "Font Lock mode face used to highlight spaces." :group 'show-tabs) -(define-generic-mode 'show-tabs-generic-mode +(define-generic-mode show-tabs-generic-mode () ;; no comment char () ;; no keywords - show-tabs-generic-mode-font-lock-defaults-1 + show-tabs-generic-mode-font-lock-defaults-1 () ;; no auto-mode-alist ;; (list 'show-tabs-generic-mode-hook-fun) nil @@ -1705,41 +1630,37 @@ ;; DNS modes ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-generic-mode 'named-boot-generic-mode - ;;List of comment characters - (list ?\;) - ;;List of keywords +(define-generic-mode named-boot-generic-mode + ;; List of comment characters + (list ?\;) + ;; List of keywords (list "cache" "primary" "secondary" "forwarders" "limit" "options" "directory" "check-names") - ;;List of additional font-lock-expressions + ;; List of additional font-lock-expressions (list (list "\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-constant-face) (list "^directory\\s-+\\(.*\\)" 1 'font-lock-variable-name-face) (list "^\\(primary\\|cache\\)\\s-+\\([.A-Za-z]+\\)\\s-+\\(.*\\)" (list 2 'font-lock-variable-name-face) - (list 3 'font-lock-constant-face)) - ) - ;;List of additional automode-alist expressions + (list 3 'font-lock-constant-face))) + ;; List of additional automode-alist expressions (list "/etc/named.boot\\'") - ;;List of set up functions to call - nil - ) + ;; List of set up functions to call + nil) -(define-generic-mode 'named-database-generic-mode - ;;List of comment characters +(define-generic-mode named-database-generic-mode + ;; List of comment characters (list ?\;) - ;;List of keywords + ;; List of keywords (list "IN" "NS" "CNAME" "SOA" "PTR" "MX" "A") - ;;List of additional font-lock-expressions + ;; List of additional font-lock-expressions (list (list "\\([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\\)" 1 'font-lock-constant-face) - (list "^\\([.A-Za-z0-9]+\\)" 1 'font-lock-variable-name-face) - ) - ;;List of additional automode-alist expressions + (list "^\\([.A-Za-z0-9]+\\)" 1 'font-lock-variable-name-face)) + ;; List of additional automode-alist expressions nil - ;;List of set up functions to call - nil - ) + ;; List of set up functions to call + nil) (defvar named-database-time-string "%Y%m%d%H" "Timestring for named serial numbers.") @@ -1747,27 +1668,25 @@ (defun named-database-print-serial () "Print a serial number based on the current date." (interactive) - (insert (format-time-string named-database-time-string (current-time))) - ) + (insert (format-time-string named-database-time-string (current-time)))) -(define-generic-mode 'resolve-conf-generic-mode - ;;List of comment characters +(define-generic-mode resolve-conf-generic-mode + ;; List of comment characters (list ?#) - ;;List of keywords + ;; List of keywords (list "nameserver" "domain" "search" "sortlist" "options") - ;;List of additional font-lock-expressions + ;; List of additional font-lock-expressions nil - ;;List of additional automode-alist expressions + ;; List of additional automode-alist expressions (list "/etc/resolv[e]?.conf\\'") - ;;List of set up functions to call - nil - ) + ;; List of set up functions to call + nil) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Modes for spice and common electrical engineering circuit netlist formats ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-generic-mode 'spice-generic-mode +(define-generic-mode spice-generic-mode nil (list "and" @@ -1784,8 +1703,7 @@ "vccap" "vccs" "vcr" - "vcvs" - ) + "vcvs") '( ("^\\s-*\\([*].*\\)" 1 'font-lock-comment-face) (" \\(\\$ .*\\)$" 1 'font-lock-comment-face) @@ -1795,8 +1713,7 @@ ("^\\s-*\\([.]\\w+\\>\\)" 1 'font-lock-keyword-face) ("\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 'font-lock-variable-name-face) ("\\('[^']+'\\)" 1 'font-lock-string-face) - ("\\(\"[^\"]+\"\\)" 1 'font-lock-string-face) - ) + ("\\(\"[^\"]+\"\\)" 1 'font-lock-string-face)) (list "\\.[sS][pP]\\'" "\\.[sS][pP][iI]\\'" "\\.[sS][pP][iI][cC][eE]\\'" @@ -1806,24 +1723,20 @@ ;; Make keywords case-insensitive (function (lambda() - (setq font-lock-defaults (list 'generic-font-lock-defaults nil t)))) - ) - "Generic mode for SPICE circuit netlist files." - ) + (setq font-lock-defaults (list 'generic-font-lock-defaults nil t))))) + "Generic mode for SPICE circuit netlist files.") -(define-generic-mode 'ibis-generic-mode +(define-generic-mode ibis-generic-mode (list ?|) nil '( ("[[]\\([^]]*\\)[]]" 1 'font-lock-keyword-face) - ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 'font-lock-variable-name-face) - ) + ("\\(\\(_\\|\\w\\)+\\)\\s-*=" 1 'font-lock-variable-name-face)) (list "\\.[iI][bB][sS]\\'") (list 'generic-bracket-support) - "Generic mode for IBIS circuit netlist files." - ) + "Generic mode for IBIS circuit netlist files.") -(define-generic-mode 'astap-generic-mode +(define-generic-mode astap-generic-mode nil (list "analyze" @@ -1838,16 +1751,13 @@ "print" "run" "controls" - "table" - ) - '( - ("^\\s-*\\([*].*\\)" 1 'font-lock-comment-face) + "table") + '(("^\\s-*\\([*].*\\)" 1 'font-lock-comment-face) (";\\s-*\\([*].*\\)" 1 'font-lock-comment-face) ("^\\s-*\\([.]\\w+\\>\\)" 1 'font-lock-keyword-face) ("\\('[^']+'\\)" 1 'font-lock-string-face) ("\\(\"[^\"]+\"\\)" 1 'font-lock-string-face) - ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 'font-lock-variable-name-face) - ) + ("[(,]\\s-*\\(\\([.]\\|_\\|\\w\\)+\\)\\s-*=" 1 'font-lock-variable-name-face)) (list "\\.[aA][pP]\\'" "\\.[aA][sS][xX]\\'" "\\.[aA][sS][tT][aA][pP]\\'" @@ -1859,15 +1769,13 @@ ;; Make keywords case-insensitive (function (lambda() - (setq font-lock-defaults (list 'generic-font-lock-defaults nil t)))) - ) - "Generic mode for ASTAP circuit netlist files." - ) + (setq font-lock-defaults (list 'generic-font-lock-defaults nil t))))) + "Generic mode for ASTAP circuit netlist files.") -(define-generic-mode 'etc-modules-conf-generic-mode - ;;List of comment characters +(define-generic-mode etc-modules-conf-generic-mode + ;; List of comment characters (list ?#) - ;;List of keywords + ;; List of keywords (list "above" "alias" @@ -1900,13 +1808,12 @@ "pre-remove" "remove" "persistdir") - ;;List of additional font-lock-expressions + ;; List of additional font-lock-expressions nil - ;;List of additional automode-alist expressions + ;; List of additional automode-alist expressions (list "/etc/modules.conf" "/etc/conf.modules") - ;;List of set up functions to call - nil - ) + ;; List of set up functions to call + nil) (provide 'generic-x)