461
461
;;; DOS/Windows BAT files
462
462
(when (memq 'bat-generic-mode generic-extras-enable-list)
464
(define-generic-mode bat-generic-mode
469
;; Make this one first in the list, otherwise comments will
470
;; be over-written by other variables
471
'("^[@ \t]*\\([rR][eE][mM][^\n\r]*\\)" 1 font-lock-comment-face t)
472
'("^[ \t]*\\(::.*\\)" 1 font-lock-comment-face t)
473
'("^[@ \t]*\\([bB][rR][eE][aA][kK]\\|[vV][eE][rR][iI][fF][yY]\\)[ \t]+\\([oO]\\([nN]\\|[fF][fF]\\)\\)"
474
(1 font-lock-builtin-face)
475
(2 font-lock-constant-face t t))
476
;; Any text (except ON/OFF) following ECHO is a string.
477
'("^[@ \t]*\\([eE][cC][hH][oO]\\)[ \t]+\\(\\([oO]\\([nN]\\|[fF][fF]\\)\\)\\|\\([^>|\r\n]+\\)\\)"
478
(1 font-lock-builtin-face)
479
(3 font-lock-constant-face t t)
480
(5 font-lock-string-face t t))
481
;; These keywords appear as the first word on a line. (Actually, they
482
;; can also appear after "if ..." or "for ..." clause, but since they
483
;; are frequently used in simple text, we punt.)
484
;; In `generic-bat-mode-setup-function' we make the keywords
486
(generic-make-keywords-list
489
font-lock-keyword-face "^[@ \t]*")
490
;; These keywords can be anywhere on a line
491
;; In `generic-bat-mode-setup-function' we make the keywords
493
(generic-make-keywords-list
499
font-lock-keyword-face)
500
;; These are built-in commands. Only frequently-used ones are listed.
501
(generic-make-keywords-list
502
'("CALL" "call" "Call"
510
"PAUSE" "pause" "Pause"
511
"PROMPT" "prompt" "Prompt"
515
"START" "start" "Start"
516
"SHIFT" "shift" "Shift")
517
font-lock-builtin-face "[ \t|\n]")
518
'("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t)
519
'("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t)
520
'("\\(%[0-9]\\)" 1 font-lock-variable-name-face t)
521
'("[\t ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face)
522
'("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
523
(1 font-lock-keyword-face)
524
(2 font-lock-function-name-face nil t))
525
'("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
526
(1 font-lock-builtin-face)
527
(2 font-lock-variable-name-face t t))))
528
'("\\.[bB][aA][tT]\\'"
530
"\\`[cC][oO][nN][fF][iI][gG]\\."
531
"\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
532
'(generic-bat-mode-setup-function)
533
"Generic mode for MS-Windows batch files.")
535
(defvar bat-generic-mode-syntax-table nil
536
"Syntax table in use in `bat-generic-mode' buffers.")
538
(defvar bat-generic-mode-keymap (make-sparse-keymap)
539
"Keymap for `bat-generic-mode'.")
541
(defun bat-generic-mode-compile ()
542
"Run the current BAT file in a compilation buffer."
544
(let ((compilation-buffer-name-function
547
(concat "*" (buffer-file-name) "*")))))
549
(concat (w32-shell-name) " -c " (buffer-file-name)))))
551
(eval-when-compile (require 'comint))
552
(defun bat-generic-mode-run-as-comint ()
553
"Run the current BAT file in a comint buffer."
556
(let* ((file (buffer-file-name))
557
(buf-name (concat "*" file "*")))
558
(with-current-buffer (get-buffer-create buf-name)
567
(display-buffer buf-name))))
569
(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
571
;; Make underscores count as words
572
(unless bat-generic-mode-syntax-table
573
(setq bat-generic-mode-syntax-table (make-syntax-table))
574
(modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
576
;; bat-generic-mode doesn't use the comment functionality of
577
;; define-generic-mode because it has a three-letter comment-string,
578
;; so we do it here manually instead
579
(defun generic-bat-mode-setup-function ()
580
(make-local-variable 'parse-sexp-ignore-comments)
581
(make-local-variable 'comment-start)
582
(make-local-variable 'comment-start-skip)
583
(make-local-variable 'comment-end)
584
(setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
585
parse-sexp-ignore-comments t
588
comment-start-skip "[Rr][Ee][Mm] *")
589
(set-syntax-table bat-generic-mode-syntax-table)
590
;; Make keywords case-insensitive
591
(setq font-lock-defaults '(generic-font-lock-keywords nil t))
592
(use-local-map bat-generic-mode-keymap)))
463
(define-obsolete-function-alias 'bat-generic-mode 'bat-mode "24.4"))
595
466
;; Mailagent is a Unix mail filtering program. Anyone wanna do a
1418
1284
"Function argument constants used in InstallShield 3 and 5."))
1420
(defvar rul-generic-mode-syntax-table nil
1286
;; c++-mode-syntax-table used to be autoloaded, with an initial nil value.
1287
;; This file did not load cc-mode, and therefore rul-generic-mode-syntax-table
1288
;; would have different values according to whether or not cc-mode
1289
;; happened to be loaded before this file was.
1291
(defvar c++-mode-syntax-table)
1293
(defvar rul-generic-mode-syntax-table
1294
(let ((table (make-syntax-table c++-mode-syntax-table)))
1295
(modify-syntax-entry ?\r "> b" table)
1296
(modify-syntax-entry ?\n "> b" table)
1297
(modify-syntax-entry ?/ ". 124b" table)
1298
(modify-syntax-entry ?* ". 23" table)
1421
1300
"Syntax table to use in `rul-generic-mode' buffers.")
1423
(setq rul-generic-mode-syntax-table
1424
(make-syntax-table c++-mode-syntax-table))
1426
(modify-syntax-entry ?\r "> b" rul-generic-mode-syntax-table)
1427
(modify-syntax-entry ?\n "> b" rul-generic-mode-syntax-table)
1429
(modify-syntax-entry ?/ ". 124b" rul-generic-mode-syntax-table)
1430
(modify-syntax-entry ?* ". 23" rul-generic-mode-syntax-table)
1432
1302
;; here manually instead
1433
1303
(defun generic-rul-mode-setup-function ()
1434
1304
(make-local-variable 'parse-sexp-ignore-comments)
1468
1338
(1 font-lock-keyword-face)
1469
1339
(2 font-lock-constant-face nil t))
1470
1340
;; system variables
1471
(generic-make-keywords-list
1472
installshield-system-variables-list
1473
font-lock-variable-name-face "[^_]" "[^_]")
1341
(list (concat "[^_]"
1342
(regexp-opt installshield-system-variables-list 'symbols)
1344
1 font-lock-variable-name-face)
1474
1345
;; system functions
1475
(generic-make-keywords-list
1476
installshield-system-functions-list
1477
font-lock-function-name-face "[^_]" "[^_]")
1346
(list (concat "[^_]"
1347
(regexp-opt installshield-system-functions-list 'symbols)
1349
1 font-lock-function-name-face)
1478
1350
;; type keywords
1479
(generic-make-keywords-list
1480
installshield-types-list
1481
font-lock-type-face "[^_]" "[^_]")
1351
(list (concat "[^_]"
1352
(regexp-opt installshield-types-list 'symbols)
1354
1 font-lock-type-face)
1482
1355
;; function argument constants
1483
(generic-make-keywords-list
1484
installshield-funarg-constants-list
1485
font-lock-variable-name-face "[^_]" "[^_]"))) ; is this face the best choice?
1356
(list (concat "[^_]"
1357
(regexp-opt installshield-funarg-constants-list 'symbols)
1359
1 font-lock-variable-name-face))) ; is this face the best choice?
1486
1360
'("\\.[rR][uU][lL]\\'")
1487
1361
'(generic-rul-mode-setup-function)
1488
1362
"Generic mode for InstallShield RUL files.")