[plt-scheme] running an MzScheme debugger in Emacs?

From: Benjamin L. Russell (dekudekuplex at yahoo.com)
Date: Fri Apr 25 05:52:24 EDT 2008

Notwithstanding Robby Findler's comments to the contrary, I agree that there are numerous features in Emacs such that, while some may have functionally equivalent features in DrScheme, they are not fully compensated for by the equivalent features in DrScheme.

As a minor example, pressing "C-s" (i.e., the Ctrl key depressed with the 's' key) performs a real-time, character-by-character forward search in Emacs, and "C-r" searches in the reverse direction, using the same character string.  The DrScheme search function does not start a search until I've already specified what to search for, and augmenting the search string does not extend the search in real-time until I separately command the search again.  Further, there does not seem to be a way to take the current search string and search for the same string in the reverse direction using the equivalent of "C-r".

For example, suppose I have the following program:

;; Towers of Hanoi, plt1.1
;; PLT-Scheme-specific Version 1.1 of Towers of Hanoi
;; Copyright(C) April 02, 2008, at 19:38, 
;; by Benjamin L. Russell

(define (hanoi n)
  (hanoi-helper 'A 'B 'C n))

(define (hanoi-helper source using destination n)
  (cond ((= n 1)
         (printf "Moving from disc ~a to ~a.\n" source destination))
         (hanoi-helper source destination using (- n 1))
         (hanoi-helper source using destination 1)
         (hanoi-helper using source destination (- n 1)))))

In Emacs, entering "C-s (hanoi-helper source d" would take me character-by-character for the next maximally matching string until it highlighted the "(hanoi-helper source d" portion of the third line from the bottom.  Then, deleting the final 'd' would take me back up to the "(hanoi-helper source " part of the first line of the function, and entering 'u' would stay on that line, additionally highlighting the next character, 'u'.  Then, pressing "C-s" again would highlight the next occurrence of that string, in the second-to-last line of that function.  Pressing "C-r" here would being a reverse-direction search, starting at that line; pressing "C-r" one more time would then take me back to the first line of that function, when that string occurred last time.

This kind of functionality can come in handy at times.  There is no real equivalent in DrScheme with this fineness of granularity.

This is no problem for most tasks, but SICP is a very challenging book, and I would at least like to work in my favorite editing environment while working on the exercises in that book in order to focus more on the problems.

Unfortunately, it seems that MzScheme does not run a debugger in Emacs, and that Emacs cannot run an inferior interactive MIT Scheme mode in Windows, but only in UNIX, because their inferior interactive Scheme mode relies on UNIX signals, which are not present in Windows.

I checked out their default editor for Windows, Edwin, but although it seems to have a good debugger, there does not seem to be much online documentation for customizing it.  Since MzScheme does not seem to have a debugger that runs in Emacs, for specifically the purposes of doing the exercises in SICP, what I would really like to do is to take my .emacs file, create an Edwin version of it, and have Edwin start with the same settings (at least until a debugger for MzScheme that can run in Emacs is developed), but since Edwin is Scheme-based while Emacs in Emacs LISP-based, this does not seem possible.  In fact, I couldn't even look up which directory to put the Edwin-init.scm file to have its settings take effect in Windows.  At minimum, I would like to preserve my color scheme, fonts, keyboard shortcuts, and, if possible, functionality of such tools as Quack.

In sum, there seem to be the following options:

1) Forget about Emacs, and get used to DrScheme.
2) Forget about Emacs, and get used to Edwin.
3) Forget about Windows, and somehow find a place to use Emacs running MIT Scheme in an inferior mode in *NIX.
4) Because of lack of documentation, do a lot of research to figure out how to customize Edwin to emulate my customized version of Emacs.
5) Forget about SICP, and stick with HtDP and PLAI.
6) Wait until somebody creates a debugger for MzScheme that runs in Emacs.
7) Do a lot of research, and write my own debugger for MzScheme that runs in Emacs.

Benjamin L. Russell

--- On Fri, 4/25/08, Robby Findler <robby at cs.uchicago.edu> wrote:

> From: Robby Findler <robby at cs.uchicago.edu>
> Subject: Re: [plt-scheme] running an MzScheme debugger in Emacs?
> To: "Ben Simon" <benjisimon at gmail.com>
> Cc: "PLT Scheme List" <plt-scheme at list.cs.brown.edu>
> Date: Friday, April 25, 2008, 2:50 AM
> There are a few of those things in DrScheme. As below.
> Robby
> On Thu, Apr 24, 2008 at 12:34 PM, Ben Simon
> <benjisimon at gmail.com> wrote:
> >
> > On Thu, Apr 24, 2008 at 12:09 PM, Chongkai Zhu
> <czhu at cs.utah.edu> wrote:
> >
> > > Why don't you use DrScheme?
> >
> >
> > I do use DrScheme, but there a whole bunch of features
> that I use in emacs
> > every day that I miss dearly, including:
> >
> > (in no particular order)
> >
> > - dyanmic abbreviation completion (M-/)
> This one is there, at least.
> > - spell checking
> > - dired
> > - the ability to split, join, and resize windows and
> look at two parts of
> > the same file at the same time - all by keystroke
> This one too, at least I think it is all available by
> keystoke, but
> I'm not sure of all of the stuff emacs has.
> > - quick shell access
> > - the ablity to yank previously cut text
> also there.
> > - quick buffer switching by keystroke
> > - subversion integration
> > - auto inserts
> > (I'm sure there are more, and most of them are
> invisible to me because I use
> > them so frequently)
> >
> > Some of these might not seem like a big deal - but
> once you get used to
> > being able to hit M-$ to see if you spelled a variable
> right, you really
> > miss it when it's gone.  In fact, I could probably
> give an impassioned plea
> > to add any of the above features to DrScheme...
> >
> > Don't get me wrong - the debugging support in
> DrScheme is nothing short of
> > amazing.  It's the best I've seen in any
> programming language or editor.
> > And like I said, I use it and enjoy it.
> >
> > It's just that from an editing perspective, emacs
> nails quite a few things.
> >
> > -Ben
> >
> >
> >
> > >
> > >
> > > Chongkai
> > >
> > > Benjamin L. Russell wrote:
> > >
> > > > Is there a way to run an MzScheme debugger
> in Emacs, similarly to the
> > MIT Scheme debugger in Edwin?
> > > >
> > > >
> > > >
> > >
> > > _________________________________________________
> > >  For list-related administrative tasks:
> > > 
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> > >
> >
> >
> >
> > --
> > Have an idea for software? I can make it happen -
> > http://www.ideas2executables.com
> > My Blog: http://benjisimon.blogspot.com
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
> >
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.