annotate lisp/=batmode.el @ 35612:446e8151c90f

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Fri, 26 Jan 2001 14:37:45 +0000
parents 6ac6575b349d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16497
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; batmode.el --- Simple mode for Windows BAT files
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1996 Free Software Foundation, Inc.
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Peter Breton <pbreton@i-kinetics.com>
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Created: Thu Jul 25 1996
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: BAT, DOS, Windows
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Commentary:
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 ;; USAGE: Byte-compile this file, and add the following lines to your
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; emacs initialization file (.emacs/_emacs):
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; (setq auto-mode-alist
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32 ;; (append
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; (list (cons "\\.[bB][aA][tT]$" 'bat-mode))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34 ;; ;; For DOS init files
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;; (list (cons "CONFIG\\." 'bat-mode))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36 ;; (list (cons "AUTOEXEC\\." 'bat-mode))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
37 ;; auto-mode-alist))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39 ;; (autoload 'bat-mode "batmode"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 ;; "DOS and WIndows BAT files" t)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 ;; TODO:
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 ;; Support "compiles" ?
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 ;; Imenu? Don't have real functions.....
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 ;;; Change log:
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 ;; $Log: batmode.el,v $
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 ;; Revision 1.3 1996/08/22 02:31:47 peter
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 ;; Added Usage message, credit to folks from NTEmacs mailing list,
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51 ;; Syntax table, New font-lock keywords
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 ;; Revision 1.2 1996/08/18 16:27:13 peter
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 ;; Added preliminary global-font-lock support
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 ;; Revision 1.1 1996/08/18 16:14:18 peter
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 ;; Initial revision
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 ;;
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 ;; Credit for suggestions, patches and bug-fixes:
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 ;; Robert Brodersen <rbrodersen@siebel.com>
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 ;; ACorreir@pervasive-sw.com (Alfred Correira)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 ;;; Code:
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (defvar bat-mode-map nil "Local keymap for bat-mode buffers.")
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; Make this lowercase if you like
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (defvar bat-mode-comment-start "REM "
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 "Comment string to use in BAT mode")
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (defvar bat-mode-syntax-table nil
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 "Syntax table in use in Bat-mode buffers.")
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (if bat-mode-map
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 nil
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (setq bat-mode-map (copy-keymap global-map))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 )
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 ;; Make underscores count as words
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (if bat-mode-syntax-table
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ()
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (setq bat-mode-syntax-table (make-syntax-table))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (modify-syntax-entry ?_ "w" bat-mode-syntax-table)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 )
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (defun bat-mode ()
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 "Mode for DOS and Windows BAT files"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (interactive)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (kill-all-local-variables)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (use-local-map bat-mode-map)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (set-syntax-table bat-mode-syntax-table)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (make-local-variable 'parse-sexp-ignore-comments)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 (make-local-variable 'comment-start)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (make-local-variable 'comment-start-skip)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (make-local-variable 'comment-end)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 (make-local-variable 'executable-command)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (make-local-variable 'font-lock-defaults)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (setq major-mode 'bat-mode
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 mode-name "bat"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 comment-end ""
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 comment-start bat-mode-comment-start
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 comment-start-skip "[Rr][Ee][Mm] *"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 parse-sexp-ignore-comments t
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 )
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; Global font-lock support
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ;; (setq font-lock-defaults (list 'bat-font-lock-keywords nil t nil nil))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (setq font-lock-defaults (list 'bat-font-lock-keywords nil))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (run-hooks 'bat-mode-hook))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 (defvar bat-font-lock-keywords
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (list
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 ;; Make this one first in the list, otherwise comments will
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ;; be over-written by other variables
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (list "^[@ \t]*\\([rR][eE][mM].*\\)" 1 'font-lock-comment-face t)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (list "^[ \t]*\\(::-.*\\)" 1 'font-lock-comment-face t)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (list
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (concat "\\(\\<"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (mapconcat 'identity
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 '(
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 "call"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 "echo"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 "exist"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "errorlevel"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 "for"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 "goto"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 "if"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 "not"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 "path"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 "pause"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 "prompt"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
140 "set"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 "start"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 )
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 "\\>\\|\\<")
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
144 "\\>\\)") 1 'font-lock-keyword-face)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (list "^[ \t]*\\(:\\sw+\\)" 1 'font-lock-function-name-face t)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 (list "\\(%\\sw+%\\)" 1 'font-lock-reference-face)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 (list "\\(%[0-9]\\)" 1 'font-lock-reference-face)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (list "\\(/[^/ \t\n]+\\)" 1 'font-lock-type-face)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (list "\\<\\(goto\\)\\>[ \t]*\\(\\sw+\\)?"
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 '(1 font-lock-keyword-face)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 '(2 font-lock-function-name-face nil t))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
152
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
153 )
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
154 "Keywords to hilight in BAT mode")
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
155
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
156 ;;; don't do it in Win-Emacs
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 (if (boundp 'font-lock-defaults-alist)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (add-to-list
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 'font-lock-defaults-alist
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (cons 'bat-mode
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (list 'bat-font-lock-keywords nil t nil nil))))
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
163 (provide 'bat-mode)
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
164
6ac6575b349d Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 ;;; batmode.el ends here