Mercurial > emacs
annotate lisp/progmodes/prolog.el @ 64802:4f150b99e062
(ansi-color-make-extent, ansi-color-set-extent-face):
Use fboundp, not functionp.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Tue, 09 Aug 2005 02:55:25 +0000 |
parents | 629afbe74e61 |
children | a372b82c546e edf295560b5a |
rev | line source |
---|---|
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
1 ;;; prolog.el --- major mode for editing and running Prolog under Emacs |
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
2 |
64699
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1986, 1987, 2001, 2002, 2003, 2004, 2005 |
629afbe74e61
Update copyright for release of 22.1 for progmodes directory.
Nick Roberts <nickrob@snap.net.nz>
parents:
64085
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
845 | 5 |
17977 | 6 ;; Author: Masanobu UMEDA <umerin@mse.kyutech.ac.jp> |
814
38b2499cb3e9
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
807
diff
changeset
|
7 ;; Keywords: languages |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
8 |
41 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
41 | 14 ;; any later version. |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
14169 | 22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
41 | 25 |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
26 ;;; Commentary: |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
27 |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
28 ;; This package provides a major mode for editing Prolog. It knows |
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
29 ;; about Prolog syntax and comments, and can send regions to an inferior |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
30 ;; Prolog interpreter process. Font locking is tuned towards GNU Prolog. |
2308
f287613dfc28
Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
2307
diff
changeset
|
31 |
807
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
32 ;;; Code: |
4f28bd14272c
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
659
diff
changeset
|
33 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
34 (defgroup prolog nil |
64048
6182d0adade2
(prolog): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
62461
diff
changeset
|
35 "Major mode for editing and running Prolog under Emacs." |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
36 :group 'languages) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
37 |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
38 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
39 (defcustom prolog-program-name |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
40 (let ((names '("prolog" "gprolog"))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
41 (while (and names |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
42 (not (executable-find (car names)))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
43 (setq names (cdr names))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
44 (or (car names) "prolog")) |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
45 "*Program name for invoking an inferior Prolog with `run-prolog'." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
46 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
47 :group 'prolog) |
41 | 48 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
49 (defcustom prolog-consult-string "reconsult(user).\n" |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 "*(Re)Consult mode (for C-Prolog and Quintus Prolog). " |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
51 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 :group 'prolog) |
41 | 53 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
54 (defcustom prolog-compile-string "compile(user).\n" |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 "*Compile mode (for Quintus Prolog)." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
56 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 :group 'prolog) |
41 | 58 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 (defcustom prolog-eof-string "end_of_file.\n" |
64072
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
60 "*String that represents end of file for Prolog. |
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
61 When nil, send actual operating system end of file." |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
63 :group 'prolog) |
41 | 64 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
65 (defcustom prolog-indent-width 4 |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 "Level of indentation in Prolog buffers." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
67 :type 'integer |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 :group 'prolog) |
41 | 69 |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
70 (defvar prolog-font-lock-keywords |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
71 '(("\\(#[<=]=>\\|:-\\)\\|\\(#=\\)\\|\\(#[#<>\\/][=\\/]*\\|!\\)" |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
72 0 font-lock-keyword-face) |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
73 ("\\<\\(is\\|write\\|nl\\|read_\\sw+\\)\\>" |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
74 1 font-lock-keyword-face) |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
75 ("^\\(\\sw+\\)\\s-*\\((\\(.+\\))\\)*" |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
76 (1 font-lock-function-name-face) |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
77 (3 font-lock-variable-name-face))) |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
78 "Font-lock keywords for Prolog mode.") |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
79 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
80 (defvar prolog-mode-syntax-table |
41 | 81 (let ((table (make-syntax-table))) |
82 (modify-syntax-entry ?_ "w" table) | |
83 (modify-syntax-entry ?\\ "\\" table) | |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
84 (modify-syntax-entry ?/ ". 14" table) |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
85 (modify-syntax-entry ?* ". 23" table) |
41 | 86 (modify-syntax-entry ?+ "." table) |
87 (modify-syntax-entry ?- "." table) | |
88 (modify-syntax-entry ?= "." table) | |
89 (modify-syntax-entry ?% "<" table) | |
8217
a09642334f69
(prolog-mode-syntax-table): Make newline end comments.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
90 (modify-syntax-entry ?\n ">" table) |
41 | 91 (modify-syntax-entry ?< "." table) |
92 (modify-syntax-entry ?> "." table) | |
93 (modify-syntax-entry ?\' "\"" table) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
94 table)) |
41 | 95 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
96 (defvar prolog-mode-abbrev-table nil) |
41 | 97 (define-abbrev-table 'prolog-mode-abbrev-table ()) |
98 | |
99 (defun prolog-mode-variables () | |
100 (make-local-variable 'paragraph-separate) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
101 (setq paragraph-separate (concat "%%\\|$\\|" page-delimiter)) ;'%%..' |
41 | 102 (make-local-variable 'paragraph-ignore-fill-prefix) |
103 (setq paragraph-ignore-fill-prefix t) | |
20396 | 104 (make-local-variable 'imenu-generic-expression) |
58713
75d6f143fced
(prolog-mode-variables): Fix imenu-generic-expression.
Juri Linkov <juri@jurta.org>
parents:
53891
diff
changeset
|
105 (setq imenu-generic-expression '((nil "^\\sw+" 0))) |
41 | 106 (make-local-variable 'indent-line-function) |
107 (setq indent-line-function 'prolog-indent-line) | |
108 (make-local-variable 'comment-start) | |
109 (setq comment-start "%") | |
110 (make-local-variable 'comment-start-skip) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
111 (setq comment-start-skip "\\(?:%+\\|/\\*+\\)[ \t]*") |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
112 (make-local-variable 'comment-end-skip) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
113 (setq comment-end-skip "[ \t]*\\(\n\\|\\*+/\\)") |
41 | 114 (make-local-variable 'comment-column) |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
115 (setq comment-column 48)) |
41 | 116 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
117 (defvar prolog-mode-map |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
118 (let ((map (make-sparse-keymap))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
119 (define-key map "\e\C-x" 'prolog-consult-region) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
120 map)) |
41 | 121 |
258 | 122 ;;;###autoload |
41 | 123 (defun prolog-mode () |
124 "Major mode for editing Prolog code for Prologs. | |
125 Blank lines and `%%...' separate paragraphs. `%'s start comments. | |
126 Commands: | |
127 \\{prolog-mode-map} | |
242 | 128 Entry to this mode calls the value of `prolog-mode-hook' |
41 | 129 if that value is non-nil." |
130 (interactive) | |
131 (kill-all-local-variables) | |
132 (use-local-map prolog-mode-map) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
133 (set-syntax-table prolog-mode-syntax-table) |
41 | 134 (setq major-mode 'prolog-mode) |
135 (setq mode-name "Prolog") | |
136 (prolog-mode-variables) | |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
137 ;; font lock |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
138 (setq font-lock-defaults '(prolog-font-lock-keywords |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
139 nil nil nil |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
140 beginning-of-line)) |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
141 (run-mode-hooks 'prolog-mode-hook)) |
41 | 142 |
143 (defun prolog-indent-line (&optional whole-exp) | |
144 "Indent current line as Prolog code. | |
145 With argument, indent any additional lines of the same clause | |
146 rigidly along with this one (not yet)." | |
147 (interactive "p") | |
148 (let ((indent (prolog-indent-level)) | |
149 (pos (- (point-max) (point))) beg) | |
150 (beginning-of-line) | |
151 (setq beg (point)) | |
152 (skip-chars-forward " \t") | |
153 (if (zerop (- indent (current-column))) | |
154 nil | |
155 (delete-region beg (point)) | |
156 (indent-to indent)) | |
157 (if (> (- (point-max) pos) (point)) | |
158 (goto-char (- (point-max) pos))) | |
159 )) | |
160 | |
161 (defun prolog-indent-level () | |
64072
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
162 "Compute Prolog indentation level." |
41 | 163 (save-excursion |
164 (beginning-of-line) | |
165 (skip-chars-forward " \t") | |
166 (cond | |
167 ((looking-at "%%%") 0) ;Large comment starts | |
168 ((looking-at "%[^%]") comment-column) ;Small comment starts | |
169 ((bobp) 0) ;Beginning of buffer | |
170 (t | |
171 (let ((empty t) ind more less) | |
172 (if (looking-at ")") | |
173 (setq less t) ;Find close | |
174 (setq less nil)) | |
175 ;; See previous indentation | |
176 (while empty | |
177 (forward-line -1) | |
178 (beginning-of-line) | |
179 (if (bobp) | |
180 (setq empty nil) | |
181 (skip-chars-forward " \t") | |
182 (if (not (or (looking-at "%[^%]") (looking-at "\n"))) | |
183 (setq empty nil)))) | |
184 (if (bobp) | |
185 (setq ind 0) ;Beginning of buffer | |
186 (setq ind (current-column))) ;Beginning of clause | |
187 ;; See its beginning | |
188 (if (looking-at "%%[^%]") | |
189 ind | |
190 ;; Real prolog code | |
191 (if (looking-at "(") | |
192 (setq more t) ;Find open | |
193 (setq more nil)) | |
194 ;; See its tail | |
195 (end-of-prolog-clause) | |
196 (or (bobp) (forward-char -1)) | |
197 (cond ((looking-at "[,(;>]") | |
198 (if (and more (looking-at "[^,]")) | |
199 (+ ind prolog-indent-width) ;More indentation | |
200 (max tab-width ind))) ;Same indentation | |
201 ((looking-at "-") tab-width) ;TAB | |
202 ((or less (looking-at "[^.]")) | |
203 (max (- ind prolog-indent-width) 0)) ;Less indentation | |
204 (t 0)) ;No indentation | |
205 ))) | |
206 ))) | |
207 | |
208 (defun end-of-prolog-clause () | |
209 "Go to end of clause in this line." | |
210 (beginning-of-line 1) | |
211 (let* ((eolpos (save-excursion (end-of-line) (point)))) | |
212 (if (re-search-forward comment-start-skip eolpos 'move) | |
213 (goto-char (match-beginning 0))) | |
214 (skip-chars-backward " \t"))) | |
215 | |
216 ;;; | |
217 ;;; Inferior prolog mode | |
218 ;;; | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
219 (defvar inferior-prolog-mode-map |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
220 (let ((map (make-sparse-keymap))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
221 ;; This map will inherit from `comint-mode-map' when entering |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
222 ;; inferior-prolog-mode. |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
223 map)) |
41 | 224 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
225 (defvar inferior-prolog-mode-syntax-table prolog-mode-syntax-table) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
226 (defvar inferior-prolog-mode-abbrev-table prolog-mode-abbrev-table) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
227 |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
228 (define-derived-mode inferior-prolog-mode comint-mode "Inferior Prolog" |
41 | 229 "Major mode for interacting with an inferior Prolog process. |
230 | |
231 The following commands are available: | |
232 \\{inferior-prolog-mode-map} | |
233 | |
242 | 234 Entry to this mode calls the value of `prolog-mode-hook' with no arguments, |
235 if that value is non-nil. Likewise with the value of `comint-mode-hook'. | |
236 `prolog-mode-hook' is called after `comint-mode-hook'. | |
41 | 237 |
62461
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
238 You can send text to the inferior Prolog from other buffers using the commands |
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
239 `process-send-region', `process-send-string' and \\[prolog-consult-region]. |
41 | 240 |
241 Commands: | |
242 Tab indents for Prolog; with argument, shifts rest | |
243 of expression rigidly with the current line. | |
242 | 244 Paragraphs are separated only by blank lines and '%%'. |
245 '%'s start comments. | |
41 | 246 |
247 Return at end of buffer sends line as input. | |
248 Return not at end copies rest of line to end and sends it. | |
249 \\[comint-kill-input] and \\[backward-kill-word] are kill commands, imitating normal Unix input editing. | |
250 \\[comint-interrupt-subjob] interrupts the shell or its current subjob if any. | |
251 \\[comint-stop-subjob] stops. \\[comint-quit-subjob] sends quit signal." | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
252 (setq comint-prompt-regexp "^| [ ?][- ] *") |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
253 (prolog-mode-variables)) |
41 | 254 |
258 | 255 ;;;###autoload |
41 | 256 (defun run-prolog () |
257 "Run an inferior Prolog process, input and output via buffer *prolog*." | |
258 (interactive) | |
259 (require 'comint) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
260 (pop-to-buffer (make-comint "prolog" prolog-program-name)) |
41 | 261 (inferior-prolog-mode)) |
262 | |
263 (defun prolog-consult-region (compile beg end) | |
242 | 264 "Send the region to the Prolog process made by \"M-x run-prolog\". |
265 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode." | |
41 | 266 (interactive "P\nr") |
267 (save-excursion | |
268 (if compile | |
62461
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
269 (process-send-string "prolog" prolog-compile-string) |
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
270 (process-send-string "prolog" prolog-consult-string)) |
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
271 (process-send-region "prolog" beg end) |
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
272 (process-send-string "prolog" "\n") ;May be unnecessary |
41 | 273 (if prolog-eof-string |
62461
3321bf6b1f4d
Replace `send-string' by `process-send-string'; replace `send-region' by `process-send-region'.
Juanma Barranquero <lekktu@gmail.com>
parents:
58713
diff
changeset
|
274 (process-send-string "prolog" prolog-eof-string) |
41 | 275 (process-send-eof "prolog")))) ;Send eof to prolog process. |
276 | |
277 (defun prolog-consult-region-and-go (compile beg end) | |
278 "Send the region to the inferior Prolog, and switch to *prolog* buffer. | |
242 | 279 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode." |
41 | 280 (interactive "P\nr") |
281 (prolog-consult-region compile beg end) | |
282 (switch-to-buffer "*prolog*")) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
283 |
18383 | 284 (provide 'prolog) |
285 | |
52401 | 286 ;;; arch-tag: f3ec6748-1272-4ab6-8826-c50cb1607636 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
287 ;;; prolog.el ends here |