aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Marshall1996-10-23 09:21:10 +0000
committerSimon Marshall1996-10-23 09:21:10 +0000
commit4e59dfb557b8b071b7368805b3257b99d894b9f1 (patch)
treee51eedfd2a96d3115ec43a72410e518ba1831b8e
parent5572c1d1e97467801fe4f3435a20f3b6ba93f344 (diff)
downloademacs-4e59dfb557b8b071b7368805b3257b99d894b9f1.tar.gz
emacs-4e59dfb557b8b071b7368805b3257b99d894b9f1.zip
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 @@
1;;; awk-mode.el --- AWK code editing commands for Emacs 1;;; awk-mode.el --- AWK code editing commands for Emacs
2 2
3;; Copyright (C) 1988, 1994 Free Software Foundation, Inc. 3;; Copyright (C) 1988, 1994, 1996 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: unix, languages 6;; Keywords: unix, languages
@@ -49,12 +49,64 @@
49 (modify-syntax-entry ?> "." awk-mode-syntax-table) 49 (modify-syntax-entry ?> "." awk-mode-syntax-table)
50 (modify-syntax-entry ?& "." awk-mode-syntax-table) 50 (modify-syntax-entry ?& "." awk-mode-syntax-table)
51 (modify-syntax-entry ?| "." awk-mode-syntax-table) 51 (modify-syntax-entry ?| "." awk-mode-syntax-table)
52 (modify-syntax-entry ?_ "_" awk-mode-syntax-table)
52 (modify-syntax-entry ?\' "\"" awk-mode-syntax-table)) 53 (modify-syntax-entry ?\' "\"" awk-mode-syntax-table))
53 54
54(defvar awk-mode-abbrev-table nil 55(defvar awk-mode-abbrev-table nil
55 "Abbrev table in use in Awk-mode buffers.") 56 "Abbrev table in use in Awk-mode buffers.")
56(define-abbrev-table 'awk-mode-abbrev-table ()) 57(define-abbrev-table 'awk-mode-abbrev-table ())
57 58
59;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>.
60(defconst awk-font-lock-keywords
61 (eval-when-compile
62 (list
63 ;;
64 ;; Function names.
65 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
66 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
67 ;;
68 ;; Variable names.
69 (cons (concat "\\<\\("
70; ("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO"
71; "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR"
72; "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP")
73 "ARG\\([CV]\\|IND\\)\\|CONVFMT\\|E\\(NVIRON\\|RRNO\\)\\|"
74 "F\\(I\\(ELDWIDTHS\\|LENAME\\)\\|NR\\|S\\)\\|IGNORECASE\\|"
75 "N[FR]\\|O\\(F\\(MT\\|S\\)\\|RS\\)\\|"
76 "R\\(LENGTH\\|S\\(\\|TART\\)\\)\\|SUBSEP"
77 "\\)\\>")
78 'font-lock-variable-name-face)
79 ;;
80 ;; Keywords.
81 (concat "\\<\\("
82; ("BEGIN" "END" "break" "continue" "delete" "exit" "for"
83; "getline" "if" "next" "print" "printf" "return" "while")
84 "BEGIN\\|END\\|break\\|continue\\|delete\\|exit\\|for\\|"
85 "getline\\|if\\|next\\|printf?\\|return\\|while"
86 "\\)\\>")
87 ;;
88 ;; Builtins.
89 (list (concat "\\<\\("
90; ("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int"
91; "length" "log" "match" "rand" "sin" "split" "sprintf"
92; "sqrt" "srand" "sub" "substr" "system" "time"
93; "tolower" "toupper")
94 "atan2\\|c\\(lose\\|os\\|time\\)\\|exp\\|gsub\\|"
95 "in\\(dex\\|t\\)\\|l\\(ength\\|og\\)\\|match\\|rand\\|"
96 "s\\(in\\|p\\(lit\\|rintf\\)\\|qrt\\|rand\\|"
97 "ub\\(\\|str\\)\\|ystem\\)\\|"
98 "t\\(ime\\|o\\(lower\\|upper\\)\\)"
99 "\\)(")
100 1 'font-lock-builtin-face)
101 ;;
102 ;; Operators. Is this too much?
103 (cons (mapconcat 'identity
104 '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~")
105 "\\|")
106 'font-lock-reference-face)
107 ))
108 "Default expressions to highlight in AWK mode.")
109
58;;;###autoload 110;;;###autoload
59(defun awk-mode () 111(defun awk-mode ()
60 "Major mode for editing AWK code. 112 "Major mode for editing AWK code.
@@ -92,6 +144,10 @@ with no args, if that value is non-nil."
92 (setq comment-start-skip "#+ *") 144 (setq comment-start-skip "#+ *")
93 (make-local-variable 'comment-indent-function) 145 (make-local-variable 'comment-indent-function)
94 (setq comment-indent-function 'c-comment-indent) 146 (setq comment-indent-function 'c-comment-indent)
147 (make-local-variable 'font-lock-defaults)
148 (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w"))))
95 (run-hooks 'awk-mode-hook)) 149 (run-hooks 'awk-mode-hook))
96 150
151(provide 'awk-mode)
152
97;;; awk-mode.el ends here 153;;; awk-mode.el ends here