annotate lisp/progmodes/prolog.el @ 111686:e8049570c647

* lisp/eshell/: Use with-silent-modifications. * lisp/eshell/esh-cmd.el (eshell-parse-command): * lisp/eshell/esh-arg.el (eshell-parse-arguments): * lisp/eshell/em-script.el (eshell-source-file): Use with-silent-modifications.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 23 Nov 2010 12:36:15 -0500
parents b72ff43b041f
children b47e85affa59
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
101002
3b3c7e10cd97 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
3 ;; Copyright (C) 1986, 1987, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 104542
diff changeset
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
845
213978acbc1e entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
5
17977
727cf56647a4 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17414
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
10
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
14 ;; (at your option) any later version.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
15
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
19 ;; GNU General Public License for more details.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
20
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 87649
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
23
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
24 ;;; Commentary:
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
25
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
26 ;; 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
27 ;; 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
28 ;; 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
29
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
30 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
31
65238
a372b82c546e (comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents: 64699
diff changeset
32 (defvar comint-prompt-regexp)
85510
e2eac01cf548 * progmodes/prolog.el: Undo previous change.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85451
diff changeset
33 (defvar comint-process-echoes)
109839
f2b0181ddf31 * lisp/progmodes/prolog.el (smie): Require.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108643
diff changeset
34 (require 'smie)
65238
a372b82c546e (comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents: 64699
diff changeset
35
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
36 (defgroup prolog nil
64048
6182d0adade2 (prolog): Finish `defgroup' description with period.
Juanma Barranquero <lekktu@gmail.com>
parents: 62461
diff changeset
37 "Major mode for editing and running Prolog under Emacs."
66963
a11fdee52c05 Add :link (custom-group-link font-lock-faces) to defgroup.
Juri Linkov <juri@jurta.org>
parents: 65238
diff changeset
38 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
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
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
43 (let ((names '("prolog" "gprolog" "swipl")))
53891
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"))
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
48 "Program name for invoking an inferior Prolog with `run-prolog'."
17414
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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"
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
53 "(Re)Consult mode (for C-Prolog and Quintus Prolog). "
17414
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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"
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
58 "Compile mode (for Quintus Prolog)."
17414
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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"
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
63 "String that represents end of file for Prolog.
64072
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
84 (let ((table (make-syntax-table)))
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
85 (modify-syntax-entry ?_ "w" table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
89 (modify-syntax-entry ?+ "." table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
90 (modify-syntax-entry ?- "." table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
91 (modify-syntax-entry ?= "." table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
94 (modify-syntax-entry ?< "." table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
95 (modify-syntax-entry ?> "." table)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
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
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
100 (define-abbrev-table 'prolog-mode-abbrev-table ())
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
101
110446
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
102 (defun prolog-smie-forward-token ()
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
103 (forward-comment (point-max))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
104 (buffer-substring-no-properties
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
105 (point)
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
106 (progn (cond
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
107 ((looking-at "[!;]") (forward-char 1))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
108 ((not (zerop (skip-chars-forward "#&*+-./:<=>?@\\^`~"))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
109 ((not (zerop (skip-syntax-forward "w_'"))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
110 ;; In case of non-ASCII punctuation.
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
111 ((not (zerop (skip-syntax-forward ".")))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
112 (point))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
113
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
114 (defun prolog-smie-backward-token ()
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
115 (forward-comment (- (point-max)))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
116 (buffer-substring-no-properties
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
117 (point)
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
118 (progn (cond
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
119 ((memq (char-before) '(?! ?\;)) (forward-char -1))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
120 ((not (zerop (skip-chars-backward "#&*+-./:<=>?@\\^`~"))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
121 ((not (zerop (skip-syntax-backward "w_'"))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
122 ;; In case of non-ASCII punctuation.
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
123 ((not (zerop (skip-syntax-backward ".")))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
124 (point))))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
125
111440
b72ff43b041f * lisp/emacs-lisp/smie.el: Simplify the smie-rules-function return values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
126 (defconst prolog-smie-grammar
108632
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
127 ;; Rather than construct the operator levels table from the BNF,
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
128 ;; we directly provide the operator precedences from GNU Prolog's
110446
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
129 ;; manual (7.14.10 op/3). The only problem is that GNU Prolog's
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
130 ;; manual uses precedence levels in the opposite sense (higher
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
131 ;; numbers bind less tightly) than SMIE, so we use negative numbers.
108632
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
132 '(("." -10000 -10000)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
133 (":-" -1200 -1200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
134 ("-->" -1200 -1200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
135 (";" -1100 -1100)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
136 ("->" -1050 -1050)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
137 ("," -1000 -1000)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
138 ("\\+" -900 -900)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
139 ("=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
140 ("\\=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
141 ("=.." -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
142 ("==" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
143 ("\\==" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
144 ("@<" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
145 ("@=<" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
146 ("@>" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
147 ("@>=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
148 ("is" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
149 ("=:=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
150 ("=\\=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
151 ("<" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
152 ("=<" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
153 (">" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
154 (">=" -700 -700)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
155 (":" -600 -600)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
156 ("+" -500 -500)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
157 ("-" -500 -500)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
158 ("/\\" -500 -500)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
159 ("\\/" -500 -500)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
160 ("*" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
161 ("/" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
162 ("//" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
163 ("rem" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
164 ("mod" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
165 ("<<" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
166 (">>" -400 -400)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
167 ("**" -200 -200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
168 ("^" -200 -200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
169 ;; Prefix
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
170 ;; ("+" 200 200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
171 ;; ("-" 200 200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
172 ;; ("\\" 200 200)
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
173 )
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
174 "Precedence levels of infix operators.")
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
175
111232
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
176 (defun prolog-smie-rules (kind token)
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
177 (pcase (cons kind token)
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
178 (`(:elem . basic) prolog-indent-width)
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
179 (`(:after . ".") 0) ;; To work around smie-closer-alist.
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
180 (`(:after . ,(or `":-" `"->")) prolog-indent-width)))
108632
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
181
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
182 (defun prolog-mode-variables ()
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
183 (make-local-variable 'paragraph-separate)
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
184 (setq paragraph-separate (concat "%%\\|$\\|" page-delimiter)) ;'%%..'
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
185 (make-local-variable 'paragraph-ignore-fill-prefix)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
186 (setq paragraph-ignore-fill-prefix t)
20396
ba46225fd687 (prolog-mode-variables):
Karl Heuer <kwzh@gnu.org>
parents: 18383
diff changeset
187 (make-local-variable 'imenu-generic-expression)
58713
75d6f143fced (prolog-mode-variables): Fix imenu-generic-expression.
Juri Linkov <juri@jurta.org>
parents: 53891
diff changeset
188 (setq imenu-generic-expression '((nil "^\\sw+" 0)))
111232
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
189
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
190 ;; Setup SMIE.
111440
b72ff43b041f * lisp/emacs-lisp/smie.el: Simplify the smie-rules-function return values.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111429
diff changeset
191 (smie-setup prolog-smie-grammar #'prolog-smie-rules
111232
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
192 :forward-token #'prolog-smie-forward-token
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
193 :backward-token #'prolog-smie-backward-token)
110446
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
194 (set (make-local-variable 'smie-blink-matching-triggers) '(?.))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
195 (set (make-local-variable 'smie-closer-alist) '((t . ".")))
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
196 (add-hook 'post-self-insert-hook #'smie-blink-matching-open 'append 'local)
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
197 ;; There's no real closer in Prolog anyway.
f81447dd641c * lisp/progmodes/prolog.el (prolog-smie-forward-token)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 109839
diff changeset
198 (set (make-local-variable 'smie-blink-matching-inners) t)
111232
a9904c1962db SMIE: change indent rules format, improve smie-setup.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110446
diff changeset
199
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
200 (make-local-variable 'comment-start)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
201 (setq comment-start "%")
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
202 (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
203 (setq comment-start-skip "\\(?:%+\\|/\\*+\\)[ \t]*")
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
204 (make-local-variable 'comment-end-skip)
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
205 (setq comment-end-skip "[ \t]*\\(\n\\|\\*+/\\)")
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
206 (make-local-variable 'comment-column)
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
207 (setq comment-column 48))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
208
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
209 (defvar prolog-mode-map
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
210 (let ((map (make-sparse-keymap)))
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
211 (define-key map "\e\C-x" 'prolog-consult-region)
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
212 (define-key map "\C-c\C-l" 'inferior-prolog-load-file)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
213 (define-key map "\C-c\C-z" 'switch-to-prolog)
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
214 map))
108643
d9c9cf61db24 * progmodes/prolog.el (smie-indent-basic): Declare for byte-compiler.
Juanma Barranquero <lekktu@gmail.com>
parents: 108632
diff changeset
215
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
216 (easy-menu-define prolog-mode-menu prolog-mode-map "Menu for Prolog mode."
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
217 ;; Mostly copied from scheme-mode's menu.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
218 ;; Not tremendously useful, but it's a start.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
219 '("Prolog"
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
220 ["Indent line" indent-according-to-mode t]
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
221 ["Indent region" indent-region t]
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
222 ["Comment region" comment-region t]
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
223 ["Uncomment region" uncomment-region t]
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
224 "--"
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
225 ["Run interactive Prolog session" run-prolog t]
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
226 ))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
227
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 242
diff changeset
228 ;;;###autoload
108588
7c03bbe03019 * progmodes/prolog.el (prolog-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
229 (define-derived-mode prolog-mode prog-mode "Prolog"
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
230 "Major mode for editing Prolog code for Prologs.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
231 Blank lines and `%%...' separate paragraphs. `%'s start comments.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
232 Commands:
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
233 \\{prolog-mode-map}
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
234 Entry to this mode calls the value of `prolog-mode-hook'
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
235 if that value is non-nil."
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
236 (prolog-mode-variables)
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
237 (set (make-local-variable 'comment-add) 1)
45608
706ae7fb4033 (prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 20396
diff changeset
238 (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
239 nil nil nil
108588
7c03bbe03019 * progmodes/prolog.el (prolog-mode): Use define-derived-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 106815
diff changeset
240 beginning-of-line)))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
241
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
242 (defun end-of-prolog-clause ()
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
243 "Go to end of clause in this line."
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
244 (beginning-of-line 1)
111429
249a1455856a Use line-end-position rather than end-of-line, etc.
Glenn Morris <rgm@gnu.org>
parents: 111232
diff changeset
245 (let* ((eolpos (line-end-position)))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
246 (if (re-search-forward comment-start-skip eolpos 'move)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
247 (goto-char (match-beginning 0)))
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
248 (skip-chars-backward " \t")))
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
249
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
250 ;;;
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
251 ;;; Inferior prolog mode
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
252 ;;;
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
253 (defvar inferior-prolog-mode-map
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
254 (let ((map (make-sparse-keymap)))
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
255 ;; 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
256 ;; inferior-prolog-mode.
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
257 (define-key map [remap self-insert-command]
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
258 'inferior-prolog-self-insert-command)
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
259 map))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
260
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
261 (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
262 (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
263
104363
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
264 (defvar inferior-prolog-error-regexp-alist
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
265 ;; GNU Prolog used to not follow the GNU standard format.
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
266 '(("^\\(.*?\\):\\([0-9]+\\) error: .*(char:\\([0-9]+\\)" 1 2 3)
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
267 gnu))
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
268
87122
f6591f36eb87 Remove directory part from filenames in function declarations.
Glenn Morris <rgm@gnu.org>
parents: 86243
diff changeset
269 (declare-function comint-mode "comint")
f6591f36eb87 Remove directory part from filenames in function declarations.
Glenn Morris <rgm@gnu.org>
parents: 86243
diff changeset
270 (declare-function comint-send-string "comint" (process string))
f6591f36eb87 Remove directory part from filenames in function declarations.
Glenn Morris <rgm@gnu.org>
parents: 86243
diff changeset
271 (declare-function comint-send-region "comint" (process start end))
f6591f36eb87 Remove directory part from filenames in function declarations.
Glenn Morris <rgm@gnu.org>
parents: 86243
diff changeset
272 (declare-function comint-send-eof "comint" ())
104542
5986db97372e (compilation-error-regexp-alist, compilation-forget-errors): Declare.
Glenn Morris <rgm@gnu.org>
parents: 104363
diff changeset
273 (defvar compilation-error-regexp-alist)
86243
4d615a83cee2 * progmodes/idlw-help.el: Require browse-url unconditionally, it
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85510
diff changeset
274
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
275 (define-derived-mode inferior-prolog-mode comint-mode "Inferior Prolog"
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
276 "Major mode for interacting with an inferior Prolog process.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
277
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
278 The following commands are available:
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
279 \\{inferior-prolog-mode-map}
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
280
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
281 Entry to this mode calls the value of `prolog-mode-hook' with no arguments,
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
282 if that value is non-nil. Likewise with the value of `comint-mode-hook'.
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
283 `prolog-mode-hook' is called after `comint-mode-hook'.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
284
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
285 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
286 `process-send-region', `process-send-string' and \\[prolog-consult-region].
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
287
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
288 Commands:
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
289 Tab indents for Prolog; with argument, shifts rest
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
290 of expression rigidly with the current line.
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
291 Paragraphs are separated only by blank lines and '%%'.
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
292 '%'s start comments.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
293
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
294 Return at end of buffer sends line as input.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
295 Return not at end copies rest of line to end and sends it.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
296 \\[comint-kill-input] and \\[backward-kill-word] are kill commands, imitating normal Unix input editing.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
297 \\[comint-interrupt-subjob] interrupts the shell or its current subjob if any.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
298 \\[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
299 (setq comint-prompt-regexp "^| [ ?][- ] *")
104363
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
300 (set (make-local-variable 'compilation-error-regexp-alist)
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
301 inferior-prolog-error-regexp-alist)
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
302 (compilation-shell-minor-mode)
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
303 (prolog-mode-variables))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
304
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
305 (defvar inferior-prolog-buffer nil)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
306
85451
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
307 (defvar inferior-prolog-flavor 'unknown
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
308 "Either a symbol or a buffer position offset by one.
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
309 If a buffer position, the flavor has not been determined yet and
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
310 it is expected that the process's output has been or will
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
311 be inserted at that position plus one.")
e1af3a725ca4 * textmodes/two-column.el (2C-split, 2C-merge):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78234
diff changeset
312
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
313 (defun inferior-prolog-run (&optional name)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
314 (with-current-buffer (make-comint "prolog" (or name prolog-program-name))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
315 (inferior-prolog-mode)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
316 (setq-default inferior-prolog-buffer (current-buffer))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
317 (make-local-variable 'inferior-prolog-buffer)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
318 (when (and name (not (equal name prolog-program-name)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
319 (set (make-local-variable 'prolog-program-name) name))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
320 (set (make-local-variable 'inferior-prolog-flavor)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
321 ;; Force re-detection.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
322 (let* ((proc (get-buffer-process (current-buffer)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
323 (pmark (and proc (marker-position (process-mark proc)))))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
324 (cond
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
325 ((null pmark) (1- (point-min)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
326 ;; The use of insert-before-markers in comint.el together with
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
327 ;; the potential use of comint-truncate-buffer in the output
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
328 ;; filter, means that it's difficult to reliably keep track of
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
329 ;; the buffer position where the process's output started.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
330 ;; If possible we use a marker at "start - 1", so that
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
331 ;; insert-before-marker at `start' won't shift it. And if not,
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
332 ;; we fall back on using a plain integer.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
333 ((> pmark (point-min)) (copy-marker (1- pmark)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
334 (t (1- pmark)))))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
335 (add-hook 'comint-output-filter-functions
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
336 'inferior-prolog-guess-flavor nil t)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
337
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
338 (defun inferior-prolog-process (&optional dontstart)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
339 (or (and (buffer-live-p inferior-prolog-buffer)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
340 (get-buffer-process inferior-prolog-buffer))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
341 (unless dontstart
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
342 (inferior-prolog-run)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
343 ;; Try again.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
344 (inferior-prolog-process))))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
345
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
346 (defun inferior-prolog-guess-flavor (&optional ignored)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
347 (save-excursion
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
348 (goto-char (1+ inferior-prolog-flavor))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
349 (setq inferior-prolog-flavor
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
350 (cond
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
351 ((looking-at "GNU Prolog") 'gnu)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
352 ((looking-at "Welcome to SWI-Prolog") 'swi)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
353 ((looking-at ".*\n") 'unknown) ;There's at least one line.
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
354 (t inferior-prolog-flavor))))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
355 (when (symbolp inferior-prolog-flavor)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
356 (remove-hook 'comint-output-filter-functions
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
357 'inferior-prolog-guess-flavor t)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
358 (if (eq inferior-prolog-flavor 'gnu)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
359 (set (make-local-variable 'comint-process-echoes) t))))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
360
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 242
diff changeset
361 ;;;###autoload
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
362 (defalias 'run-prolog 'switch-to-prolog)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
363 ;;;###autoload
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
364 (defun switch-to-prolog (&optional name)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
365 "Run an inferior Prolog process, input and output via buffer *prolog*.
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
366 With prefix argument \\[universal-prefix], prompt for the program to use."
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
367 (interactive
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
368 (list (when current-prefix-arg
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
369 (let ((proc (inferior-prolog-process 'dontstart)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
370 (if proc
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
371 (if (yes-or-no-p "Kill current process before starting new one? ")
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
372 (kill-process proc)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
373 (error "Abort")))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
374 (read-string "Run Prolog: " prolog-program-name)))))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
375 (unless (inferior-prolog-process 'dontstart)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
376 (inferior-prolog-run name))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
377 (pop-to-buffer inferior-prolog-buffer))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
378
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
379 (defun inferior-prolog-self-insert-command ()
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
380 "Insert the char in the buffer or pass it directly to the process."
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
381 (interactive)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
382 (let* ((proc (get-buffer-process (current-buffer)))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
383 (pmark (and proc (marker-position (process-mark proc)))))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
384 (if (and (eq inferior-prolog-flavor 'gnu)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
385 pmark
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
386 (null current-prefix-arg)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
387 (eobp)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
388 (eq (point) pmark)
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
389 (save-excursion
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
390 (goto-char (- pmark 3))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
391 (looking-at " \\? ")))
104363
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
392 ;; This is GNU prolog waiting to know whether you want more answers
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
393 ;; or not (or abort, etc...). The answer is a single char, not
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
394 ;; a line, so pass this char directly rather than wait for RET to
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
395 ;; send a whole line.
101002
3b3c7e10cd97 Replace last-command-char with last-command-event.
Glenn Morris <rgm@gnu.org>
parents: 100908
diff changeset
396 (comint-send-string proc (string last-command-event))
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
397 (call-interactively 'self-insert-command))))
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
398
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
399 (defun prolog-consult-region (compile beg end)
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
400 "Send the region to the Prolog process made by \"M-x run-prolog\".
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
401 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode."
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
402 (interactive "P\nr")
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
403 (let ((proc (inferior-prolog-process)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
404 (comint-send-string proc
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
405 (if compile prolog-compile-string
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
406 prolog-consult-string))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
407 (comint-send-region proc beg end)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
408 (comint-send-string proc "\n") ;May be unnecessary
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
409 (if prolog-eof-string
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
410 (comint-send-string proc prolog-eof-string)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
411 (with-current-buffer (process-buffer proc)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
412 (comint-send-eof))))) ;Send eof to prolog process.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
413
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
414 (defun prolog-consult-region-and-go (compile beg end)
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
415 "Send the region to the inferior Prolog, and switch to *prolog* buffer.
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
416 If COMPILE (prefix arg) is not nil, use compile mode rather than consult mode."
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
417 (interactive "P\nr")
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
418 (prolog-consult-region compile beg end)
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
419 (pop-to-buffer inferior-prolog-buffer))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
420
104542
5986db97372e (compilation-error-regexp-alist, compilation-forget-errors): Declare.
Glenn Morris <rgm@gnu.org>
parents: 104363
diff changeset
421 ;; inferior-prolog-mode uses the autoloaded compilation-shell-minor-mode.
5986db97372e (compilation-error-regexp-alist, compilation-forget-errors): Declare.
Glenn Morris <rgm@gnu.org>
parents: 104363
diff changeset
422 (declare-function compilation-forget-errors "compile" ())
5986db97372e (compilation-error-regexp-alist, compilation-forget-errors): Declare.
Glenn Morris <rgm@gnu.org>
parents: 104363
diff changeset
423
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
424 (defun inferior-prolog-load-file ()
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
425 "Pass the current buffer's file to the inferior prolog process."
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
426 (interactive)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
427 (save-buffer)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
428 (let ((file buffer-file-name)
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
429 (proc (inferior-prolog-process)))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
430 (with-current-buffer (process-buffer proc)
104363
790054ad67dd (inferior-prolog-error-regexp-alist): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 101002
diff changeset
431 (compilation-forget-errors)
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
432 (comint-send-string proc (concat "['" (file-relative-name file) "'].\n"))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
433 (pop-to-buffer (current-buffer)))))
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
434
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
435 (provide 'prolog)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
436
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
437 ;;; prolog.el ends here