• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/share/emacs/site-lisp/
1;;; autoconf-mode.el --- autoconf code editing commands for Emacs
2
3;; Author: Martin Buchholz (martin@xemacs.org)
4;; Maintainer: Martin Buchholz
5;; Keywords: languages, faces, m4, configure
6
7;; This file is part of Autoconf
8
9;; Copyright (C) 2001, 2006, 2009 Free Software Foundation, Inc.
10;;
11;; This program 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 of the License, or
14;; (at your option) any later version.
15;;
16;; This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
23
24;; A major mode for editing autoconf input (like configure.in).
25;; Derived from m4-mode.el by Andrew Csillag (drew@staff.prodigy.com)
26
27;;; Your should add the following to your Emacs configuration file:
28
29;;  (autoload 'autoconf-mode "autoconf-mode"
30;;            "Major mode for editing autoconf files." t)
31;;  (setq auto-mode-alist
32;;        (cons '("\\.ac\\'\\|configure\\.in\\'" . autoconf-mode)
33;;              auto-mode-alist))
34
35;;; Code:
36
37;;thank god for make-regexp.el!
38(defvar autoconf-font-lock-keywords
39  `(("\\bdnl \\(.*\\)"  1 font-lock-comment-face t)
40    ("\\$[0-9*#@]" . font-lock-variable-name-face)
41    ("\\b\\(m4_\\)?\\(builtin\\|change\\(com\\|quote\\|word\\)\\|d\\(e\\(bug\\(file\\|mode\\)\\|cr\\|f\\(ine\\|n\\)\\)\\|iv\\(ert\\|num\\)\\|nl\\|umpdef\\)\\|e\\(rrprint\\|syscmd\\|val\\)\\|f\\(ile\\|ormat\\)\\|gnu\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(exit\\|wrap\\)\\|aketemp\\|kstemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|un\\(d\\(efine\\|ivert\\)\\|ix\\)\\)\\b" . font-lock-keyword-face)
42    ("^\\(\\(m4_\\)?define\\(_default\\)?\\|A._DEFUN\\|m4_defun\\(_once\\|_init\\)?\\)(\\[?\\([A-Za-z0-9_]+\\)" 5 font-lock-function-name-face)
43    "default font-lock-keywords")
44)
45
46(defvar autoconf-mode-syntax-table nil
47  "syntax table used in autoconf mode")
48(setq autoconf-mode-syntax-table (make-syntax-table))
49(modify-syntax-entry ?\" "\""  autoconf-mode-syntax-table)
50;;(modify-syntax-entry ?\' "\""  autoconf-mode-syntax-table)
51(modify-syntax-entry ?#  "<\n" autoconf-mode-syntax-table)
52(modify-syntax-entry ?\n ">#"  autoconf-mode-syntax-table)
53(modify-syntax-entry ?\( "()"   autoconf-mode-syntax-table)
54(modify-syntax-entry ?\) ")("   autoconf-mode-syntax-table)
55(modify-syntax-entry ?\[ "(]"  autoconf-mode-syntax-table)
56(modify-syntax-entry ?\] ")["  autoconf-mode-syntax-table)
57(modify-syntax-entry ?*  "."   autoconf-mode-syntax-table)
58(modify-syntax-entry ?_  "_"   autoconf-mode-syntax-table)
59
60(defvar autoconf-mode-map
61  (let ((map (make-sparse-keymap)))
62    (define-key map '[(control c) (\;)] 'comment-region)
63    map))
64
65(defun autoconf-current-defun ()
66  "Autoconf value for `add-log-current-defun-function'.
67This tells add-log.el how to find the current macro."
68  (save-excursion
69    (if (re-search-backward "^\\(m4_define\\(_default\\)?\\|m4_defun\\(_once\\|_init\\)?\\|A._DEFUN\\)(\\[*\\([A-Za-z0-9_]+\\)" nil t)
70	(buffer-substring (match-beginning 4)
71			  (match-end 4))
72      nil)))
73
74;;;###autoload
75(defun autoconf-mode ()
76  "A major-mode to edit Autoconf files like configure.ac.
77\\{autoconf-mode-map}
78"
79  (interactive)
80  (kill-all-local-variables)
81  (use-local-map autoconf-mode-map)
82
83  (make-local-variable 'add-log-current-defun-function)
84  (setq add-log-current-defun-function 'autoconf-current-defun)
85
86  (make-local-variable 'comment-start)
87  (setq comment-start "# ")
88  (make-local-variable 'parse-sexp-ignore-comments)
89  (setq parse-sexp-ignore-comments t)
90
91  (make-local-variable	'font-lock-defaults)
92  (setq major-mode 'autoconf-mode)
93  (setq mode-name "Autoconf")
94  (setq font-lock-defaults `(autoconf-font-lock-keywords nil))
95  (set-syntax-table autoconf-mode-syntax-table)
96  (run-hooks 'autoconf-mode-hook))
97
98(provide 'autoconf-mode)
99
100;;; autoconf-mode.el ends here
101