Mercurial > emacs
annotate lisp/progmodes/prolog.el @ 65546:6759056e7603
Document `image-load-path'.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 15 Sep 2005 14:02:34 +0000 |
parents | a372b82c546e |
children | a11fdee52c05 a3716f7538f2 |
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 |
65238
a372b82c546e
(comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64699
diff
changeset
|
34 (defvar comint-prompt-regexp) |
a372b82c546e
(comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64699
diff
changeset
|
35 |
a372b82c546e
(comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64699
diff
changeset
|
36 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
37 (defgroup prolog nil |
64048
6182d0adade2
(prolog): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents:
62461
diff
changeset
|
38 "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
|
39 :group 'languages) |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
40 |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
41 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
42 (defcustom prolog-program-name |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
43 (let ((names '("prolog" "gprolog"))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
44 (while (and names |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
45 (not (executable-find (car names)))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
46 (setq names (cdr names))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
47 (or (car names) "prolog")) |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
48 "*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
|
49 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
50 :group 'prolog) |
41 | 51 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
52 (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
|
53 "*(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
|
54 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
55 :group 'prolog) |
41 | 56 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
57 (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
|
58 "*Compile mode (for Quintus Prolog)." |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
59 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
60 :group 'prolog) |
41 | 61 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
62 (defcustom prolog-eof-string "end_of_file.\n" |
64072
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
63 "*String that represents end of file for Prolog. |
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
64 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
|
65 :type 'string |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
66 :group 'prolog) |
41 | 67 |
17414
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
68 (defcustom prolog-indent-width 4 |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
69 "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
|
70 :type 'integer |
f967f12c8ec8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
14169
diff
changeset
|
71 :group 'prolog) |
41 | 72 |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
73 (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
|
74 '(("\\(#[<=]=>\\|:-\\)\\|\\(#=\\)\\|\\(#[#<>\\/][=\\/]*\\|!\\)" |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
75 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
|
76 ("\\<\\(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
|
77 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
|
78 ("^\\(\\sw+\\)\\s-*\\((\\(.+\\))\\)*" |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
79 (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
|
80 (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
|
81 "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
|
82 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
83 (defvar prolog-mode-syntax-table |
41 | 84 (let ((table (make-syntax-table))) |
85 (modify-syntax-entry ?_ "w" table) | |
86 (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
|
87 (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
|
88 (modify-syntax-entry ?* ". 23" table) |
41 | 89 (modify-syntax-entry ?+ "." table) |
90 (modify-syntax-entry ?- "." table) | |
91 (modify-syntax-entry ?= "." table) | |
92 (modify-syntax-entry ?% "<" table) | |
8217
a09642334f69
(prolog-mode-syntax-table): Make newline end comments.
Richard M. Stallman <rms@gnu.org>
parents:
2308
diff
changeset
|
93 (modify-syntax-entry ?\n ">" table) |
41 | 94 (modify-syntax-entry ?< "." table) |
95 (modify-syntax-entry ?> "." table) | |
96 (modify-syntax-entry ?\' "\"" table) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
97 table)) |
41 | 98 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
99 (defvar prolog-mode-abbrev-table nil) |
41 | 100 (define-abbrev-table 'prolog-mode-abbrev-table ()) |
101 | |
102 (defun prolog-mode-variables () | |
103 (make-local-variable 'paragraph-separate) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
104 (setq paragraph-separate (concat "%%\\|$\\|" page-delimiter)) ;'%%..' |
41 | 105 (make-local-variable 'paragraph-ignore-fill-prefix) |
106 (setq paragraph-ignore-fill-prefix t) | |
20396 | 107 (make-local-variable 'imenu-generic-expression) |
58713
75d6f143fced
(prolog-mode-variables): Fix imenu-generic-expression.
Juri Linkov <juri@jurta.org>
parents:
53891
diff
changeset
|
108 (setq imenu-generic-expression '((nil "^\\sw+" 0))) |
41 | 109 (make-local-variable 'indent-line-function) |
110 (setq indent-line-function 'prolog-indent-line) | |
111 (make-local-variable 'comment-start) | |
112 (setq comment-start "%") | |
113 (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
|
114 (setq comment-start-skip "\\(?:%+\\|/\\*+\\)[ \t]*") |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
115 (make-local-variable 'comment-end-skip) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
116 (setq comment-end-skip "[ \t]*\\(\n\\|\\*+/\\)") |
41 | 117 (make-local-variable 'comment-column) |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
118 (setq comment-column 48)) |
41 | 119 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
120 (defvar prolog-mode-map |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
121 (let ((map (make-sparse-keymap))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
122 (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
|
123 map)) |
41 | 124 |
258 | 125 ;;;###autoload |
41 | 126 (defun prolog-mode () |
127 "Major mode for editing Prolog code for Prologs. | |
128 Blank lines and `%%...' separate paragraphs. `%'s start comments. | |
129 Commands: | |
130 \\{prolog-mode-map} | |
242 | 131 Entry to this mode calls the value of `prolog-mode-hook' |
41 | 132 if that value is non-nil." |
133 (interactive) | |
134 (kill-all-local-variables) | |
135 (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
|
136 (set-syntax-table prolog-mode-syntax-table) |
41 | 137 (setq major-mode 'prolog-mode) |
138 (setq mode-name "Prolog") | |
139 (prolog-mode-variables) | |
45608
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
140 ;; font lock |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
141 (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
|
142 nil nil nil |
706ae7fb4033
(prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
20396
diff
changeset
|
143 beginning-of-line)) |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
144 (run-mode-hooks 'prolog-mode-hook)) |
41 | 145 |
146 (defun prolog-indent-line (&optional whole-exp) | |
147 "Indent current line as Prolog code. | |
148 With argument, indent any additional lines of the same clause | |
149 rigidly along with this one (not yet)." | |
150 (interactive "p") | |
151 (let ((indent (prolog-indent-level)) | |
152 (pos (- (point-max) (point))) beg) | |
153 (beginning-of-line) | |
154 (setq beg (point)) | |
155 (skip-chars-forward " \t") | |
156 (if (zerop (- indent (current-column))) | |
157 nil | |
158 (delete-region beg (point)) | |
159 (indent-to indent)) | |
160 (if (> (- (point-max) pos) (point)) | |
161 (goto-char (- (point-max) pos))) | |
162 )) | |
163 | |
164 (defun prolog-indent-level () | |
64072
db79be1bac82
(prolog-eof-string): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64048
diff
changeset
|
165 "Compute Prolog indentation level." |
41 | 166 (save-excursion |
167 (beginning-of-line) | |
168 (skip-chars-forward " \t") | |
169 (cond | |
170 ((looking-at "%%%") 0) ;Large comment starts | |
171 ((looking-at "%[^%]") comment-column) ;Small comment starts | |
172 ((bobp) 0) ;Beginning of buffer | |
173 (t | |
174 (let ((empty t) ind more less) | |
175 (if (looking-at ")") | |
176 (setq less t) ;Find close | |
177 (setq less nil)) | |
178 ;; See previous indentation | |
179 (while empty | |
180 (forward-line -1) | |
181 (beginning-of-line) | |
182 (if (bobp) | |
183 (setq empty nil) | |
184 (skip-chars-forward " \t") | |
185 (if (not (or (looking-at "%[^%]") (looking-at "\n"))) | |
186 (setq empty nil)))) | |
187 (if (bobp) | |
188 (setq ind 0) ;Beginning of buffer | |
189 (setq ind (current-column))) ;Beginning of clause | |
190 ;; See its beginning | |
191 (if (looking-at "%%[^%]") | |
192 ind | |
193 ;; Real prolog code | |
194 (if (looking-at "(") | |
195 (setq more t) ;Find open | |
196 (setq more nil)) | |
197 ;; See its tail | |
198 (end-of-prolog-clause) | |
199 (or (bobp) (forward-char -1)) | |
200 (cond ((looking-at "[,(;>]") | |
201 (if (and more (looking-at "[^,]")) | |
202 (+ ind prolog-indent-width) ;More indentation | |
203 (max tab-width ind))) ;Same indentation | |
204 ((looking-at "-") tab-width) ;TAB | |
205 ((or less (looking-at "[^.]")) | |
206 (max (- ind prolog-indent-width) 0)) ;Less indentation | |
207 (t 0)) ;No indentation | |
208 ))) | |
209 ))) | |
210 | |
211 (defun end-of-prolog-clause () | |
212 "Go to end of clause in this line." | |
213 (beginning-of-line 1) | |
214 (let* ((eolpos (save-excursion (end-of-line) (point)))) | |
215 (if (re-search-forward comment-start-skip eolpos 'move) | |
216 (goto-char (match-beginning 0))) | |
217 (skip-chars-backward " \t"))) | |
218 | |
219 ;;; | |
220 ;;; Inferior prolog mode | |
221 ;;; | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
222 (defvar inferior-prolog-mode-map |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
223 (let ((map (make-sparse-keymap))) |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
224 ;; 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
|
225 ;; inferior-prolog-mode. |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
226 map)) |
41 | 227 |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
228 (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
|
229 (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
|
230 |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
231 (define-derived-mode inferior-prolog-mode comint-mode "Inferior Prolog" |
41 | 232 "Major mode for interacting with an inferior Prolog process. |
233 | |
234 The following commands are available: | |
235 \\{inferior-prolog-mode-map} | |
236 | |
242 | 237 Entry to this mode calls the value of `prolog-mode-hook' with no arguments, |
238 if that value is non-nil. Likewise with the value of `comint-mode-hook'. | |
239 `prolog-mode-hook' is called after `comint-mode-hook'. | |
41 | 240 |
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
|
241 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
|
242 `process-send-region', `process-send-string' and \\[prolog-consult-region]. |
41 | 243 |
244 Commands: | |
245 Tab indents for Prolog; with argument, shifts rest | |
246 of expression rigidly with the current line. | |
242 | 247 Paragraphs are separated only by blank lines and '%%'. |
248 '%'s start comments. | |
41 | 249 |
250 Return at end of buffer sends line as input. | |
251 Return not at end copies rest of line to end and sends it. | |
252 \\[comint-kill-input] and \\[backward-kill-word] are kill commands, imitating normal Unix input editing. | |
253 \\[comint-interrupt-subjob] interrupts the shell or its current subjob if any. | |
254 \\[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
|
255 (setq comint-prompt-regexp "^| [ ?][- ] *") |
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
256 (prolog-mode-variables)) |
41 | 257 |
258 | 258 ;;;###autoload |
41 | 259 (defun run-prolog () |
260 "Run an inferior Prolog process, input and output via buffer *prolog*." | |
261 (interactive) | |
262 (require 'comint) | |
53891
4b85b1e3d610
(prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
52401
diff
changeset
|
263 (pop-to-buffer (make-comint "prolog" prolog-program-name)) |
41 | 264 (inferior-prolog-mode)) |
265 | |
266 (defun prolog-consult-region (compile beg end) | |
242 | 267 "Send the region to the Prolog process made by \"M-x run-prolog\". |
268 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode." | |
41 | 269 (interactive "P\nr") |
270 (save-excursion | |
271 (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
|
272 (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
|
273 (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
|
274 (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
|
275 (process-send-string "prolog" "\n") ;May be unnecessary |
41 | 276 (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
|
277 (process-send-string "prolog" prolog-eof-string) |
41 | 278 (process-send-eof "prolog")))) ;Send eof to prolog process. |
279 | |
280 (defun prolog-consult-region-and-go (compile beg end) | |
281 "Send the region to the inferior Prolog, and switch to *prolog* buffer. | |
242 | 282 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode." |
41 | 283 (interactive "P\nr") |
284 (prolog-consult-region compile beg end) | |
285 (switch-to-buffer "*prolog*")) | |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
286 |
18383 | 287 (provide 'prolog) |
288 | |
52401 | 289 ;;; arch-tag: f3ec6748-1272-4ab6-8826-c50cb1607636 |
659
505130d1ddf8
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
258
diff
changeset
|
290 ;;; prolog.el ends here |