From: Simon Marshall Date: Wed, 23 Oct 1996 09:21:10 +0000 (+0000) Subject: Add Font Lock support. Provide when loaded. X-Git-Tag: emacs-20.1~3493 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4e59dfb557b8b071b7368805b3257b99d894b9f1;p=emacs.git Add Font Lock support. Provide when loaded. --- 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 . +(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