lisp/bat-file-mode.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Fri, 05 Feb 2010 16:23:40 +0200
changeset 307 cb789e9ce92a
parent 306 0d8df38892d5
child 308 febb0a155d8d
permissions -rw-r--r--
Added highliting for some keyword.

;;; bat-file-mode.el --- batch file major mode

;; Copyright (C) 2010 by Oleksandr Gavenko <gavenkoa@gmail.com>

;; You can do anything with this file without any warranty.

;; Author: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com>
;; Created: 2010-01-28
;; Version: 0.1
;; Keywords: languages

;;; Commentary:
;;
;; Very pure highlighting and not all available syntax.

;;; Code:

;;;###autoload
(define-generic-mode 'bat-file-mode
  (list "REM " ":: ")
  nil
  '(
    ("\\(:[[:alnum:]_]+\\)" (1 'font-lock-function-name-face))
    ("\\<\\([iI][fF]\\|[eE][lL][sS][eE]\\|[fF][oO][rR]\\|[iI][nN]\\|[dD][oO]\\|[gG][oO][tT][oO]\
\\|[nN][oO][tT]\\|[eE][rR][rR][oO][rR][lL][eE][vV][eE][lL]\
\\|[pP][aA][uU][sS][eE]\\|[eE][cC][hH][oO]\\|[pP][rR][oO][mM][pP][tT]\
\\|[cC][aA][lL][lL]\\|[sS][eE][tT]\\|[sS][tT][aA][rR][tT]\\)\\>" (1 'font-lock-keyword-face))
    ("\\(:[[:alpha:]][[:alnum:]_]*\\)" (1 'font-lock-function-name-face))
    ("\\(%[[:digit:]]\\|%%[[:alpha:]]\\|%[[:alpha:]][[:alnum:]]*%\\)" (1 'font-lock-variable-name-face))
    ("set[[:blank:]]+\\([[:alpha:]][[:alnum:]]*\\)[[:blank:]]*=" (1 'font-lock-variable-name-face))
    ;; ("\\(\\%[a-z]\\)" (1 'font-lock-reference-face))
    ;; ("\\(%\\sw+%\\)" (1 'font-lock-reference-face))
    ;; ("\\(%[0-9]\\)" (1 'font-lock-reference-face))
    )
  (list "\\.\\([bB][aA][tT]\\|[cC][mM][dD]\\|[nN][sS][hH]\\)$")
  nil
  "Generic mode for batch files.")

;; (autoload 'myfunction "mypackage" "Do what I say." t)

(setq bat-file-mode-hook
 (lambda ()
   (modify-syntax-entry ?\" "\"")
   (modify-syntax-entry ?' "\"")
   (modify-syntax-entry ?\\ "\\")
   (modify-syntax-entry ?% ".")
   (modify-syntax-entry ?= ".")
   (modify-syntax-entry ?_ "w")
   )
 )

;; (add-hook
;;  'bat-file-mode-hook
;;  (lambda ()
;;    (modify-syntax-entry ?\" "\"")
;;    (modify-syntax-entry ?' "\"")
;;    (modify-syntax-entry ?\\ "\\")
;;    (modify-syntax-entry ?= ".")
;;    (modify-syntax-entry ?_ "w")
;;    ))

;; .bat file gramma:
;;
;; cmd ::= path { arg }
;; path ::=

(provide 'bat-file-mode)

;;; bat-file-mode.el ends here