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 2001, 2006 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 2, or (at your option) 14;; 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, write to the Free Software 23;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 24;; 02110-1301, USA. 25 26;; A major mode for editing autoconf input (like configure.in). 27;; Derived from m4-mode.el by Andrew Csillag (drew@staff.prodigy.com) 28 29;;; Your should add the following to your Emacs configuration file: 30 31;; (autoload 'autoconf-mode "autoconf-mode" 32;; "Major mode for editing autoconf files." t) 33;; (setq auto-mode-alist 34;; (cons '("\\.ac\\'\\|configure\\.in\\'" . autoconf-mode) 35;; auto-mode-alist)) 36 37;;; Code: 38 39;;thank god for make-regexp.el! 40(defvar autoconf-font-lock-keywords 41 `(("\\bdnl \\(.*\\)" 1 font-lock-comment-face t) 42 ("\\$[0-9*#@]" . font-lock-variable-name-face) 43 ("\\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) 44 ("^\\(\\(m4_\\)?define\\|A._DEFUN\\|m4_defun\\)(\\[?\\([A-Za-z0-9_]+\\)" 3 font-lock-function-name-face) 45 "default font-lock-keywords") 46) 47 48(defvar autoconf-mode-syntax-table nil 49 "syntax table used in autoconf mode") 50(setq autoconf-mode-syntax-table (make-syntax-table)) 51(modify-syntax-entry ?\" "\"" autoconf-mode-syntax-table) 52;;(modify-syntax-entry ?\' "\"" autoconf-mode-syntax-table) 53(modify-syntax-entry ?# "<\n" autoconf-mode-syntax-table) 54(modify-syntax-entry ?\n ">#" 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(modify-syntax-entry ?* "." autoconf-mode-syntax-table) 60(modify-syntax-entry ?_ "_" autoconf-mode-syntax-table) 61 62(defvar autoconf-mode-map 63 (let ((map (make-sparse-keymap))) 64 (define-key map '[(control c) (\;)] 'comment-region) 65 map)) 66 67(defun autoconf-current-defun () 68 "Autoconf value for `add-log-current-defun-function'. 69This tells add-log.el how to find the current macro." 70 (save-excursion 71 (if (re-search-backward "^\\(m4_define\\|m4_defun\\|A._DEFUN\\)(\\[*\\([A-Za-z0-9_]+\\)" nil t) 72 (buffer-substring (match-beginning 2) 73 (match-end 2)) 74 nil))) 75 76;;;###autoload 77(defun autoconf-mode () 78 "A major-mode to edit Autoconf files like configure.ac. 79\\{autoconf-mode-map} 80" 81 (interactive) 82 (kill-all-local-variables) 83 (use-local-map autoconf-mode-map) 84 85 (make-local-variable 'add-log-current-defun-function) 86 (setq add-log-current-defun-function 'autoconf-current-defun) 87 88 (make-local-variable 'comment-start) 89 (setq comment-start "# ") 90 (make-local-variable 'parse-sexp-ignore-comments) 91 (setq parse-sexp-ignore-comments t) 92 93 (make-local-variable 'font-lock-defaults) 94 (setq major-mode 'autoconf-mode) 95 (setq mode-name "Autoconf") 96 (setq font-lock-defaults `(autoconf-font-lock-keywords nil)) 97 (set-syntax-table autoconf-mode-syntax-table) 98 (run-hooks 'autoconf-mode-hook)) 99 100(provide 'autoconf-mode) 101 102;;; autoconf-mode.el ends here 103