hello! i am trying to learn some common lisp using slime.
i like to type my lists into the repl and then i copy paste
the ones that work into a file to save them. what i would
like to do is have a key chord like (save-previous-input-to-file).
or should i not work in the repl. thanks, david
+ david <·····@earthlink.net>:
| hello! i am trying to learn some common lisp using slime.
| i like to type my lists into the repl and then i copy paste
| the ones that work into a file to save them. what i would
| like to do is have a key chord like (save-previous-input-to-file).
| or should i not work in the repl. thanks, david
Well, for what it's worth, the history can be found in the variable
slime-repl-input-history, which is just a list of strings.
So something like this might work:
(defun save-previous-input-to-buffer (buf)
(interactive "BBuffer to save in: ")
(let ((cmd (first slime-repl-input-history)))
(save-excursion
(set-buffer (get-buffer-create buf))
(insert cmd))))
You may wish to add code to add a newline before and/or after, and
optionally move point to the end of the buffer first.
Personally, I tend to just write up and load a file of defuns and
things I am working on, then as I change things in the file I just
evaluate them with C-x C-e or C-c C-c. One-off stuff I just type
directly into the REPL.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
On Sun, 09 Apr 2006 17:26:38 +0200, Harald Hanche-Olsen wrote:
> Well, for what it's worth, the history can be found in the variable
> slime-repl-input-history, which is just a list of strings.
>
> So something like this might work:
>
> (defun save-previous-input-to-buffer (buf)
> (interactive "BBuffer to save in: ")
> (let ((cmd (first slime-repl-input-history)))
> (save-excursion
> (set-buffer (get-buffer-create buf))
> (insert cmd))))
>
thanks! so is this code emacs lisp or cl?
would i be wanting to put it in my .emacs?
+ david <·····@earthlink.net>:
| On Sun, 09 Apr 2006 17:26:38 +0200, Harald Hanche-Olsen wrote:
|
|> (defun save-previous-input-to-buffer (buf)
|> (interactive "BBuffer to save in: ")
|> (let ((cmd (first slime-repl-input-history)))
|> (save-excursion
|> (set-buffer (get-buffer-create buf))
|> (insert cmd))))
|
| thanks! so is this code emacs lisp or cl?
| would i be wanting to put it in my .emacs?
Thats elisp, to go in .emacs.
Use with M-x save-previous-input-to-buffer or, if you get tired of
typing that (though completion saves you from typing the whole thing),
to be bound to a key of your choice. Read about hooks and keybinding
in the emacs documentation to find out how.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell