|
|
 |
 |
 |
 |
Scheme Programming Language
|
 |
 |
 |
 |
 |
 |
 |
 |
inferior scheme mode : the enter key
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.cava @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
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)))))) -- Emlio 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 frhlich bin!
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.cava @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
|
 |
 |
 |
 |
|