summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marshall <simon@gnu.org>1996-10-23 09:21:10 +0000
committerSimon Marshall <simon@gnu.org>1996-10-23 09:21:10 +0000
commit4e59dfb557b8b071b7368805b3257b99d894b9f1 (patch)
treee51eedfd2a96d3115ec43a72410e518ba1831b8e
parent5572c1d1e97467801fe4f3435a20f3b6ba93f344 (diff)
downloademacs-4e59dfb557b8b071b7368805b3257b99d894b9f1.tar.gz
Add Font Lock support. Provide when loaded.
-rw-r--r--lisp/progmodes/awk-mode.el58
1 files changed, 57 insertions, 1 deletions
diff --git a/lisp/progmodes/awk-mode.el b/lisp/progmodes/awk-mode.el
index 7d70fe02e3a..3ba782bac38 100644
--- a/lisp/progmodes/awk-mode.el
+++ b/lisp/progmodes/awk-mode.el
@@ -1,6 +1,6 @@
;;; awk-mode.el --- AWK code editing commands for Emacs
-;; Copyright (C) 1988, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1988, 1994, 1996 Free Software Foundation, Inc.
;; Maintainer: FSF
;; Keywords: unix, languages
@@ -49,12 +49,64 @@
(modify-syntax-entry ?> "." awk-mode-syntax-table)
(modify-syntax-entry ?& "." awk-mode-syntax-table)
(modify-syntax-entry ?| "." awk-mode-syntax-table)
+ (modify-syntax-entry ?_ "_" awk-mode-syntax-table)
(modify-syntax-entry ?\' "\"" awk-mode-syntax-table))
(defvar awk-mode-abbrev-table nil
"Abbrev table in use in Awk-mode buffers.")
(define-abbrev-table 'awk-mode-abbrev-table ())
+;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>.
+(defconst awk-font-lock-keywords
+ (eval-when-compile
+ (list
+ ;;
+ ;; Function names.
+ '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
+ (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
+ ;;
+ ;; Variable names.
+ (cons (concat "\\<\\("
+; ("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO"
+; "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR"
+; "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP")
+ "ARG\\([CV]\\|IND\\)\\|CONVFMT\\|E\\(NVIRON\\|RRNO\\)\\|"
+ "F\\(I\\(ELDWIDTHS\\|LENAME\\)\\|NR\\|S\\)\\|IGNORECASE\\|"
+ "N[FR]\\|O\\(F\\(MT\\|S\\)\\|RS\\)\\|"
+ "R\\(LENGTH\\|S\\(\\|TART\\)\\)\\|SUBSEP"
+ "\\)\\>")
+ 'font-lock-variable-name-face)
+ ;;
+ ;; Keywords.
+ (concat "\\<\\("
+; ("BEGIN" "END" "break" "continue" "delete" "exit" "for"
+; "getline" "if" "next" "print" "printf" "return" "while")
+ "BEGIN\\|END\\|break\\|continue\\|delete\\|exit\\|for\\|"
+ "getline\\|if\\|next\\|printf?\\|return\\|while"
+ "\\)\\>")
+ ;;
+ ;; Builtins.
+ (list (concat "\\<\\("
+; ("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int"
+; "length" "log" "match" "rand" "sin" "split" "sprintf"
+; "sqrt" "srand" "sub" "substr" "system" "time"
+; "tolower" "toupper")
+ "atan2\\|c\\(lose\\|os\\|time\\)\\|exp\\|gsub\\|"
+ "in\\(dex\\|t\\)\\|l\\(ength\\|og\\)\\|match\\|rand\\|"
+ "s\\(in\\|p\\(lit\\|rintf\\)\\|qrt\\|rand\\|"
+ "ub\\(\\|str\\)\\|ystem\\)\\|"
+ "t\\(ime\\|o\\(lower\\|upper\\)\\)"
+ "\\)(")
+ 1 'font-lock-builtin-face)
+ ;;
+ ;; Operators. Is this too much?
+ (cons (mapconcat 'identity
+ '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~")
+ "\\|")
+ 'font-lock-reference-face)
+ ))
+ "Default expressions to highlight in AWK mode.")
+
;;;###autoload
(defun awk-mode ()
"Major mode for editing AWK code.
@@ -92,6 +144,10 @@ with no args, if that value is non-nil."
(setq comment-start-skip "#+ *")
(make-local-variable 'comment-indent-function)
(setq comment-indent-function 'c-comment-indent)
+ (make-local-variable 'font-lock-defaults)
+ (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w"))))
(run-hooks 'awk-mode-hook))
+(provide 'awk-mode)
+
;;; awk-mode.el ends here