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