Mercurial > emacs
changeset 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 | 82b0566ece27 |
children | c51321427e96 |
files | lisp/progmodes/awk-mode.el |
diffstat | 1 files changed, 57 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/awk-mode.el Wed Oct 23 09:16:54 1996 +0000 +++ b/lisp/progmodes/awk-mode.el Wed Oct 23 09:21:10 1996 +0000 @@ -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 @@ (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