1*d874e919Schristos;;; autoconf-mode.el --- autoconf code editing commands for Emacs 2*d874e919Schristos 3*d874e919Schristos;; Author: Martin Buchholz (martin@xemacs.org) 4*d874e919Schristos;; Maintainer: Martin Buchholz 5*d874e919Schristos;; Keywords: languages, faces, m4, configure 6*d874e919Schristos 7*d874e919Schristos;; This file is part of Autoconf 8*d874e919Schristos 9*d874e919Schristos;; Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc. 10*d874e919Schristos;; 11*d874e919Schristos;; This program is free software: you can redistribute it and/or modify 12*d874e919Schristos;; it under the terms of the GNU General Public License as published by 13*d874e919Schristos;; the Free Software Foundation, either version 3 of the License, or 14*d874e919Schristos;; (at your option) any later version. 15*d874e919Schristos;; 16*d874e919Schristos;; This program is distributed in the hope that it will be useful, 17*d874e919Schristos;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18*d874e919Schristos;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19*d874e919Schristos;; GNU General Public License for more details. 20*d874e919Schristos;; 21*d874e919Schristos;; You should have received a copy of the GNU General Public License 22*d874e919Schristos;; along with this program. If not, see <http://www.gnu.org/licenses/>. 23*d874e919Schristos 24*d874e919Schristos;; A major mode for editing autoconf input (like configure.in). 25*d874e919Schristos;; Derived from m4-mode.el by Andrew Csillag (drew@staff.prodigy.com) 26*d874e919Schristos 27*d874e919Schristos;;; Your should add the following to your Emacs configuration file: 28*d874e919Schristos 29*d874e919Schristos;; (autoload 'autoconf-mode "autoconf-mode" 30*d874e919Schristos;; "Major mode for editing autoconf files." t) 31*d874e919Schristos;; (setq auto-mode-alist 32*d874e919Schristos;; (cons '("\\.ac\\'\\|configure\\.in\\'" . autoconf-mode) 33*d874e919Schristos;; auto-mode-alist)) 34*d874e919Schristos 35*d874e919Schristos;;; Code: 36*d874e919Schristos 37*d874e919Schristos;;thank god for make-regexp.el! 38*d874e919Schristos(defvar autoconf-font-lock-keywords 39*d874e919Schristos `(("\\bdnl \\(.*\\)" 1 font-lock-comment-face t) 40*d874e919Schristos ("\\$[0-9*#@]" . font-lock-variable-name-face) 41*d874e919Schristos ("\\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*d874e919Schristos ("^\\(\\(m4_\\)?define\\(_default\\)?\\|A._DEFUN\\|m4_defun\\(_once\\|_init\\)?\\)(\\[?\\([A-Za-z0-9_]+\\)" 5 font-lock-function-name-face) 43*d874e919Schristos "default font-lock-keywords") 44*d874e919Schristos) 45*d874e919Schristos 46*d874e919Schristos(defvar autoconf-mode-syntax-table nil 47*d874e919Schristos "syntax table used in autoconf mode") 48*d874e919Schristos(setq autoconf-mode-syntax-table (make-syntax-table)) 49*d874e919Schristos(modify-syntax-entry ?\" "\"" autoconf-mode-syntax-table) 50*d874e919Schristos;;(modify-syntax-entry ?\' "\"" autoconf-mode-syntax-table) 51*d874e919Schristos(modify-syntax-entry ?# "<\n" autoconf-mode-syntax-table) 52*d874e919Schristos(modify-syntax-entry ?\n ">#" autoconf-mode-syntax-table) 53*d874e919Schristos(modify-syntax-entry ?\( "()" autoconf-mode-syntax-table) 54*d874e919Schristos(modify-syntax-entry ?\) ")(" autoconf-mode-syntax-table) 55*d874e919Schristos(modify-syntax-entry ?\[ "(]" autoconf-mode-syntax-table) 56*d874e919Schristos(modify-syntax-entry ?\] ")[" autoconf-mode-syntax-table) 57*d874e919Schristos(modify-syntax-entry ?* "." autoconf-mode-syntax-table) 58*d874e919Schristos(modify-syntax-entry ?_ "_" autoconf-mode-syntax-table) 59*d874e919Schristos 60*d874e919Schristos(defvar autoconf-mode-map 61*d874e919Schristos (let ((map (make-sparse-keymap))) 62*d874e919Schristos (define-key map '[(control c) (\;)] 'comment-region) 63*d874e919Schristos map)) 64*d874e919Schristos 65*d874e919Schristos(defun autoconf-current-defun () 66*d874e919Schristos "Autoconf value for `add-log-current-defun-function'. 67*d874e919SchristosThis tells add-log.el how to find the current macro." 68*d874e919Schristos (save-excursion 69*d874e919Schristos (if (re-search-backward "^\\(m4_define\\(_default\\)?\\|m4_defun\\(_once\\|_init\\)?\\|A._DEFUN\\)(\\[*\\([A-Za-z0-9_]+\\)" nil t) 70*d874e919Schristos (buffer-substring (match-beginning 4) 71*d874e919Schristos (match-end 4)) 72*d874e919Schristos nil))) 73*d874e919Schristos 74*d874e919Schristos;;;###autoload 75*d874e919Schristos(defun autoconf-mode () 76*d874e919Schristos "A major-mode to edit Autoconf files like configure.ac. 77*d874e919Schristos\\{autoconf-mode-map} 78*d874e919Schristos" 79*d874e919Schristos (interactive) 80*d874e919Schristos (kill-all-local-variables) 81*d874e919Schristos (use-local-map autoconf-mode-map) 82*d874e919Schristos 83*d874e919Schristos (make-local-variable 'add-log-current-defun-function) 84*d874e919Schristos (setq add-log-current-defun-function 'autoconf-current-defun) 85*d874e919Schristos 86*d874e919Schristos (make-local-variable 'comment-start) 87*d874e919Schristos (setq comment-start "# ") 88*d874e919Schristos (make-local-variable 'parse-sexp-ignore-comments) 89*d874e919Schristos (setq parse-sexp-ignore-comments t) 90*d874e919Schristos 91*d874e919Schristos (make-local-variable 'font-lock-defaults) 92*d874e919Schristos (setq major-mode 'autoconf-mode) 93*d874e919Schristos (setq mode-name "Autoconf") 94*d874e919Schristos (setq font-lock-defaults `(autoconf-font-lock-keywords nil)) 95*d874e919Schristos (set-syntax-table autoconf-mode-syntax-table) 96*d874e919Schristos (run-hooks 'autoconf-mode-hook)) 97*d874e919Schristos 98*d874e919Schristos(provide 'autoconf-mode) 99*d874e919Schristos 100*d874e919Schristos;;; autoconf-mode.el ends here 101