Re: Some questions concerning buffers

Nicolas Neuss <[email protected]> 23 May 2003 18:53:55 +0200
Newsgroups gmane.lisp.ilisp.general
Organization IWR
Message-ID <[email protected]>
(Sorry for the duplicate message, I meant to post it to the group.)

Thanks for your answer.  One thing is still not as I want to have it: I
would like to have the output buffer visible after the command and
scrolling (the reason is that I usually print statistics about some ongoing
computation).

For fun, I have tried this with my keyboard macro approach:

(fset 'copy-eval-last-sexp
   [?\C-  ?\C-\M-b ?\M-w ?\C-\M-f ?\M-x ?c ?m ?u ?l ?i ?s ?p return ?\M-> ?\C-y return ?\C-x ?o])

;;; set it to some key: whatever (for me [f9] is starting up lisp)
(global-set-key [f9] 'copy-eval-last-sexp)

This works, with one problem: jumping back is too fast and the cursor in
the output buffer remains at the beginning of the expression and the buffer
does not scroll...

Hmm,

Nicolas.

"Clementson, Bill" <[email protected]> writes:

> From: Nicolas Neuss on Friday, May 23, 2003 7:41 AM
> > Rolf Wester <[email protected]> writes:
> > 
> > > 2. When I define the function
> > > 
> > > (defun test ()
> > >   (loop for i from 0 to 99 do
> > >     (loop for j from 0 below 3000 do (* j i)) do
> > >     (print i) (force-output *standard-output*)))
> > 
> > I had the same problem and do not quite understand the 
> > solution you give on c.l.l. involving 
> > ilisp-*use-fsf-compliant-keybindings*.  Do you mean to use 
> > the "-and-go" versions of evaluation and compilation 
> > functions?  This works, but what if I want to remain in my 
> > sourc code window?  In this case, the setting of the 
> > fsf-keybindings does not matter for me.
> > 
> > I have an ugly solution which is to define a keyboard macro 
> > consisting of (eval-and-go & jumping back).  If nobody posts 
> > a better solution I'll probably turn this into a function and 
> > set it to some key.
> 
> I'm not sure if I understand the problem exactly, so the following may
> not be what you two want. I think you want to be able to evaluate an
> sexp in a lisp source code buffer and have the output go to the listener
> buffer without leaving the source buffer - is that correct? If so, the
> following code may do what you want. It's a quick hack, so please don't
> look too closely at the code :).
> 
> (defun copy-eval-last-sexp (arg)
>   "Evaluate the last s-expression in the source buffer in the Lisp
> listener."
>   (interactive "p")
>   (let ((end (point))
> 	(beg (save-excursion
> 	       (backward-list 1)
> 	       (point)))
> 	(edit-buffer (current-buffer)))
>     (cond ((and (member* ilisp-buffer (buffer-list)
> 			 :key #'buffer-name
> 			 :test #'equal)
> 		(get-buffer-process (get-buffer ilisp-buffer)))
> 	   (switch-to-buffer ilisp-buffer)
> 	   (end-of-buffer)
> 	   (switch-to-buffer edit-buffer)
> 	   (append-to-buffer ilisp-buffer beg end)
> 	   (switch-to-buffer ilisp-buffer)
> 	   (return-ilisp)
> 	   (switch-to-buffer ilisp-buffer)
> 	   (switch-to-buffer edit-buffer)))))
> 
> (global-set-key [f9] 'copy-eval-last-sexp)
> 
> Evaluate the function and set it to a key (in this example, I've
> globally set it to F9). Start up ilisp and open your test file. Put the
> cursor after the (run 2000) expression in the source file and press F9
> (or whatever key you set it to). The output should go directly to the
> ilisp listener buffer while you continue to edit the source file.
> 
> Hope that helps.
> 
> --
> Bill Clementson


-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge