| 1 | ;;; awk-mode.el --- AWK code editing commands for Emacs |
| 2 | |
| 3 | ;; Copyright (C) 1988 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Maintainer: FSF |
| 6 | ;; Keywords: unix, languages |
| 7 | |
| 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 |
| 12 | ;; the Free Software Foundation; either version 2, or (at your option) |
| 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 |
| 21 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 22 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 23 | |
| 24 | ;;; Commentary: |
| 25 | |
| 26 | ;; Sets up C-mode with support for awk-style #-comments and a lightly |
| 27 | ;; hacked syntax table. |
| 28 | |
| 29 | ;;; Code: |
| 30 | |
| 31 | (defvar awk-mode-syntax-table nil |
| 32 | "Syntax table in use in Awk-mode buffers.") |
| 33 | |
| 34 | (if awk-mode-syntax-table |
| 35 | () |
| 36 | (setq awk-mode-syntax-table (make-syntax-table)) |
| 37 | (modify-syntax-entry ?\\ "\\" awk-mode-syntax-table) |
| 38 | (modify-syntax-entry ?\n "> " awk-mode-syntax-table) |
| 39 | (modify-syntax-entry ?\f "> " awk-mode-syntax-table) |
| 40 | (modify-syntax-entry ?\# "< " 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 | |
| 53 | (defvar awk-mode-abbrev-table nil |
| 54 | "Abbrev table in use in Awk-mode buffers.") |
| 55 | (define-abbrev-table 'awk-mode-abbrev-table ()) |
| 56 | |
| 57 | ;;;###autoload |
| 58 | (defun awk-mode () |
| 59 | "Major mode for editing AWK code. |
| 60 | This is much like C mode except for the syntax of comments. It uses |
| 61 | the same keymap as C mode and has the same variables for customizing |
| 62 | indentation. It has its own abbrev table and its own syntax table. |
| 63 | |
| 64 | Turning on AWK mode calls the value of the variable `awk-mode-hook' |
| 65 | with no args, if that value is non-nil." |
| 66 | (interactive) |
| 67 | (kill-all-local-variables) |
| 68 | (use-local-map c-mode-map) |
| 69 | (setq major-mode 'awk-mode) |
| 70 | (setq mode-name "AWK") |
| 71 | (setq local-abbrev-table awk-mode-abbrev-table) |
| 72 | (set-syntax-table awk-mode-syntax-table) |
| 73 | (make-local-variable 'paragraph-start) |
| 74 | (setq paragraph-start (concat "^$\\|" page-delimiter)) |
| 75 | (make-local-variable 'paragraph-separate) |
| 76 | (setq paragraph-separate paragraph-start) |
| 77 | (make-local-variable 'paragraph-ignore-fill-prefix) |
| 78 | (setq paragraph-ignore-fill-prefix t) |
| 79 | (make-local-variable 'indent-line-function) |
| 80 | (setq indent-line-function 'c-indent-line) |
| 81 | (make-local-variable 'require-final-newline) |
| 82 | (setq require-final-newline t) |
| 83 | (make-local-variable 'comment-start) |
| 84 | (setq comment-start "# ") |
| 85 | (make-local-variable 'comment-end) |
| 86 | (setq comment-end "") |
| 87 | (make-local-variable 'comment-column) |
| 88 | (setq comment-column 32) |
| 89 | (make-local-variable 'comment-start-skip) |
| 90 | (setq comment-start-skip "#+ *") |
| 91 | (make-local-variable 'comment-indent-function) |
| 92 | (setq comment-indent-function 'c-comment-indent) |
| 93 | (run-hooks 'awk-mode-hook)) |
| 94 | |
| 95 | ;;; awk-mode.el ends here |