aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog3
-rw-r--r--lisp/generic-x.el2
-rw-r--r--lisp/progmodes/bat-mode.el (renamed from lisp/progmodes/dos.el)84
3 files changed, 41 insertions, 48 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 70e10615dd7..e1d366f0510 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,8 @@
12013-08-07 Stefan Monnier <monnier@iro.umontreal.ca> 12013-08-07 Stefan Monnier <monnier@iro.umontreal.ca>
2 2
3 * progmodes/bat-mode.el: Rename from dos.el. Use "bat-" prefix.
4 (dos-mode-help): Remove. Use describe-mode (C-h m) instead.
5
3 * emacs-lisp/bytecomp.el: Check existence of f in #'f. 6 * emacs-lisp/bytecomp.el: Check existence of f in #'f.
4 (byte-compile-callargs-warn): Use `push'. 7 (byte-compile-callargs-warn): Use `push'.
5 (byte-compile-arglist-warn): Ignore higher-order "calls". 8 (byte-compile-arglist-warn): Ignore higher-order "calls".
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 698819d73a1..c964b53952e 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -460,7 +460,7 @@ like an INI file. You can add this hook to `find-file-hook'."
460 460
461;;; DOS/Windows BAT files 461;;; DOS/Windows BAT files
462(when (memq 'bat-generic-mode generic-extras-enable-list) 462(when (memq 'bat-generic-mode generic-extras-enable-list)
463 (define-obsolete-function-alias 'bat-generic-mode 'dos-mode "24.4")) 463 (define-obsolete-function-alias 'bat-generic-mode 'bat-mode "24.4"))
464 464
465;;; Mailagent 465;;; Mailagent
466;; Mailagent is a Unix mail filtering program. Anyone wanna do a 466;; Mailagent is a Unix mail filtering program. Anyone wanna do a
diff --git a/lisp/progmodes/dos.el b/lisp/progmodes/bat-mode.el
index 593b5e9fc92..45c350e9847 100644
--- a/lisp/progmodes/dos.el
+++ b/lisp/progmodes/bat-mode.el
@@ -1,4 +1,4 @@
1;;; dos.el --- Major mode for editing Dos scripts 1;;; bat-mode.el --- Major mode for editing DOS/Windows scripts
2 2
3;; Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. 3;; Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc.
4 4
@@ -22,13 +22,13 @@
22 22
23;;; Commentary: 23;;; Commentary:
24;; 24;;
25;; Major mode for editing Dos scripts (batch files). Provides syntax 25;; Major mode for editing DOS/Windows scripts (batch files). Provides syntax
26;; highlighting, a basic template, access to Dos help pages, imenu/outline 26;; highlighting, a basic template, access to DOS help pages, imenu/outline
27;; navigation, and the ability to run scripts from within Emacs. The syntax 27;; navigation, and the ability to run scripts from within Emacs. The syntax
28;; groups for highlighting are: 28;; groups for highlighting are:
29;; 29;;
30;; Face Example 30;; Face Example
31;; dos-label-face :LABEL 31;; bat-label-face :LABEL
32;; font-lock-comment-face rem 32;; font-lock-comment-face rem
33;; font-lock-builtin-face copy 33;; font-lock-builtin-face copy
34;; font-lock-keyword-face goto 34;; font-lock-keyword-face goto
@@ -39,7 +39,7 @@
39;; 39;;
40;; Usage: 40;; Usage:
41;; 41;;
42;; See documentation of function `dos-mode'. 42;; See documentation of function `bat-mode'.
43;; 43;;
44;; Separate package `dos-indent' (Matthew Fidler) provides rudimentary 44;; Separate package `dos-indent' (Matthew Fidler) provides rudimentary
45;; indentation, see http://www.emacswiki.org/emacs/dos-indent.el. 45;; indentation, see http://www.emacswiki.org/emacs/dos-indent.el.
@@ -52,20 +52,19 @@
52 52
53;; 1 Preamble 53;; 1 Preamble
54 54
55(defgroup dos nil 55(defgroup bat-mode nil
56 "Major mode for editing DOS/Windows batch files." 56 "Major mode for editing DOS/Windows batch files."
57 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces) 57 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
58 :group 'languages) 58 :group 'languages)
59 59
60;; 2 User variables 60;; 2 User variables
61 61
62(defface dos-label-face '((t :weight bold)) 62(defface bat-label-face '((t :weight bold))
63 "Font Lock mode face used to highlight labels in batch files." 63 "Font Lock mode face used to highlight labels in batch files.")
64 :group 'dos)
65 64
66;; 3 Internal variables 65;; 3 Internal variables
67 66
68(defvar dos-font-lock-keywords 67(defvar bat-font-lock-keywords
69 (eval-when-compile 68 (eval-when-compile
70 (let ((COMMANDS 69 (let ((COMMANDS
71 '("assoc" "at" "attrib" "cd" "cls" "color" "copy" "date" "del" "dir" 70 '("assoc" "at" "attrib" "cd" "cls" "color" "copy" "date" "del" "dir"
@@ -84,7 +83,7 @@
84 ("^[ \t]*\\(@?rem\\_>\\|::\\).*" 83 ("^[ \t]*\\(@?rem\\_>\\|::\\).*"
85 (0 font-lock-comment-face t)) 84 (0 font-lock-comment-face t))
86 ("^:[^:].*" 85 ("^:[^:].*"
87 . 'dos-label-face) 86 . 'bat-label-face)
88 ("\\<_\\(defined\\|set\\)\\_>[ \t]*\\(\\w+\\)" 87 ("\\<_\\(defined\\|set\\)\\_>[ \t]*\\(\\w+\\)"
89 (2 font-lock-variable-name-face)) 88 (2 font-lock-variable-name-face))
90 ("%\\(\\w+\\)%?" 89 ("%\\(\\w+\\)%?"
@@ -99,30 +98,28 @@
99 (,(concat "\\_<" (regexp-opt UNIX) "\\_>") 98 (,(concat "\\_<" (regexp-opt UNIX) "\\_>")
100 . font-lock-warning-face))))) 99 . font-lock-warning-face)))))
101 100
102(defvar dos-menu 101(defvar bat-menu
103 '("Dos" 102 '("Bat"
104 ["Run" dos-run :help "Run script"] 103 ["Run" bat-run :help "Run script"]
105 ["Run with Args" dos-run-args :help "Run script with args"] 104 ["Run with Args" bat-run-args :help "Run script with args"]
106 "--" 105 "--"
107 ["Imenu" imenu :help "Navigate with imenu"] 106 ["Imenu" imenu :help "Navigate with imenu"]
108 "--" 107 "--"
109 ["Template" dos-template :help "Insert template"] 108 ["Template" bat-template :help "Insert template"]
110 "--" 109 "--"
111 ["Help (Command)" dos-cmd-help :help "Show help page for Dos command"] 110 ["Help (Command)" bat-cmd-help :help "Show help page for DOS command"]))
112 ["Help (Mode)" dos-mode-help :help "Show help page for Emacs Dos Mode"]))
113 111
114(defvar dos-mode-map 112(defvar bat-mode-map
115 (let ((map (make-sparse-keymap))) 113 (let ((map (make-sparse-keymap)))
116 (easy-menu-define nil map nil dos-menu) 114 (easy-menu-define nil map nil bat-menu)
117 (define-key map [?\C-c ?\C-.] 'dos-mode-help) 115 (define-key map [?\C-c ?\C-/] 'bat-cmd-help) ;FIXME: Why not C-c C-? ?
118 (define-key map [?\C-c ?\C-/] 'dos-cmd-help) ;FIXME: Why not C-c C-? ? 116 (define-key map [?\C-c ?\C-a] 'bat-run-args)
119 (define-key map [?\C-c ?\C-a] 'dos-run-args) 117 (define-key map [?\C-c ?\C-c] 'bat-run)
120 (define-key map [?\C-c ?\C-c] 'dos-run) 118 (define-key map [?\C-c ?\C-t] 'bat-template)
121 (define-key map [?\C-c ?\C-t] 'dos-template) 119 (define-key map [?\C-c ?\C-v] 'bat-run)
122 (define-key map [?\C-c ?\C-v] 'dos-run)
123 map)) 120 map))
124 121
125(defvar dos-mode-syntax-table 122(defvar bat-mode-syntax-table
126 (let ((table (make-syntax-table))) 123 (let ((table (make-syntax-table)))
127 ;; Beware: `w' should not be used for non-alphabetic chars. 124 ;; Beware: `w' should not be used for non-alphabetic chars.
128 (modify-syntax-entry ?~ "_" table) 125 (modify-syntax-entry ?~ "_" table)
@@ -137,55 +134,48 @@
137 134
138;; 4 User functions 135;; 4 User functions
139 136
140(defun dos-cmd-help (cmd) 137(defun bat-cmd-help (cmd)
141 "Show help for batch file command CMD." 138 "Show help for batch file command CMD."
142 (interactive "sHelp: ") 139 (interactive "sHelp: ")
143 (if (string-equal cmd "net") 140 (if (string-equal cmd "net")
144 ;; FIXME: liable to quoting nightmare. Use call-process? 141 ;; FIXME: liable to quoting nightmare. Use call-process?
145 (shell-command "net /?") (shell-command (concat "help " cmd)))) 142 (shell-command "net /?") (shell-command (concat "help " cmd))))
146 143
147(defun dos-mode-help () 144(defun bat-run ()
148 "Show help page for `dos-mode'."
149 (interactive)
150 (describe-function 'dos-mode)
151 (switch-to-buffer "*Help*") (delete-other-windows) (message nil))
152
153(defun dos-run ()
154 "Run a batch file." 145 "Run a batch file."
155 (interactive) 146 (interactive)
156 ;; FIXME: liable to quoting nightmare. Use call/start-process? 147 ;; FIXME: liable to quoting nightmare. Use call/start-process?
157 (save-buffer) (shell-command buffer-file-name)) 148 (save-buffer) (shell-command buffer-file-name))
158 149
159(defun dos-run-args (args) 150(defun bat-run-args (args)
160 "Run a batch file with ARGS." 151 "Run a batch file with ARGS."
161 (interactive "sArgs: ") 152 (interactive "sArgs: ")
162 ;; FIXME: Use `compile'? 153 ;; FIXME: Use `compile'?
163 (shell-command (concat buffer-file-name " " args))) 154 (shell-command (concat buffer-file-name " " args)))
164 155
165(defun dos-template () 156(defun bat-template ()
166 "Insert minimal batch file template." 157 "Insert minimal batch file template."
167 (interactive) 158 (interactive)
168 (goto-char (point-min)) (insert "@echo off\nsetlocal\n\n")) 159 (goto-char (point-min)) (insert "@echo off\nsetlocal\n\n"))
169 160
170;;;###autoload 161;;;###autoload
171(add-to-list 'auto-mode-alist '("\\.\\(bat\\|cmd\\)\\'" . dos-mode)) 162(add-to-list 'auto-mode-alist '("\\.\\(bat\\|cmd\\)\\'" . bat-mode))
172 163
173;; 5 Main function 164;; 5 Main function
174 165
175;;;###autoload 166;;;###autoload
176(define-derived-mode dos-mode prog-mode "Dos" 167(define-derived-mode bat-mode prog-mode "Bat"
177 "Major mode for editing DOS/Windows batch files.\n 168 "Major mode for editing DOS/Windows batch files.\n
178The `dos-mode-help' command shows this page.\n 169Start a new script from `bat-template'. Read help pages for DOS commands
179Start a new script from `dos-template'. Read help pages for Dos commands 170with `bat-cmd-help'. Navigate between sections using `imenu'.
180with `dos-cmd-help'. Navigate between sections using `imenu'. 171Run script using `bat-run' and `bat-run-args'.\n
181Run script using `dos-run' and `dos-run-args'.\n 172\\{bat-mode-map}"
182\\{dos-mode-map}"
183 (setq-local comment-start "rem ") 173 (setq-local comment-start "rem ")
184 (setq-local font-lock-defaults 174 (setq-local font-lock-defaults
185 '(dos-font-lock-keywords nil t)) ; case-insensitive keywords 175 '(bat-font-lock-keywords nil t)) ; case-insensitive keywords
186 (setq-local imenu-generic-expression '((nil "^:[^:].*" 0))) 176 (setq-local imenu-generic-expression '((nil "^:[^:].*" 0)))
187 (setq-local outline-regexp ":[^:]")) 177 (setq-local outline-regexp ":[^:]"))
188 178
189(provide 'dos) 179(provide 'bat-mode)
190 180
191;;; dos.el ends here 181;;; bat-mode.el ends here