aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-05-20 18:37:35 +0000
committerRichard M. Stallman1997-05-20 18:37:35 +0000
commit9108fd3aefcc66024d829333a352f5f425f46bff (patch)
tree0c7d24de74ed30ace12f43dcd98b6a52330ad9d1
parentdf36c26254a671d2adc2ad2b02c115d7f2b0b226 (diff)
downloademacs-9108fd3aefcc66024d829333a352f5f425f46bff.tar.gz
emacs-9108fd3aefcc66024d829333a352f5f425f46bff.zip
(m4-program): Guess which m4 binary to use.
(m4-start-m4): New function. (m4-end-m4): New function. (m4-m4-buffer, m4-m4-region): Now use m4-start-m4. (m4-font-lock-keywords): Collaps 4 regex's into 1.
-rw-r--r--lisp/progmodes/m4-mode.el57
1 files changed, 40 insertions, 17 deletions
diff --git a/lisp/progmodes/m4-mode.el b/lisp/progmodes/m4-mode.el
index a9177ea91e0..a76c5add026 100644
--- a/lisp/progmodes/m4-mode.el
+++ b/lisp/progmodes/m4-mode.el
@@ -1,6 +1,6 @@
1;;; m4-mode.el --- m4 code editing commands for Emacs 1;;; m4-mode.el --- m4 code editing commands for Emacs
2 2
3;;; Copyright (C) 1996 Free Software Foundation, Inc. 3;;; Copyright (C) 1996, 1997 Free Software Foundation, Inc.
4 4
5;; Author: Andrew Csillag <drew@staff.prodigy.com> 5;; Author: Andrew Csillag <drew@staff.prodigy.com>
6;; Maintainer: Andrew Csillag <drew@staff.prodigy.com> 6;; Maintainer: Andrew Csillag <drew@staff.prodigy.com>
@@ -43,27 +43,39 @@
43;; (setq auto-mode-alist 43;; (setq auto-mode-alist
44;; (cons '(".*\\.m4$" . m4-mode) 44;; (cons '(".*\\.m4$" . m4-mode)
45;; auto-mode-alist)) 45;; auto-mode-alist))
46
47;;; Thanks: 46;;; Thanks:
48;;; to Akim Demaille and Terry Jones for the bug reports 47;;; to Akim Demaille and Terry Jones for the bug reports
48;;; to Simon Marshall for the regexp tip
49;;; to Martin Buchholz for some general fixes
49 50
50;;; Code: 51;;; Code:
51 52
52;;path to the m4 program 53(defvar m4-program
53(defvar m4-program "/usr/local/bin/m4") 54 (cond
55 ((file-exists-p "/usr/local/bin/m4") "/usr/local/bin/m4")
56 ((file-exists-p "/usr/bin/m4") "/usr/bin/m4")
57 ((file-exists-p "/bin/m4") "/bin/m4")
58 ((file-exists-p "/usr/ccs/bin/m4") "/usr/ccs/bin/m4")
59 )
60 "File name of the m4 executable.")
61
62;;options to m4
63(defconst m4-program-options nil)
64;;to use --prefix-builtins, you can use
65;;(defconst m4-program-options '("-P"))
66;;or
67;;(defconst m4-program-options '("--prefix-builtins"))
54 68
55;;thank god for make-regexp.el!
56(defvar m4-font-lock-keywords 69(defvar m4-font-lock-keywords
57 `( 70 `(
58 ("^\\\#.*" . font-lock-comment-face) 71 ("\\(\\b\\(m4_\\)?dnl\\b\\|^\\#\\).*$" . font-lock-comment-face)
59 ("\\\$\\\*" . font-lock-variable-name-face) 72; ("\\(\\bdnl\\b\\|\\bm4_dnl\\b\\|^\\#\\).*$" . font-lock-comment-face)
60 ("\\\$[0-9]" . font-lock-variable-name-face) 73 ("\\$[*#@0-9]" . font-lock-variable-name-face)
61 ("\\\$\\\#" . font-lock-variable-name-face)
62 ("\\\$\\\@" . font-lock-variable-name-face) 74 ("\\\$\\\@" . font-lock-variable-name-face)
63 ("\\\$\\\*" . font-lock-variable-name-face) 75 ("\\\$\\\*" . font-lock-variable-name-face)
64 ("\\b\\(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\\)\\|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) 76 ("\\b\\(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\\)\\|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)
65 ("\\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\\)\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(_undefine\\|exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|undivert\\)\\)\\b" . font-lock-keyword-face) 77 ("\\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\\)\\|i\\(f\\(def\\|else\\)\\|n\\(c\\(lude\\|r\\)\\|d\\(ex\\|ir\\)\\)\\)\\|l\\(en\\|ine\\)\\|m\\(4\\(_undefine\\|exit\\|wrap\\)\\|aketemp\\)\\|p\\(atsubst\\|opdef\\|ushdef\\)\\|regexp\\|s\\(hift\\|include\\|ubstr\\|ys\\(cmd\\|val\\)\\)\\|tra\\(ceo\\(ff\\|n\\)\\|nslit\\)\\|undivert\\)\\)\\b" . font-lock-keyword-face)
66 "default font-lock-keywords") 78 "Default font-lock-keywords for m4 mode.")
67) 79)
68 80
69;;this may still need some work 81;;this may still need some work
@@ -79,6 +91,7 @@
79(modify-syntax-entry ?* "w" m4-mode-syntax-table) 91(modify-syntax-entry ?* "w" m4-mode-syntax-table)
80(modify-syntax-entry ?_ "w" m4-mode-syntax-table) 92(modify-syntax-entry ?_ "w" m4-mode-syntax-table)
81(modify-syntax-entry ?\" "w" m4-mode-syntax-table) 93(modify-syntax-entry ?\" "w" m4-mode-syntax-table)
94(modify-syntax-entry ?\" "w" m4-mode-syntax-table)
82 95
83(defvar m4-mode-map 96(defvar m4-mode-map
84 (let ((map (make-sparse-keymap))) 97 (let ((map (make-sparse-keymap)))
@@ -87,23 +100,33 @@
87 (define-key map "\C-c\C-c" 'comment-region) 100 (define-key map "\C-c\C-c" 'comment-region)
88 map)) 101 map))
89 102
103(defun m4-end-m4 (process event)
104 (cond ((equal event "kill\n") (princ "m4 process done"))
105 (t (princ
106 (format "Process: %s had the event `%s'" process event)))))
107
108(defun m4-start-m4 ()
109 (eval (append (append '(start-process "m4process" "*m4 output*" m4-program)
110 m4-program-options) '("-e")))
111 (set-process-sentinel (get-process "m4process") 'm4-end-m4))
112
90(defun m4-m4-buffer () 113(defun m4-m4-buffer ()
91 "send contents of the current buffer to m4" 114 "send contents of the current buffer to m4"
92 (interactive) 115 (interactive)
93 (start-process "m4process" "*m4 output*" m4-program "-e") 116 (m4-start-m4)
94 (process-send-region "m4process" (point-min) (point-max)) 117 (process-send-region "m4process" (point-min) (point-max))
95 (process-send-eof "m4process") 118 (process-send-eof "m4process")
96 (switch-to-buffer "*m4 output*") 119 (switch-to-buffer-other-window "*m4 output*")
97) 120 (delete-process "m4process"))
121
98 122
99(defun m4-m4-region () 123(defun m4-m4-region ()
100 "send contents of the current region to m4" 124 "send contents of the current region to m4"
101 (interactive) 125 (interactive)
102 (start-process "m4process" "*m4 output*" m4-program "-e") 126 (m4-start-m4)
103 (process-send-region "m4process" (point) (mark)) 127 (process-send-region "m4process" (point) (mark))
104 (process-send-eof "m4process") 128 (process-send-eof "m4process")
105 (switch-to-buffer "*m4 output*") 129 (switch-to-buffer-other-window "*m4 output*"))
106)
107 130
108(defun m4-mode () 131(defun m4-mode ()
109 "A major-mode to edit m4 macro files 132 "A major-mode to edit m4 macro files
@@ -122,7 +145,7 @@
122 (make-local-variable 'font-lock-defaults) 145 (make-local-variable 'font-lock-defaults)
123 (setq major-mode 'm4-mode 146 (setq major-mode 'm4-mode
124 mode-name "m4" 147 mode-name "m4"
125 font-lock-defaults `(m4-font-lock-keywords nil) 148 font-lock-defaults '(m4-font-lock-keywords nil)
126 ) 149 )
127 (set-syntax-table m4-mode-syntax-table) 150 (set-syntax-table m4-mode-syntax-table)
128 (run-hooks 'm4-mode-hook)) 151 (run-hooks 'm4-mode-hook))