The patch below is based on awk-mode.el from FSF Emacs 20.7.
The patch adds code to syncronize with FSF's awk-mode as well as some
additional fontification:
awk regular expressions are fontified as strings
function calls are fontified
users variables are fontified
Please, commit it to CVS.
Nick.
Index: ChangeLog
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-packages/prog/prog-modes/ChangeLog,v
retrieving revision 1.32
diff -u -r1.32 ChangeLog
--- ChangeLog 2000/09/06 11:47:58 1.32
+++ ChangeLog 2000/10/03 16:19:40
@@ -1,3 +1,8 @@
+2000-10-03 Nick V. Pakoulin <npak(a)ispras.ru>
+
+ * awk-mode.el: Synched with FSF Emacs 20.7
+ Added some extra fontification.
+
2000-08-29 Alex Schroeder <alex(a)gnu.org>
* sql.el (sql-postgres): Use sql-postgres-options.
Index: awk-mode.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs-packages/prog/prog-modes/awk-mode.el,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 awk-mode.el
--- awk-mode.el 1998/01/14 06:44:54 1.1.1.1
+++ awk-mode.el 2000/10/03 16:37:30
@@ -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
@@ -22,7 +22,7 @@
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.
-;;; Synched up with: FSF 19.34.
+;;; Synched up with: FSF 20.7
;;; Commentary:
@@ -51,12 +51,86 @@
(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(a)mixing.qc.dfo.ca>.
+(defconst awk-font-lock-keywords
+ (eval-when-compile
+ (list
+ ;;
+ ;; Regular expressions. npak(a)ispras.ru
+ ;; We shoul do it before any other fontification
+ ;; Split into two cases for Speed god.
+ (cons "^[ \t]*/\\(\\(\\([\\].\\)?[^/\\]*\\)+\\)"
+ '(1 'font-lock-string-face))
+ (cons "[!~+-*=&|(][ \t]*/\\(\\(\\([\\].\\)?[^/\\]*\\)+\\)"
+ '(1 font-lock-string-face))
+ ;; 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")
+ ;; And "RT" npak(a)ispras.ru
+ "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\\)\\|T\\)\\|SUBSEP"
+ "\\)\\>\\|"
+ ;; Field identifiers $0, $1, etc npak(a)ispras.ru
+ "\\$\\([0-9]+\\|\\sw+\\)")
+ 'font-lock-variable-name-face)
+ ;;
+ ;; Keywords.
+ (concat "\\<\\("
+; ("BEGIN" "END" "break" "continue"
"delete" "exit" "for"
+; "getline" "if" "next" "print"
"printf" "return" "while")
+; and "do" "else" "in" "nextfile"
npak(a)ispras.ru
+ "BEGIN\\|END\\|break\\|continue\\|d\\(elete\\|o\\)\\|"
+ "e\\(lse\\|xit\\)\\|for\\|"
+ "getline\\|i[fn]\\|next\\(file\\)\\|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")
+; and "fflush" npak(a)ispras.ru
+ "atan2\\|c\\(lose\\|os\\|time\\)\\|exp\\|gsub\\|fflush\\|"
+ "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-reference-face)
+ ;; Function call, variables. npak(a)ispras.ru
+ (list "\\<\\([A-Za-z_]\\sw*\\)(" 1 'font-lock-function-name-face)
+ (list "\\<\\([A-Za-z_]\\sw*\\)\\($\\|[^(]\\)"
+ 1 'font-lock-variable-name-face)
+ ;;
+ ;; Operators. Is this too much?
+ ;; Yes, it is. npak(a)ispras.ru
+; (cons (mapconcat 'identity
+; '("&&" "||" "<=" "<"
">=" ">" "==" "!=" "!~"
"~")
+; "\\|")
+; 'font-lock-reference-face)
+ ))
+ "Default expressions to highlight in AWK mode.")
+
+;; npak(a)ispras.ru
+(put 'awk-mode 'font-lock-defaults
+ '(awk-font-lock-keywords nil nil ((?_ . "w"))))
+
;;;###autoload
(defun awk-mode ()
"Major mode for editing AWK code.
@@ -69,6 +143,7 @@
(interactive)
(kill-all-local-variables)
(require 'cc-mode)
+ (c-initialize-cc-mode)
(use-local-map c-mode-map)
(setq major-mode 'awk-mode)
(setq mode-name "AWK")
@@ -94,6 +169,13 @@
(setq comment-start-skip "#+ *")
(make-local-variable 'comment-indent-function)
(setq comment-indent-function 'c-comment-indent)
+ (make-local-variable 'parse-sexp-ignore-comments)
+ (setq parse-sexp-ignore-comments t)
+ ;; No need in XEmacs
+ ;(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
Show replies by date