annotate lisp/progmodes/prolog.el @ 112200:c315834fc2f0

* font-lock.el (font-lock-verbose): Default to nil.
author Chong Yidong <cyd@stupidchicken.com>
date Wed, 12 Jan 2011 23:30:23 -0500
parents 0bfc36865094
children 43d75ad47207
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1 ;;; prolog.el --- major mode for editing and running Prolog (and Mercury) code
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3 ;; Copyright (C) 1986, 1987, 1997, 1998, 1999, 2002, 2003, 2011 Free Software Foundation, Inc.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
5 ;; Authors: Emil Åström <emil_astrom(at)hotmail(dot)com>
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
6 ;; Milan Zamazal <pdm(at)freesoft(dot)cz>
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
7 ;; Stefan Bruda <stefan(at)bruda(dot)ca> (current maintainer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
8 ;; * See below for more details
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
9 ;; Keywords: prolog major mode sicstus swi mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
10
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
11 (defvar prolog-mode-version "1.22"
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
12 "Prolog mode version number.")
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
13
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
14 ;; This file is part of GNU Emacs.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
15
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
16 ;; GNU Emacs is free software: you can redistribute it and/or modify
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
17 ;; it under the terms of the GNU General Public License as published by
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
18 ;; the Free Software Foundation, either version 3 of the License, or
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
19 ;; (at your option) any later version.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
20
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
21 ;; GNU Emacs is distributed in the hope that it will be useful,
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
24 ;; GNU General Public License for more details.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
25
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
26 ;; You should have received a copy of the GNU General Public License
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
27 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
28
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
29 ;; Original author: Masanobu UMEDA <umerin(at)mse(dot)kyutech(dot)ac(dot)jp>
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
30 ;; Parts of this file was taken from a modified version of the original
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
31 ;; by Johan Andersson, Peter Olin, Mats Carlsson, Johan Bevemyr, Stefan
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
32 ;; Andersson, and Per Danielsson (all SICS people), and Henrik Båkman
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
33 ;; at Uppsala University, Sweden.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
34 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
35 ;; Some ideas and also a few lines of code have been borrowed (not stolen ;-)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
36 ;; from Oz.el, the Emacs major mode for the Oz programming language,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
37 ;; Copyright (C) 1993 DFKI GmbH, Germany, with permission.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
38 ;; Authors: Ralf Scheidhauer and Michael Mehl ([scheidhr|mehl](at)dfki(dot)uni-sb(dot)de)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
39 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
40 ;; More ideas and code have been taken from the SICStus debugger mode
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
41 ;; (http://www.csd.uu.se/~perm/source_debug/index.shtml -- broken link
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
42 ;; as of Mon May 5 08:23:48 EDT 2003) by Per Mildner.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
43 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
44 ;; Additions for ECLiPSe and other helpful suggestions: Stephan Heuel
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
45 ;; <heuel(at)ipb(dot)uni-bonn(dot)de>
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
46
2308
f287613dfc28 Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
47 ;;; Commentary:
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
48 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
49 ;; This package provides a major mode for editing Prolog code, with
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
50 ;; all the bells and whistles one would expect, including syntax
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
51 ;; highlighting and auto indentation. It can also send regions to an
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
52 ;; inferior Prolog process.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
53 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
54 ;; The code requires the comint, easymenu, info, imenu, and font-lock
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
55 ;; libraries. These are normally distributed with GNU Emacs and
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
56 ;; XEmacs.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
57
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
58 ;;; Installation:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
59 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
60 ;; Insert the following lines in your init file--typically ~/.emacs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
61 ;; (GNU Emacs and XEmacs <21.4), or ~/.xemacs/init.el (XEmacs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
62 ;; 21.4)--to use this mode when editing Prolog files under Emacs:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
63 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
64 ;; (setq load-path (cons "/usr/lib/xemacs/site-lisp" load-path))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
65 ;; (autoload 'run-prolog "prolog" "Start a Prolog sub-process." t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
66 ;; (autoload 'prolog-mode "prolog" "Major mode for editing Prolog programs." t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
67 ;; (autoload 'mercury-mode "prolog" "Major mode for editing Mercury programs." t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
68 ;; (setq prolog-system 'swi) ; optional, the system you are using;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
69 ;; ; see `prolog-system' below for possible values
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
70 ;; (setq auto-mode-alist (append '(("\\.pl$" . prolog-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
71 ;; ("\\.m$" . mercury-mode))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
72 ;; auto-mode-alist))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
73 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
74 ;; where the path in the first line is the file system path to this file.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
75 ;; MSDOS paths can be written like "d:/programs/emacs-19.34/site-lisp".
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
76 ;; Note: In XEmacs, either `/usr/lib/xemacs/site-lisp' (RPM default in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
77 ;; Red Hat-based distributions) or `/usr/local/lib/xemacs/site-lisp'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
78 ;; (default when compiling from sources) are automatically added to
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
79 ;; `load-path', so the first line is not necessary provided that you
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
80 ;; put this file in the appropriate place.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
81 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
82 ;; The last s-expression above makes sure that files ending with .pl
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
83 ;; are assumed to be Prolog files and not Perl, which is the default
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
84 ;; Emacs setting. If this is not wanted, remove this line. It is then
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
85 ;; necessary to either
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
86 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
87 ;; o insert in your Prolog files the following comment as the first line:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
88 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
89 ;; % -*- Mode: Prolog -*-
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
90 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
91 ;; and then the file will be open in Prolog mode no matter its
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
92 ;; extension, or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
93 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
94 ;; o manually switch to prolog mode after opening a Prolog file, by typing
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
95 ;; M-x prolog-mode.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
96 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
97 ;; If the command to start the prolog process ('sicstus', 'pl' or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
98 ;; 'swipl' for SWI prolog, etc.) is not available in the default path,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
99 ;; then it is necessary to set the value of the environment variable
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
100 ;; EPROLOG to a shell command to invoke the prolog process. In XEmacs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
101 ;; and Emacs 20+ you can also customize the variable
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
102 ;; `prolog-program-name' (in the group `prolog-inferior') and provide
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
103 ;; a full path for your Prolog system (swi, scitus, etc.).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
104 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
105 ;; Note: I (Stefan, the current maintainer) work under XEmacs. Future
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
106 ;; developments will thus be biased towards XEmacs (OK, I admit it,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
107 ;; I am biased towards XEmacs in general), though I will do my best
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
108 ;; to keep the GNU Emacs compatibility. So if you work under Emacs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
109 ;; and see something that does not work do drop me a line, as I have
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
110 ;; a smaller chance to notice this kind of bugs otherwise.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
111
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
112 ;; Changelog:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
113
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
114 ;; Version 1.22:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
115 ;; o Allowed both 'swipl' and 'pl' as names for the SWI Prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
116 ;; interpreter.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
117 ;; o Atoms that start a line are not blindly coloured as
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
118 ;; predicates. Instead we check that they are followed by ( or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
119 ;; :- first. Patch suggested by Guy Wiener.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
120 ;; Version 1.21:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
121 ;; o Cleaned up the code that defines faces. The missing face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
122 ;; warnings on some Emacsen should disappear.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
123 ;; Version 1.20:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
124 ;; o Improved the handling of clause start detection and multi-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
125 ;; comments: `prolog-clause-start' no longer finds non-predicate
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
126 ;; (e.g., capitalized strings) beginning of clauses.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
127 ;; `prolog-tokenize' recognizes when the end point is within a
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
128 ;; multi-line comment.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
129 ;; Version 1.19:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
130 ;; o Minimal changes for Aquamacs inclusion and in general for
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
131 ;; better coping with finding the Prolog executable. Patch
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
132 ;; provided by David Reitter
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
133 ;; Version 1.18:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
134 ;; o Fixed syntax highlighting for clause heads that do not begin at
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
135 ;; the beginning of the line.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
136 ;; o Fixed compilation warnings under Emacs.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
137 ;; o Updated the email address of the current maintainer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
138 ;; Version 1.17:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
139 ;; o Minor indentation fix (patch by Markus Triska)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
140 ;; o `prolog-underscore-wordchar-flag' defaults now to nil (more
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
141 ;; consistent to other Emacs modes)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
142 ;; Version 1.16:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
143 ;; o Eliminated a possible compilation warning.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
144 ;; Version 1.15:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
145 ;; o Introduced three new customizable variables: electric colon
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
146 ;; (`prolog-electric-colon-flag', default nil), electric dash
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
147 ;; (`prolog-electric-dash-flag', default nil), and a possibility
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
148 ;; to prevent the predicate template insertion from adding commata
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
149 ;; (`prolog-electric-dot-full-predicate-template', defaults to t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
150 ;; since it seems quicker to me to just type those commata). A
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
151 ;; trivial adaptation of a patch by Markus Triska.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
152 ;; o Improved the behaviour of electric if-then-else to only skip
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
153 ;; forward if the parenthesis/semicolon is preceded by
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
154 ;; whitespace. Once more a trivial adaptation of a patch by
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
155 ;; Markus Triska.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
156 ;; Version 1.14:
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
157 ;; o Cleaned up align code. `prolog-align-flag' is eliminated (since
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
158 ;; on a second thought it does not do anything useful). Added key
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
159 ;; binding (C-c C-a) and menu entry for alignment.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
160 ;; o Condensed regular expressions for lower and upper case
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
161 ;; characters (GNU Emacs seems to go over the regexp length limit
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
162 ;; with the original form). My code on the matter was improved
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
163 ;; considerably by Markus Triska.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
164 ;; o Fixed `prolog-insert-spaces-after-paren' (which used an
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
165 ;; unitialized variable).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
166 ;; o Minor changes to clean up the code and avoid some implicit
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
167 ;; package requirements.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
168 ;; Version 1.13:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
169 ;; o Removed the use of `map-char-table' in `prolog-build-case-strings'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
170 ;; which appears to cause prblems in (at least) Emacs 23.0.0.1.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
171 ;; o Added if-then-else indentation + corresponding electric
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
172 ;; characters. New customization: `prolog-electric-if-then-else-flag'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
173 ;; o Align support (requires `align'). New customization:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
174 ;; `prolog-align-flag'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
175 ;; o Temporary consult files have now the same name throughout the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
176 ;; session. This prevents issues with reconsulting a buffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
177 ;; (this event is no longer passed to Prolog as a request to
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
178 ;; consult a new file).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
179 ;; o Adaptive fill mode is now turned on. Comment indentation is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
180 ;; still worse than it could be though, I am working on it.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
181 ;; o Improved filling and auto-filling capabilities. Now block
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
182 ;; comments should be [auto-]filled correctly most of the time;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
183 ;; the following pattern in particular is worth noting as being
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
184 ;; filled correctly:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
185 ;; <some code here> % some comment here that goes beyond the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
186 ;; % rightmost column, possibly combined with
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
187 ;; % subsequent comment lines
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
188 ;; o `prolog-char-quote-workaround' now defaults to nil.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
189 ;; o Note: Many of the above improvements have been suggested by
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
190 ;; Markus Triska, who also provided useful patches on the matter
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
191 ;; when he realized that I was slow in responding. Many thanks.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
192 ;; Version 1.11 / 1.12
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
193 ;; o GNU Emacs compatibility fix for paragraph filling (fixed
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
194 ;; incorrectly in 1.11, fix fixed in 1.12).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
195 ;; Version 1.10
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
196 ;; o Added paragraph filling in comment blocks and also correct auto
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
197 ;; filling for comments.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
198 ;; o Fixed the possible "Regular expression too big" error in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
199 ;; `prolog-electric-dot'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
200 ;; Version 1.9
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
201 ;; o Parenthesis expressions are now indented by default so that
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
202 ;; components go one underneath the other, just as for compound
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
203 ;; terms. You can use the old style (the second and subsequent
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
204 ;; lines being indented to the right in a parenthesis expression)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
205 ;; by setting the customizable variable `prolog-paren-indent-p'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
206 ;; (group "Prolog Indentation") to t.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
207 ;; o (Somehow awkward) handling of the 0' character escape
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
208 ;; sequence. I am looking into a better way of doing it but
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
209 ;; prospects look bleak. If this breaks things for you please let
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
210 ;; me know and also set the `prolog-char-quote-workaround' (group
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
211 ;; "Prolog Other") to nil.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
212 ;; Version 1.8
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
213 ;; o Key binding fix.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
214 ;; Version 1.7
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
215 ;; o Fixed a number of issues with the syntax of single quotes,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
216 ;; including Debian bug #324520.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
217 ;; Version 1.6
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
218 ;; o Fixed mercury mode menu initialization (Debian bug #226121).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
219 ;; o Fixed (i.e., eliminated) Delete remapping (Debian bug #229636).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
220 ;; o Corrected indentation for clauses defining quoted atoms.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
221 ;; Version 1.5:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
222 ;; o Keywords fontifying should work in console mode so this is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
223 ;; enabled everywhere.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
224 ;; Version 1.4:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
225 ;; o Now supports GNU Prolog--minor adaptation of a patch by Stefan
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
226 ;; Moeding.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
227 ;; Version 1.3:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
228 ;; o Info-follow-nearest-node now called correctly under Emacs too
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
229 ;; (thanks to Nicolas Pelletier). Should be implemented more
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
230 ;; elegantly (i.e., without compilation warnings) in the future.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
231 ;; Version 1.2:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
232 ;; o Another prompt fix, still in SWI mode (people seem to have
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
233 ;; changed the prompt of SWI Prolog).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
234 ;; Version 1.1:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
235 ;; o Fixed dots in the end of line comments causing indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
236 ;; problems. The following code is now correctly indented (note
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
237 ;; the dot terminating the comment):
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
238 ;; a(X) :- b(X),
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
239 ;; c(X). % comment here.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
240 ;; a(X).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
241 ;; and so is this (and variants):
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
242 ;; a(X) :- b(X),
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
243 ;; c(X). /* comment here. */
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
244 ;; a(X).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
245 ;; Version 1.0:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
246 ;; o Revamped the menu system.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
247 ;; o Yet another prompt recognition fix (SWI mode).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
248 ;; o This is more of a renumbering than a new edition. I promoted
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
249 ;; the mode to version 1.0 to emphasize the fact that it is now
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
250 ;; mature and stable enough to be considered production (in my
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
251 ;; opinion anyway).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
252 ;; Version 0.1.41:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
253 ;; o GNU Emacs compatibility fixes.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
254 ;; Version 0.1.40:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
255 ;; o prolog-get-predspec is now suitable to be called as
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
256 ;; imenu-extract-index-name-function. The predicate index works.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
257 ;; o Since imenu works now as advertised, prolog-imenu-flag is t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
258 ;; by default.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
259 ;; o Eliminated prolog-create-predicate-index since the imenu
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
260 ;; utilities now work well. Actually, this function is also
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
261 ;; buggy, and I see no reason to fix it since we do not need it
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
262 ;; anyway.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
263 ;; o Fixed prolog-pred-start, prolog-clause-start, prolog-clause-info.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
264 ;; o Fix for prolog-build-case-strings; now prolog-upper-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
265 ;; and prolog-lower-case-string are correctly initialized,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
266 ;; o Various font-lock changes; most importantly, block comments (/*
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
267 ;; ... */) are now correctly fontified in XEmacs even when they
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
268 ;; extend on multiple lines.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
269 ;; Version 0.1.36:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
270 ;; o The debug prompt of SWI Prolog is now correctly recognized.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
271 ;; Version 0.1.35:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
272 ;; o Minor font-lock bug fixes.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
273
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
274
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
275 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
276
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
277 (eval-when-compile
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
278 (require 'compile)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
279 (require 'font-lock)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
280 ;; We need imenu everywhere because of the predicate index!
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
281 (require 'imenu)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
282 ;)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
283 (require 'info)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
284 (require 'shell)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
285 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
286
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
287 (require 'comint)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
288 (require 'easymenu)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
289 (require 'align)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
290
65238
a372b82c546e (comint-prompt-regexp): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents: 64699
diff changeset
291
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
292 (defgroup prolog nil
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
293 "Major modes for editing and running Prolog and Mercury files."
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
294 :group 'languages)
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
295
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
296 (defgroup prolog-faces nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
297 "Prolog mode specific faces."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
298 :group 'font-lock)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
299
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
300 (defgroup prolog-indentation nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
301 "Prolog mode indentation configuration."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
302 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
303
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
304 (defgroup prolog-font-lock nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
305 "Prolog mode font locking patterns."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
306 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
307
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
308 (defgroup prolog-keyboard nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
309 "Prolog mode keyboard flags."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
310 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
311
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
312 (defgroup prolog-inferior nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
313 "Inferior Prolog mode options."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
314 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
315
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
316 (defgroup prolog-other nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
317 "Other Prolog mode options."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
318 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
319
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
320
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
321 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
322 ;; User configurable variables
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
323 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
324
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
325 ;; General configuration
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
326
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
327 (defcustom prolog-system nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
328 "*Prolog interpreter/compiler used.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
329 The value of this variable is nil or a symbol.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
330 If it is a symbol, it determines default values of other configuration
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
331 variables with respect to properties of the specified Prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
332 interpreter/compiler.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
333
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
334 Currently recognized symbol values are:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
335 eclipse - Eclipse Prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
336 mercury - Mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
337 sicstus - SICStus Prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
338 swi - SWI Prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
339 gnu - GNU Prolog"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
340 :group 'prolog
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
341 :type '(choice (const :tag "SICStus" :value sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
342 (const :tag "SWI Prolog" :value swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
343 (const :tag "Default" :value nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
344 (make-variable-buffer-local 'prolog-system)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
345
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
346 ;; NB: This alist can not be processed in prolog-mode-variables to
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
347 ;; create a prolog-system-version-i variable since it is needed
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
348 ;; prior to the call to prolog-mode-variables.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
349 (defcustom prolog-system-version
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
350 '((sicstus (3 . 6))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
351 (swi (0 . 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
352 (mercury (0 . 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
353 (eclipse (3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
354 (gnu (0 . 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
355 "*Alist of Prolog system versions.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
356 The version numbers are of the format (Major . Minor)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
357 :group 'prolog)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
358
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
359 ;; Indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
360
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
361 (defcustom prolog-indent-width 4
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
362 "*The indentation width used by the editing buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
363 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
364 :type 'integer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
365
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
366 (defcustom prolog-align-comments-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
367 "*Non-nil means automatically align comments when indenting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
368 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
369 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
370
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
371 (defcustom prolog-indent-mline-comments-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
372 "*Non-nil means indent contents of /* */ comments.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
373 Otherwise leave such lines as they are."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
374 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
375 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
376
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
377 (defcustom prolog-object-end-to-0-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
378 "*Non-nil means indent closing '}' in SICStus object definitions to level 0.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
379 Otherwise indent to `prolog-indent-width'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
380 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
381 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
382
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
383 (defcustom prolog-left-indent-regexp "\\(;\\|\\*?->\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
384 "*Regexp for character sequences after which next line is indented.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
385 Next line after such a regexp is indented to the opening paranthesis level."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
386 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
387 :type 'regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
388
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
389 (defcustom prolog-paren-indent-p nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
390 "*If non-nil, increase indentation for parenthesis expressions.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
391 The second and subsequent line in a parenthesis expression other than
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
392 a compound term can either be indented `prolog-paren-indent' to the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
393 right (if this variable is non-nil) or in the same way as for compound
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
394 terms (if this variable is nil, default)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
395 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
396 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
397
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
398 (defcustom prolog-paren-indent 4
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
399 "*The indentation increase for parenthesis expressions.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
400 Only used in ( If -> Then ; Else) and ( Disj1 ; Disj2 ) style expressions."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
401 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
402 :type 'integer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
403
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
404 (defcustom prolog-parse-mode 'beg-of-clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
405 "*The parse mode used (decides from which point parsing is done).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
406 Legal values:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
407 'beg-of-line - starts parsing at the beginning of a line, unless the
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
408 previous line ends with a backslash. Fast, but has
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
409 problems detecting multiline /* */ comments.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
410 'beg-of-clause - starts parsing at the beginning of the current clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
411 Slow, but copes better with /* */ comments."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
412 :group 'prolog-indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
413 :type '(choice (const :value beg-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
414 (const :value beg-of-clause)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
415
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
416 ;; Font locking
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
417
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
418 (defcustom prolog-keywords
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
419 '((eclipse
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
420 ("use_module" "begin_module" "module_interface" "dynamic"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
421 "external" "export" "dbgcomp" "nodbgcomp" "compile"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
422 (mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
423 ("all" "else" "end_module" "equality" "external" "fail" "func" "if"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
424 "implementation" "import_module" "include_module" "inst" "instance"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
425 "interface" "mode" "module" "not" "pragma" "pred" "some" "then" "true"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
426 "type" "typeclass" "use_module" "where"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
427 (sicstus
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
428 ("block" "dynamic" "mode" "module" "multifile" "meta_predicate"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
429 "parallel" "public" "sequential" "volatile"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
430 (swi
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
431 ("discontiguous" "dynamic" "ensure_loaded" "export" "export_list" "import"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
432 "meta_predicate" "module" "module_transparent" "multifile" "require"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
433 "use_module" "volatile"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
434 (gnu
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
435 ("built_in" "char_conversion" "discontiguous" "dynamic" "ensure_linked"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
436 "ensure_loaded" "foreign" "include" "initialization" "multifile" "op"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
437 "public" "set_prolog_flag"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
438 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
439 ("dynamic" "module")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
440 "*Alist of Prolog keywords which is used for font locking of directives."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
441 :group 'prolog-font-lock
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
442 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
443
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
444 (defcustom prolog-types
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
445 '((mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
446 ("char" "float" "int" "io__state" "string" "univ"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
447 (t nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
448 "*Alist of Prolog types used by font locking."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
449 :group 'prolog-font-lock
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
450 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
451
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
452 (defcustom prolog-mode-specificators
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
453 '((mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
454 ("bound" "di" "free" "ground" "in" "mdi" "mui" "muo" "out" "ui" "uo"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
455 (t nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
456 "*Alist of Prolog mode specificators used by font locking."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
457 :group 'prolog-font-lock
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
458 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
459
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
460 (defcustom prolog-determinism-specificators
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
461 '((mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
462 ("cc_multi" "cc_nondet" "det" "erroneous" "failure" "multi" "nondet"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
463 "semidet"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
464 (t nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
465 "*Alist of Prolog determinism specificators used by font locking."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
466 :group 'prolog-font-lock
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
467 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
468
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
469 (defcustom prolog-directives
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
470 '((mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
471 ("^#[0-9]+"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
472 (t nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
473 "*Alist of Prolog source code directives used by font locking."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
474 :group 'prolog-font-lock
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
475 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
476
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
477
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
478 ;; Keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
479
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
480 (defcustom prolog-electric-newline-flag (not (fboundp 'electric-indent-mode))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
481 "*Non-nil means automatically indent the next line when the user types RET."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
482 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
483 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
484
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
485 (defcustom prolog-hungry-delete-key-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
486 "*Non-nil means delete key consumes all preceding spaces."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
487 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
488 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
489
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
490 (defcustom prolog-electric-dot-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
491 "*Non-nil means make dot key electric.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
492 Electric dot appends newline or inserts head of a new clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
493 If dot is pressed at the end of a line where at least one white space
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
494 precedes the point, it inserts a recursive call to the current predicate.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
495 If dot is pressed at the beginning of an empty line, it inserts the head
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
496 of a new clause for the current predicate. It does not apply in strings
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
497 and comments.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
498 It does not apply in strings and comments."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
499 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
500 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
501
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
502 (defcustom prolog-electric-dot-full-predicate-template nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
503 "*If nil, electric dot inserts only the current predicate's name and `('
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
504 for recursive calls or new clause heads. Non-nil means to also
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
505 insert enough commata to cover the predicate's arity and `)',
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
506 and dot and newline for recursive calls."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
507 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
508 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
509
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
510 (defcustom prolog-electric-underscore-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
511 "*Non-nil means make underscore key electric.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
512 Electric underscore replaces the current variable with underscore.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
513 If underscore is pressed not on a variable then it behaves as usual."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
514 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
515 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
516
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
517 (defcustom prolog-electric-tab-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
518 "*Non-nil means make TAB key electric.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
519 Electric TAB inserts spaces after parentheses, ->, and ;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
520 in ( If -> Then ; Else) and ( Disj1 ; Disj2 ) style expressions."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
521 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
522 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
523
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
524 (defcustom prolog-electric-if-then-else-flag nil
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
525 "*Non-nil makes `(', `>' and `;' electric
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
526 to automatically indent if-then-else constructs."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
527 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
528 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
529
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
530 (defcustom prolog-electric-colon-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
531 "*Makes `:' electric (inserts `:-' on a new line).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
532 If non-nil, pressing `:' at the end of a line that starts in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
533 the first column (i.e., clause heads) inserts ` :-' and newline."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
534 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
535 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
536
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
537 (defcustom prolog-electric-dash-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
538 "*Makes `-' electric (inserts a `-->' on a new line).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
539 If non-nil, pressing `-' at the end of a line that starts in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
540 the first column (i.e., DCG heads) inserts ` -->' and newline."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
541 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
542 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
543
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
544 (defcustom prolog-old-sicstus-keys-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
545 "*Non-nil means old SICStus Prolog mode keybindings are used."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
546 :group 'prolog-keyboard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
547 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
548
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
549 ;; Inferior mode
45608
706ae7fb4033 (prolog-mode-syntax-table): Add flags to ?/ and ?* entries
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 20396
diff changeset
550
53891
4b85b1e3d610 (prolog-program-name): Use gprolog if available.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 52401
diff changeset
551 (defcustom prolog-program-name
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
552 `(((getenv "EPROLOG") (eval (getenv "EPROLOG")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
553 (eclipse "eclipse")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
554 (mercury nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
555 (sicstus "sicstus")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
556 (swi ,(if (not (executable-find "swipl")) "pl" "swipl"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
557 (gnu "gprolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
558 (t ,(let ((names '("prolog" "gprolog" "swipl" "pl")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
559 (while (and names
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
560 (not (executable-find (car names))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
561 (setq names (cdr names)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
562 (or (car names) "prolog"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
563 "*Alist of program names for invoking an inferior Prolog with `run-prolog'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
564 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
565 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
566
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
567 (defcustom prolog-program-switches
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
568 '((sicstus ("-i"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
569 (t nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
570 "*Alist of switches given to inferior Prolog run with `run-prolog'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
571 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
572 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
573
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
574 (defcustom prolog-consult-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
575 '((eclipse "[%f].")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
576 (mercury nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
577 (sicstus (eval (if (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
578 "prolog:zap_file(%m,%b,consult,%l)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
579 "prolog:zap_file(%m,%b,consult).")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
580 (swi "[%f].")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
581 (gnu "[%f].")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
582 (t "reconsult(%f)."))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
583 "*Alist of strings defining predicate for reconsulting.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
584
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
585 Some parts of the string are replaced:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
586 `%f' by the name of the consulted file (can be a temporary file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
587 `%b' by the file name of the buffer to consult
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
588 `%m' by the module name and name of the consulted file separated by colon
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
589 `%l' by the line offset into the file. This is 0 unless consulting a
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
590 region of a buffer, in which case it is the number of lines before
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
591 the region."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
592 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
593 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
594
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
595 (defcustom prolog-compile-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
596 '((eclipse "[%f].")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
597 (mercury "mmake ")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
598 (sicstus (eval (if (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
599 "prolog:zap_file(%m,%b,compile,%l)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
600 "prolog:zap_file(%m,%b,compile).")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
601 (swi "[%f].")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
602 (t "compile(%f)."))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
603 "*Alist of strings and lists defining predicate for recompilation.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
604
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
605 Some parts of the string are replaced:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
606 `%f' by the name of the compiled file (can be a temporary file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
607 `%b' by the file name of the buffer to compile
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
608 `%m' by the module name and name of the compiled file separated by colon
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
609 `%l' by the line offset into the file. This is 0 unless compiling a
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
610 region of a buffer, in which case it is the number of lines before
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
611 the region.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
612
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
613 If `prolog-program-name' is non-nil, it is a string sent to a Prolog process.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
614 If `prolog-program-name' is nil, it is an argument to the `compile' function."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
615 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
616 :type 'sexp)
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
617
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
618 (defcustom prolog-eof-string "end_of_file.\n"
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
619 "*Alist of strings that represent end of file for prolog.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
620 nil means send actual operating system end of file."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
621 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
622 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
623
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
624 (defcustom prolog-prompt-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
625 '((eclipse "^[a-zA-Z0-9()]* *\\?- \\|^\\[[a-zA-Z]* [0-9]*\\]:")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
626 (sicstus "| [ ?][- ] *")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
627 (swi "^\\(\\[[a-zA-Z]*\\] \\)?[1-9]?[0-9]*[ ]?\\?- \\|^| +")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
628 (t "^ *\\?-"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
629 "*Alist of prompts of the prolog system command line."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
630 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
631 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
632
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
633 (defcustom prolog-continued-prompt-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
634 '((sicstus "^\\(| +\\| +\\)")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
635 (t "^|: +"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
636 "*Alist of regexps matching the prompt when consulting `user'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
637 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
638 :type 'sexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
639
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
640 (defcustom prolog-debug-on-string "debug.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
641 "*Predicate for enabling debug mode."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
642 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
643 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
644
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
645 (defcustom prolog-debug-off-string "nodebug.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
646 "*Predicate for disabling debug mode."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
647 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
648 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
649
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
650 (defcustom prolog-trace-on-string "trace.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
651 "*Predicate for enabling tracing."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
652 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
653 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
654
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
655 (defcustom prolog-trace-off-string "notrace.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
656 "*Predicate for disabling tracing."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
657 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
658 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
659
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
660 (defcustom prolog-zip-on-string "zip.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
661 "*Predicate for enabling zip mode for SICStus."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
662 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
663 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
664
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
665 (defcustom prolog-zip-off-string "nozip.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
666 "*Predicate for disabling zip mode for SICStus."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
667 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
668 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
669
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
670 (defcustom prolog-use-standard-consult-compile-method-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
671 "*Non-nil means use the standard compilation method.
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
672 Otherwise the new compilation method will be used. This
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
673 utilises a special compilation buffer with the associated
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
674 features such as parsing of error messages and automatically
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
675 jumping to the source code responsible for the error.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
676
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
677 Warning: the new method is so far only experimental and
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
678 does contain bugs. The recommended setting for the novice user
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
679 is non-nil for this variable."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
680 :group 'prolog-inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
681 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
682
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
683
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
684 ;; Miscellaneous
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
685
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
686 (defcustom prolog-use-prolog-tokenizer-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
687 "*Non-nil means use the internal prolog tokenizer for indentation etc.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
688 Otherwise use `parse-partial-sexp' which is faster but sometimes incorrect."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
689 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
690 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
691
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
692 (defcustom prolog-imenu-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
693 "*Non-nil means add a clause index menu for all prolog files."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
694 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
695 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
696
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
697 (defcustom prolog-imenu-max-lines 3000
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
698 "*The maximum number of lines of the file for imenu to be enabled.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
699 Relevant only when `prolog-imenu-flag' is non-nil."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
700 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
701 :type 'integer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
702
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
703 (defcustom prolog-info-predicate-index
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
704 "(sicstus)Predicate Index"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
705 "*The info node for the SICStus predicate index."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
706 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
707 :type 'string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
708
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
709 (defcustom prolog-underscore-wordchar-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
710 "*Non-nil means underscore (_) is a word-constituent character."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
711 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
712 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
713
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
714 (defcustom prolog-use-sicstus-sd nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
715 "*If non-nil, use the source level debugger of SICStus 3#7 and later."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
716 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
717 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
718
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
719 (defcustom prolog-char-quote-workaround nil
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
720 ;; FIXME: Use syntax-propertize-function to fix it right.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
721 "*If non-nil, declare 0 as a quote character so that 0'<char> does not break syntax highlighting.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
722 This is really kludgy but I have not found any better way of handling it."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
723 :group 'prolog-other
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
724 :type 'boolean)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
725
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
726
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
727 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
728 ;; Internal variables
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
729 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
730
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
731 ;;(defvar prolog-temp-filename "") ; Later set by `prolog-temporary-file'
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
732
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
733 (defvar prolog-mode-syntax-table
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
734 (let ((table (make-syntax-table)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
735 (if prolog-underscore-wordchar-flag
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
736 (modify-syntax-entry ?_ "w" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
737 (modify-syntax-entry ?_ "_" table))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
738
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
739 (modify-syntax-entry ?+ "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
740 (modify-syntax-entry ?- "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
741 (modify-syntax-entry ?= "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
742 (modify-syntax-entry ?< "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
743 (modify-syntax-entry ?> "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
744 (modify-syntax-entry ?| "." table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
745 (modify-syntax-entry ?\' "\"" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
746
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
747 ;; Any better way to handle the 0'<char> construct?!?
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
748 (when prolog-char-quote-workaround
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
749 (modify-syntax-entry ?0 "\\" table))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
750
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
751 (modify-syntax-entry ?% "<" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
752 (modify-syntax-entry ?\n ">" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
753 (if (featurep 'xemacs)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
754 (progn
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
755 (modify-syntax-entry ?* ". 67" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
756 (modify-syntax-entry ?/ ". 58" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
757 )
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
758 ;; Emacs wants to see this it seems:
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
759 (modify-syntax-entry ?* ". 23b" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
760 (modify-syntax-entry ?/ ". 14" table)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
761 )
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
762 table))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
763 (defvar prolog-mode-abbrev-table nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
764 (defvar prolog-upper-case-string ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
765 "A string containing all upper case characters.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
766 Set by prolog-build-case-strings.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
767 (defvar prolog-lower-case-string ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
768 "A string containing all lower case characters.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
769 Set by prolog-build-case-strings.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
770
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
771 (defvar prolog-atom-char-regexp ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
772 "Set by prolog-set-atom-regexps.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
773 ;; "Regexp specifying characters which constitute atoms without quoting.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
774 (defvar prolog-atom-regexp ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
775 "Set by prolog-set-atom-regexps.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
776
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
777 (defconst prolog-left-paren "[[({]"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
778 "The characters used as left parentheses for the indentation code.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
779 (defconst prolog-right-paren "[])}]"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
780 "The characters used as right parentheses for the indentation code.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
781
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
782 (defconst prolog-quoted-atom-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
783 "\\(^\\|[^0-9]\\)\\('\\([^\n']\\|\\\\'\\)*'\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
784 "Regexp matching a quoted atom.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
785 (defconst prolog-string-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
786 "\\(\"\\([^\n\"]\\|\\\\\"\\)*\"\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
787 "Regexp matching a string.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
788 (defconst prolog-head-delimiter "\\(:-\\|\\+:\\|-:\\|\\+\\?\\|-\\?\\|-->\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
789 "A regexp for matching on the end delimiter of a head (e.g. \":-\").")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
790
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
791 (defvar prolog-compilation-buffer "*prolog-compilation*"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
792 "Name of the output buffer for Prolog compilation/consulting.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
793
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
794 (defvar prolog-temporary-file-name nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
795 (defvar prolog-keywords-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
796 (defvar prolog-types-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
797 (defvar prolog-mode-specificators-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
798 (defvar prolog-determinism-specificators-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
799 (defvar prolog-directives-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
800 (defvar prolog-program-name-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
801 (defvar prolog-program-switches-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
802 (defvar prolog-consult-string-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
803 (defvar prolog-compile-string-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
804 (defvar prolog-eof-string-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
805 (defvar prolog-prompt-regexp-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
806 (defvar prolog-continued-prompt-regexp-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
807 (defvar prolog-help-function-i nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
808
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
809 (defvar prolog-align-rules
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
810 (eval-when-compile
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
811 (mapcar
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
812 (lambda (x)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
813 (let ((name (car x))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
814 (sym (cdr x)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
815 `(,(intern (format "prolog-%s" name))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
816 (regexp . ,(format "\\(\\s-*\\)%s\\(\\s-*\\)" sym))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
817 (tab-stop . nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
818 (modes . '(prolog-mode))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
819 (group . (1 2)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
820 '(("dcg" . "-->") ("rule" . ":-") ("simplification" . "<=>")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
821 ("propagation" . "==>")))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
822
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
823
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
824
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
825 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
826 ;; Prolog mode
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
827 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
828
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
829 ;; Example: (prolog-atleast-version '(3 . 6))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
830 (defun prolog-atleast-version (version)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
831 "Return t if the version of the current prolog system is VERSION or later.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
832 VERSION is of the format (Major . Minor)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
833 ;; Version.major < major or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
834 ;; Version.major = major and Version.minor <= minor
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
835 (let* ((thisversion (prolog-find-value-by-system prolog-system-version))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
836 (thismajor (car thisversion))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
837 (thisminor (cdr thisversion)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
838 (or (< (car version) thismajor)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
839 (and (= (car version) thismajor)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
840 (<= (cdr version) thisminor)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
841 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
842
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
843 (define-abbrev-table 'prolog-mode-abbrev-table ())
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
844
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
845 (defun prolog-find-value-by-system (alist)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
846 "Get value from ALIST according to `prolog-system'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
847 (if (listp alist)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
848 (let (result
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
849 id)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
850 (while alist
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
851 (setq id (car (car alist)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
852 (if (or (eq id prolog-system)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
853 (eq id t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
854 (and (listp id)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
855 (eval id)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
856 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
857 (setq result (car (cdr (car alist))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
858 (if (and (listp result)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
859 (eq (car result) 'eval))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
860 (setq result (eval (car (cdr result)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
861 (setq alist nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
862 (setq alist (cdr alist))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
863 result)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
864 alist))
108632
d38b0dd2bdbe Provide a simple generic indentation engine and use it for Prolog.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 108588
diff changeset
865
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
866 (defun prolog-mode-variables ()
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
867 "Set some common variables to Prolog code specific values."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
868 (setq local-abbrev-table prolog-mode-abbrev-table)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
869 (make-local-variable 'paragraph-start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
870 (setq paragraph-start (concat "[ \t]*$\\|" page-delimiter)) ;'%%..'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
871 (make-local-variable 'paragraph-separate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
872 (setq paragraph-separate paragraph-start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
873 (make-local-variable 'paragraph-ignore-fill-prefix)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
874 (setq paragraph-ignore-fill-prefix t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
875 (make-local-variable 'normal-auto-fill-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
876 (setq normal-auto-fill-function 'prolog-do-auto-fill)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
877 (make-local-variable 'indent-line-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
878 (setq indent-line-function 'prolog-indent-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
879 (make-local-variable 'comment-start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
880 (setq comment-start "%")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
881 (make-local-variable 'comment-end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
882 (setq comment-end "")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
883 (make-local-variable 'comment-start-skip)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
884 ;; This complex regexp makes sure that comments cannot start
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
885 ;; inside quoted atoms or strings
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
886 (setq comment-start-skip
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
887 (format "^\\(\\(%s\\|%s\\|[^\n\'\"%%]\\)*\\)\\(/\\*+ *\\|%%+ *\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
888 prolog-quoted-atom-regexp prolog-string-regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
889 (make-local-variable 'comment-column)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
890 (make-local-variable 'comment-indent-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
891 (setq comment-indent-function 'prolog-comment-indent)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
892 (make-local-variable 'parens-require-spaces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
893 (setq parens-require-spaces nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
894 ;; Initialize Prolog system specific variables
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
895 (let ((vars '(prolog-keywords prolog-types prolog-mode-specificators
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
896 prolog-determinism-specificators prolog-directives
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
897 prolog-program-name prolog-program-switches
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
898 prolog-consult-string prolog-compile-string prolog-eof-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
899 prolog-prompt-regexp prolog-continued-prompt-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
900 prolog-help-function)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
901 (while vars
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
902 (set (intern (concat (symbol-name (car vars)) "-i"))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
903 (prolog-find-value-by-system (symbol-value (car vars))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
904 (setq vars (cdr vars))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
905 (when (null prolog-program-name-i)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
906 (make-local-variable 'compile-command)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
907 (setq compile-command prolog-compile-string-i))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
908 (make-local-variable 'font-lock-defaults)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
909 (setq font-lock-defaults
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
910 '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
911 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
912
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
913 (defun prolog-mode-keybindings-common (map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
914 "Define keybindings common to both Prolog modes in MAP."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
915 (define-key map "\C-c?" 'prolog-help-on-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
916 (define-key map "\C-c/" 'prolog-help-apropos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
917 (define-key map "\C-c\C-d" 'prolog-debug-on)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
918 (define-key map "\C-c\C-t" 'prolog-trace-on)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
919 (if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
920 (prolog-atleast-version '(3 . 7)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
921 (define-key map "\C-c\C-z" 'prolog-zip-on))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
922 (define-key map "\C-c\r" 'run-prolog))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
923
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
924 (defun prolog-mode-keybindings-edit (map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
925 "Define keybindings for Prolog mode in MAP."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
926 (define-key map "\M-a" 'prolog-beginning-of-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
927 (define-key map "\M-e" 'prolog-end-of-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
928 (define-key map "\M-q" 'prolog-fill-paragraph)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
929 (define-key map "\C-c\C-a" 'align)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
930 (define-key map "\C-\M-a" 'prolog-beginning-of-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
931 (define-key map "\C-\M-e" 'prolog-end-of-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
932 (define-key map "\M-\C-c" 'prolog-mark-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
933 (define-key map "\M-\C-h" 'prolog-mark-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
934 (define-key map "\M-\C-n" 'prolog-forward-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
935 (define-key map "\M-\C-p" 'prolog-backward-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
936 (define-key map "\C-c\C-n" 'prolog-insert-predicate-template)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
937 (define-key map "\C-c\C-s" 'prolog-insert-predspec)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
938 (define-key map "\M-\r" 'prolog-insert-next-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
939 (define-key map "\C-c\C-va" 'prolog-variables-to-anonymous)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
940 (define-key map "\C-c\C-v\C-s" 'prolog-view-predspec)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
941
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
942 (define-key map [Backspace] 'prolog-electric-delete)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
943 (define-key map "." 'prolog-electric-dot)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
944 (define-key map "_" 'prolog-electric-underscore)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
945 (define-key map "(" 'prolog-electric-if-then-else)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
946 (define-key map ";" 'prolog-electric-if-then-else)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
947 (define-key map ">" 'prolog-electric-if-then-else)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
948 (define-key map ":" 'prolog-electric-colon)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
949 (define-key map "-" 'prolog-electric-dash)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
950 (if prolog-electric-newline-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
951 (define-key map "\r" 'newline-and-indent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
952
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
953 ;; If we're running SICStus, then map C-c C-c e/d to enabling
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
954 ;; and disabling of the source-level debugging facilities.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
955 ;(if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
956 ; (prolog-atleast-version '(3 . 7)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
957 ; (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
958 ; (define-key map "\C-c\C-ce" 'prolog-enable-sicstus-sd)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
959 ; (define-key map "\C-c\C-cd" 'prolog-disable-sicstus-sd)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
960 ; ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
961
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
962 (if prolog-old-sicstus-keys-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
963 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
964 (define-key map "\C-c\C-c" 'prolog-consult-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
965 (define-key map "\C-cc" 'prolog-consult-region)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
966 (define-key map "\C-cC" 'prolog-consult-buffer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
967 (define-key map "\C-c\C-k" 'prolog-compile-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
968 (define-key map "\C-ck" 'prolog-compile-region)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
969 (define-key map "\C-cK" 'prolog-compile-buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
970 (define-key map "\C-c\C-p" 'prolog-consult-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
971 (define-key map "\C-c\C-r" 'prolog-consult-region)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
972 (define-key map "\C-c\C-b" 'prolog-consult-buffer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
973 (define-key map "\C-c\C-f" 'prolog-consult-file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
974 (define-key map "\C-c\C-cp" 'prolog-compile-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
975 (define-key map "\C-c\C-cr" 'prolog-compile-region)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
976 (define-key map "\C-c\C-cb" 'prolog-compile-buffer)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
977 (define-key map "\C-c\C-cf" 'prolog-compile-file))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
978
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
979 ;; Inherited from the old prolog.el.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
980 (define-key map "\e\C-x" 'prolog-consult-region)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
981 (define-key map "\C-c\C-l" 'prolog-consult-file)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
982 (define-key map "\C-c\C-z" 'switch-to-prolog))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
983
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
984 (defun prolog-mode-keybindings-inferior (map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
985 "Define keybindings for inferior Prolog mode in MAP."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
986 ;; No inferior mode specific keybindings now.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
987 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
988
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
989 (defvar prolog-mode-map
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
990 (let ((map (make-sparse-keymap)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
991 (prolog-mode-keybindings-common map)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
992 (prolog-mode-keybindings-edit map)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
993 map))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
994
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
995
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
996 (defvar prolog-mode-hook nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
997 "List of functions to call after the prolog mode has initialised.")
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
998
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
999 (unless (fboundp 'prog-mode)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1000 (defalias 'prog-mode 'fundamental-mode))
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 242
diff changeset
1001 ;;;###autoload
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1002 (define-derived-mode prolog-mode prog-mode "Prolog"
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1003 "Major mode for editing Prolog code.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1004
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1005 Blank lines and `%%...' separate paragraphs. `%'s starts a comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1006 line and comments can also be enclosed in /* ... */.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1007
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1008 If an optional argument SYSTEM is non-nil, set up mode for the given system.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1009
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1010 To find out what version of Prolog mode you are running, enter
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1011 `\\[prolog-mode-version]'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1012
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1013 Commands:
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1014 \\{prolog-mode-map}
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
1015 Entry to this mode calls the value of `prolog-mode-hook'
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1016 if that value is non-nil."
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1017 (setq mode-name (concat "Prolog"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1018 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1019 ((eq prolog-system 'eclipse) "[ECLiPSe]")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1020 ((eq prolog-system 'sicstus) "[SICStus]")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1021 ((eq prolog-system 'swi) "[SWI]")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1022 ((eq prolog-system 'gnu) "[GNU]")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1023 (t ""))))
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1024 (prolog-mode-variables)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1025 (prolog-build-case-strings)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1026 (prolog-set-atom-regexps)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1027 (dolist (ar prolog-align-rules) (add-to-list 'align-rules-list ar))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1028
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1029 ;; imenu entry moved to the appropriate hook for consistency
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1030
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1031 ;; Load SICStus debugger if suitable
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1032 (if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1033 (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1034 prolog-use-sicstus-sd)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1035 (prolog-enable-sicstus-sd)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1036
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1037 (defvar mercury-mode-map
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1038 (let ((map (make-sparse-keymap)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1039 (set-keymap-parent map prolog-mode-map)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1040 map))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1041
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1042 ;;;###autoload
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1043 (define-derived-mode mercury-mode prolog-mode "Prolog[Mercury]"
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1044 "Major mode for editing Mercury programs.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1045 Actually this is just customized `prolog-mode'."
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1046 (set (make-local-variable 'prolog-system) 'mercury))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1047
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1048
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1049 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1050 ;; Inferior prolog mode
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1051 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1052
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1053 (defvar prolog-inferior-mode-map
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1054 (let ((map (make-sparse-keymap)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1055 (prolog-mode-keybindings-common map)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1056 (prolog-mode-keybindings-inferior map)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1057 map))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1058
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1059 (defvar prolog-inferior-mode-hook nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1060 "List of functions to call after the inferior prolog mode has initialised.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1061
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1062 (define-derived-mode prolog-inferior-mode comint-mode "Inferior Prolog"
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1063 "Major mode for interacting with an inferior Prolog process.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1064
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1065 The following commands are available:
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1066 \\{prolog-inferior-mode-map}
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1067
242
5647f2040009 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 41
diff changeset
1068 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
1069 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
1070 `prolog-mode-hook' is called after `comint-mode-hook'.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1071
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1072 You can send text to the inferior Prolog from other buffers
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1073 using the commands `send-region', `send-string' and \\[prolog-consult-region].
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1074
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1075 Commands:
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1076 Tab indents for Prolog; with argument, shifts rest
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1077 of expression rigidly with the current line.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1078 Paragraphs are separated only by blank lines and '%%'. '%'s start comments.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1079
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1080 Return at end of buffer sends line as input.
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1081 Return not at end copies rest of line to end and sends it.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1082 \\[comint-delchar-or-maybe-eof] sends end-of-file as input.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1083 \\[comint-kill-input] and \\[backward-kill-word] are kill commands,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1084 imitating normal Unix input editing.
41
467ee6fe6503 Initial revision
root <root>
parents:
diff changeset
1085 \\[comint-interrupt-subjob] interrupts the shell or its current subjob if any.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1086 \\[comint-stop-subjob] stops, likewise.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1087 \\[comint-quit-subjob] sends quit signal, likewise.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1088
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1089 To find out what version of Prolog mode you are running, enter
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1090 `\\[prolog-mode-version]'."
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1091 (setq comint-input-filter 'prolog-input-filter)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1092 (setq mode-line-process '(": %s"))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1093 (prolog-mode-variables)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1094 (setq comint-prompt-regexp prolog-prompt-regexp-i)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1095 (set (make-local-variable 'shell-dirstack-query) "pwd."))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1096
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1097 (defun prolog-input-filter (str)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1098 (cond ((string-match "\\`\\s *\\'" str) nil) ;whitespace
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1099 ((not (eq major-mode 'prolog-inferior-mode)) t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1100 ((= (length str) 1) nil) ;one character
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1101 ((string-match "\\`[rf] *[0-9]*\\'" str) nil) ;r(edo) or f(ail)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1102 (t t)))
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
1103
258
1e0bc00dca7a *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 242
diff changeset
1104 ;;;###autoload
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1105 (defun run-prolog (arg)
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
1106 "Run an inferior Prolog process, input and output via buffer *prolog*.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1107 With prefix argument ARG, restart the Prolog process if running before."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1108 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1109 (if (and arg (get-process "prolog"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1110 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1111 (process-send-string "prolog" "halt.\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1112 (while (get-process "prolog") (sit-for 0.1))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1113 (let ((buff (buffer-name)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1114 (if (not (string= buff "*prolog*"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1115 (prolog-goto-prolog-process-buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1116 ;; Load SICStus debugger if suitable
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1117 (if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1118 (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1119 prolog-use-sicstus-sd)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1120 (prolog-enable-sicstus-sd))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1121 (prolog-mode-variables)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1122 (prolog-ensure-process)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1123 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1124
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1125 (defun prolog-ensure-process (&optional wait)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1126 "If Prolog process is not running, run it.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1127 If the optional argument WAIT is non-nil, wait for Prolog prompt specified by
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1128 the variable `prolog-prompt-regexp'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1129 (if (null prolog-program-name-i)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1130 (error "This Prolog system has defined no interpreter."))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1131 (if (comint-check-proc "*prolog*")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1132 ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1133 (apply 'make-comint "prolog" prolog-program-name-i nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1134 prolog-program-switches-i)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1135 (with-current-buffer "*prolog*"
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1136 (prolog-inferior-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1137 (if wait
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1138 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1139 (goto-char (point-max))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1140 (while
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1141 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1142 (not
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1143 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1144 (concat "\\(" prolog-prompt-regexp-i "\\)" "\\=")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1145 nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1146 (sit-for 0.1)))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1147
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1148 (defun prolog-process-insert-string (process string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1149 "Insert STRING into inferior Prolog buffer running PROCESS."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1150 ;; Copied from elisp manual, greek to me
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1151 (with-current-buffer (process-buffer process)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1152 ;; FIXME: Use window-point-insertion-type instead.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1153 (let ((moving (= (point) (process-mark process))))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1154 (save-excursion
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1155 ;; Insert the text, moving the process-marker.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1156 (goto-char (process-mark process))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1157 (insert string)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1158 (set-marker (process-mark process) (point)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1159 (if moving (goto-char (process-mark process))))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1160
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1161 ;;------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1162 ;; Old consulting and compiling functions
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1163 ;;------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1164
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1165 (defun prolog-old-process-region (compilep start end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1166 "Process the region limited by START and END positions.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1167 If COMPILEP is non-nil then use compilation, otherwise consulting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1168 (prolog-ensure-process)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1169 ;(let ((tmpfile prolog-temp-filename)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1170 (let ((tmpfile (prolog-bsts (prolog-temporary-file)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1171 ;(process (get-process "prolog"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1172 (first-line (1+ (count-lines
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1173 (point-min)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1174 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1175 (goto-char start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1176 (point))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1177 (write-region start end tmpfile)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1178 (process-send-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1179 "prolog" (prolog-build-prolog-command
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1180 compilep tmpfile (prolog-bsts buffer-file-name)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1181 first-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1182 (prolog-goto-prolog-process-buffer)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1183
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1184 (defun prolog-old-process-predicate (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1185 "Process the predicate around point.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1186 If COMPILEP is non-nil then use compilation, otherwise consulting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1187 (prolog-old-process-region
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1188 compilep (prolog-pred-start) (prolog-pred-end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1190 (defun prolog-old-process-buffer (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1191 "Process the entire buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1192 If COMPILEP is non-nil then use compilation, otherwise consulting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1193 (prolog-old-process-region compilep (point-min) (point-max)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1194
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1195 (defun prolog-old-process-file (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1196 "Process the file of the current buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1197 If COMPILEP is non-nil then use compilation, otherwise consulting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1198 (save-some-buffers)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1199 (prolog-ensure-process)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1200 (let ((filename (prolog-bsts buffer-file-name)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1201 (process-send-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1202 "prolog" (prolog-build-prolog-command
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1203 compilep filename filename))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1204 (prolog-goto-prolog-process-buffer)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1205
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1206
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1207 ;;------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1208 ;; Consulting and compiling
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1209 ;;------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1210
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1211 ;;; Interactive interface functions, used by both the standard
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1212 ;;; and the experimental consultation and compilation functions
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1213 (defun prolog-consult-file ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1214 "Consult file of current buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1215 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1216 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1217 (prolog-old-process-file nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1218 (prolog-consult-compile-file nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1219
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1220 (defun prolog-consult-buffer ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1221 "Consult buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1222 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1223 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1224 (prolog-old-process-buffer nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1225 (prolog-consult-compile-buffer nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1226
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1227 (defun prolog-consult-region (beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1228 "Consult region between BEG and END."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1229 (interactive "r")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1230 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1231 (prolog-old-process-region nil beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1232 (prolog-consult-compile-region nil beg end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1233
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1234 (defun prolog-consult-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1235 "Consult the predicate around current point."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1236 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1237 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1238 (prolog-old-process-predicate nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1239 (prolog-consult-compile-predicate nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1240
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1241 (defun prolog-compile-file ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1242 "Compile file of current buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1243 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1244 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1245 (prolog-old-process-file t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1246 (prolog-consult-compile-file t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1247
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1248 (defun prolog-compile-buffer ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1249 "Compile buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1250 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1251 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1252 (prolog-old-process-buffer t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1253 (prolog-consult-compile-buffer t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1254
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1255 (defun prolog-compile-region (beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1256 "Compile region between BEG and END."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1257 (interactive "r")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1258 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1259 (prolog-old-process-region t beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1260 (prolog-consult-compile-region t beg end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1261
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1262 (defun prolog-compile-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1263 "Compile the predicate around current point."
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
1264 (interactive)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1265 (if prolog-use-standard-consult-compile-method-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1266 (prolog-old-process-predicate t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1267 (prolog-consult-compile-predicate t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1268
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1269 (defun prolog-buffer-module ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1270 "Select Prolog module name appropriate for current buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1271 Bases decision on buffer contents (-*- line)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1272 ;; Look for -*- ... module: MODULENAME; ... -*-
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1273 (let (beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1274 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1275 (goto-char (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1276 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1277 (and (search-forward "-*-" (save-excursion (end-of-line) (point)) t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1278 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1279 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1280 (setq beg (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1281 (search-forward "-*-" (save-excursion (end-of-line) (point)) t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1282 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1283 (forward-char -3)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1284 (skip-chars-backward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1285 (setq end (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1286 (goto-char beg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1287 (and (let ((case-fold-search t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1288 (search-forward "module:" end t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1289 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1290 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1291 (setq beg (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1292 (if (search-forward ";" end t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1293 (forward-char -1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1294 (goto-char end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1295 (skip-chars-backward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1296 (buffer-substring beg (point)))))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1297
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1298 (defun prolog-build-prolog-command (compilep file buffername
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1299 &optional first-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1300 "Make Prolog command for FILE compilation/consulting.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1301 If COMPILEP is non-nil, consider compilation, otherwise consulting."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1302 (let* ((compile-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1303 (if compilep prolog-compile-string-i prolog-consult-string-i))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1304 (module (prolog-buffer-module))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1305 (file-name (concat "'" file "'"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1306 (module-name (if module (concat "'" module "'")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1307 (module-file (if module
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1308 (concat module-name ":" file-name)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1309 file-name))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1310 strbeg strend
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1311 (lineoffset (if first-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1312 (- first-line 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1313 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1314
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1315 ;; Assure that there is a buffer name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1316 (if (not buffername)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1317 (error "The buffer is not saved"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1318
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1319 (if (not (string-match "^'.*'$" buffername)) ; Add quotes
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1320 (setq buffername (concat "'" buffername "'")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1321 (while (string-match "%m" compile-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1322 (setq strbeg (substring compile-string 0 (match-beginning 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1323 (setq strend (substring compile-string (match-end 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1324 (setq compile-string (concat strbeg module-file strend)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1325 (while (string-match "%f" compile-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1326 (setq strbeg (substring compile-string 0 (match-beginning 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1327 (setq strend (substring compile-string (match-end 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1328 (setq compile-string (concat strbeg file-name strend)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1329 (while (string-match "%b" compile-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1330 (setq strbeg (substring compile-string 0 (match-beginning 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1331 (setq strend (substring compile-string (match-end 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1332 (setq compile-string (concat strbeg buffername strend)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1333 (while (string-match "%l" compile-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1334 (setq strbeg (substring compile-string 0 (match-beginning 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1335 (setq strend (substring compile-string (match-end 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1336 (setq compile-string (concat strbeg (format "%d" lineoffset) strend)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1337 (concat compile-string "\n")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1338
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1339 ;;; The rest of this page is experimental code!
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1340
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1341 ;; Global variables for process filter function
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1342 (defvar prolog-process-flag nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1343 "Non-nil means that a prolog task (i.e. a consultation or compilation job)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1344 is running.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1345 (defvar prolog-consult-compile-output ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1346 "Hold the unprocessed output from the current prolog task.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1347 (defvar prolog-consult-compile-first-line 1
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1348 "The number of the first line of the file to consult/compile.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1349 Used for temporary files.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1350 (defvar prolog-consult-compile-file nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1351 "The file to compile/consult (can be a temporary file).")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1352 (defvar prolog-consult-compile-real-file nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1353 "The file name of the buffer to compile/consult.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1354
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1355 (defun prolog-consult-compile (compilep file &optional first-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1356 "Consult/compile FILE.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1357 If COMPILEP is non-nil, perform compilation, otherwise perform CONSULTING.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1358 COMMAND is a string described by the variables `prolog-consult-string'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1359 and `prolog-compile-string'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1360 Optional argument FIRST-LINE is the number of the first line in the compiled
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1361 region.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1362
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1363 This function must be called from the source code buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1364 (if prolog-process-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1365 (error "Another Prolog task is running."))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1366 (prolog-ensure-process t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1367 (let* ((buffer (get-buffer-create prolog-compilation-buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1368 (real-file buffer-file-name)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1369 (command-string (prolog-build-prolog-command compilep file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1370 real-file first-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1371 (process (get-process "prolog"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1372 (old-filter (process-filter process)))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1373 (with-current-buffer buffer
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1374 (delete-region (point-min) (point-max))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1375 (compilation-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1376 ;; Setting up font-locking for this buffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1377 (make-local-variable 'font-lock-defaults)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1378 (setq font-lock-defaults
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1379 '(prolog-font-lock-keywords nil nil ((?_ . "w"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1380 (if (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1381 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1382 (make-local-variable 'compilation-parse-errors-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1383 (setq compilation-parse-errors-function
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1384 'prolog-parse-sicstus-compilation-errors)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1385 (toggle-read-only 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1386 (insert command-string "\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1387 (save-selected-window
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1388 (pop-to-buffer buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1389 (setq prolog-process-flag t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1390 prolog-consult-compile-output ""
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1391 prolog-consult-compile-first-line (if first-line (1- first-line) 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1392 prolog-consult-compile-file file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1393 prolog-consult-compile-real-file (if (string=
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1394 file buffer-file-name)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1395 nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1396 real-file))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1397 (with-current-buffer buffer
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1398 (goto-char (point-max))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1399 (set-process-filter process 'prolog-consult-compile-filter)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1400 (process-send-string "prolog" command-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1401 ;; (prolog-build-prolog-command compilep file real-file first-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1402 (while (and prolog-process-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1403 (accept-process-output process 10)) ; 10 secs is ok?
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1404 (sit-for 0.1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1405 (unless (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1406 (setq prolog-process-flag nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1407 (insert (if compilep
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1408 "\nCompilation finished.\n"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1409 "\nConsulted.\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1410 (set-process-filter process old-filter))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1411
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1412 (defun prolog-parse-sicstus-compilation-errors (limit)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1413 "Parse the prolog compilation buffer for errors.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1414 Argument LIMIT is a buffer position limiting searching.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1415 For use with the `compilation-parse-errors-function' variable."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1416 (setq compilation-error-list nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1417 (message "Parsing SICStus error messages...")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1418 (let (filepath dir file errorline)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1419 (while
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1420 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1421 "{\\([a-zA-Z ]* ERROR\\|Warning\\):.* in line[s ]*\\([0-9]+\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1422 limit t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1423 (setq errorline (string-to-number (match-string 2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1424 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1425 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1426 "{\\(consulting\\|compiling\\|processing\\) \\(.*\\)\\.\\.\\.}"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1427 limit t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1428 (setq filepath (match-string 2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1429
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1430 ;; ###### Does this work with SICStus under Windows (i.e. backslahes and stuff?)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1431 (if (string-match "\\(.*/\\)\\([^/]*\\)$" filepath)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1432 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1433 (setq dir (match-string 1 filepath))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1434 (setq file (match-string 2 filepath))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1435
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1436 (setq compilation-error-list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1437 (cons
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1438 (cons (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1439 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1440 (point-marker))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1441 (list (list file dir) errorline))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1442 compilation-error-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1443 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1444 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1445
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1446 (defun prolog-consult-compile-filter (process output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1447 "Filter function for Prolog compilation PROCESS.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1448 Argument OUTPUT is a name of the output file."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1449 ;;(message "start")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1450 (setq prolog-consult-compile-output
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1451 (concat prolog-consult-compile-output output))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1452 ;;(message "pccf1: %s" prolog-consult-compile-output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1453 ;; Iterate through the lines of prolog-consult-compile-output
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1454 (let (outputtype)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1455 (while (and prolog-process-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1456 (or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1457 ;; Trace question
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1458 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1459 (setq outputtype 'trace)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1460 (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1461 (string-match
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1462 "^[ \t]*[0-9]+[ \t]*[0-9]+[ \t]*Call:.*? "
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1463 prolog-consult-compile-output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1464
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1465 ;; Match anything
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1466 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1467 (setq outputtype 'normal)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1468 (string-match "^.*\n" prolog-consult-compile-output))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1469 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1470 ;;(message "outputtype: %s" outputtype)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1471
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1472 (setq output (match-string 0 prolog-consult-compile-output))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1473 ;; remove the text in output from prolog-consult-compile-output
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1474 (setq prolog-consult-compile-output
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1475 (substring prolog-consult-compile-output (length output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1476 ;;(message "pccf2: %s" prolog-consult-compile-output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1477
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1478 ;; If temporary files were used, then we change the error
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1479 ;; messages to point to the original source file.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1480 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1481
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1482 ;; If the prolog process was in trace mode then it requires
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1483 ;; user input
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1484 ((and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1485 (eq outputtype 'trace))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1486 (let (input)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1487 (setq input (concat (read-string output) "\n"))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
1488 (process-send-string process input)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1489 (setq output (concat output input))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1490
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1491 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1492 (if (and prolog-consult-compile-real-file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1493 (string-match
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1494 "\\({.*:.* in line[s ]*\\)\\([0-9]+\\)-\\([0-9]+\\)" output))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1495 (setq output (replace-match
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1496 ;; Adds a {processing ...} line so that
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1497 ;; `prolog-parse-sicstus-compilation-errors'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1498 ;; finds the real file instead of the temporary one.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1499 ;; Also fixes the line numbers.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1500 (format "Added by Emacs: {processing %s...}\n%s%d-%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1501 prolog-consult-compile-real-file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1502 (match-string 1 output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1503 (+ prolog-consult-compile-first-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1504 (string-to-number
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1505 (match-string 2 output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1506 (+ prolog-consult-compile-first-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1507 (string-to-number
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1508 (match-string 3 output))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1509 t t output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1510 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1511
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1512 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1513 (if (and prolog-consult-compile-real-file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1514 (string-match (format
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1515 "%s\\([ \t]*:[ \t]*\\)\\([0-9]+\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1516 prolog-consult-compile-file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1517 output))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1518 (setq output (replace-match
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1519 ;; Real filename + text + fixed linenum
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1520 (format "%s%s%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1521 prolog-consult-compile-real-file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1522 (match-string 1 output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1523 (+ prolog-consult-compile-first-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1524 (string-to-number
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1525 (match-string 2 output))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1526 t t output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1527 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1528
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1529 (t ())
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1530 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1531 ;; Write the output in the *prolog-compilation* buffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1532 (insert output)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1533
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1534 ;; If the prompt is visible, then the task is finished
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1535 (if (string-match prolog-prompt-regexp-i prolog-consult-compile-output)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1536 (setq prolog-process-flag nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1537
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1538 (defun prolog-consult-compile-file (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1539 "Consult/compile file of current buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1540 If COMPILEP is non-nil, compile, otherwise consult."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1541 (let ((file buffer-file-name))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1542 (if file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1543 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1544 (save-some-buffers)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1545 (prolog-consult-compile compilep file))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1546 (prolog-consult-compile-region compilep (point-min) (point-max)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1547
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1548 (defun prolog-consult-compile-buffer (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1549 "Consult/compile current buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1550 If COMPILEP is non-nil, compile, otherwise consult."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1551 (prolog-consult-compile-region compilep (point-min) (point-max)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1552
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1553 (defun prolog-consult-compile-region (compilep beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1554 "Consult/compile region between BEG and END.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1555 If COMPILEP is non-nil, compile, otherwise consult."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1556 ;(let ((file prolog-temp-filename)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1557 (let ((file (prolog-bsts (prolog-temporary-file)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1558 (lines (count-lines 1 beg)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1559 (write-region beg end file nil 'no-message)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1560 (write-region "\n" nil file t 'no-message)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1561 (prolog-consult-compile compilep file
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1562 (if (looking-at "^") (1+ lines) lines))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1563 (delete-file file)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1564
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1565 (defun prolog-consult-compile-predicate (compilep)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1566 "Consult/compile the predicate around current point.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1567 If COMPILEP is non-nil, compile, otherwise consult."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1568 (prolog-consult-compile-region
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1569 compilep (prolog-pred-start) (prolog-pred-end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1570
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1571
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1572 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1573 ;; Font-lock stuff
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1574 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1575
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1576 ;; Auxilliary functions
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1577 (defun prolog-make-keywords-regexp (keywords &optional protect)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1578 "Create regexp from the list of strings KEYWORDS.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1579 If PROTECT is non-nil, surround the result regexp by word breaks."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1580 (let ((regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1581 (if (fboundp 'regexp-opt)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1582 ;; Emacs 20
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1583 ;; Avoid compile warnings under earlier versions by using eval
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1584 (eval '(regexp-opt keywords))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1585 ;; Older Emacsen
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1586 (concat (mapconcat 'regexp-quote keywords "\\|")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1587 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1588 (if protect
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1589 (concat "\\<\\(" regexp "\\)\\>")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1590 regexp)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1591
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1592 (defun prolog-font-lock-object-matcher (bound)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1593 "Find SICStus objects method name for font lock.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1594 Argument BOUND is a buffer position limiting searching."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1595 (let (point
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1596 (case-fold-search nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1597 (while (and (not point)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1598 (re-search-forward "\\(::[ \t\n]*{\\|&\\)[ \t]*"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1599 bound t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1600 (while (or (re-search-forward "\\=\n[ \t]*" bound t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1601 (re-search-forward "\\=%.*" bound t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1602 (and (re-search-forward "\\=/\\*" bound t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1603 (re-search-forward "\\*/[ \t]*" bound t))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1604 (setq point (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1605 (format "\\=\\(%s\\)" prolog-atom-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1606 bound t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1607 point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1608
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1609 (defsubst prolog-face-name-p (facename)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1610 ;; Return t if FACENAME is the name of a face. This method is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1611 ;; necessary since facep in XEmacs only returns t for the actual
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1612 ;; face objects (while it's only their names that are used just
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1613 ;; about anywhere else) without providing a predicate that tests
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1614 ;; face names. This function (including the above commentary) is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1615 ;; borrowed from cc-mode.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1616 (memq facename (face-list)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1617
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1618 ;; Set everything up
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1619 (defun prolog-font-lock-keywords ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1620 "Set up font lock keywords for the current Prolog system."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1621 ;(when window-system
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1622 (require 'font-lock)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1623
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1624 ;; Define Prolog faces
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1625 (defface prolog-redo-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1626 '((((class grayscale)) (:italic t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1627 (((class color)) (:foreground "darkorchid"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1628 (t (:italic t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1629 "Prolog mode face for highlighting redo trace lines."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1630 :group 'prolog-faces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1631 (defface prolog-exit-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1632 '((((class grayscale)) (:underline t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1633 (((class color) (background dark)) (:foreground "green"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1634 (((class color) (background light)) (:foreground "ForestGreen"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1635 (t (:underline t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1636 "Prolog mode face for highlighting exit trace lines."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1637 :group 'prolog-faces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1638 (defface prolog-exception-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1639 '((((class grayscale)) (:bold t :italic t :underline t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1640 (((class color)) (:bold t :foreground "black" :background "Khaki"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1641 (t (:bold t :italic t :underline t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1642 "Prolog mode face for highlighting exception trace lines."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1643 :group 'prolog-faces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1644 (defface prolog-warning-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1645 '((((class grayscale)) (:underline t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1646 (((class color) (background dark)) (:foreground "blue"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1647 (((class color) (background light)) (:foreground "MidnightBlue"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1648 (t (:underline t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1649 "Face name to use for compiler warnings."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1650 :group 'prolog-faces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1651 (defface prolog-builtin-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1652 '((((class color) (background light)) (:foreground "Purple"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1653 (((class color) (background dark)) (:foreground "Cyan"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1654 (((class grayscale) (background light)) (:foreground "LightGray" :bold t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1655 (((class grayscale) (background dark)) (:foreground "DimGray" :bold t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1656 (t (:bold t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1657 "Face name to use for compiler warnings."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1658 :group 'prolog-faces)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1659 (defvar prolog-warning-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1660 (if (prolog-face-name-p 'font-lock-warning-face)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1661 'font-lock-warning-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1662 'prolog-warning-face)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1663 "Face name to use for built in predicates.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1664 (defvar prolog-builtin-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1665 (if (prolog-face-name-p 'font-lock-builtin-face)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1666 'font-lock-builtin-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1667 'prolog-builtin-face)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1668 "Face name to use for built in predicates.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1669 (defvar prolog-redo-face 'prolog-redo-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1670 "Face name to use for redo trace lines.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1671 (defvar prolog-exit-face 'prolog-exit-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1672 "Face name to use for exit trace lines.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1673 (defvar prolog-exception-face 'prolog-exception-face
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1674 "Face name to use for exception trace lines.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1675
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1676 ;; Font Lock Patterns
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1677 (let (
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1678 ;; "Native" Prolog patterns
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1679 (head-predicates
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1680 (list (format "^\\(%s\\)\\((\\|[ \t]*:-\\)" prolog-atom-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1681 1 font-lock-function-name-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1682 ;(list (format "^%s" prolog-atom-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1683 ; 0 font-lock-function-name-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1684 (head-predicates-1
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1685 (list (format "\\.[ \t]*\\(%s\\)" prolog-atom-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1686 1 font-lock-function-name-face) )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1687 (variables
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1688 '("\\<\\([_A-Z][a-zA-Z0-9_]*\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1689 1 font-lock-variable-name-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1690 (important-elements
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1691 (list (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1692 "[][}{;|]\\|\\\\[+=]\\|<?=>?"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1693 "[][}{!;|]\\|\\*->")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1694 0 'font-lock-keyword-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1695 (important-elements-1
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1696 '("[^-*]\\(->\\)" 1 font-lock-keyword-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1697 (predspecs ; module:predicate/cardinality
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1698 (list (format "\\<\\(%s:\\|\\)%s/[0-9]+"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1699 prolog-atom-regexp prolog-atom-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1700 0 font-lock-function-name-face 'prepend))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1701 (keywords ; directives (queries)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1702 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1703 (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1704 (concat
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1705 "\\<\\("
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1706 (prolog-make-keywords-regexp prolog-keywords-i)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1707 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1708 (prolog-make-keywords-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1709 prolog-determinism-specificators-i)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1710 "\\)\\>")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1711 (concat
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1712 "^[?:]- *\\("
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1713 (prolog-make-keywords-regexp prolog-keywords-i)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1714 "\\)\\>"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1715 1 prolog-builtin-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1716 (quoted_atom (list prolog-quoted-atom-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1717 2 'font-lock-string-face 'append))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1718 (string (list prolog-string-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1719 1 'font-lock-string-face 'append))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1720 ;; SICStus specific patterns
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1721 (sicstus-object-methods
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1722 (if (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1723 '(prolog-font-lock-object-matcher
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1724 1 font-lock-function-name-face)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1725 ;; Mercury specific patterns
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1726 (types
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1727 (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1728 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1729 (prolog-make-keywords-regexp prolog-types-i t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1730 0 'font-lock-type-face)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1731 (modes
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1732 (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1733 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1734 (prolog-make-keywords-regexp prolog-mode-specificators-i t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1735 0 'font-lock-reference-face)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1736 (directives
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1737 (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1738 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1739 (prolog-make-keywords-regexp prolog-directives-i t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1740 0 'prolog-warning-face)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1741 ;; Inferior mode specific patterns
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1742 (prompt
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1743 (list prolog-prompt-regexp-i 0 'font-lock-keyword-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1744 (trace-exit
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1745 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1746 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1747 '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exit\\):"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1748 1 prolog-exit-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1749 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1750 '("[ \t]*\\(Exit\\):[ \t]*([ \t0-9]*)" 1 prolog-exit-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1751 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1752 (trace-fail
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1753 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1754 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1755 '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Fail\\):"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1756 1 prolog-warning-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1757 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1758 '("[ \t]*\\(Fail\\):[ \t]*([ \t0-9]*)" 1 prolog-warning-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1759 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1760 (trace-redo
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1761 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1762 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1763 '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Redo\\):"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1764 1 prolog-redo-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1765 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1766 '("[ \t]*\\(Redo\\):[ \t]*([ \t0-9]*)" 1 prolog-redo-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1767 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1768 (trace-call
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1769 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1770 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1771 '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Call\\):"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1772 1 font-lock-function-name-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1773 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1774 '("[ \t]*\\(Call\\):[ \t]*([ \t0-9]*)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1775 1 font-lock-function-name-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1776 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1777 (trace-exception
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1778 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1779 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1780 '("[ \t]*[0-9]+[ \t]+[0-9]+[ \t]*\\(Exception\\):"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1781 1 prolog-exception-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1782 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1783 '("[ \t]*\\(Exception\\):[ \t]*([ \t0-9]*)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1784 1 prolog-exception-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1785 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1786 (error-message-identifier
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1787 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1788 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1789 '("{\\([A-Z]* ?ERROR:\\)" 1 prolog-exception-face prepend))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1790 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1791 '("^[[]\\(WARNING:\\)" 1 prolog-builtin-face prepend))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1792 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1793 (error-whole-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1794 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1795 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1796 '("{\\([A-Z]* ?ERROR:.*\\)}[ \t]*$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1797 1 font-lock-comment-face append))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1798 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1799 '("^[[]WARNING:[^]]*[]]$" 0 font-lock-comment-face append))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1800 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1801 (error-warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1802 ;; Mostly errors that SICStus asks the user about how to solve,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1803 ;; such as "NAME CLASH:" for example.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1804 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1805 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1806 '("^[A-Z ]*[A-Z]+:" 0 prolog-warning-face))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1807 (t nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1808 (warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1809 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1810 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1811 '("\\({ ?\\(Warning\\|WARNING\\) ?:.*}\\)[ \t]*$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1812 2 prolog-warning-face prepend))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1813 (t nil))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1814
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1815 ;; Make font lock list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1816 (delq
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1817 nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1818 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1819 ((eq major-mode 'prolog-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1820 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1821 head-predicates
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1822 head-predicates-1
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1823 quoted_atom
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1824 string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1825 variables
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1826 important-elements
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1827 important-elements-1
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1828 predspecs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1829 keywords
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1830 sicstus-object-methods
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1831 types
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1832 modes
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1833 directives))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1834 ((eq major-mode 'prolog-inferior-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1835 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1836 prompt
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1837 error-message-identifier
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1838 error-whole-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1839 error-warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1840 warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1841 predspecs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1842 trace-exit
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1843 trace-fail
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1844 trace-redo
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1845 trace-call
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1846 trace-exception))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1847 ((eq major-mode 'compilation-mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1848 (list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1849 error-message-identifier
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1850 error-whole-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1851 error-warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1852 warning-messages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1853 predspecs))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1854 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1855
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1856
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1857 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1858 ;; Indentation stuff
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1859 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1860
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1861 ;; NB: This function *MUST* have this optional argument since XEmacs
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1862 ;; assumes it. This does not mean we have to use it...
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1863 (defun prolog-indent-line (&optional whole-exp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1864 "Indent current line as Prolog code.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1865 With argument, indent any additional lines of the same clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1866 rigidly along with this one (not yet)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1867 (interactive "p")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1868 (let ((indent (prolog-indent-level))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1869 (pos (- (point-max) (point))) beg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1870 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1871 (setq beg (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1872 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1873 (if (zerop (- indent (current-column)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1874 nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1875 (delete-region beg (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1876 (indent-to indent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1877 (if (> (- (point-max) pos) (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1878 (goto-char (- (point-max) pos)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1879
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1880 ;; Align comments
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1881 (if prolog-align-comments-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1882 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1883 (prolog-goto-comment-column t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1884
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1885 ;; Insert spaces if needed
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1886 (if (or prolog-electric-tab-flag prolog-electric-if-then-else-flag)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1887 (prolog-insert-spaces-after-paren))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1888 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1889
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1890 (defun prolog-comment-indent ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1891 "Compute prolog comment indentation."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1892 (cond ((looking-at "%%%") (prolog-indentation-level-of-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1893 ((looking-at "%%") (prolog-indent-level))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1894 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1895 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1896 (skip-chars-backward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1897 ;; Insert one space at least, except at left margin.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1898 (max (+ (current-column) (if (bolp) 0 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1899 comment-column)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1900 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1901
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1902 (defun prolog-indent-level ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1903 "Compute prolog indentation level."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1904 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1905 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1906 (let ((totbal (prolog-region-paren-balance
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1907 (prolog-clause-start t) (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1908 (oldpoint (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1909 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1910 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1911 ((looking-at "%%%") (prolog-indentation-level-of-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1912 ;Large comment starts
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1913 ((looking-at "%[^%]") comment-column) ;Small comment starts
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1914 ((bobp) 0) ;Beginning of buffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1915
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1916 ;; If we found '}' then we must check if it's the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1917 ;; end of an object declaration or something else.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1918 ((and (looking-at "}")
72696
560a2e73e11b (inferior-prolog-flavor): New var left out of previous commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 72684
diff changeset
1919 (save-excursion
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1920 (forward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1921 ;; Goto to matching {
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1922 (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1923 (prolog-backward-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1924 (backward-list))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1925 (skip-chars-backward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1926 (backward-char 2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1927 (looking-at "::")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1928 ;; It was an object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1929 (if prolog-object-end-to-0-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1930 0
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1931 prolog-indent-width))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1932
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1933 ;;End of /* */ comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1934 ((looking-at "\\*/")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1935 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1936 (prolog-find-start-of-mline-comment)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1937 (skip-chars-backward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1938 (- (current-column) 2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1939
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1940 ;; Here we check if the current line is within a /* */ pair
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1941 ((and (looking-at "[^%/]")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1942 (eq (prolog-in-string-or-comment) 'cmt))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1943 (if prolog-indent-mline-comments-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1944 (prolog-find-start-of-mline-comment)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1945 ;; Same as before
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1946 (prolog-indentation-level-of-line)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1947
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1948 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1949 (let ((empty t) ind linebal)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1950 ;; See previous indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1951 (while empty
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1952 (forward-line -1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1953 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1954 (if (= (point) (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1955 (setq empty nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1956 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1957 (if (not (or (not (member (prolog-in-string-or-comment) '(nil txt)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1958 (looking-at "%")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1959 (looking-at "\n")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1960 (setq empty nil))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1961
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1962 ;; Store this line's indentation
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1963 (if (= (point) (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1964 (setq ind 0) ;Beginning of buffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1965 (setq ind (current-column))) ;Beginning of clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1966
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1967 ;; Compute the balance of the line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1968 (setq linebal (prolog-paren-balance))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1969 ;;(message "bal of previous line %d totbal %d" linebal totbal)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1970 (if (< linebal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1971 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1972 ;; Add 'indent-level' mode to find-unmatched-paren instead?
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1973 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1974 (setq ind (prolog-find-indent-of-matching-paren))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1975
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1976 ;;(message "ind %d" ind)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1977 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1978
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1979 ;; Check if the line ends with ":-", ".", ":: {", "}" (might be
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1980 ;; unnecessary), "&" or ")" (The last four concerns SICStus objects)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1981 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1982 ;; If the last char of the line is a '&' then set the indent level
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1983 ;; to prolog-indent-width (used in SICStus objects)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1984 ((and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1985 (looking-at ".+&[ \t]*\\(%.*\\|\\)$"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1986 (setq ind prolog-indent-width))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1987
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1988 ;; Increase indentation if the previous line was the head of a rule
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1989 ;; and does not contain a '.'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1990 ((and (looking-at (format ".*%s[^\\.]*[ \t]*\\(%%.*\\|\\)$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1991 prolog-head-delimiter))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1992 ;; We must check that the match is at a paren balance of 0.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1993 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1994 (let ((p (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1995 (re-search-forward prolog-head-delimiter)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1996 (>= 0 (prolog-region-paren-balance p (point))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1997 (let (headindent)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1998 (if (< (prolog-paren-balance) 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
1999 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2000 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2001 (setq headindent (prolog-find-indent-of-matching-paren)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2002 (setq headindent (prolog-indentation-level-of-line)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2003 (setq ind (+ headindent prolog-indent-width))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2004
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2005 ;; The previous line was the head of an object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2006 ((looking-at ".+ *::.*{[ \t]*$")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2007 (setq ind prolog-indent-width))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2008
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2009 ;; If a '.' is found at the end of the previous line, then
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2010 ;; decrease the indentation. (The \\(%.*\\|\\) part of the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2011 ;; regexp is for comments at the end of the line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2012 ((and (looking-at "^.+\\.[ \t]*\\(%.*\\|\\)$")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2013 ;; Make sure that the '.' found is not in a comment or string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2014 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2015 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2016 (re-search-backward "\\.[ \t]*\\(%.*\\|\\)$" (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2017 ;; Guard against the real '.' being followed by a
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2018 ;; commented '.'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2019 (if (eq (prolog-in-string-or-comment) 'cmt) ;; commented out '.'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2020 (let ((here (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2021 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2022 (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2023 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2024 (re-search-backward "\\.[ \t]*%.*$" here t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2025 (not (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2026 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2027 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2028 (setq ind 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2029
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2030 ;; If a '.' is found at the end of the previous line, then
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2031 ;; decrease the indentation. (The /\\*.*\\*/ part of the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2032 ;; regexp is for C-like comments at the end of the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2033 ;; line--can we merge with the case above?).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2034 ((and (looking-at "^.+\\.[ \t]*\\(/\\*.*\\|\\)$")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2035 ;; Make sure that the '.' found is not in a comment or string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2036 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2037 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2038 (re-search-backward "\\.[ \t]*\\(/\\*.*\\|\\)$" (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2039 ;; Guard against the real '.' being followed by a
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2040 ;; commented '.'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2041 (if (eq (prolog-in-string-or-comment) 'cmt) ;; commented out '.'
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2042 (let ((here (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2043 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2044 (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2045 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2046 (re-search-backward "\\.[ \t]*/\\*.*$" here t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2047 (not (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2048 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2049 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2050 (setq ind 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2051
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2052 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2053
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2054 ;; If the last non comment char is a ',' or left paren or a left-
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2055 ;; indent-regexp then indent to open parenthesis level
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2056 (if (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2057 (> totbal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2058 ;; SICStus objects have special syntax rules if point is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2059 ;; not inside additional parens (objects are defined
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2060 ;; within {...})
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2061 (not (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2062 (= totbal 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2063 (prolog-in-object))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2064 (if (looking-at
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2065 (format "\\(%s\\|%s\\|0'.\\|[0-9]+'[0-9a-zA-Z]+\\|[^\n\'\"%%]\\)*\\(,\\|%s\\|%s\\)\[ \t]*\\(%%.*\\|\\)$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2066 prolog-quoted-atom-regexp prolog-string-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2067 prolog-left-paren prolog-left-indent-regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2068 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2069 (goto-char oldpoint)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2070 (setq ind (prolog-find-unmatched-paren (if prolog-paren-indent-p
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2071 'termdependent
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2072 'skipwhite)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2073 ;;(setq ind (prolog-find-unmatched-paren 'termdependent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2074 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2075 (goto-char oldpoint)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2076 (setq ind (prolog-find-unmatched-paren nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2077 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2078
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2079
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2080 ;; Return the indentation level
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2081 ind
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2082 ))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2083
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2084 (defun prolog-find-indent-of-matching-paren ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2085 "Find the indentation level based on the matching parenthesis.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2086 Indentation level is set to the one the point is after when the function is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2087 called."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2088 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2089 ;; Go to the matching paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2090 (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2091 (prolog-backward-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2092 (backward-list))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2093
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2094 ;; If this was the first paren on the line then return this line's
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2095 ;; indentation level
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2096 (if (prolog-paren-is-the-first-on-line-p)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2097 (prolog-indentation-level-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2098 ;; It was not the first one
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2099 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2100 ;; Find the next paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2101 (prolog-goto-next-paren 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2102
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2103 ;; If this paren is a left one then use its column as indent level,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2104 ;; if not then recurse this function
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2105 (if (looking-at prolog-left-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2106 (+ (current-column) 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2107 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2108 (forward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2109 (prolog-find-indent-of-matching-paren)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2110 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2111 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2112
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2113 (defun prolog-indentation-level-of-line ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2114 "Return the indentation level of the current line."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2115 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2116 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2117 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2118 (current-column)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2119
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2120 (defun prolog-first-pos-on-line ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2121 "Return the first position on the current line."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2122 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2123 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2124 (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2125
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2126 (defun prolog-paren-is-the-first-on-line-p ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2127 "Return t if the parenthesis under the point is the first one on the line.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2128 Return nil otherwise.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2129 Note: does not check if the point is actually at a parenthesis!"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2130 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2131 (let ((begofline (prolog-first-pos-on-line)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2132 (if (= begofline (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2133 t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2134 (if (prolog-goto-next-paren begofline)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2135 nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2136 t)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2137
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2138 (defun prolog-find-unmatched-paren (&optional mode)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2139 "Return the column of the last unmatched left parenthesis.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2140 If MODE is `skipwhite' then any white space after the parenthesis is added to
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2141 the answer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2142 If MODE is `plusone' then the parenthesis' column +1 is returned.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2143 If MODE is `termdependent' then if the unmatched parenthesis is part of
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2144 a compound term the function will work as `skipwhite', otherwise
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2145 it will return the column paren plus the value of `prolog-paren-indent'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2146 If MODE is nil or not set then the parenthesis' exact column is returned."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2147 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2148 ;; If the next paren we find is a left one we're finished, if it's
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2149 ;; a right one then we go back one step and recurse
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2150 (prolog-goto-next-paren 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2151
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2152 (let ((roundparen (looking-at "(")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2153 (if (looking-at prolog-left-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2154 (let ((not-part-of-term
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2155 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2156 (backward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2157 (looking-at "[ \t]"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2158 (if (eq mode nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2159 (current-column)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2160 (if (and roundparen
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2161 (eq mode 'termdependent)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2162 not-part-of-term)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2163 (+ (current-column)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2164 (if prolog-electric-tab-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2165 ;; Electric TAB
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2166 prolog-paren-indent
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2167 ;; Not electric TAB
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2168 (if (looking-at ".[ \t]*$")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2169 2
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2170 prolog-paren-indent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2171 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2172
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2173 (forward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2174 (if (or (eq mode 'skipwhite) (eq mode 'termdependent) )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2175 (skip-chars-forward " \t"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2176 (current-column))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2177 ;; Not looking at left paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2178 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2179 (forward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2180 ;; Go to the matching paren. When we get there we have a total
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2181 ;; balance of 0.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2182 (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2183 (prolog-backward-list)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2184 (backward-list))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2185 (prolog-find-unmatched-paren mode)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2186 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2187
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2188
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2189 (defun prolog-paren-balance ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2190 "Return the parenthesis balance of the current line.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2191 A return value of n means n more left parentheses than right ones."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2192 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2193 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2194 (prolog-region-paren-balance (prolog-first-pos-on-line) (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2195
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2196 (defun prolog-region-paren-balance (beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2197 "Return the summed parenthesis balance in the region.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2198 The region is limited by BEG and END positions."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2199 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2200 (let ((state (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2201 (prolog-tokenize beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2202 (parse-partial-sexp beg end))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2203 (nth 0 state))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2204
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2205 (defun prolog-goto-next-paren (limit-pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2206 "Move the point to the next parenthesis earlier in the buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2207 Return t if a match was found before LIMIT-POS. Return nil otherwise."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2208 (let (retval)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2209 (setq retval (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2210 (concat prolog-left-paren "\\|" prolog-right-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2211 limit-pos t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2212
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2213 ;; If a match was found but it was in a string or comment, then recurse
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2214 (if (and retval (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2215 (prolog-goto-next-paren limit-pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2216 retval)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2217 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2218
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2219 (defun prolog-in-string-or-comment ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2220 "Check whether string, atom, or comment is under current point.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2221 Return:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2222 `txt' if the point is in a string, atom, or character code expression
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2223 `cmt' if the point is in a comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2224 nil otherwise."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2225 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2226 (let* ((start
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2227 (if (eq prolog-parse-mode 'beg-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2228 ;; 'beg-of-line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2229 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2230 (let (safepoint)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2231 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2232 (setq safepoint (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2233 (while (and (> (point) (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2234 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2235 (forward-line -1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2236 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2237 (if (not (bobp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2238 (backward-char 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2239 (looking-at "\\\\"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2240 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2241 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2242 (setq safepoint (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2243 safepoint))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2244 ;; 'beg-of-clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2245 (prolog-clause-start)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2246 (end (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2247 (state (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2248 (prolog-tokenize start end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2249 (parse-partial-sexp start end))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2250 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2251 ((nth 3 state) 'txt) ; String
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2252 ((nth 4 state) 'cmt) ; Comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2253 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2254 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2255 ((looking-at "%") 'cmt) ; Start of a comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2256 ((looking-at "/\\*") 'cmt) ; Start of a comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2257 ((looking-at "\'") 'txt) ; Start of an atom
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2258 ((looking-at "\"") 'txt) ; Start of a string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2259 (t nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2260 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2261 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2262
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2263 (defun prolog-find-start-of-mline-comment ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2264 "Return the start column of a /* */ comment.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2265 This assumes that the point is inside a comment."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2266 (re-search-backward "/\\*" (point-min) t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2267 (forward-char 2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2268 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2269 (current-column))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2270
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2271 (defun prolog-insert-spaces-after-paren ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2272 "Insert spaces after the opening parenthesis, \"then\" (->) and \"else\" (;) branches.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2273 Spaces are inserted if all preceding objects on the line are
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2274 whitespace characters, parentheses, or then/else branches."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2275 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2276 (let ((regexp (concat "(\\|" prolog-left-indent-regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2277 level)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2278 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2279 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2280 (when (looking-at regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2281 ;; Treat "( If -> " lines specially.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2282 ;;(if (looking-at "(.*->")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2283 ;; (setq incr 2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2284 ;; (setq incr prolog-paren-indent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2285
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2286 ;; work on all subsequent "->", "(", ";"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2287 (while (looking-at regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2288 (goto-char (match-end 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2289 (setq level (+ (prolog-find-unmatched-paren) prolog-paren-indent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2290
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2291 ;; Remove old white space
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2292 (let ((start (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2293 (skip-chars-forward " \t")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2294 (delete-region start (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2295 (indent-to level)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2296 (skip-chars-forward " \t"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2297 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2298 (when (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2299 (backward-char 2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2300 (looking-at "\\s ;\\|\\s (\\|->")) ; (looking-at "\\s \\((\\|;\\)"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2301 (skip-chars-forward " \t"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2302 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2303
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2304 ;;;; Comment filling
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2305
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2306 (defun prolog-comment-limits ()
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2307 "Return the current comment limits plus the comment type (block or line).
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2308 The comment limits are the range of a block comment or the range that
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2309 contains all adjacent line comments (i.e. all comments that starts in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2310 the same column with no empty lines or non-whitespace characters
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2311 between them)."
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2312 (let ((here (point))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2313 lit-limits-b lit-limits-e lit-type beg end
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2314 )
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2315 (save-restriction
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2316 ;; Widen to catch comment limits correctly.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2317 (widen)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2318 (setq end (save-excursion (end-of-line) (point))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2319 beg (save-excursion (beginning-of-line) (point)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2320 (save-excursion
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2321 (beginning-of-line)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2322 (setq lit-type (if (search-forward-regexp "%" end t) 'line 'block))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2323 ; (setq lit-type 'line)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2324 ;(if (search-forward-regexp "^[ \t]*%" end t)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2325 ; (setq lit-type 'line)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2326 ; (if (not (search-forward-regexp "%" end t))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2327 ; (setq lit-type 'block)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2328 ; (if (not (= (forward-line 1) 0))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2329 ; (setq lit-type 'block)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2330 ; (setq done t
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2331 ; ret (prolog-comment-limits)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2332 ; ))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2333 (if (eq lit-type 'block)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2334 (progn
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2335 (goto-char here)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2336 (when (looking-at "/\\*") (forward-char 2))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2337 (when (and (looking-at "\\*") (> (point) (point-min))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2338 (forward-char -1) (looking-at "/"))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2339 (forward-char 1))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2340 (when (save-excursion (search-backward "/*" nil t))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2341 (list (save-excursion (search-backward "/*") (point))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2342 (or (search-forward "*/" nil t) (point-max)) lit-type)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2343 ;; line comment
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2344 (setq lit-limits-b (- (point) 1)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2345 lit-limits-e end)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2346 (condition-case nil
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2347 (if (progn (goto-char lit-limits-b)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2348 (looking-at "%"))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2349 (let ((col (current-column)) done)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2350 (setq beg (point)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2351 end lit-limits-e)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2352 ;; Always at the beginning of the comment
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2353 ;; Go backward now
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2354 (beginning-of-line)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2355 (while (and (zerop (setq done (forward-line -1)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2356 (search-forward-regexp "^[ \t]*%" (save-excursion (end-of-line) (point)) t)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2357 (= (+ 1 col) (current-column)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2358 (setq beg (- (point) 1)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2359 (when (= done 0)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2360 (forward-line 1))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2361 ;; We may have a line with code above...
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2362 (when (and (zerop (setq done (forward-line -1)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2363 (search-forward "%" (save-excursion (end-of-line) (point)) t)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2364 (= (+ 1 col) (current-column)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2365 (setq beg (- (point) 1)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2366 (when (= done 0)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2367 (forward-line 1))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2368 ;; Go forward
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2369 (goto-char lit-limits-b)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2370 (beginning-of-line)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2371 (while (and (zerop (forward-line 1))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2372 (search-forward-regexp "^[ \t]*%" (save-excursion (end-of-line) (point)) t)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2373 (= (+ 1 col) (current-column)))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2374 (setq end (save-excursion (end-of-line) (point))))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2375 (list beg end lit-type))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2376 (list lit-limits-b lit-limits-e lit-type)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2377 )
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2378 (error (list lit-limits-b lit-limits-e lit-type))))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2379 ))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2380
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2381 (defun prolog-guess-fill-prefix ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2382 ;; fill 'txt entities?
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2383 (when (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2384 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2385 (equal (prolog-in-string-or-comment) 'cmt))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2386 (let* ((bounds (prolog-comment-limits))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2387 (cbeg (car bounds))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2388 (type (nth 2 bounds))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2389 beg end)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2390 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2391 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2392 (setq end (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2393 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2394 (setq beg (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2395 (if (and (eq type 'line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2396 (> cbeg beg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2397 (save-excursion (not (search-forward-regexp "^[ \t]*%"
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2398 cbeg t))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2399 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2400 (goto-char cbeg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2401 (search-forward-regexp "%+[ \t]*" end t)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2402 (prolog-replace-in-string (buffer-substring beg (point))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2403 "[^ \t%]" " "))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2404 ;(goto-char beg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2405 (if (search-forward-regexp "^[ \t]*\\(%+\\|\\*+\\|/\\*+\\)[ \t]*"
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2406 end t)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2407 (prolog-replace-in-string (buffer-substring beg (point)) "/" " ")
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2408 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2409 (when (search-forward-regexp "^[ \t]+" end t)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2410 (buffer-substring beg (point)))))))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2411
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2412 (defun prolog-fill-paragraph ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2413 "Fill paragraph comment at or after point."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2414 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2415 (let* ((bounds (prolog-comment-limits))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2416 (type (nth 2 bounds)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2417 (if (eq type 'line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2418 (let ((fill-prefix (prolog-guess-fill-prefix)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2419 (fill-paragraph nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2420 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2421 (save-restriction
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2422 ;; exclude surrounding lines that delimit a multiline comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2423 ;; and don't contain alphabetic characters, like "/*******",
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2424 ;; "- - - */" etc.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2425 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2426 (backward-paragraph)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2427 (unless (bobp) (forward-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2428 (if (string-match "^/\\*[^a-zA-Z]*$" (thing-at-point 'line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2429 (narrow-to-region (point-at-eol) (point-max))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2430 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2431 (forward-paragraph)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2432 (forward-line -1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2433 (if (string-match "^[^a-zA-Z]*\\*/$" (thing-at-point 'line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2434 (narrow-to-region (point-min) (point-at-bol))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2435 (let ((fill-prefix (prolog-guess-fill-prefix)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2436 (fill-paragraph nil))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2437 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2438
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2439 (defun prolog-do-auto-fill ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2440 "Carry out Auto Fill for Prolog mode.
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2441 In effect it sets the `fill-prefix' when inside comments and then calls
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2442 `do-auto-fill'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2443 (let ((fill-prefix (prolog-guess-fill-prefix)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2444 (do-auto-fill)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2445 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2446
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2447 (defalias 'prolog-replace-in-string
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2448 (if (fboundp 'replace-in-string)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2449 #'replace-in-string
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2450 (lambda (str regexp newtext &optional literal)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2451 (replace-regexp-in-string regexp newtext str nil literal))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2452
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2453 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2454 ;; The tokenizer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2455 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2456
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2457 (defconst prolog-tokenize-searchkey
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2458 (concat "[0-9]+'"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2459 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2460 "['\"]"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2461 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2462 prolog-left-paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2463 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2464 prolog-right-paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2465 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2466 "%"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2467 "\\|"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2468 "/\\*"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2469 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2470
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2471 (defun prolog-tokenize (beg end &optional stopcond)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2472 "Tokenize a region of prolog code between BEG and END.
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2473 STOPCOND decides the stop condition of the parsing. Valid values
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2474 are 'zerodepth which stops the parsing at the first right parenthesis
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2475 where the parenthesis depth is zero, 'skipover which skips over
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2476 the current entity (e.g. a list, a string, etc.) and nil.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2477
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2478 The function returns a list with the following information:
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2479 0. parenthesis depth
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2480 3. 'atm if END is inside an atom
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2481 'str if END is inside a string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2482 'chr if END is in a character code expression (0'x)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2483 nil otherwise
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2484 4. non-nil if END is inside a comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2485 5. end position (always equal to END if STOPCOND is nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2486 The rest of the elements are undefined."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2487 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2488 (let* ((end2 (1+ end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2489 oldp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2490 (depth 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2491 (quoted nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2492 inside_cmt
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2493 (endpos end2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2494 skiptype ; The type of entity we'll skip over
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2495 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2496 (goto-char beg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2497
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2498 (if (and (eq stopcond 'skipover)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2499 (looking-at "[^[({'\"]"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2500 (setq endpos (point)) ; Stay where we are
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2501 (while (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2502 (re-search-forward prolog-tokenize-searchkey end2 t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2503 (< (point) end2))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2504 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2505 (setq oldp (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2506 (goto-char (match-beginning 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2507 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2508 ;; Atoms and strings
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2509 ((looking-at "'")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2510 ;; Find end of atom
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2511 (if (re-search-forward "[^\\]'" end2 'limit)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2512 ;; Found end of atom
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2513 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2514 (setq oldp end2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2515 (if (and (eq stopcond 'skipover)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2516 (not skiptype))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2517 (setq endpos (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2518 (setq oldp (point)))) ; Continue tokenizing
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2519 (setq quoted 'atm)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2520
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2521 ((looking-at "\"")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2522 ;; Find end of string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2523 (if (re-search-forward "[^\\]\"" end2 'limit)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2524 ;; Found end of string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2525 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2526 (setq oldp end2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2527 (if (and (eq stopcond 'skipover)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2528 (not skiptype))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2529 (setq endpos (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2530 (setq oldp (point)))) ; Continue tokenizing
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2531 (setq quoted 'str)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2532
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2533 ;; Paren stuff
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2534 ((looking-at prolog-left-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2535 (setq depth (1+ depth))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2536 (setq skiptype 'paren))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2537
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2538 ((looking-at prolog-right-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2539 (setq depth (1- depth))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2540 (if (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2541 (or (eq stopcond 'zerodepth)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2542 (and (eq stopcond 'skipover)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2543 (eq skiptype 'paren)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2544 (= depth 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2545 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2546 (setq endpos (1+ (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2547 (setq oldp end2))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2548
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2549 ;; Comment stuff
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2550 ((looking-at comment-start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2551 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2552 ;; (if (>= (point) end2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2553 (if (>= (point) end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2554 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2555 (setq inside_cmt t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2556 (setq oldp end2))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2557 (setq oldp (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2558
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2559 ((looking-at "/\\*")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2560 (if (re-search-forward "\\*/" end2 'limit)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2561 (setq oldp (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2562 (setq inside_cmt t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2563 (setq oldp end2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2564
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2565 ;; 0'char
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2566 ((looking-at "0'")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2567 (setq oldp (1+ (match-end 0)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2568 (if (> oldp end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2569 (setq quoted 'chr)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2570
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2571 ;; base'number
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2572 ((looking-at "[0-9]+'")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2573 (goto-char (match-end 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2574 (skip-chars-forward "0-9a-zA-Z")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2575 (setq oldp (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2576
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2577
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2578 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2579 (goto-char oldp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2580 )) ; End of while
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2581 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2582
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2583 ;; Deal with multi-line comments
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2584 (and (prolog-inside-mline-comment end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2585 (setq inside_cmt t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2586
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2587 ;; Create return list
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2588 (list depth nil nil quoted inside_cmt endpos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2589 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2590
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2591 (defun prolog-inside-mline-comment (here)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2592 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2593 (goto-char here)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2594 (let* ((next-close (save-excursion (search-forward "*/" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2595 (next-open (save-excursion (search-forward "/*" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2596 (prev-open (save-excursion (search-backward "/*" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2597 (prev-close (save-excursion (search-backward "*/" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2598 (unmatched-next-close (and next-close
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2599 (or (not next-open)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2600 (> next-open next-close))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2601 (unmatched-prev-open (and prev-open
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2602 (or (not prev-close)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2603 (> prev-open prev-close))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2604 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2605 (or unmatched-next-close unmatched-prev-open)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2606 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2607
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2608
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2609 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2610 ;; Online help
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2611 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2612
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2613 (defvar prolog-help-function
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2614 '((mercury nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2615 (eclipse prolog-help-online)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2616 ;; (sicstus prolog-help-info)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2617 (sicstus prolog-find-documentation)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2618 (swi prolog-help-online)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2619 (t prolog-help-online))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2620 "Alist for the name of the function for finding help on a predicate.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2621
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2622 (defun prolog-help-on-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2623 "Invoke online help on the atom under cursor."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2624 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2625
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2626 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2627 ;; Redirect help for SICStus to `prolog-find-documentation'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2628 ((eq prolog-help-function-i 'prolog-find-documentation)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2629 (prolog-find-documentation))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2630
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2631 ;; Otherwise, ask for the predicate name and then call the function
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2632 ;; in prolog-help-function-i
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2633 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2634 (let* (word
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2635 predicate
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2636 ;point
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2637 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2638 (setq word (prolog-atom-under-point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2639 (setq predicate (read-from-minibuffer
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2640 (format "Help on predicate%s: "
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2641 (if word
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2642 (concat " (default " word ")")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2643 ""))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2644 (if (string= predicate "")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2645 (setq predicate word))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2646 (if prolog-help-function-i
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2647 (funcall prolog-help-function-i predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2648 (error "Sorry, no help method defined for this Prolog system."))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2649 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2650
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2651 (defun prolog-help-info (predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2652 (let ((buffer (current-buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2653 oldp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2654 (str (concat "^\\* " (regexp-quote predicate) " */")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2655 (require 'info)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2656 (pop-to-buffer nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2657 (Info-goto-node prolog-info-predicate-index)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2658 (if (not (re-search-forward str nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2659 (error (format "Help on predicate `%s' not found." predicate)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2660
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2661 (setq oldp (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2662 (if (re-search-forward str nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2663 ;; Multiple matches, ask user
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2664 (let ((max 2)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2665 n)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2666 ;; Count matches
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2667 (while (re-search-forward str nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2668 (setq max (1+ max)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2669
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2670 (goto-char oldp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2671 (re-search-backward "[^ /]" nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2672 (recenter 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2673 (setq n (read-string ;; was read-input, which is obsolete
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2674 (format "Several matches, choose (1-%d): " max) "1"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2675 (forward-line (- (string-to-number n) 1)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2676 ;; Single match
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2677 (re-search-backward "[^ /]" nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2678
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2679 ;; (Info-follow-nearest-node (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2680 (prolog-Info-follow-nearest-node)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2681 (re-search-forward (concat "^`" (regexp-quote predicate)) nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2682 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2683 (recenter 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2684 (pop-to-buffer buffer)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2685
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2686 (defun prolog-Info-follow-nearest-node ()
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2687 (if (featurep 'xemacs)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2688 (Info-follow-nearest-node (point))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2689 (Info-follow-nearest-node)))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2690
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2691 (defun prolog-help-online (predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2692 (prolog-ensure-process)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2693 (process-send-string "prolog" (concat "help(" predicate ").\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2694 (display-buffer "*prolog*"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2695
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2696 (defun prolog-help-apropos (string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2697 "Find Prolog apropos on given STRING.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2698 This function is only available when `prolog-system' is set to `swi'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2699 (interactive "sApropos: ")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2700 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2701 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2702 (prolog-ensure-process)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2703 (process-send-string "prolog" (concat "apropos(" string ").\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2704 (display-buffer "*prolog*"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2705 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2706 (error "Sorry, no Prolog apropos available for this Prolog system."))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2707
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2708 (defun prolog-atom-under-point ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2709 "Return the atom under or left to the point."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2710 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2711 (let ((nonatom_chars "[](){},\. \t\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2712 start)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2713 (skip-chars-forward (concat "^" nonatom_chars))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2714 (skip-chars-backward nonatom_chars)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2715 (skip-chars-backward (concat "^" nonatom_chars))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2716 (setq start (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2717 (skip-chars-forward (concat "^" nonatom_chars))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2718 (buffer-substring-no-properties start (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2719 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2720
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2721
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2722 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2723 ;; Help function with completion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2724 ;; Stolen from Per Mildner's SICStus debugger mode and modified
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2725
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2726 (defun prolog-find-documentation ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2727 "Go to the Info node for a predicate in the SICStus Info manual."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2728 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2729 (let ((pred (prolog-read-predicate)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2730 (prolog-goto-predicate-info pred)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2731
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2732 (defvar prolog-info-alist nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2733 "Alist with all builtin predicates.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2734 Only for internal use by `prolog-find-documentation'")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2735
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2736 ;; Very similar to prolog-help-info except that that function cannot
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2737 ;; cope with arity and that it asks the user if there are several
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2738 ;; functors with different arity. This function also uses
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2739 ;; prolog-info-alist for finding the info node, rather than parsing
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2740 ;; the predicate index.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2741 (defun prolog-goto-predicate-info (predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2742 "Go to the info page for PREDICATE, which is a PredSpec."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2743 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2744 (require 'info)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2745 (string-match "\\(.*\\)/\\([0-9]+\\).*$" predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2746 (let ((buffer (current-buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2747 (name (match-string 1 predicate))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2748 (arity (match-string 2 predicate))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2749 ;oldp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2750 ;(str (regexp-quote predicate))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2751 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2752 (setq arity (string-to-number arity))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2753 (pop-to-buffer nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2754
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2755 (Info-goto-node
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2756 prolog-info-predicate-index) ;; We must be in the SICStus pages
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2757 (Info-goto-node (car (cdr (assoc predicate prolog-info-alist))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2758
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2759 (prolog-find-term (regexp-quote name) arity "^`")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2760
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2761 (recenter 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2762 (pop-to-buffer buffer))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2763 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2764
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2765 (defun prolog-read-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2766 "Read a PredSpec from the user.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2767 Returned value is a string \"FUNCTOR/ARITY\".
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2768 Interaction supports completion."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2769 (let ((initial (prolog-atom-under-point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2770 answer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2771 ;; If the predicate index is not yet built, do it now
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2772 (if (not prolog-info-alist)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2773 (prolog-build-info-alist))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2774 ;; Test if the initial string could be the base for completion.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2775 ;; Discard it if not.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2776 (if (eq (try-completion initial prolog-info-alist) nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2777 (setq initial ""))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2778 ;; Read the PredSpec from the user
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2779 (setq answer (completing-read
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2780 "Help on predicate: "
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2781 prolog-info-alist nil t initial))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2782 (if (equal answer "")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2783 initial
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2784 answer)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2785
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2786 (defun prolog-build-info-alist (&optional verbose)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2787 "Build an alist of all builtins and library predicates.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2788 Each element is of the form (\"NAME/ARITY\" . (INFO-NODE1 INFO-NODE2 ...)).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2789 Typically there is just one Info node associated with each name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2790 If an optional argument VERBOSE is non-nil, print messages at the beginning
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2791 and end of list building."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2792 (if verbose
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2793 (message "Building info alist..."))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2794 (setq prolog-info-alist
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2795 (let ((l ())
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2796 (last-entry (cons "" ())))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2797 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2798 (save-window-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2799 ;; select any window but the minibuffer (as we cannot switch
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2800 ;; buffers in minibuffer window.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2801 ;; I am not sure this is the right/best way
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2802 (if (active-minibuffer-window) ; nil if none active
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2803 (select-window (next-window)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2804 ;; Do this after going away from minibuffer window
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2805 (save-window-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2806 (info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2807 (Info-goto-node prolog-info-predicate-index)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2808 (goto-char (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2809 (while (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2810 "^\\* \\(.+\\)/\\([0-9]+\\)\\([^\n:*]*\\):" nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2811 (let* ((name (match-string 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2812 (arity (string-to-number (match-string 2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2813 (comment (match-string 3))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2814 (fa (format "%s/%d%s" name arity comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2815 info-node)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2816 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2817 ;; Extract the info node name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2818 (setq info-node (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2819 (re-search-forward ":[ \t]*\\([^:]+\\).$")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2820 (match-string 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2821 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2822 ;; ###### Easier? (from Milan version 0.1.28)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2823 ;; (setq info-node (Info-extract-menu-node-name))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2824 (if (equal fa (car last-entry))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2825 (setcdr last-entry (cons info-node (cdr last-entry)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2826 (setq last-entry (cons fa (list info-node))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2827 l (cons last-entry l)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2828 (nreverse l)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2829 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2830 (if verbose
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2831 (message "Building info alist... done.")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2832
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2833
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2834 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2835 ;; Miscellaneous functions
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2836 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2837
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2838 ;; For Windows. Change backslash to slash. SICStus handles either
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2839 ;; path separator but backslash must be doubled, therefore use slash.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2840 (defun prolog-bsts (string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2841 "Change backslashes to slashes in STRING."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2842 (let ((str1 (copy-sequence string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2843 (len (length string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2844 (i 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2845 (while (< i len)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2846 (if (char-equal (aref str1 i) ?\\)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2847 (aset str1 i ?/))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2848 (setq i (1+ i)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2849 str1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2850
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2851 ;(defun prolog-temporary-file ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2852 ; "Make temporary file name for compilation."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2853 ; (make-temp-name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2854 ; (concat
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2855 ; (or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2856 ; (getenv "TMPDIR")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2857 ; (getenv "TEMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2858 ; (getenv "TMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2859 ; (getenv "SYSTEMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2860 ; "/tmp")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2861 ; "/prolcomp")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2862 ;(setq prolog-temp-filename (prolog-bsts (prolog-temporary-file)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2863
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2864 (defun prolog-temporary-file ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2865 "Make temporary file name for compilation."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2866 (if prolog-temporary-file-name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2867 ;; We already have a file, erase content and continue
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2868 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2869 (write-region "" nil prolog-temporary-file-name nil 'silent)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2870 prolog-temporary-file-name)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2871 ;; Actually create the file and set `prolog-temporary-file-name' accordingly
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2872 (let* ((umask (default-file-modes))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2873 (temporary-file-directory (or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2874 (getenv "TMPDIR")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2875 (getenv "TEMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2876 (getenv "TMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2877 (getenv "SYSTEMP")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2878 "/tmp"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2879 (prefix (expand-file-name "prolcomp" temporary-file-directory))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2880 (suffix ".pl")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2881 file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2882 (unwind-protect
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2883 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2884 ;; Create temp files with strict access rights.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2885 (set-default-file-modes #o700)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2886 (while (condition-case ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2887 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2888 (setq file (concat (make-temp-name prefix) suffix))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2889 ;; (concat (make-temp-name "/tmp/prolcomp") ".pl")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2890 (unless (file-exists-p file)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2891 (write-region "" nil file nil 'silent))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2892 nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2893 (file-already-exists t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2894 ;; the file was somehow created by someone else between
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2895 ;; `make-temp-name' and `write-region', let's try again.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2896 nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2897 (setq prolog-temporary-file-name file))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2898 ;; Reset the umask.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2899 (set-default-file-modes umask)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2900 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2901
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2902 (defun prolog-goto-prolog-process-buffer ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2903 "Switch to the prolog process buffer and go to its end."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2904 (switch-to-buffer-other-window "*prolog*")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2905 (goto-char (point-max))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2906 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2907
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2908 (defun prolog-enable-sicstus-sd ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2909 "Enable the source level debugging facilities of SICStus 3.7 and later."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2910 (interactive)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2911 (require 'pltrace) ; Load the SICStus debugger code
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2912 ;; Turn on the source level debugging by default
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2913 (add-hook 'prolog-inferior-mode-hook 'pltrace-on)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2914 (if (not prolog-use-sicstus-sd)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2915 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2916 ;; If there is a *prolog* buffer, then call pltrace-on
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2917 (if (get-buffer "*prolog*")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2918 ;; Avoid compilation warnings by using eval
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2919 (eval '(pltrace-on)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2920 (setq prolog-use-sicstus-sd t)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
2921 )))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2922
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2923 (defun prolog-disable-sicstus-sd ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2924 "Disable the source level debugging facilities of SICStus 3.7 and later."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2925 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2926 (setq prolog-use-sicstus-sd nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2927 ;; Remove the hook
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2928 (remove-hook 'prolog-inferior-mode-hook 'pltrace-on)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2929 ;; If there is a *prolog* buffer, then call pltrace-off
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2930 (if (get-buffer "*prolog*")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2931 ;; Avoid compile warnings by using eval
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2932 (eval '(pltrace-off))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2933
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2934 (defun prolog-debug-on (&optional arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2935 "Enable debugging.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2936 When called with prefix argument ARG, disable debugging instead."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2937 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2938 (if arg
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2939 (prolog-debug-off)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2940 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2941 prolog-debug-on-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2942 (process-send-string "prolog" prolog-debug-on-string)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2943
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2944 (defun prolog-debug-off ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2945 "Disable debugging."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2946 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2947 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2948 prolog-debug-off-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2949 (process-send-string "prolog" prolog-debug-off-string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2950
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2951 (defun prolog-trace-on (&optional arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2952 "Enable tracing.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2953 When called with prefix argument ARG, disable tracing instead."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2954 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2955 (if arg
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2956 (prolog-trace-off)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2957 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2958 prolog-trace-on-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2959 (process-send-string "prolog" prolog-trace-on-string)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2960
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2961 (defun prolog-trace-off ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2962 "Disable tracing."
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
2963 (interactive)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2964 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2965 prolog-trace-off-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2966 (process-send-string "prolog" prolog-trace-off-string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2967
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2968 (defun prolog-zip-on (&optional arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2969 "Enable zipping (for SICStus 3.7 and later).
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2970 When called with prefix argument ARG, disable zipping instead."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2971 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2972 (if arg
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2973 (prolog-zip-off)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2974 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2975 prolog-zip-on-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2976 (process-send-string "prolog" prolog-zip-on-string)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2977
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2978 (defun prolog-zip-off ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2979 "Disable zipping (for SICStus 3.7 and later)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2980 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2981 (prolog-process-insert-string (get-process "prolog")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2982 prolog-zip-off-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2983 (process-send-string "prolog" prolog-zip-off-string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2984
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2985 ;; (defun prolog-create-predicate-index ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2986 ;; "Create an index for all predicates in the buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2987 ;; (let ((predlist '())
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2988 ;; clauseinfo
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2989 ;; object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2990 ;; pos
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2991 ;; )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2992 ;; (goto-char (point-min))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2993 ;; ;; Replace with prolog-clause-start!
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2994 ;; (while (re-search-forward "^.+:-" nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2995 ;; (setq pos (match-beginning 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2996 ;; (setq clauseinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2997 ;; (setq object (prolog-in-object))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2998 ;; (setq predlist (append
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
2999 ;; predlist
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3000 ;; (list (cons
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3001 ;; (if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3002 ;; (prolog-in-object))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3003 ;; (format "%s::%s/%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3004 ;; object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3005 ;; (nth 0 clauseinfo)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3006 ;; (nth 1 clauseinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3007 ;; (format "%s/%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3008 ;; (nth 0 clauseinfo)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3009 ;; (nth 1 clauseinfo)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3010 ;; pos
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3011 ;; ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3012 ;; (prolog-end-of-predicate))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3013 ;; predlist))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3014
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3015 (defun prolog-get-predspec ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3016 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3017 (let ((state (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3018 (object (prolog-in-object)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3019 (if (or (equal (nth 0 state) "") (equal (prolog-in-string-or-comment) 'cmt))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3020 nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3021 (if (and (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3022 object)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3023 (format "%s::%s/%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3024 object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3025 (nth 0 state)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3026 (nth 1 state))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3027 (format "%s/%d"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3028 (nth 0 state)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3029 (nth 1 state)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3030 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3031
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3032 ;; For backward compatibility. Stolen from custom.el.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3033 (or (fboundp 'match-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3034 ;; Introduced in Emacs 19.29.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3035 (defun match-string (num &optional string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3036 "Return string of text matched by last search.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3037 NUM specifies which parenthesized expression in the last regexp.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3038 Value is nil if NUMth pair didn't match, or there were less than NUM pairs.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3039 Zero means the entire text matched by the whole regexp or whole string.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3040 STRING should be given if the last search was by `string-match' on STRING."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3041 (if (match-beginning num)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3042 (if string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3043 (substring string (match-beginning num) (match-end num))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3044 (buffer-substring (match-beginning num) (match-end num))))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3045
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3046 (defun prolog-pred-start ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3047 "Return the starting point of the first clause of the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3048 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3049 (goto-char (prolog-clause-start))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3050 ;; Find first clause, unless it was a directive
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3051 (if (and (not (looking-at "[:?]-"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3052 (not (looking-at "[ \t]*[%/]")) ; Comment
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3053
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3054 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3055 (let* ((pinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3056 (predname (nth 0 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3057 (arity (nth 1 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3058 (op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3059 (while (and (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3060 (format "^%s\\([(\\.]\\| *%s\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3061 predname prolog-head-delimiter) nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3062 (= arity (nth 1 (prolog-clause-info)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3063 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3064 (setq op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3065 (if (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3066 ;; Skip to the beginning of declarations of the predicate
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3067 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3068 (goto-char (prolog-beginning-of-clause))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3069 (while (and (not (eq (point) op))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3070 (looking-at
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3071 (format ":-[ \t]*\\(pred\\|mode\\)[ \t]+%s"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3072 predname)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3073 (setq op (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3074 (goto-char (prolog-beginning-of-clause)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3075 op)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3076 (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3077
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3078 (defun prolog-pred-end ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3079 "Return the position at the end of the last clause of the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3080 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3081 (goto-char (prolog-clause-end)) ; if we are before the first predicate
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3082 (goto-char (prolog-clause-start))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3083 (let* ((pinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3084 (predname (nth 0 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3085 (arity (nth 1 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3086 oldp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3087 (notdone t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3088 (op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3089 (if (looking-at "[:?]-")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3090 ;; This was a directive
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3091 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3092 (if (and (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3093 (looking-at
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3094 (format ":-[ \t]*\\(pred\\|mode\\)[ \t]+\\(%s+\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3095 prolog-atom-regexp)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3096 ;; Skip predicate declarations
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3097 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3098 (setq predname (buffer-substring-no-properties
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3099 (match-beginning 2) (match-end 2)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3100 (while (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3101 (format
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3102 "\n*\\(:-[ \t]*\\(pred\\|mode\\)[ \t]+\\)?%s[( \t]"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3103 predname)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3104 nil t))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3105 (goto-char (prolog-clause-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3106 (setq op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3107 ;; It was not a directive, find the last clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3108 (while (and notdone
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3109 (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3110 (format "^%s\\([(\\.]\\| *%s\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3111 predname prolog-head-delimiter) nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3112 (= arity (nth 1 (prolog-clause-info))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3113 (setq oldp (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3114 (setq op (prolog-clause-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3115 (if (>= oldp op)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3116 ;; End of clause not found.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3117 (setq notdone nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3118 ;; Continue while loop
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3119 (goto-char op))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3120 op)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3121
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3122 (defun prolog-clause-start (&optional not-allow-methods)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3123 "Return the position at the start of the head of the current clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3124 If NOTALLOWMETHODS is non-nil then do not match on methods in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3125 objects (relevent only if 'prolog-system' is set to 'sicstus)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3126 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3127 (let ((notdone t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3128 (retval (point-min)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3129 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3130
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3131 ;; SICStus object?
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3132 (if (and (not not-allow-methods)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3133 (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3134 (prolog-in-object))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3135 (while (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3136 notdone
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3137 ;; Search for a head or a fact
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3138 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3139 ;; If in object, then find method start.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3140 ;; "^[ \t]+[a-z$].*\\(:-\\|&\\|:: {\\|,\\)"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3141 "^[ \t]+[a-z$].*\\(:-\\|&\\|:: {\\)" ; The comma causes
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3142 ; problems since we cannot assume
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3143 ; that the line starts at column 0,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3144 ; thus we don't know if the line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3145 ; is a head or a subgoal
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3146 (point-min) t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3147 (if (>= (prolog-paren-balance) 0) ; To no match on " a) :-"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3148 ;; Start of method found
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3149 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3150 (setq retval (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3151 (setq notdone nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3152 ) ; End of while
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3153
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3154 ;; Not in object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3155 (while (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3156 notdone
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3157 ;; Search for a text at beginning of a line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3158 ;; ######
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3159 ;; (re-search-backward "^[a-z$']" nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3160 (let ((case-fold-search nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3161 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3162 ;; (format "^[%s$']" prolog-lower-case-string)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3163 ;; FIXME: Use [:lower:]
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3164 (format "^\\([%s$']\\|[:?]-\\)" prolog-lower-case-string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3165 nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3166 (let ((bal (prolog-paren-balance)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3167 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3168 ((> bal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3169 ;; Start of clause found
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3170 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3171 (setq retval (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3172 (setq notdone nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3173 ((and (= bal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3174 (looking-at
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3175 (format ".*\\(\\.\\|%s\\|!,\\)[ \t]*\\(%%.*\\|\\)$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3176 prolog-head-delimiter)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3177 ;; Start of clause found if the line ends with a '.' or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3178 ;; a prolog-head-delimiter
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3179 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3180 (setq retval (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3181 (setq notdone nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3182 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3183 (t nil) ; Do nothing
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3184 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3185
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3186 retval)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3187
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3188 (defun prolog-clause-end (&optional not-allow-methods)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3189 "Return the position at the end of the current clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3190 If NOTALLOWMETHODS is non-nil then do not match on methods in
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3191 objects (relevent only if 'prolog-system' is set to 'sicstus)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3192 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3193 (beginning-of-line) ; Necessary since we use "^...." for the search
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3194 (if (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3195 (if (and (not not-allow-methods)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3196 (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3197 (prolog-in-object))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3198 (format
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3199 "^\\(%s\\|%s\\|[^\n\'\"%%]\\)*&[ \t]*\\(\\|%%.*\\)$\\|[ \t]*}"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3200 prolog-quoted-atom-regexp prolog-string-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3201 (format
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3202 "^\\(%s\\|%s\\|[^\n\'\"%%]\\)*\\.[ \t]*\\(\\|%%.*\\)$"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3203 prolog-quoted-atom-regexp prolog-string-regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3204 nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3205 (if (and (prolog-in-string-or-comment)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3206 (not (eobp)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3207 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3208 (forward-char)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3209 (prolog-clause-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3210 (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3211 (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3212
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3213 (defun prolog-clause-info ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3214 "Return a (name arity) list for the current clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3215 (let (predname (arity 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3216 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3217 (goto-char (prolog-clause-start))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3218 (let ((op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3219 (if (looking-at prolog-atom-char-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3220 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3221 (skip-chars-forward "^ (\\.")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3222 (setq predname (buffer-substring op (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3223 (setq predname ""))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3224 ;; Retrieve the arity
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3225 (if (looking-at prolog-left-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3226 (let ((endp (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3227 (prolog-forward-list) (point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3228 (setq arity 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3229 (forward-char 1) ; Skip the opening paren
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3230 (while (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3231 (skip-chars-forward "^[({,'\"")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3232 (< (point) endp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3233 (if (looking-at ",")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3234 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3235 (setq arity (1+ arity))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3236 (forward-char 1) ; Skip the comma
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3237 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3238 ;; We found a string, list or something else we want
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3239 ;; to skip over. Always use prolog-tokenize,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3240 ;; parse-partial-sexp does not have a 'skipover mode.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3241 (goto-char (nth 5 (prolog-tokenize (point) endp 'skipover))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3242 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3243 (list predname arity)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3244 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3245
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3246 (defun prolog-in-object ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3247 "Return object name if the point is inside a SICStus object definition."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3248 ;; Return object name if the last line that starts with a character
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3249 ;; that is neither white space nor a comment start
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3250 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3251 (if (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3252 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3253 (looking-at "\\([^\n ]+\\)[ \t]*::[ \t]*{"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3254 ;; We were in the head of the object
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3255 (match-string 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3256 ;; We were not in the head
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3257 (if (and (re-search-backward "^[a-z$'}]" nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3258 (looking-at "\\([^\n ]+\\)[ \t]*::[ \t]*{"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3259 (match-string 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3260 nil))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3261
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3262 (defun prolog-forward-list ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3263 "Move the point to the matching right parenthesis."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3264 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3265 (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3266 (let ((state (prolog-tokenize (point) (point-max) 'zerodepth)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3267 (goto-char (nth 5 state)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3268 (forward-list)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3269
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3270 ;; NB: This could be done more efficiently!
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3271 (defun prolog-backward-list ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3272 "Move the point to the matching left parenthesis."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3273 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3274 (if prolog-use-prolog-tokenizer-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3275 (let ((bal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3276 (paren-regexp (concat prolog-left-paren "\\|" prolog-right-paren))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3277 (notdone t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3278 (while (and notdone (re-search-backward paren-regexp nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3279 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3280 ((looking-at prolog-left-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3281 (if (not (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3282 (setq bal (1+ bal)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3283 (if (= bal 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3284 (setq notdone nil)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3285 ((looking-at prolog-right-paren)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3286 (if (not (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3287 (setq bal (1- bal))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3288 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3289 (backward-list)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3290
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3291 (defun prolog-beginning-of-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3292 "Move to the beginning of current clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3293 If already at the beginning of clause, move to previous clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3294 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3295 (let ((point (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3296 (new-point (prolog-clause-start)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3297 (if (and (>= new-point point)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3298 (> point 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3299 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3300 (goto-char (1- point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3301 (goto-char (prolog-clause-start)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3302 (goto-char new-point)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3303 (skip-chars-forward " \t"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3304
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3305 ;; (defun prolog-previous-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3306 ;; "Move to the beginning of the previous clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3307 ;; (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3308 ;; (forward-char -1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3309 ;; (prolog-beginning-of-clause))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3310
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3311 (defun prolog-end-of-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3312 "Move to the end of clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3313 If already at the end of clause, move to next clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3314 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3315 (let ((point (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3316 (new-point (prolog-clause-end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3317 (if (and (<= new-point point)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3318 (not (eq new-point (point-max))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3319 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3320 (goto-char (1+ point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3321 (goto-char (prolog-clause-end)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3322 (goto-char new-point))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3323
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3324 ;; (defun prolog-next-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3325 ;; "Move to the beginning of the next clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3326 ;; (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3327 ;; (prolog-end-of-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3328 ;; (forward-char)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3329 ;; (prolog-end-of-clause)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3330 ;; (prolog-beginning-of-clause))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3331
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3332 (defun prolog-beginning-of-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3333 "Go to the nearest beginning of predicate before current point.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3334 Return the final point or nil if no such a beginning was found."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3335 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3336 (let ((op (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3337 (pos (prolog-pred-start)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3338 (if pos
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3339 (if (= op pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3340 (if (not (bobp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3341 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3342 (goto-char pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3343 (backward-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3344 (setq pos (prolog-pred-start))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3345 (if pos
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3346 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3347 (goto-char pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3348 (point)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3349 (goto-char pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3350 (point)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3351
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3352 (defun prolog-end-of-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3353 "Go to the end of the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3354 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3355 (let ((op (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3356 (goto-char (prolog-pred-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3357 (if (= op (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3358 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3359 (forward-line 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3360 (prolog-end-of-predicate)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3361
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3362 (defun prolog-insert-predspec ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3363 "Insert the predspec for the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3364 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3365 (let* ((pinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3366 (predname (nth 0 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3367 (arity (nth 1 pinfo)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3368 (insert (format "%s/%d" predname arity))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3369
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3370 (defun prolog-view-predspec ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3371 "Insert the predspec for the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3372 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3373 (let* ((pinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3374 (predname (nth 0 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3375 (arity (nth 1 pinfo)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3376 (message (format "%s/%d" predname arity))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3377
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3378 (defun prolog-insert-predicate-template ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3379 "Insert the template for the current clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3380 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3381 (let* ((n 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3382 oldp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3383 (pinfo (prolog-clause-info))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3384 (predname (nth 0 pinfo))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3385 (arity (nth 1 pinfo)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3386 (insert predname)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3387 (if (> arity 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3388 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3389 (insert "(")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3390 (when prolog-electric-dot-full-predicate-template
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3391 (setq oldp (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3392 (while (< n arity)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3393 (insert ",")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3394 (setq n (1+ n)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3395 (insert ")")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3396 (goto-char oldp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3397 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3398 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3399
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3400 (defun prolog-insert-next-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3401 "Insert newline and the name of the current clause."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3402 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3403 (insert "\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3404 (prolog-insert-predicate-template))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3405
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3406 (defun prolog-insert-module-modeline ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3407 "Insert a modeline for module specification.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3408 This line should be first in the buffer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3409 The module name should be written manually just before the semi-colon."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3410 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3411 (insert "%%% -*- Module: ; -*-\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3412 (backward-char 6))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3413
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3414 (defalias 'prolog-uncomment-region
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3415 (if (fboundp 'uncomment-region) #'uncomment-region
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3416 (lambda (beg end)
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3417 "Uncomment the region between BEG and END."
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3418 (interactive "r")
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3419 (comment-region beg end -1))))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3420
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3421 (defun prolog-goto-comment-column (&optional nocreate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3422 "Move comments on the current line to the correct position.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3423 If NOCREATE is nil (or omitted) and there is no comment on the line, then
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3424 a new comment is created."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3425 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3426 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3427 (if (or (not nocreate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3428 (and
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3429 (re-search-forward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3430 (format "^\\(\\(%s\\|%s\\|[^\n\'\"%%]\\)*\\)%% *"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3431 prolog-quoted-atom-regexp prolog-string-regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3432 (save-excursion (end-of-line) (point)) 'limit)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3433 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3434 (goto-char (match-beginning 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3435 (not (eq (prolog-in-string-or-comment) 'txt)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3436 (indent-for-comment)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3437
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3438 (defun prolog-indent-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3439 "*Indent the current predicate."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3440 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3441 (indent-region (prolog-pred-start) (prolog-pred-end) nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3442
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3443 (defun prolog-indent-buffer ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3444 "*Indent the entire buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3445 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3446 (indent-region (point-min) (point-max) nil))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3447
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3448 (defun prolog-mark-clause ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3449 "Put mark at the end of this clause and move point to the beginning."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3450 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3451 (let ((pos (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3452 (goto-char (prolog-clause-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3453 (forward-line 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3454 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3455 (set-mark (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3456 (goto-char pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3457 (goto-char (prolog-clause-start))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3458
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3459 (defun prolog-mark-predicate ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3460 "Put mark at the end of this predicate and move point to the beginning."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3461 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3462 (let (pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3463 (goto-char (prolog-pred-end))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3464 (setq pos (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3465 (forward-line 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3466 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3467 (set-mark (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3468 (goto-char pos)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3469 (goto-char (prolog-pred-start))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3470
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3471 ;; Stolen from `cc-mode.el':
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3472 (defun prolog-electric-delete (arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3473 "Delete preceding character or whitespace.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3474 If `prolog-hungry-delete-key-flag' is non-nil, then all preceding whitespace is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3475 consumed. If however an ARG is supplied, or `prolog-hungry-delete-key-flag' is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3476 nil, or point is inside a literal then the function in the variable
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3477 `backward-delete-char' is called."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3478 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3479 (if (or (not prolog-hungry-delete-key-flag)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3480 arg
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3481 (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3482 (funcall 'backward-delete-char (prefix-numeric-value arg))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3483 (let ((here (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3484 (skip-chars-backward " \t\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3485 (if (/= (point) here)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3486 (delete-region (point) here)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3487 (funcall 'backward-delete-char 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3488 ))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3489
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3490 ;; For XEmacs compatibility (suggested by Per Mildner)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3491 (put 'prolog-electric-delete 'pending-delete 'supersede)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3492
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3493 (defun prolog-electric-if-then-else (arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3494 "If `prolog-electric-if-then-else-flag' is non-nil, indent if-then-else constructs.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3495 Bound to the >, ; and ( keys."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3496 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3497 (self-insert-command (prefix-numeric-value arg))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3498 (if prolog-electric-if-then-else-flag (prolog-insert-spaces-after-paren)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3499
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3500 (defun prolog-electric-colon (arg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3501 "If `prolog-electric-colon-flag' is non-nil, insert the electric `:' construct.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3502 That is, insert space (if appropriate), `:-' and newline if colon is pressed
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3503 at the end of a line that starts in the first column (i.e., clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3504 heads)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3505 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3506 (if (and prolog-electric-colon-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3507 (null arg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3508 (eolp)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3509 ;(not (string-match "^\\s " (thing-at-point 'line))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3510 (not (string-match "^\\(\\s \\|%\\)" (thing-at-point 'line))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3511 (progn
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3512 (unless (save-excursion (backward-char 1) (looking-at "\\s "))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3513 (insert " "))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3514 (insert ":-\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3515 (prolog-indent-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3516 (self-insert-command (prefix-numeric-value arg))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3517
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3518 (defun prolog-electric-dash (arg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3519 "If `prolog-electric-dash-flag' is non-nil, insert the electric `-' construct.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3520 that is, insert space (if appropriate), `-->' and newline if dash is pressed
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3521 at the end of a line that starts in the first column (i.e., DCG
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3522 heads)."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3523 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3524 (if (and prolog-electric-dash-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3525 (null arg)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3526 (eolp)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3527 ;(not (string-match "^\\s " (thing-at-point 'line))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3528 (not (string-match "^\\(\\s \\|%\\)" (thing-at-point 'line))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3529 (progn
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3530 (unless (save-excursion (backward-char 1) (looking-at "\\s "))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3531 (insert " "))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3532 (insert "-->\n")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3533 (prolog-indent-line))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3534 (self-insert-command (prefix-numeric-value arg))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3535
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3536 (defun prolog-electric-dot (arg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3537 "Insert dot and newline or a head of a new clause.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3538
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3539 If `prolog-electric-dot-flag' is nil, then simply insert dot.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3540 Otherwise::
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3541 When invoked at the end of nonempty line, insert dot and newline.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3542 When invoked at the end of an empty line, insert a recursive call to
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3543 the current predicate.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3544 When invoked at the beginning of line, insert a head of a new clause
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3545 of the current predicate.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3546
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3547 When called with prefix argument ARG, insert just dot."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3548 (interactive "P")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3549 ;; Check for situations when the electricity should not be active
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3550 (if (or (not prolog-electric-dot-flag)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3551 arg
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3552 (prolog-in-string-or-comment)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3553 ;; Do not be electric in a floating point number or an operator
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3554 (not
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3555 (or
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3556 ;; (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3557 ;; ######
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3558 ;; "\\(^\\|[])}a-zA-Z_!'0-9]+\\)[ \t]*\\=" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3559 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3560 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3561 ;; "\\(^\\|[])}_!'0-9]+\\)[ \t]*\\=" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3562 "\\(^\\|[])}_!'0-9]+\\)[ \t]*\\="
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3563 nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3564 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3565 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3566 ;; "\\(^\\|[])}a-zA-Z]+\\)[ \t]*\\=" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3567 (format "\\(^\\|[])}%s]+\\)[ \t]*\\="
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3568 prolog-lower-case-string) ;FIXME: [:lower:]
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3569 nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3570 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3571 (re-search-backward
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3572 ;; "\\(^\\|[])}a-zA-Z]+\\)[ \t]*\\=" nil t)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3573 (format "\\(^\\|[])}%s]+\\)[ \t]*\\="
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3574 prolog-upper-case-string) ;FIXME: [:upper:]
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3575 nil t))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3576 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3577 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3578 ;; Do not be electric if inside a parenthesis pair.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3579 (not (= (prolog-region-paren-balance (prolog-clause-start) (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3580 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3581 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3582 (funcall 'self-insert-command (prefix-numeric-value arg))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3583 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3584 ;; Beginning of line
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3585 ((bolp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3586 (prolog-insert-predicate-template))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3587 ;; At an empty line with at least one whitespace
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3588 ((save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3589 (beginning-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3590 (looking-at "[ \t]+$"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3591 (prolog-insert-predicate-template)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3592 (when prolog-electric-dot-full-predicate-template
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3593 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3594 (end-of-line)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3595 (insert ".\n"))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3596 ;; Default
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3597 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3598 (insert ".\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3599 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3600
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3601 (defun prolog-electric-underscore ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3602 "Replace variable with an underscore.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3603 If `prolog-electric-underscore-flag' is non-nil and the point is
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3604 on a variable then replace the variable with underscore and skip
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3605 the following comma and whitespace, if any.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3606 If the point is not on a variable then insert underscore."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3607 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3608 (if prolog-electric-underscore-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3609 (let (;start
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3610 (oldcase case-fold-search)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3611 (oldp (point)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3612 (setq case-fold-search nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3613 ;; ######
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3614 ;;(skip-chars-backward "a-zA-Z_")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3615 (skip-chars-backward
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3616 (format "%s%s_"
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3617 ;; FIXME: Why not "a-zA-Z"?
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3618 prolog-lower-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3619 prolog-upper-case-string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3620
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3621 ;(setq start (point))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3622 (if (and (not (prolog-in-string-or-comment))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3623 ;; ######
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3624 ;; (looking-at "\\<[_A-Z][a-zA-Z_0-9]*\\>"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3625 (looking-at (format "\\<[_%s][%s%s_0-9]*\\>"
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3626 ;; FIXME: Use [:upper:] and friends.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3627 prolog-upper-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3628 prolog-lower-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3629 prolog-upper-case-string)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3630 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3631 (replace-match "_")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3632 (skip-chars-forward ", \t\n"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3633 (goto-char oldp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3634 (self-insert-command 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3635 (setq case-fold-search oldcase)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3636 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3637 (self-insert-command 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3638 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3639
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3640
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3641 (defun prolog-find-term (functor arity &optional prefix)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3642 "Go to the position at the start of the next occurance of a term.
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3643 The term is specified with FUNCTOR and ARITY. The optional argument
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3644 PREFIX is the prefix of the search regexp."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3645 (let* (;; If prefix is not set then use the default "\\<"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3646 (prefix (if (not prefix)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3647 "\\<"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3648 prefix))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3649 (regexp (concat prefix functor))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3650 (i 1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3651
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3652 ;; Build regexp for the search if the arity is > 0
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3653 (if (= arity 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3654 ;; Add that the functor must be at the end of a word. This
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3655 ;; does not work if the arity is > 0 since the closing )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3656 ;; is not a word constituent.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3657 (setq regexp (concat regexp "\\>"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3658 ;; Arity is > 0, add parens and commas
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3659 (setq regexp (concat regexp "("))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3660 (while (< i arity)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3661 (setq regexp (concat regexp ".+,"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3662 (setq i (1+ i)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3663 (setq regexp (concat regexp ".+)")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3664
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3665 ;; Search, and return position
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3666 (if (re-search-forward regexp nil t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3667 (goto-char (match-beginning 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3668 (error "Term not found"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3669 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3670
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3671 (defun prolog-variables-to-anonymous (beg end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3672 "Replace all variables within a region BEG to END by anonymous variables."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3673 (interactive "r")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3674 (save-excursion
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3675 (let ((oldcase case-fold-search))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3676 (setq case-fold-search nil)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3677 (goto-char end)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3678 (while (re-search-backward "\\<[A-Z_][a-zA-Z_0-9]*\\>" beg t)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3679 (progn
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3680 (replace-match "_")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3681 (backward-char)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3682 (setq case-fold-search oldcase)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3683 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3684
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3685
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3686 (defun prolog-set-atom-regexps ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3687 "Set the `prolog-atom-char-regexp' and `prolog-atom-regexp' variables.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3688 Must be called after `prolog-build-case-strings'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3689 (setq prolog-atom-char-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3690 (format "[%s%s0-9_$]"
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3691 ;; FIXME: why not a-zA-Z?
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3692 prolog-lower-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3693 prolog-upper-case-string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3694 (setq prolog-atom-regexp
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3695 (format "[%s$]%s*"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3696 prolog-lower-case-string
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3697 prolog-atom-char-regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3698 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3699
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3700 (defun prolog-build-case-strings ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3701 "Set `prolog-upper-case-string' and `prolog-lower-case-string'.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3702 Uses the current case-table for extracting the relevant information."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3703 (let ((up_string "")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3704 (low_string ""))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3705 ;; Use `map-char-table' if it is defined. Otherwise enumerate all
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3706 ;; numbers between 0 and 255. `map-char-table' is probably safer.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3707 ;;
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3708 ;; `map-char-table' causes problems under Emacs 23.0.0.1, the
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3709 ;; while loop seems to do its job well (Ryszard Szopa)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3710 ;;
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3711 ;;(if (and (not (featurep 'xemacs))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3712 ;; (fboundp 'map-char-table))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3713 ;; (map-char-table
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3714 ;; (lambda (key value)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3715 ;; (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3716 ;; ((and
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3717 ;; (eq (prolog-int-to-char key) (downcase key))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3718 ;; (eq (prolog-int-to-char key) (upcase key)))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3719 ;; ;; Do nothing if upper and lower case are the same
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3720 ;; )
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3721 ;; ((eq (prolog-int-to-char key) (downcase key))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3722 ;; ;; The char is lower case
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3723 ;; (setq low_string (format "%s%c" low_string key)))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3724 ;; ((eq (prolog-int-to-char key) (upcase key))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3725 ;; ;; The char is upper case
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3726 ;; (setq up_string (format "%s%c" up_string key)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3727 ;; ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3728 ;; (current-case-table))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3729 ;; `map-char-table' was undefined.
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3730 (let ((key 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3731 (while (< key 256)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3732 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3733 ((and
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3734 (eq (prolog-int-to-char key) (downcase key))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3735 (eq (prolog-int-to-char key) (upcase key)))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3736 ;; Do nothing if upper and lower case are the same
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3737 )
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3738 ((eq (prolog-int-to-char key) (downcase key))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3739 ;; The char is lower case
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3740 (setq low_string (format "%s%c" low_string key)))
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3741 ((eq (prolog-int-to-char key) (upcase key))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3742 ;; The char is upper case
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3743 (setq up_string (format "%s%c" up_string key)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3744 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3745 (setq key (1+ key))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3746 ;; )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3747 ;; The strings are single-byte strings
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3748 (setq prolog-upper-case-string (prolog-dash-letters up_string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3749 (setq prolog-lower-case-string (prolog-dash-letters low_string))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3750 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3751
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3752 ;(defun prolog-regexp-dash-continuous-chars (chars)
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3753 ; (let ((ints (mapcar #'prolog-char-to-int (string-to-list chars)))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3754 ; (beg 0)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3755 ; (end 0))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3756 ; (if (null ints)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3757 ; chars
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3758 ; (while (and (< (+ beg 1) (length chars))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3759 ; (not (or (= (+ (nth beg ints) 1) (nth (+ beg 1) ints))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3760 ; (= (nth beg ints) (nth (+ beg 1) ints)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3761 ; (setq beg (+ beg 1)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3762 ; (setq beg (+ beg 1)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3763 ; end beg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3764 ; (while (and (< (+ end 1) (length chars))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3765 ; (or (= (+ (nth end ints) 1) (nth (+ end 1) ints))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3766 ; (= (nth end ints) (nth (+ end 1) ints))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3767 ; (setq end (+ end 1)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3768 ; (if (equal (substring chars end) "")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3769 ; (substring chars 0 beg)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3770 ; (concat (substring chars 0 beg) "-"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3771 ; (prolog-regexp-dash-continuous-chars (substring chars end))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3772 ; )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3773
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3774 (defun prolog-ints-intervals (ints)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3775 "Return a list of intervals (from . to) covering INTS."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3776 (when ints
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3777 (setq ints (sort ints '<))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3778 (let ((prev (car ints))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3779 (interval-start (car ints))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3780 intervals)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3781 (while ints
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3782 (let ((next (car ints)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3783 (when (> next (1+ prev)) ; start of new interval
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3784 (setq intervals (cons (cons interval-start prev) intervals))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3785 (setq interval-start next))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3786 (setq prev next)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3787 (setq ints (cdr ints))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3788 (setq intervals (cons (cons interval-start prev) intervals))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3789 (reverse intervals))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3790
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3791 (defun prolog-dash-letters (string)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3792 "Return a condensed regexp covering all letters in STRING."
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3793 (let ((intervals (prolog-ints-intervals (mapcar #'prolog-char-to-int
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3794 (string-to-list string))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3795 codes)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3796 (while intervals
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3797 (let* ((i (car intervals))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3798 (from (car i))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3799 (to (cdr i))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3800 (c (cond ((= from to) `(,from))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3801 ((= (1+ from) to) `(,from ,to))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3802 (t `(,from ?- ,to)))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3803 (setq codes (cons c codes)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3804 (setq intervals (cdr intervals)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3805 (apply 'concat (reverse codes))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3806
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3807 ;(defun prolog-condense-character-sets (regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3808 ; "Condense adjacent characters in character sets of REGEXP."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3809 ; (let ((next -1))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3810 ; (while (setq next (string-match "\\[\\(.*?\\)\\]" regexp (1+ next)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3811 ; (setq regexp (replace-match (prolog-dash-letters (match-string 1 regexp))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3812 ; t t regexp 1))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3813 ; regexp)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3814
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3815 ;; GNU Emacs compatibility: GNU Emacs does not differentiate between
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3816 ;; ints and chars, or at least these two are interchangeable.
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3817 (defalias 'prolog-int-to-char
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3818 (if (fboundp 'int-to-char) #'int-to-char #'identity))
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3819
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3820 (defalias 'prolog-char-to-int
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3821 (if (fboundp 'char-to-int) #'char-to-int #'identity))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3822
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3823 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3824 ;; Menu stuff (both for the editing buffer and for the inferior
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3825 ;; prolog buffer)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3826 ;;-------------------------------------------------------------------
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3827
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3828 (unless (fboundp 'region-exists-p)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3829 (defun region-exists-p ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3830 "Non-nil iff the mark is set. Lobotomized version for Emacsen that do not provide their own."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3831 (mark)))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3832
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3833 (defun prolog-menu ()
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3834 "Create the menus for the Prolog editing buffers.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3835 These menus are dynamically created because one may change systems
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3836 during the life of an Emacs session, and because GNU Emacs wants them
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3837 so by ignoring `easy-menu-add'."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3838
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3839 ;; GNU Emacs ignores `easy-menu-add' so the order in which the menus
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3840 ;; are defined _is_ important!
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3841
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3842 (easy-menu-define
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3843 prolog-edit-menu-help (current-local-map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3844 "Help menu for the Prolog mode."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3845 (append
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3846 (if (featurep 'xemacs) '("Help") '("Prolog-help"))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3847 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3848 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3849 '(["On predicate" prolog-help-on-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3850 "---"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3851 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3852 '(["On predicate" prolog-help-on-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3853 ["Apropos" prolog-help-apropos t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3854 "---")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3855 '(["Describe mode" describe-mode t])))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3856
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3857 (easy-menu-define
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3858 prolog-edit-menu-runtime (current-local-map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3859 "Runtime Prolog commands available from the editing buffer"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3860 (append
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3861 ;; runtime menu name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3862 (list (cond ((eq prolog-system 'eclipse)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3863 "ECLiPSe")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3864 ((eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3865 "Mercury")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3866 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3867 "Prolog")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3868 ;; consult items, NIL for mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3869 (unless (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3870 '("---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3871 ["Consult file" prolog-consult-file t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3872 ["Consult buffer" prolog-consult-buffer t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3873 ["Consult region" prolog-consult-region (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3874 ["Consult predicate" prolog-consult-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3875 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3876 ;; compile items, NIL for everything but SICSTUS
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3877 (when (eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3878 '("---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3879 ["Compile file" prolog-compile-file t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3880 ["Compile buffer" prolog-compile-buffer t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3881 ["Compile region" prolog-compile-region (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3882 ["Compile predicate" prolog-compile-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3883 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3884 ;; debug items, NIL for mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3885 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3886 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3887 ;; In SICStus, these are pairwise disjunctive,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3888 ;; so it's enough with one "off"-command
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3889 (if (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3890 (list "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3891 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3892 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3893 ["Zip" prolog-zip-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3894 ["All debug off" prolog-debug-off t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3895 '("Source level debugging"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3896 ["Enable" prolog-enable-sicstus-sd t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3897 ["Disable" prolog-disable-sicstus-sd t]))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3898 (list "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3899 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3900 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3901 ["All debug off" prolog-debug-off t])))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3902 ((not (eq prolog-system 'mercury))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3903 '("---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3904 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3905 ["Debug off" prolog-debug-off t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3906 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3907 ["Trace off" prolog-trace-off t]))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3908 ;; default (mercury) nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3909 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3910 (list "---"
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3911 (if (featurep 'xemacs)
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3912 [(concat "Run " (cond ((eq prolog-system 'eclipse) "ECLiPSe")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3913 ((eq prolog-system 'mercury) "Mercury")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3914 (t "Prolog")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3915 run-prolog t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3916 ["Run Prolog" run-prolog t]))))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3917
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3918 (easy-menu-define
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3919 prolog-edit-menu-insert-move (current-local-map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3920 "Commands for Prolog code manipulation."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3921 (append
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3922 (list "Code"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3923 ["Comment region" comment-region (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3924 ["Uncomment region" prolog-uncomment-region (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3925 ["Add comment/move to comment" indent-for-comment t])
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3926 (unless (eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3927 (list ["Convert variables in region to '_'" prolog-variables-to-anonymous (region-exists-p)]))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3928 (list "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3929 ["Insert predicate template" prolog-insert-predicate-template t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3930 ["Insert next clause head" prolog-insert-next-clause t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3931 ["Insert predicate spec" prolog-insert-predspec t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3932 ["Insert module modeline" prolog-insert-module-modeline t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3933 "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3934 ["Beginning of clause" prolog-beginning-of-clause t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3935 ["End of clause" prolog-end-of-clause t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3936 ["Beginning of predicate" prolog-beginning-of-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3937 ["End of predicate" prolog-end-of-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3938 "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3939 ["Indent line" prolog-indent-line t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3940 ["Indent region" indent-region (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3941 ["Indent predicate" prolog-indent-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3942 ["Indent buffer" prolog-indent-buffer t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3943 ["Align region" align (region-exists-p)]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3944 "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3945 ["Mark clause" prolog-mark-clause t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3946 ["Mark predicate" prolog-mark-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3947 ["Mark paragraph" mark-paragraph t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3948 ;"---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3949 ;["Fontify buffer" font-lock-fontify-buffer t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3950 )))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3951
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3952 (easy-menu-add prolog-edit-menu-insert-move)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3953 (easy-menu-add prolog-edit-menu-runtime)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3954
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3955 ;; Add predicate index menu
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3956 ;(make-variable-buffer-local 'imenu-create-index-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3957 (make-local-variable 'imenu-create-index-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3958 (setq imenu-create-index-function 'imenu-default-create-index-function)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3959 ;;Milan (this has problems with object methods...) ###### Does it? (Stefan)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3960 (setq imenu-prev-index-position-function 'prolog-beginning-of-predicate)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3961 (setq imenu-extract-index-name-function 'prolog-get-predspec)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3962
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3963 (if (and prolog-imenu-flag
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3964 (< (count-lines (point-min) (point-max)) prolog-imenu-max-lines))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3965 (imenu-add-to-menubar "Predicates"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3966
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3967 (easy-menu-add prolog-edit-menu-help))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3968
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3969 (defun prolog-inferior-menu ()
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3970 "Create the menus for the Prolog inferior buffer.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3971 This menu is dynamically created because one may change systems during
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3972 the life of an Emacs session."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3973
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3974 (easy-menu-define
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3975 prolog-inferior-menu-help (current-local-map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3976 "Help menu for the Prolog inferior mode."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3977 (append
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
3978 (if (featurep 'xemacs) '("Help") '("Prolog-help"))
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3979 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3980 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3981 '(["On predicate" prolog-help-on-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3982 "---"))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3983 ((eq prolog-system 'swi)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3984 '(["On predicate" prolog-help-on-predicate t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3985 ["Apropos" prolog-help-apropos t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3986 "---")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3987 '(["Describe mode" describe-mode t])))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3988
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3989 (easy-menu-define
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3990 prolog-inferior-menu-all (current-local-map)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3991 "Menu for the inferior Prolog buffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3992 (append
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3993 ;; menu name
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3994 (list (cond ((eq prolog-system 'eclipse)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3995 "ECLiPSe")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3996 ((eq prolog-system 'mercury)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3997 "Mercury")
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3998 (t
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
3999 "Prolog")))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4000 ;; debug items, NIL for mercury
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4001 (cond
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4002 ((eq prolog-system 'sicstus)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4003 ;; In SICStus, these are pairwise disjunctive,
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4004 ;; so it's enough with one "off"-command
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4005 (if (prolog-atleast-version '(3 . 7))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4006 (list "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4007 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4008 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4009 ["Zip" prolog-zip-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4010 ["All debug off" prolog-debug-off t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4011 '("Source level debugging"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4012 ["Enable" prolog-enable-sicstus-sd t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4013 ["Disable" prolog-disable-sicstus-sd t]))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4014 (list "---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4015 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4016 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4017 ["All debug off" prolog-debug-off t])))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4018 ((not (eq prolog-system 'mercury))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4019 '("---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4020 ["Debug" prolog-debug-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4021 ["Debug off" prolog-debug-off t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4022 ["Trace" prolog-trace-on t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4023 ["Trace off" prolog-trace-off t]))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4024 ;; default (mercury) nil
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4025 )
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4026 ;; runtime
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4027 '("---"
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4028 ["Interrupt Prolog" comint-interrupt-subjob t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4029 ["Quit Prolog" comint-quit-subjob t]
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4030 ["Kill Prolog" comint-kill-subjob t])
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4031 ))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4032
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4033 (easy-menu-add prolog-inferior-menu-all)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4034 (easy-menu-add prolog-inferior-menu-help))
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4035
112190
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
4036 (add-hook 'prolog-mode-hook 'prolog-menu) ;FIXME.
0bfc36865094 * lisp/progmodes/prolog.el: Fix up coding conventions and such.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 112189
diff changeset
4037 (add-hook 'prolog-inferior-mode-hook 'prolog-inferior-menu) ;FIXME.
112189
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4038
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4039 (defun prolog-mode-version ()
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4040 "Echo the current version of Prolog mode in the minibuffer."
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4041 (interactive)
b8f8e953d12f * lisp/progmodes/prolog.el: Replace by a whole new file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 111870
diff changeset
4042 (message "Using Prolog mode version %s" prolog-mode-version))
72684
f65ec4fd2be1 Remove * in docstrings.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 68773
diff changeset
4043
18383
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
4044 (provide 'prolog)
11218164bc54 Add provide call.
Richard M. Stallman <rms@gnu.org>
parents: 17977
diff changeset
4045
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 258
diff changeset
4046 ;;; prolog.el ends here