Home > Archive > Scheme > February 2005 > scheme-mode in Emacs
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 |
scheme-mode in Emacs
|
|
| William Xuuu 2005-02-06, 3:59 pm |
| Hi,
In lisp-interaction-mode, `M-x eval-last-sexp' can print outputs in
minibuffer. How to define a similar function in scheme-mode ?
thanks.
--
William
| |
| Karl Pflästerer 2005-02-07, 4:05 pm |
| On 6 Feb 2005, william_xuuu@163.com wrote:
> In lisp-interaction-mode, `M-x eval-last-sexp' can print outputs in
> minibuffer. How to define a similar function in scheme-mode ?
Your question would have better been asked in an (X)Emacs group.
Nevertheless here is a function:
(defun my-scheme-eval-last-sexp (&optional insert)
(interactive "P")
(let ((standard-output (if insert (current-buffer) t))
(cmd (buffer-substring (save-excursion (backward-sexp) (point)) (point))))
(with-temp-buffer
(comint-redirect-send-command-to-process cmd (current-buffer) (get-process "scheme") nil t)
(while (string= (buffer-string) "") (sleep-for 0.01))
(princ (buffer-string)))))
It assumes a Scheme process had been started (and is named `scheme'
which is the default behaviour). With a prefix argument it inserts the
result of the expression in the current buffer.
KP
|
|
|
|
|