Fix up comment convention on the arch-tag lines.
[bpt/emacs.git] / lisp / obsolete / awk-mode.el
CommitLineData
c0274f38
ER
1;;; awk-mode.el --- AWK code editing commands for Emacs
2
f2e3589a 3;; Copyright (C) 1988, 1994, 1996, 2000, 2001, 2002, 2003, 2004,
2f043267 4;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
9750e079 5
fd7fa35a 6;; Maintainer: FSF
e9571d2a 7;; Keywords: unix, languages
fd7fa35a 8
745bc783
JB
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
5a9dffec 13;; the Free Software Foundation; either version 3, or (at your option)
745bc783
JB
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
b578f267 22;; along with GNU Emacs; see the file COPYING. If not, write to the
3a35cf56
LK
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
745bc783 25
e41b2db1
ER
26;;; Commentary:
27
28;; Sets up C-mode with support for awk-style #-comments and a lightly
29;; hacked syntax table.
30
fd7fa35a 31;;; Code:
745bc783 32
61b8c98e
SM
33(defvar awk-mode-syntax-table
34 (let ((st (make-syntax-table)))
35 (modify-syntax-entry ?\\ "\\" st)
36 (modify-syntax-entry ?\n "> " st)
37 (modify-syntax-entry ?\f "> " st)
38 (modify-syntax-entry ?\# "< " st)
39 ;; / can delimit regexes or be a division operator. We assume that it is
40 ;; more commonly used for regexes and fix the remaining cases with
41 ;; `font-lock-syntactic-keywords'.
42 (modify-syntax-entry ?/ "\"" st)
43 (modify-syntax-entry ?* "." st)
44 (modify-syntax-entry ?+ "." st)
45 (modify-syntax-entry ?- "." st)
46 (modify-syntax-entry ?= "." st)
47 (modify-syntax-entry ?% "." st)
48 (modify-syntax-entry ?< "." st)
49 (modify-syntax-entry ?> "." st)
50 (modify-syntax-entry ?& "." st)
51 (modify-syntax-entry ?| "." st)
52 (modify-syntax-entry ?_ "_" st)
53 (modify-syntax-entry ?\' "\"" st)
54 st)
55 "Syntax table in use in `awk-mode' buffers.")
745bc783 56
4e59dfb5
SM
57;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>.
58(defconst awk-font-lock-keywords
59 (eval-when-compile
60 (list
61 ;;
62 ;; Function names.
178a6a45 63 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
4e59dfb5
SM
64 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
65 ;;
66 ;; Variable names.
178a6a45
SM
67 (cons (regexp-opt
68 '("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO"
69 "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR"
70 "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP") 'words)
4e59dfb5
SM
71 'font-lock-variable-name-face)
72 ;;
73 ;; Keywords.
178a6a45 74 (regexp-opt
e14c5251 75 '("BEGIN" "END" "break" "continue" "delete" "do" "exit" "else" "for"
178a6a45 76 "getline" "if" "next" "print" "printf" "return" "while") 'words)
4e59dfb5
SM
77 ;;
78 ;; Builtins.
178a6a45
SM
79 (list (regexp-opt
80 '("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int"
81 "length" "log" "match" "rand" "sin" "split" "sprintf"
82 "sqrt" "srand" "sub" "substr" "system" "time"
83 "tolower" "toupper") 'words)
4e59dfb5
SM
84 1 'font-lock-builtin-face)
85 ;;
86 ;; Operators. Is this too much?
178a6a45 87 (cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~"))
883212ce 88 'font-lock-constant-face)
4e59dfb5
SM
89 ))
90 "Default expressions to highlight in AWK mode.")
91
61b8c98e
SM
92(require 'syntax)
93
94(defconst awk-font-lock-syntactic-keywords
95 ;; `/' is mostly used for /.../ regular expressions, but is also
96 ;; used as a division operator. Distinguishing between the two is
97 ;; a pain in the youknowwhat.
98 ;; '(("\\(^\\|[<=>-+*%/!^,~(?:|&]\\)\\s-*\\(/\\)\\([^/\n\\]\\|\\\\.\\)*\\(/\\)"
99 ;; (2 "\"") (4 "\"")))
100 '(("[^<=>-+*%/!^,~(?:|& \t\n\f]\\s-*\\(/\\)"
101 (1 (unless (nth 3 (syntax-ppss (match-beginning 1))) "."))))
102 "Syntactic keywords for `awk-mode'.")
103
75d6bc9b 104;; No longer autoloaded since it might clobber the autoload directive in CC Mode.
178a6a45 105(define-derived-mode awk-mode c-mode "AWK"
745bc783 106 "Major mode for editing AWK code.
178a6a45
SM
107This is much like C mode except for the syntax of comments. Its keymap
108inherits from C mode's and it has the same variables for customizing
745bc783
JB
109indentation. It has its own abbrev table and its own syntax table.
110
178a6a45
SM
111Turning on AWK mode runs `awk-mode-hook'."
112 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
113 (set (make-local-variable 'paragraph-separate) paragraph-start)
114 (set (make-local-variable 'comment-start) "# ")
115 (set (make-local-variable 'comment-end) "")
116 (set (make-local-variable 'comment-start-skip) "#+ *")
61b8c98e
SM
117 (setq font-lock-defaults '(awk-font-lock-keywords
118 nil nil ((?_ . "w")) nil
119 (parse-sexp-lookup-properties . t)
120 (font-lock-syntactic-keywords
121 . awk-font-lock-syntactic-keywords))))
c0274f38 122
4e59dfb5
SM
123(provide 'awk-mode)
124
cbee283d 125;; arch-tag: 14ebc02a-b3c5-4e76-8034-6ca9ac0af0e6
c0274f38 126;;; awk-mode.el ends here