Mercurial > emacs
annotate lisp/progmodes/awk-mode.el @ 34810:61d22833847a
*** empty log message ***
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 21 Dec 2000 21:27:37 +0000 |
parents | 19d92160ddac |
children | c6e48d7cdb07 |
rev | line source |
---|---|
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
1 ;;; awk-mode.el --- AWK code editing commands for Emacs |
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
2 |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
3 ;; Copyright (C) 1988,94,96,2000 Free Software Foundation, Inc. |
845 | 4 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
5 ;; Maintainer: FSF |
2247
2c7997f249eb
Add or correct keywords
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
845
diff
changeset
|
6 ;; Keywords: unix, languages |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
7 |
257 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option) |
257 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
14169 | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
257 | 24 |
2307
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
25 ;;; Commentary: |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
26 |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
27 ;; Sets up C-mode with support for awk-style #-comments and a lightly |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
28 ;; hacked syntax table. |
10e417efb12a
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2247
diff
changeset
|
29 |
811
e694e0879463
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
662
diff
changeset
|
30 ;;; Code: |
257 | 31 |
32 (defvar awk-mode-syntax-table nil | |
33 "Syntax table in use in Awk-mode buffers.") | |
34 | |
35 (if awk-mode-syntax-table | |
36 () | |
37 (setq awk-mode-syntax-table (make-syntax-table)) | |
38 (modify-syntax-entry ?\\ "\\" awk-mode-syntax-table) | |
5329
af96725f9e00
(awk-mode-syntax-table): Was mistakenly changing
Richard M. Stallman <rms@gnu.org>
parents:
5266
diff
changeset
|
39 (modify-syntax-entry ?\n "> " awk-mode-syntax-table) |
af96725f9e00
(awk-mode-syntax-table): Was mistakenly changing
Richard M. Stallman <rms@gnu.org>
parents:
5266
diff
changeset
|
40 (modify-syntax-entry ?\f "> " awk-mode-syntax-table) |
af96725f9e00
(awk-mode-syntax-table): Was mistakenly changing
Richard M. Stallman <rms@gnu.org>
parents:
5266
diff
changeset
|
41 (modify-syntax-entry ?\# "< " awk-mode-syntax-table) |
257 | 42 (modify-syntax-entry ?/ "." awk-mode-syntax-table) |
43 (modify-syntax-entry ?* "." awk-mode-syntax-table) | |
44 (modify-syntax-entry ?+ "." awk-mode-syntax-table) | |
45 (modify-syntax-entry ?- "." awk-mode-syntax-table) | |
46 (modify-syntax-entry ?= "." awk-mode-syntax-table) | |
47 (modify-syntax-entry ?% "." awk-mode-syntax-table) | |
48 (modify-syntax-entry ?< "." awk-mode-syntax-table) | |
49 (modify-syntax-entry ?> "." awk-mode-syntax-table) | |
50 (modify-syntax-entry ?& "." awk-mode-syntax-table) | |
51 (modify-syntax-entry ?| "." awk-mode-syntax-table) | |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
52 (modify-syntax-entry ?_ "_" awk-mode-syntax-table) |
257 | 53 (modify-syntax-entry ?\' "\"" awk-mode-syntax-table)) |
54 | |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
55 ;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>. |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
56 (defconst awk-font-lock-keywords |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
57 (eval-when-compile |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
58 (list |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
59 ;; |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
60 ;; Function names. |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
61 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?" |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
62 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t)) |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
63 ;; |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
64 ;; Variable names. |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
65 (cons (regexp-opt |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
66 '("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
67 "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
68 "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP") 'words) |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
69 'font-lock-variable-name-face) |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
70 ;; |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
71 ;; Keywords. |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
72 (regexp-opt |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
73 '("BEGIN" "END" "break" "continue" "delete" "exit" "else" "for" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
74 "getline" "if" "next" "print" "printf" "return" "while") 'words) |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
75 ;; |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
76 ;; Builtins. |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
77 (list (regexp-opt |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
78 '("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
79 "length" "log" "match" "rand" "sin" "split" "sprintf" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
80 "sqrt" "srand" "sub" "substr" "system" "time" |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
81 "tolower" "toupper") 'words) |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
82 1 'font-lock-builtin-face) |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
83 ;; |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
84 ;; Operators. Is this too much? |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
85 (cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~")) |
20953
f3f9df46d008
Changed font-lock-reference-face to font-lock-constant-face.
Simon Marshall <simon@gnu.org>
parents:
19322
diff
changeset
|
86 'font-lock-constant-face) |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
87 )) |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
88 "Default expressions to highlight in AWK mode.") |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
89 |
257 | 90 ;;;###autoload |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
91 (define-derived-mode awk-mode c-mode "AWK" |
257 | 92 "Major mode for editing AWK code. |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
93 This is much like C mode except for the syntax of comments. Its keymap |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
94 inherits from C mode's and it has the same variables for customizing |
257 | 95 indentation. It has its own abbrev table and its own syntax table. |
96 | |
33210
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
97 Turning on AWK mode runs `awk-mode-hook'." |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
98 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter)) |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
99 (set (make-local-variable 'paragraph-separate) paragraph-start) |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
100 (set (make-local-variable 'comment-start) "# ") |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
101 (set (make-local-variable 'comment-end) "") |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
102 (set (make-local-variable 'comment-start-skip) "#+ *") |
19d92160ddac
Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
31984
diff
changeset
|
103 (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w"))))) |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
104 |
16451
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
105 (provide 'awk-mode) |
0e181c85b17e
Add Font Lock support. Provide when loaded.
Simon Marshall <simon@gnu.org>
parents:
14169
diff
changeset
|
106 |
662
8a533acedb77
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
257
diff
changeset
|
107 ;;; awk-mode.el ends here |