Home > Archive > Scheme > May 2007 > inferior scheme mode : the enter key
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
inferior scheme mode : the enter key
|
|
| wayo.cavazos@gmail.com 2007-05-02, 10:06 pm |
| Hello,
Here's what I'd like the enter key to do. comint-send-input if the
input is a complete expression. Otherwise do newline-and-indent. This
is similar to how DrScheme works.
Anyone know how to get Emacs to do this?
Ed
| |
|
| wayo.cavazos@gmail.com wrote:
> Hello,
>
> Here's what I'd like the enter key to do. comint-send-input if the
> input is a complete expression. Otherwise do newline-and-indent. This
> is similar to how DrScheme works.
>
> Anyone know how to get Emacs to do this?
That's already how inferior-lisp mode works, IIRC. Perhaps perusal
of that code would be informative. I may have a look, but not right
this minute.
-- JK
| |
| Emilio Lopes 2007-05-03, 7:07 pm |
| wayo cavazos@gmail com writes:
> Here's what I'd like the enter key to do. comint-send-input if the
> input is a complete expression. Otherwise do newline-and-indent. This
> is similar to how DrScheme works.
> Anyone know how to get Emacs to do this?
Bind the following to "return" in `inferior-scheme-mode-map':
;; From http://www.cs.indiana.edu/chezscheme/emacs/iuscheme.el
(defun scheme-return ()
"Newline and indent, or evaluate the sexp before the prompt.
Complete sexps are evaluated; for incomplete sexps inserts a newline
and indents."
(interactive)
(let ((input-start (process-mark (get-buffer-process (current-buffer)))))
(if (< (point) input-start)
(comint-send-input) ; this does magic stuff
(let ((state (save-excursion
(parse-partial-sexp input-start (point)))))
(if (and (< (car state) 1) ; depth in parens is zero
(not (nth 3 state)) ; not in a string
(not (save-excursion ; nothing after the point
(search-forward-regexp "[^ \t\n\r]" nil t))))
(comint-send-input) ; then go for it.
(newline-and-indent))))))
--
Emílio C. Lopes Ich leb und weiß nit wie lang,
Munich, Germany ich stirb und weiß nit wann,
ich fahr und weiß nit wohin,
(Martinus von Biberach) mich wundert, dass ich fröhlich bin!
| |
| wayo.cavazos@gmail.com 2007-05-03, 7:07 pm |
| On May 3, 2:10 pm, Emilio Lopes <e...@gmx.net> wrote:
> Bind the following to "return" in `inferior-scheme-mode-map':
Works for me. Thanks!
Ed
| |
|
| Hi Ed,
Good suggestions - noticed Emilio gave an excellent reference.
As an aside though, I was wondering how Scheme tested key press
combinations. You see, I used to tinker with basic and it was a snap to map
whatever you wanted to any particular key combination you liked by using
scan codes. Take a look at this link to see what is available:
http://www.win.tue.nl/~aeb/linux/kbd/scancodes.html
I'm still trying to fuddle my way with Scheme but maybe it can do this
approach without necessarily altering the environment permanently ... Key
combinations have been (almost) standardised in Windoze but then there are
other OS and many keyboards. These codes always came in handy and so far as
I can tell, remain a feature within many Microshaft languages.
Mike
<wayo.cavazos@gmail.com> wrote in message
news:1178154079.251538.221160@n76g2000hsh.googlegroups.com...
> Hello,
>
> Here's what I'd like the enter key to do. comint-send-input if the
> input is a complete expression. Otherwise do newline-and-indent. This
> is similar to how DrScheme works.
>
> Anyone know how to get Emacs to do this?
>
> Ed
>
|
|
|
|
|