* Emacs interaction mode for Guile
@ 2002-10-20 9:29 Mikael Djurfeldt
2002-10-20 17:01 ` Mikael Djurfeldt
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Djurfeldt @ 2002-10-20 9:29 UTC (permalink / raw)
Cc: djurfeldt
In 1996 I wrote a hack for interacting with Guile through Emacs.
Since then, I've been using Guile that way myself.
Since then, I've also planned to release it, but I've thought that I
should rewrite the code first. Since I've not done that, and since it
now seems even more distant that that will happen soon, since people
have been asking for it, and since I've been sitting on the code for
ridiculously long, I just want to tell you that you can download it
here:
http://kvast.blakulla.net/mdj/guileint-1.5.tgz
Guile-Emacs interface
=====================
This is version 1.5 of an Emacs interaction mode for running the Guile
Scheme interpreter. (The Guile side of the interface resides in
ice-9/emacs.scm.)
It was originally part of a Guile-based course environment at KTH,
Stockholm.
Disclaimer
----------
The core of this code was thrown together in a few days and was never
intended as more than a prototype. It has then evolved through
patching to quickly fix problems or adding new features and has for a
very long time been a playground for miscellaneous wild ideas. The
quality of the code reflects this.
Features
--------
1. Automatic displaying (and highlighting) of erring expression in
source buffer.
2. Tracking of source expressions in the source buffer so that
scheme:s view of source positions can be translated into actual
position which may be different due to recent editing in the
buffer.
3. Errors and backtraces come up in separate buffers. (This keeps the
interaction buffer cleaner, and it's easier to see what you've
written before.)
4. The part of the interaction buffer above the prompt line is write
protected. The motivation is to enforce a correct dialog history.
5. Typing things in the interaction buffer while point is above the
prompt line moves point to prompt line.
6. Previous expressions in the interaction buffer are clickable.
Clicking reenters the expression to the interpreter. Clicking
with shift copies the expression to the prompt line.
7. Backtraces are clickable so that klicking on a certain frame
highlights the corresponding expression in the source buffer.
8. Clicking on a variable in a backtrace displays it's value in
the echo area.
9. The users input and the computers answer has different faces.
10. Incomplete expressions in scheme buffers has a special face.
11. Probably several more features which I haven't documented here
yet...
Planned features
----------------
12. When single stepping through code, the current expression should
be highlighted in the source buffer.
Short notes on how to run it
----------------------------
Choose "Guile" in the "Interpret" menu.
Then you should get a scheme window with a running Guile.
First try typing something erroneous.
You should get an error + backtrace window.
You can exit this with `q' or ESC.
Then try opening a scheme file, e. g. "foo.scm".
Type in something, e. g.,
(define (fac x)
(if (= x 0)
(koko)
(* x (fac (1- x)))))
Choose "Eval buffer" from the menu, then type "(foo 3)" in
the scheme interpreter window.
Your scheme buffer ("foo.scm") should now pop up, split into three
sections, and the expression "(koko)" should be marked in red.
Again, typing `q' or ESC *in the error or backtrace window* will
remove these windows.
Now try out the different items in the Scheme buffer "Scheme" menu.
If you go to the buffer "foo.scm" and select "Attach buffer" in the
menu, all changes to definitions in that buffer will be automagically
transfered to scheme. So, the illusion produced is that typing in the
"foo.scm" buffer is like typing into scheme memory.
This illusion breaks down, however, if the scheme buffer contains
other stuff than procedure definitions...
Code
----
The two main components are:
* Code that can track positions of expressions in a source buffer
while editing. It maintains overlays over each top-level
expression, and can create new ones and delete old ones on the fly.
* An extension to comint so that it gets a dispatching I/O multiplexer
similar to the one in xscheme.el.
Most things are in "guile.el".
Some setups + additional code is done by init-file-like files like
"guile-init.el". These are relics from the two first days of the
interface's life when it still had something reminiscent of
structure... ;-)
Files with the same names as files in the Emacs distribution is slight
modifications of the correspondees. I originally planned to try
getting these included in Emacs.
The following changes have been made to files from the Emacs distribution:
cmuscheme.el:
1. New buffer local variable:
inferior-scheme-mode-line-process
2. The variable
scheme-buffer
has been replaced by the buffer local variable
inferior-scheme-associated-buffers
3. mode-line-process has been changed to use
inferior-scheme-mode-line-process
comint.el:
1. New buffer local variables:
comint-unallowed-output-filter-functions
comint-output-filter-function
comint-allow-output-p
comint-dispatch-state
comint-string-accumulator
comint-string-receiver
comint-receiving-buffer
comint-buffer-receiver
2. Patch to comint-exec
Use comint-output-filter-function instead of comint-output-filter.
3. Patch to comint-output-filter.
4. New functions:
comint-insert-output
comint-dispatch-filter-initialize
comint-dispatch-output-filter
5. New variables:
comint-dispatch-escape-character
comint-dispatch-string-end-regexp
comint-dispatch-buffer-end-regexp
comint-dispatch-alist
Debugging
---------
If you do
M-x guile-show-overlays
in a scheme source buffer, the interface will show how it interprets
the expressions in the buffer (and how it tracks them, when they are
modified).
Shut it off with
M-x guile-hide-overlays
I use *pairs* of colors for denoting each meaning. This is so that
you can distinguish adjacent overlays from eachother.
Colors mean:
dark/light blue: expressions are unmodified since last sent to Guile
green/pink: expressions have been modified
underlined: expressions are "broken" (which means that they can't be
sent to Guile)
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Emacs interaction mode for Guile
2002-10-20 9:29 Emacs interaction mode for Guile Mikael Djurfeldt
@ 2002-10-20 17:01 ` Mikael Djurfeldt
2002-10-21 11:43 ` Mikael Djurfeldt
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Djurfeldt @ 2002-10-20 17:01 UTC (permalink / raw)
Cc: guile-user, guile-devel
Mikael Djurfeldt <mdj@kvast.blakulla.net> writes:
> http://kvast.blakulla.net/mdj/guileint-1.5.tgz
It appears that the Guile side of the emacs interaction mode has
ceased to work in later versions of Guile. I'll try to find out why.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Emacs interaction mode for Guile
2002-10-20 17:01 ` Mikael Djurfeldt
@ 2002-10-21 11:43 ` Mikael Djurfeldt
2002-12-01 18:06 ` Neil Jerram
0 siblings, 1 reply; 4+ messages in thread
From: Mikael Djurfeldt @ 2002-10-21 11:43 UTC (permalink / raw)
Cc: guile-user, guile-devel, erik, orre, Neil Jerram
Mikael Djurfeldt <mdj@kvast.blakulla.net> writes:
> Mikael Djurfeldt <mdj@kvast.blakulla.net> writes:
>
> > http://kvast.blakulla.net/mdj/guileint-1.5.tgz
>
> It appears that the Guile side of the emacs interaction mode has
> ceased to work in later versions of Guile. I'll try to find out why.
OK, the problem was that somewhere in Guile-1.5, the Guile side of the
emacs interface ceased to be activated. A patch is supplied below.
Also, I've put a new version of the interface with notes about this
and instructions when to apply the patch as:
http://kvast.blakulla.net/mdj/guileint-1.5.1.tgz
NOTE: Somewhere in Guile 1.5, a bug was introduced in the Guile side
of the Emacs interface. This bug prevents the Emacs interface
from being activated and also suppresses the Guile prompt if
readline is activated. A patch for Guile is supplied below:
Index: guile-readline/ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/guile-readline/ChangeLog,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -r1.83 -r1.84
--- guile-readline/ChangeLog 30 Apr 2002 07:41:43 -0000 1.83
+++ guile-readline/ChangeLog 21 Oct 2002 11:22:04 -0000 1.84
@@ -1,3 +1,8 @@
+2002-10-21 Mikael Djurfeldt <mdj@linnaeus>
+
+ * readline.scm (activate-readline): Look for use-emacs-interface
+ option in the guile-user module instead of the-root-module.
+
2002-04-30 Marius Vollmer <marius.vollmer@uni-dortmund.de>
* autogen.sh: Invoke plain aclocal instead of guile-aclocal.sh.
Index: guile-readline/readline.scm
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/guile-readline/readline.scm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- guile-readline/readline.scm 30 Jan 2002 00:03:39 -0000 1.18
+++ guile-readline/readline.scm 21 Oct 2002 11:22:04 -0000 1.19
@@ -1,6 +1,6 @@
;;;; readline.scm --- support functions for command-line editing
;;;;
-;;;; Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+;;;; Copyright (C) 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@@ -199,8 +199,9 @@
(define-public (activate-readline)
(if (and (isatty? (current-input-port))
- (not (and (module-defined? the-root-module 'use-emacs-interface)
- (module-ref the-root-module 'use-emacs-interface))))
+ (not (let ((guile-user-module (resolve-module '(guile-user))))
+ (and (module-defined? guile-user-module 'use-emacs-interface)
+ (module-ref guile-user-module 'use-emacs-interface)))))
(let ((read-hook (lambda () (run-hook before-read-hook))))
(set-current-input-port (readline-port))
(set! repl-reader
Index: ice-9/ChangeLog
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/ice-9/ChangeLog,v
retrieving revision 1.513
retrieving revision 1.514
diff -u -r1.513 -r1.514
--- ice-9/ChangeLog 9 Oct 2002 22:47:51 -0000 1.513
+++ ice-9/ChangeLog 20 Oct 2002 21:51:53 -0000 1.514
@@ -1,3 +1,9 @@
+2002-10-20 Mikael Djurfeldt <mdj@linnaeus>
+
+ * boot-9.scm (top-repl): Look for use-emacs-interface in
+ guile-user-module (should it be there?) instead of
+ the-root-module.
+
2002-10-10 Marius Vollmer <mvo@zagadka.ping.de>
* boot-9.scm (top-repl): Use 2 as the limit when saving the stack.
Index: ice-9/boot-9.scm
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/ice-9/boot-9.scm,v
retrieving revision 1.287
retrieving revision 1.288
diff -u -r1.287 -r1.288
--- ice-9/boot-9.scm 9 Oct 2002 22:47:34 -0000 1.287
+++ ice-9/boot-9.scm 20 Oct 2002 21:51:16 -0000 1.288
@@ -2832,8 +2832,8 @@
(let ((guile-user-module (resolve-module '(guile-user))))
;; Load emacs interface support if emacs option is given.
- (if (and (module-defined? the-root-module 'use-emacs-interface)
- (module-ref the-root-module 'use-emacs-interface))
+ (if (and (module-defined? guile-user-module 'use-emacs-interface)
+ (module-ref guile-user-module 'use-emacs-interface))
(load-emacs-interface))
;; Use some convenient modules (in reverse order)
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-12-01 18:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-10-20 9:29 Emacs interaction mode for Guile Mikael Djurfeldt
2002-10-20 17:01 ` Mikael Djurfeldt
2002-10-21 11:43 ` Mikael Djurfeldt
2002-12-01 18:06 ` Neil Jerram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).