Fix doc strings in ispell.el/.
[emacs.git] / lisp / progmodes / autoconf.el
bloba7242f6c23235f8211951781ae5de8ffe498663c
1 ;;; autoconf.el --- mode for editing Autoconf configure.in files
3 ;; Copyright (C) 2000-2012 Free Software Foundation, Inc.
5 ;; Author: Dave Love <fx@gnu.org>
6 ;; Keywords: 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 3 of the License, or
13 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; Provides fairly minimal font-lock, imenu and indentation support
26 ;; for editing configure.in files. Only Autoconf syntax is processed.
27 ;; There is no attempt to deal with shell text -- probably that will
28 ;; always lose.
30 ;; This is specialized for configure.in files. It doesn't inherit the
31 ;; general M4 stuff from M4 mode.
33 ;; There is also an autoconf-mode.el in existence. That appears to be
34 ;; for editing the Autoconf M4 source, rather than configure.in files.
36 ;;; Code:
38 (defvar font-lock-syntactic-keywords)
40 (defvar autoconf-mode-map (make-sparse-keymap))
42 (defvar autoconf-mode-hook nil
43 "Hook run by `autoconf-mode'.")
45 (defconst autoconf-definition-regexp
46 "AC_\\(SUBST\\|DEFINE\\(_UNQUOTED\\)?\\)(\\[*\\(\\sw+\\)\\]*")
48 (defvar autoconf-font-lock-keywords
49 `(("\\_<A[CHMS]_\\sw+" . font-lock-keyword-face)
50 (,autoconf-definition-regexp
51 3 font-lock-function-name-face)
52 ;; Are any other M4 keywords really appropriate for configure.in,
53 ;; given that we do `dnl'?
54 ("changequote" . font-lock-keyword-face)))
56 (defvar autoconf-mode-syntax-table
57 (let ((table (make-syntax-table)))
58 (modify-syntax-entry ?\" "." table)
59 (modify-syntax-entry ?\n ">" table)
60 (modify-syntax-entry ?# "<" table)
61 table))
63 (defvar autoconf-imenu-generic-expression
64 (list (list nil autoconf-definition-regexp 3)))
66 ;; It's not clear how best to implement this.
67 (defun autoconf-current-defun-function ()
68 "Function to use for `add-log-current-defun-function' in Autoconf mode.
69 This version looks back for an AC_DEFINE or AC_SUBST. It will stop
70 searching backwards at another AC_... command."
71 (save-excursion
72 (with-syntax-table (copy-syntax-table autoconf-mode-syntax-table)
73 (modify-syntax-entry ?_ "w")
74 (if (re-search-backward autoconf-definition-regexp
75 (save-excursion (beginning-of-defun) (point))
77 (match-string-no-properties 3)))))
79 ;;;###autoload
80 (define-derived-mode autoconf-mode prog-mode "Autoconf"
81 "Major mode for editing Autoconf configure.in files."
82 (set (make-local-variable 'parens-require-spaces) nil) ; for M4 arg lists
83 (set (make-local-variable 'defun-prompt-regexp)
84 "^[ \t]*A[CM]_\\(\\sw\\|\\s_\\)+")
85 (set (make-local-variable 'comment-start) "dnl ")
86 (set (make-local-variable 'comment-start-skip)
87 "\\(?:\\(\\W\\|\\`\\)dnl\\|#\\) +")
88 (set (make-local-variable 'syntax-propertize-function)
89 (syntax-propertize-rules ("\\<dnl\\>" (0 "<"))))
90 (set (make-local-variable 'font-lock-defaults)
91 `(autoconf-font-lock-keywords nil nil (("_" . "w"))))
92 (set (make-local-variable 'imenu-generic-expression)
93 autoconf-imenu-generic-expression)
94 (set (make-local-variable 'imenu-syntax-alist) '(("_" . "w")))
95 (set (make-local-variable 'indent-line-function) #'indent-relative)
96 (set (make-local-variable 'add-log-current-defun-function)
97 #'autoconf-current-defun-function))
99 (provide 'autoconf-mode)
100 (provide 'autoconf)
102 ;;; autoconf.el ends here