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