Commit | Line | Data |
---|---|---|
c0274f38 ER |
1 | ;;; awk-mode.el --- AWK code editing commands for Emacs |
2 | ||
8f1204db | 3 | ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc. |
9750e079 | 4 | |
fd7fa35a | 5 | ;; Maintainer: FSF |
e9571d2a | 6 | ;; Keywords: unix, languages |
fd7fa35a | 7 | |
745bc783 JB |
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 | |
fd7fa35a | 12 | ;; the Free Software Foundation; either version 2, or (at your option) |
745bc783 JB |
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 | |
b578f267 EN |
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. | |
745bc783 | 24 | |
e41b2db1 ER |
25 | ;;; Commentary: |
26 | ||
27 | ;; Sets up C-mode with support for awk-style #-comments and a lightly | |
28 | ;; hacked syntax table. | |
29 | ||
fd7fa35a | 30 | ;;; Code: |
745bc783 JB |
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) | |
6c045717 RS |
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) | |
745bc783 JB |
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 | ||
54 | (defvar awk-mode-abbrev-table nil | |
55 | "Abbrev table in use in Awk-mode buffers.") | |
56 | (define-abbrev-table 'awk-mode-abbrev-table ()) | |
57 | ||
58 | ;;;###autoload | |
59 | (defun awk-mode () | |
60 | "Major mode for editing AWK code. | |
61 | This is much like C mode except for the syntax of comments. It uses | |
62 | the same keymap as C mode and has the same variables for customizing | |
63 | indentation. It has its own abbrev table and its own syntax table. | |
64 | ||
65 | Turning on AWK mode calls the value of the variable `awk-mode-hook' | |
66 | with no args, if that value is non-nil." | |
67 | (interactive) | |
68 | (kill-all-local-variables) | |
80c1bbc6 | 69 | (require 'cc-mode) |
745bc783 JB |
70 | (use-local-map c-mode-map) |
71 | (setq major-mode 'awk-mode) | |
72 | (setq mode-name "AWK") | |
73 | (setq local-abbrev-table awk-mode-abbrev-table) | |
74 | (set-syntax-table awk-mode-syntax-table) | |
75 | (make-local-variable 'paragraph-start) | |
8e32e928 | 76 | (setq paragraph-start (concat "$\\|" page-delimiter)) |
745bc783 JB |
77 | (make-local-variable 'paragraph-separate) |
78 | (setq paragraph-separate paragraph-start) | |
79 | (make-local-variable 'paragraph-ignore-fill-prefix) | |
80 | (setq paragraph-ignore-fill-prefix t) | |
81 | (make-local-variable 'indent-line-function) | |
3591cb55 | 82 | (setq indent-line-function 'c-indent-line) |
745bc783 JB |
83 | (make-local-variable 'require-final-newline) |
84 | (setq require-final-newline t) | |
85 | (make-local-variable 'comment-start) | |
86 | (setq comment-start "# ") | |
87 | (make-local-variable 'comment-end) | |
88 | (setq comment-end "") | |
89 | (make-local-variable 'comment-column) | |
90 | (setq comment-column 32) | |
91 | (make-local-variable 'comment-start-skip) | |
92 | (setq comment-start-skip "#+ *") | |
e41b2db1 ER |
93 | (make-local-variable 'comment-indent-function) |
94 | (setq comment-indent-function 'c-comment-indent) | |
745bc783 | 95 | (run-hooks 'awk-mode-hook)) |
c0274f38 ER |
96 | |
97 | ;;; awk-mode.el ends here |