Blame lib/emacs/autoconf-mode.el

Packit Service 9646c7
;;; autoconf-mode.el --- autoconf code editing commands for Emacs
Packit Service 9646c7
Packit Service 9646c7
;; Author: Martin Buchholz (martin@xemacs.org)
Packit Service 9646c7
;; Maintainer: Martin Buchholz
Packit Service 9646c7
;; Keywords: languages, faces, m4, configure
Packit Service 9646c7
Packit Service 9646c7
;; This file is part of Autoconf
Packit Service 9646c7
Packit Service 9646c7
;; Copyright (C) 2001, 2006, 2009-2012 Free Software Foundation, Inc.
Packit Service 9646c7
;;
Packit Service 9646c7
;; This program is free software: you can redistribute it and/or modify
Packit Service 9646c7
;; it under the terms of the GNU General Public License as published by
Packit Service 9646c7
;; the Free Software Foundation, either version 3 of the License, or
Packit Service 9646c7
;; (at your option) any later version.
Packit Service 9646c7
;;
Packit Service 9646c7
;; This program is distributed in the hope that it will be useful,
Packit Service 9646c7
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 9646c7
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 9646c7
;; GNU General Public License for more details.
Packit Service 9646c7
;;
Packit Service 9646c7
;; You should have received a copy of the GNU General Public License
Packit Service 9646c7
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit Service 9646c7
Packit Service 9646c7
;; A major mode for editing autoconf input (like configure.in).
Packit Service 9646c7
;; Derived from m4-mode.el by Andrew Csillag (drew@staff.prodigy.com)
Packit Service 9646c7
Packit Service 9646c7
;;; Your should add the following to your Emacs configuration file:
Packit Service 9646c7
Packit Service 9646c7
;;  (autoload 'autoconf-mode "autoconf-mode"
Packit Service 9646c7
;;            "Major mode for editing autoconf files." t)
Packit Service 9646c7
;;  (setq auto-mode-alist
Packit Service 9646c7
;;        (cons '("\\.ac\\'\\|configure\\.in\\'" . autoconf-mode)
Packit Service 9646c7
;;              auto-mode-alist))
Packit Service 9646c7
Packit Service 9646c7
;;; Code:
Packit Service 9646c7
Packit Service 9646c7
;;thank god for make-regexp.el!
Packit Service 9646c7
(defvar autoconf-font-lock-keywords
Packit Service 9646c7
  `(("\\bdnl \\(.*\\)"  1 font-lock-comment-face t)
Packit Service 9646c7
    ("\\$[0-9*#@]" . font-lock-variable-name-face)
Packit Service 9646c7
    ("\\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)
Packit Service 9646c7
    ("^\\(\\(m4_\\)?define\\(_default\\)?\\|A._DEFUN\\|m4_defun\\(_once\\|_init\\)?\\)(\\[?\\([A-Za-z0-9_]+\\)" 5 font-lock-function-name-face)
Packit Service 9646c7
    "default font-lock-keywords")
Packit Service 9646c7
)
Packit Service 9646c7
Packit Service 9646c7
(defvar autoconf-mode-syntax-table nil
Packit Service 9646c7
  "syntax table used in autoconf mode")
Packit Service 9646c7
(setq autoconf-mode-syntax-table (make-syntax-table))
Packit Service 9646c7
(modify-syntax-entry ?\" "\""  autoconf-mode-syntax-table)
Packit Service 9646c7
;;(modify-syntax-entry ?\' "\""  autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?#  "<\n" autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?\n ">#"  autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?\( "()"   autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?\) ")("   autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?\[ "(]"  autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?\] ")["  autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?*  "."   autoconf-mode-syntax-table)
Packit Service 9646c7
(modify-syntax-entry ?_  "_"   autoconf-mode-syntax-table)
Packit Service 9646c7
Packit Service 9646c7
(defvar autoconf-mode-map
Packit Service 9646c7
  (let ((map (make-sparse-keymap)))
Packit Service 9646c7
    (define-key map '[(control c) (\;)] 'comment-region)
Packit Service 9646c7
    map))
Packit Service 9646c7
Packit Service 9646c7
(defun autoconf-current-defun ()
Packit Service 9646c7
  "Autoconf value for `add-log-current-defun-function'.
Packit Service 9646c7
This tells add-log.el how to find the current macro."
Packit Service 9646c7
  (save-excursion
Packit Service 9646c7
    (if (re-search-backward "^\\(m4_define\\(_default\\)?\\|m4_defun\\(_once\\|_init\\)?\\|A._DEFUN\\)(\\[*\\([A-Za-z0-9_]+\\)" nil t)
Packit Service 9646c7
	(buffer-substring (match-beginning 4)
Packit Service 9646c7
			  (match-end 4))
Packit Service 9646c7
      nil)))
Packit Service 9646c7
Packit Service 9646c7
;;;###autoload
Packit Service 9646c7
(defun autoconf-mode ()
Packit Service 9646c7
  "A major-mode to edit Autoconf files like configure.ac.
Packit Service 9646c7
\\{autoconf-mode-map}
Packit Service 9646c7
"
Packit Service 9646c7
  (interactive)
Packit Service 9646c7
  (kill-all-local-variables)
Packit Service 9646c7
  (use-local-map autoconf-mode-map)
Packit Service 9646c7
Packit Service 9646c7
  (make-local-variable 'add-log-current-defun-function)
Packit Service 9646c7
  (setq add-log-current-defun-function 'autoconf-current-defun)
Packit Service 9646c7
Packit Service 9646c7
  (make-local-variable 'comment-start)
Packit Service 9646c7
  (setq comment-start "# ")
Packit Service 9646c7
  (make-local-variable 'parse-sexp-ignore-comments)
Packit Service 9646c7
  (setq parse-sexp-ignore-comments t)
Packit Service 9646c7
Packit Service 9646c7
  (make-local-variable	'font-lock-defaults)
Packit Service 9646c7
  (setq major-mode 'autoconf-mode)
Packit Service 9646c7
  (setq mode-name "Autoconf")
Packit Service 9646c7
  (setq font-lock-defaults `(autoconf-font-lock-keywords nil))
Packit Service 9646c7
  (set-syntax-table autoconf-mode-syntax-table)
Packit Service 9646c7
  (run-hooks 'autoconf-mode-hook))
Packit Service 9646c7
Packit Service 9646c7
(provide 'autoconf-mode)
Packit Service 9646c7
Packit Service 9646c7
;;; autoconf-mode.el ends here