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