Mercurial > emacs
comparison lisp/progmodes/awk-mode.el @ 16451:0e181c85b17e
Add Font Lock support. Provide when loaded.
author | Simon Marshall <simon@gnu.org> |
---|---|
date | Wed, 23 Oct 1996 09:21:10 +0000 |
parents | 83f275dcd93a |
children | c0e681b163ce |
comparison
equal
deleted
inserted
replaced
16450:82b0566ece27 | 16451:0e181c85b17e |
---|---|
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 |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
47 (modify-syntax-entry ?% "." awk-mode-syntax-table) | 47 (modify-syntax-entry ?% "." awk-mode-syntax-table) |
48 (modify-syntax-entry ?< "." awk-mode-syntax-table) | 48 (modify-syntax-entry ?< "." awk-mode-syntax-table) |
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 ()) |
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.") | |
57 | 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. |
61 This is much like C mode except for the syntax of comments. It uses | 113 This is much like C mode except for the syntax of comments. It uses |
90 (setq comment-column 32) | 142 (setq comment-column 32) |
91 (make-local-variable 'comment-start-skip) | 143 (make-local-variable 'comment-start-skip) |
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 |