]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/m4-mode.el
Convert consecutive FSF copyright years to ranges.
[gnu-emacs] / lisp / progmodes / m4-mode.el
index 56a28b437b77ac153e92de0d46d70e68f189c76a..6a8803f1f26c74f5d8ebd2180820efe0e4c1cdbf 100644 (file)
@@ -1,6 +1,7 @@
 ;;; m4-mode.el --- m4 code editing commands for Emacs
 
-;;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1996-1997, 2001-2011
+;; Free Software Foundation, Inc.
 
 ;; Author: Andrew Csillag <drew_csillag@geocities.com>
 ;; Maintainer: Andrew Csillag <drew_csillag@geocities.com>
@@ -8,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -43,6 +42,7 @@
 
 (defgroup m4 nil
   "m4 code editing commands for Emacs."
+  :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
   :prefix "m4-"
   :group 'languages)
 
 (modify-syntax-entry ?\"  "w" m4-mode-syntax-table)
 
 (defvar m4-mode-map
-  (let ((map (make-sparse-keymap)))
+  (let ((map (make-sparse-keymap))
+       (menu-map (make-sparse-keymap)))
     (define-key map "\C-c\C-b" 'm4-m4-buffer)
     (define-key map "\C-c\C-r" 'm4-m4-region)
     (define-key map "\C-c\C-c" 'comment-region)
+    (define-key map [menu-bar m4-mode] (cons "M4" menu-map))
+    (define-key menu-map [m4c]
+      '(menu-item "Comment Region" comment-region
+                 :help "Comment Region"))
+    (define-key menu-map [m4b]
+      '(menu-item "M4 Buffer" m4-m4-buffer
+                 :help "Send contents of the current buffer to m4"))
+    (define-key menu-map [m4r]
+      '(menu-item "M4 Region" m4-m4-region
+                 :help "Send contents of the current region to m4"))
     map))
 
 (defvar m4-mode-abbrev-table nil
 (defun m4-m4-buffer ()
   "Send contents of the current buffer to m4."
   (interactive)
-  (shell-command-on-region (point-min) (point-max) m4-program "*m4-output*"
-                          nil)
+  (shell-command-on-region
+   (point-min) (point-max)
+   (mapconcat 'identity (cons m4-program m4-program-options) "\s")
+   "*m4-output*" nil)
   (switch-to-buffer-other-window "*m4-output*"))
 
 (defun m4-m4-region ()
   "Send contents of the current region to m4."
   (interactive)
-  (shell-command-on-region (point) (mark) m4-program "*m4-output*" nil)
+  (shell-command-on-region
+   (point) (mark)
+   (mapconcat 'identity (cons m4-program m4-program-options) "\s")
+   "*m4-output*" nil)
   (switch-to-buffer-other-window "*m4-output*"))
 
 ;;;###autoload
-(defun m4-mode ()
-  "A major mode to edit m4 macro files.
-\\{m4-mode-map}
-"
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map m4-mode-map)
-
-  (make-local-variable 'comment-start)
-  (setq comment-start "#")
-  (make-local-variable 'parse-sexp-ignore-comments)
-  (setq parse-sexp-ignore-comments t)
-  (setq local-abbrev-table m4-mode-abbrev-table)
-
-  (make-local-variable 'font-lock-defaults)
-  (setq major-mode 'm4-mode
-       mode-name "m4"
-       font-lock-defaults '(m4-font-lock-keywords nil)
-       )
-  (set-syntax-table m4-mode-syntax-table)
-  (run-hooks 'm4-mode-hook))
+(define-derived-mode m4-mode prog-mode "m4"
+  "A major mode to edit m4 macro files."
+  :abbrev-table m4-mode-abbrev-table
+  (set (make-local-variable 'comment-start) "#")
+  (set (make-local-variable 'parse-sexp-ignore-comments) t)
+  (set (make-local-variable 'font-lock-defaults) '(m4-font-lock-keywords nil)))
 
 (provide 'm4-mode)
 ;;stuff to play with for debugging