[CM] slime printing

Ralf Mattes rm at seid-online.de
Thu Apr 24 02:03:48 PDT 2014


On Wed, Apr 23, 2014 at 07:45:56PM +0000, James Hearon wrote:
> re: clm emacs-slime
> 
> ...might be a bit OT

Hello James,

> I was hoping to get some advice on printing from emacs-slime.  I'm trying to print output to a visible area of the emacs editor when the code is compiled and runs, such as in with-sound below.
> 
> I'm using f20, sbcl, emacs-slime, and clm but having a devil of a time getting any contrib to load and run with my .emacs file which might support more repl such as to the echo area etc.  I'm wondering what approach you folks might use to print to std out?  Are you using a contrib package or other editor and print .el utility files?

I think it might help us all answering your question if you could explain your teminology. Whta do you mean by "std out"?
Common Lisp has *standard-output* and *error-output* which both are modified by slime to send their stream data back to emacs.
Evaluating (format t "Blah") from the slime repl (you are using the slime repl, aren'gt you) should print to the slime repl
buffer.
This redirection does _not_ work from  other lisp buffers (like the slime scratch buffer et al.) 
If you just want to eval an expression in the slime repl there's slime-eval-last-expression-in-repl which can be 
bound to a keyboard shortcut.
If that's not enough you probably need to write your own helper  code - something like this:

;; -- this is the emacs side: elisp' ---

 (defun clm-message (message)
     (switch-to-buffer "*CLM Results*")
     (goto-char (point-max))
     (insert message))

;; -- this is the lisp side: common lisp ---

 (defun clm-message (message)
  (swank:eval-in-emacs `(clm-message ,message)))


This is only a proof-of-concept. IIRC you also need to configure slime to allow evaluation of expressions
from swank.
 
> I've tried things like (print ), and (format t ...) and (message ...), and those evaluate the expression to the echo area but they don't work when I compile and run and it is beeping.  Or am I totally off base, and lisp doesn't do that very well at all?

Hmm, in what language are you now? At least 'message' is emacs lisp ...
And what is the "echo area" - the minibuffer?


HTH Ralf Mattes

> 
> Thank You,
> Jim
> 
> 
> (definstrument simp (start-time duration frequency amplitude &optional (amp-env '(0 0 .5 1.0 1.0 0)))
>   (multiple-value-bind (beg end) (times->samples start-time duration)
>     (let ((osc (make-oscil :frequency frequency))
>           (amp-env (make-env amp-env :scaler amplitude :duration duration)))
>       (run 
>        (loop for i from beg below end do
>                (outa i (* (env amp-env) (oscil osc) ))
>                    (outb i (* (env amp-env) (oscil osc) ))
>                    )))))
> 
> (with-sound (:channels 2)
> (loop
> for tt from 1 to 10 by 2
> do
> ****** (print tt) *******
> (simp tt .25  220 .75)
> ))
>  		 	   		  

> _______________________________________________
> Cmdist mailing list
> Cmdist at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist



More information about the Cmdist mailing list