aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2000-11-05 19:13:34 +0000
committerStefan Monnier2000-11-05 19:13:34 +0000
commit178a6a455ec577c7982c0ce156107d0696d43031 (patch)
tree898b0d9704036ee50d38cd8d81131eaf5a2324b2
parent7e1d6bdb408f48b3efe2168d52283af44087d481 (diff)
downloademacs-178a6a455ec577c7982c0ce156107d0696d43031.tar.gz
emacs-178a6a455ec577c7982c0ce156107d0696d43031.zip
Update copyright.
(awk-mode-abbrev-table): Remove. (awk-font-lock-keywords): Use regexp-opt. (awk-mode): Use define-derived-mode.
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/progmodes/awk-mode.el97
2 files changed, 35 insertions, 72 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 58ef859de26..0f218cfa53b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,13 @@
12000-11-05 Stefan Monnier <monnier@cs.yale.edu>
2
3 * progmodes/awk-mode.el: Update copyright.
4 (awk-mode-abbrev-table): Remove.
5 (awk-font-lock-keywords): Use regexp-opt.
6 (awk-mode): Use define-derived-mode.
7
8 * emacs-lisp/regexp-opt.el (regexp-opt-group): Sort the strings
9 when extracting a suffix.
10
12000-11-04 Andre Spiegel <spiegel@gnu.org> 112000-11-04 Andre Spiegel <spiegel@gnu.org>
2 12
3 * vc-hooks.el (vc-insert-file): Rewritten. Don't bother about 13 * vc-hooks.el (vc-insert-file): Rewritten. Don't bother about
diff --git a/lisp/progmodes/awk-mode.el b/lisp/progmodes/awk-mode.el
index 599ffbd0088..8079d74301e 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, 1996 Free Software Foundation, Inc. 3;; Copyright (C) 1988,94,96,2000 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: unix, languages 6;; Keywords: unix, languages
@@ -52,102 +52,55 @@
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 (modify-syntax-entry ?\' "\"" awk-mode-syntax-table))
54 54
55(defvar awk-mode-abbrev-table nil
56 "Abbrev table in use in Awk-mode buffers.")
57(define-abbrev-table 'awk-mode-abbrev-table ())
58
59;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>. 55;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>.
60(defconst awk-font-lock-keywords 56(defconst awk-font-lock-keywords
61 (eval-when-compile 57 (eval-when-compile
62 (list 58 (list
63 ;; 59 ;;
64 ;; Function names. 60 ;; Function names.
65 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?" 61 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
66 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) 62 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
67 ;; 63 ;;
68 ;; Variable names. 64 ;; Variable names.
69 (cons (concat "\\<\\(" 65 (cons (regexp-opt
70; ("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO" 66 '("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO"
71; "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR" 67 "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR"
72; "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP") 68 "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP") 'words)
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) 69 'font-lock-variable-name-face)
79 ;; 70 ;;
80 ;; Keywords. 71 ;; Keywords.
81 (concat "\\<\\(" 72 (regexp-opt
82; ("BEGIN" "END" "break" "continue" "delete" "exit" "for" 73 '("BEGIN" "END" "break" "continue" "delete" "exit" "else" "for"
83; "getline" "if" "next" "print" "printf" "return" "while") 74 "getline" "if" "next" "print" "printf" "return" "while") 'words)
84 "BEGIN\\|END\\|break\\|continue\\|delete\\|exit\\|else\\|for\\|"
85 "getline\\|if\\|next\\|printf?\\|return\\|while"
86 "\\)\\>")
87 ;; 75 ;;
88 ;; Builtins. 76 ;; Builtins.
89 (list (concat "\\<\\(" 77 (list (regexp-opt
90; ("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int" 78 '("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int"
91; "length" "log" "match" "rand" "sin" "split" "sprintf" 79 "length" "log" "match" "rand" "sin" "split" "sprintf"
92; "sqrt" "srand" "sub" "substr" "system" "time" 80 "sqrt" "srand" "sub" "substr" "system" "time"
93; "tolower" "toupper") 81 "tolower" "toupper") 'words)
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) 82 1 'font-lock-builtin-face)
101 ;; 83 ;;
102 ;; Operators. Is this too much? 84 ;; Operators. Is this too much?
103 (cons (mapconcat 'identity 85 (cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~"))
104 '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~")
105 "\\|")
106 'font-lock-constant-face) 86 'font-lock-constant-face)
107 )) 87 ))
108 "Default expressions to highlight in AWK mode.") 88 "Default expressions to highlight in AWK mode.")
109 89
110;;;###autoload 90;;;###autoload
111(defun awk-mode () 91(define-derived-mode awk-mode c-mode "AWK"
112 "Major mode for editing AWK code. 92 "Major mode for editing AWK code.
113This is much like C mode except for the syntax of comments. It uses 93This is much like C mode except for the syntax of comments. Its keymap
114the same keymap as C mode and has the same variables for customizing 94inherits from C mode's and it has the same variables for customizing
115indentation. It has its own abbrev table and its own syntax table. 95indentation. It has its own abbrev table and its own syntax table.
116 96
117Turning on AWK mode calls the value of the variable `awk-mode-hook' 97Turning on AWK mode runs `awk-mode-hook'."
118with no args, if that value is non-nil." 98 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
119 (interactive) 99 (set (make-local-variable 'paragraph-separate) paragraph-start)
120 (kill-all-local-variables) 100 (set (make-local-variable 'comment-start) "# ")
121 (require 'cc-mode) 101 (set (make-local-variable 'comment-end) "")
122 (c-initialize-cc-mode) 102 (set (make-local-variable 'comment-start-skip) "#+ *")
123 (use-local-map c-mode-map) 103 (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w")))))
124 (setq major-mode 'awk-mode)
125 (setq mode-name "AWK")
126 (setq local-abbrev-table awk-mode-abbrev-table)
127 (set-syntax-table awk-mode-syntax-table)
128 (make-local-variable 'paragraph-start)
129 (setq paragraph-start (concat "$\\|" page-delimiter))
130 (make-local-variable 'paragraph-separate)
131 (setq paragraph-separate paragraph-start)
132 (make-local-variable 'paragraph-ignore-fill-prefix)
133 (setq paragraph-ignore-fill-prefix t)
134 (make-local-variable 'indent-line-function)
135 (setq indent-line-function 'c-indent-line)
136 (make-local-variable 'require-final-newline)
137 (setq require-final-newline t)
138 (make-local-variable 'comment-start)
139 (setq comment-start "# ")
140 (make-local-variable 'comment-end)
141 (setq comment-end "")
142 (make-local-variable 'comment-start-skip)
143 (setq comment-start-skip "#+ *")
144 (make-local-variable 'comment-indent-function)
145 (setq comment-indent-function 'c-comment-indent)
146 (make-local-variable 'parse-sexp-ignore-comments)
147 (setq parse-sexp-ignore-comments t)
148 (make-local-variable 'font-lock-defaults)
149 (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w"))))
150 (run-hooks 'awk-mode-hook))
151 104
152(provide 'awk-mode) 105(provide 'awk-mode)
153 106