(edebug-form-spec prop): use dolist.
[emacs.git] / lisp / progmodes / awk-mode.el
blob8079d74301ef5e72b7687b81256a7aa48344ad54
1 ;;; awk-mode.el --- AWK code editing commands for Emacs
3 ;; Copyright (C) 1988,94,96,2000 Free Software Foundation, Inc.
5 ;; Maintainer: FSF
6 ;; Keywords: unix, languages
8 ;; This file is part of GNU Emacs.
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
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
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.
25 ;;; Commentary:
27 ;; Sets up C-mode with support for awk-style #-comments and a lightly
28 ;; hacked syntax table.
30 ;;; Code:
32 (defvar awk-mode-syntax-table nil
33 "Syntax table in use in Awk-mode buffers.")
35 (if awk-mode-syntax-table
37 (setq awk-mode-syntax-table (make-syntax-table))
38 (modify-syntax-entry ?\\ "\\" awk-mode-syntax-table)
39 (modify-syntax-entry ?\n "> " awk-mode-syntax-table)
40 (modify-syntax-entry ?\f "> " awk-mode-syntax-table)
41 (modify-syntax-entry ?\# "< " awk-mode-syntax-table)
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)
52 (modify-syntax-entry ?_ "_" awk-mode-syntax-table)
53 (modify-syntax-entry ?\' "\"" awk-mode-syntax-table))
55 ;; Regexps written with help from Peter Galbraith <galbraith@mixing.qc.dfo.ca>.
56 (defconst awk-font-lock-keywords
57 (eval-when-compile
58 (list
60 ;; Function names.
61 '("^[ \t]*\\(function\\)\\>[ \t]*\\(\\sw+\\)?"
62 (1 font-lock-keyword-face) (2 font-lock-function-name-face nil t))
64 ;; Variable names.
65 (cons (regexp-opt
66 '("ARGC" "ARGIND" "ARGV" "CONVFMT" "ENVIRON" "ERRNO"
67 "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" "NF" "NR"
68 "OFMT" "OFS" "ORS" "RLENGTH" "RS" "RSTART" "SUBSEP") 'words)
69 'font-lock-variable-name-face)
71 ;; Keywords.
72 (regexp-opt
73 '("BEGIN" "END" "break" "continue" "delete" "exit" "else" "for"
74 "getline" "if" "next" "print" "printf" "return" "while") 'words)
76 ;; Builtins.
77 (list (regexp-opt
78 '("atan2" "close" "cos" "ctime" "exp" "gsub" "index" "int"
79 "length" "log" "match" "rand" "sin" "split" "sprintf"
80 "sqrt" "srand" "sub" "substr" "system" "time"
81 "tolower" "toupper") 'words)
82 1 'font-lock-builtin-face)
84 ;; Operators. Is this too much?
85 (cons (regexp-opt '("&&" "||" "<=" "<" ">=" ">" "==" "!=" "!~" "~"))
86 'font-lock-constant-face)
88 "Default expressions to highlight in AWK mode.")
90 ;;;###autoload
91 (define-derived-mode awk-mode c-mode "AWK"
92 "Major mode for editing AWK code.
93 This is much like C mode except for the syntax of comments. Its keymap
94 inherits from C mode's and it has the same variables for customizing
95 indentation. It has its own abbrev table and its own syntax table.
97 Turning on AWK mode runs `awk-mode-hook'."
98 (set (make-local-variable 'paragraph-start) (concat "$\\|" page-delimiter))
99 (set (make-local-variable 'paragraph-separate) paragraph-start)
100 (set (make-local-variable 'comment-start) "# ")
101 (set (make-local-variable 'comment-end) "")
102 (set (make-local-variable 'comment-start-skip) "#+ *")
103 (setq font-lock-defaults '(awk-font-lock-keywords nil nil ((?_ . "w")))))
105 (provide 'awk-mode)
107 ;;; awk-mode.el ends here