aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/generic-x.el
diff options
context:
space:
mode:
authorArni Magnusson2013-08-07 11:43:57 -0400
committerStefan Monnier2013-08-07 11:43:57 -0400
commit400a3178cb749fe9cdbad59871aa0786babd434e (patch)
tree94ae8e0a8c6dd7f72495749017d6a7e03fe253e7 /lisp/generic-x.el
parent03eb60c17ad3abb221aaa71623ce837906836d49 (diff)
downloademacs-400a3178cb749fe9cdbad59871aa0786babd434e.tar.gz
emacs-400a3178cb749fe9cdbad59871aa0786babd434e.zip
* lisp/progmodes/dos.el: New file.
* lisp/generic-x.el (bat-generic-mode): Redefine as an obsolete alias to dos-mode.
Diffstat (limited to 'lisp/generic-x.el')
-rw-r--r--lisp/generic-x.el125
1 files changed, 1 insertions, 124 deletions
diff --git a/lisp/generic-x.el b/lisp/generic-x.el
index 1867759b549..698819d73a1 100644
--- a/lisp/generic-x.el
+++ b/lisp/generic-x.el
@@ -460,130 +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 463 (define-obsolete-function-alias 'bat-generic-mode 'dos-mode "24.4"))
464(define-generic-mode bat-generic-mode
465 nil
466 nil
467 (eval-when-compile
468 (list
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
485 ;; case-insensitive
486 '("^[@ \t]*\\_<\\(for\\|if\\)\\_>" 1 font-lock-keyword-face)
487 ;; These keywords can be anywhere on a line
488 ;; In `generic-bat-mode-setup-function' we make the keywords
489 ;; case-insensitive
490 (list (regexp-opt '("do" "exist" "errorlevel" "goto" "not") 'symbols)
491 1 font-lock-keyword-face)
492 ;; These are built-in commands. Only frequently-used ones are listed.
493 (list (concat "[ \t|\n]"
494 (regexp-opt '("CALL" "call" "Call"
495 "CD" "cd" "Cd"
496 "CLS" "cls" "Cls"
497 "COPY" "copy" "Copy"
498 "DEL" "del" "Del"
499 "ECHO" "echo" "Echo"
500 "MD" "md" "Md"
501 "PATH" "path" "Path"
502 "PAUSE" "pause" "Pause"
503 "PROMPT" "prompt" "Prompt"
504 "RD" "rd" "Rd"
505 "REN" "ren" "Ren"
506 "SET" "set" "Set"
507 "START" "start" "Start"
508 "SHIFT" "shift" "Shift") 'symbols))
509 1 font-lock-builtin-face)
510 '("^[ \t]*\\(:\\sw+\\)" 1 font-lock-function-name-face t)
511 '("\\(%\\sw+%\\)" 1 font-lock-variable-name-face t)
512 '("\\(%[0-9]\\)" 1 font-lock-variable-name-face t)
513 '("[\t ]+\\([+-/][^\t\n\" ]+\\)" 1 font-lock-type-face)
514 '("[ \t\n|]\\<\\([gG][oO][tT][oO]\\)\\>[ \t]*\\(\\sw+\\)?"
515 (1 font-lock-keyword-face)
516 (2 font-lock-function-name-face nil t))
517 '("[ \t\n|]\\<\\([sS][eE][tT]\\)\\>[ \t]*\\(\\sw+\\)?[ \t]*=?"
518 (1 font-lock-builtin-face)
519 (2 font-lock-variable-name-face t t))))
520 '("\\.[bB][aA][tT]\\'"
521 "\\.[cC][mM][dD]\\'"
522 "\\`[cC][oO][nN][fF][iI][gG]\\."
523 "\\`[aA][uU][tT][oO][eE][xX][eE][cC]\\.")
524 '(generic-bat-mode-setup-function)
525 "Generic mode for MS-Windows batch files.")
526
527(defvar bat-generic-mode-syntax-table nil
528 "Syntax table in use in `bat-generic-mode' buffers.")
529
530(defvar bat-generic-mode-keymap (make-sparse-keymap)
531 "Keymap for `bat-generic-mode'.")
532
533(defun bat-generic-mode-compile ()
534 "Run the current BAT file in a compilation buffer."
535 (interactive)
536 (let ((compilation-buffer-name-function
537 (function
538 (lambda (_ign)
539 (concat "*" (buffer-file-name) "*")))))
540 (compile
541 (concat (w32-shell-name) " -c " (buffer-file-name)))))
542
543(declare-function comint-mode "comint" ())
544(declare-function comint-exec "comint" (buffer name command startfile switches))
545
546(defun bat-generic-mode-run-as-comint ()
547 "Run the current BAT file in a comint buffer."
548 (interactive)
549 (require 'comint)
550 (let* ((file (buffer-file-name))
551 (buf-name (concat "*" file "*")))
552 (with-current-buffer (get-buffer-create buf-name)
553 (erase-buffer)
554 (comint-mode)
555 (comint-exec
556 buf-name
557 file
558 (w32-shell-name)
559 nil
560 (list "-c" file))
561 (display-buffer buf-name))))
562
563(define-key bat-generic-mode-keymap "\C-c\C-c" 'bat-generic-mode-compile)
564
565;; Make underscores count as words
566(unless bat-generic-mode-syntax-table
567 (setq bat-generic-mode-syntax-table (make-syntax-table))
568 (modify-syntax-entry ?_ "w" bat-generic-mode-syntax-table))
569
570;; bat-generic-mode doesn't use the comment functionality of
571;; define-generic-mode because it has a three-letter comment-string,
572;; so we do it here manually instead
573(defun generic-bat-mode-setup-function ()
574 (make-local-variable 'parse-sexp-ignore-comments)
575 (make-local-variable 'comment-start)
576 (make-local-variable 'comment-start-skip)
577 (make-local-variable 'comment-end)
578 (setq imenu-generic-expression '((nil "^:\\(\\sw+\\)" 1))
579 parse-sexp-ignore-comments t
580 comment-end ""
581 comment-start "REM "
582 comment-start-skip "[Rr][Ee][Mm] *")
583 (set-syntax-table bat-generic-mode-syntax-table)
584 ;; Make keywords case-insensitive
585 (setq font-lock-defaults '(generic-font-lock-keywords nil t))
586 (use-local-map bat-generic-mode-keymap)))
587 464
588;;; Mailagent 465;;; Mailagent
589;; Mailagent is a Unix mail filtering program. Anyone wanna do a 466;; Mailagent is a Unix mail filtering program. Anyone wanna do a