[comp.emacs] emacs-lisp function-results - can it be sent to a buffer

mayer@hplabsc.UUCP (07/08/87)

Is there a way to get the results of gnuemacs' lisp evaluations (and
messages) to go to an output buffer rather than the message/minibuffer
line??

This would be especially useful when a whole slew of errors occur from
the evaluation of some lisp funtion and all the errors end up
overwriting each other in the message line.

Ultimately, it would be nifty-neat to be able to toggle between output
going to the message/minibuffer line and a designated output buffer
(perhaps "Lisp Output").

-- Niels.

mayer%hplnpm@HPLABS.HP.COM (Niels P. Mayer) (07/09/87)

> The lisp-interaction-mode of Emacs (which is what the *scratch* buffer is in
> by default) provides a nice REPL (read-eval-print loop) for Emacs lisp, in which
> you can type Emacs lisp expressions and have them evaluated interactively.
> The results are printed in that buffer itself.

Indeed C-J will put eval results into a lisp-interaction-mode buffer.
However, when one is in an emacs-lisp-mode buffer, one may also want to
keep a record of one's evaluation results. If I'm editing an emacs-lisp
file, I wouldn't want evaluation results getting spuriously plugged into my
code (as would happen if the buffer was in lisp-interaction-mode). It would
be consistent with gnuemacs' other language modes if the results of a C-M-X
evaluation in an emacs-lisp-mode buffer would go to the *scratch* buffer.

Anybody know how get that sort of behaviour in gnuemacs?

	-- Niels Mayer
	   Hewlett-Packard Laboratories.
	   (mayer@hplabs.hp.com)

pem@cadnetix.UUCP (Paul Meyer) (07/09/87)

[]
	I have succesfully used (with-output-to-temp-buffer) to send output
   to a buffer.  You also need to make your output come out to the lisp stdout
   to do this, using prin1/princ/whatever.  You can also create a buffer and
   pop up a window on it, then use (insert (prin1 (your-func))) or some such.

	Here are some examples that should work.  (Disclaimer--I don't have
   the time (company time) to test these):

   (defun bletch (buffername)
     "Write a string to BUFFER."
     (with-output-to-temp-buffer buffername (prin1 (+ 3 4))))
   
   (defun squat (buffername)
     "Pop up a buffer named BUFFER, and write to its end."
     (pop-to-buffer buffername)
     (save-excursion
	(goto-char (point-max))
	(insert (prin1-to-string (+ 3 4)))))

	Something I have found invaluable in lieu of a real elisp manual is
   to do M-x apropos "." then save the help buffer.  In my case,
   I dumped it to the laser printer.  I also did a command-apropos of "."
   and saved that one, then did a bunch of manipulation to get two files,
   one just the interactive commands (the straight command-apropos output)
   and one just the noninteractive ones (the apropos output not in the command-
   apropos output).  If I remember correctly, I used emacs or sed to put the
   one-line descriptions (when they existed) on the end of the name lines,
   merged the files using sort, used uniq to discard all repetitions of re-
   peated lines, then undid the joining.  When I see an interesting function
   for something I'm trying to do, I do help F to get the full description.
	Because I am working without an elisp manual, I have learned most
   things by trial and error and looking at the standard code, so I may be
   missing a much easier way to do this.

						pem@cadnetix.uucp

mike@yetti.UUCP (Mike Clarkson ) (07/10/87)

In article <2190@hplabsc.UUCP> mayer@hplabsc.UUCP (Niels Mayer) writes:
>Is there a way to get the results of gnuemacs' lisp evaluations (and
>messages) to go to an output buffer rather than the message/minibuffer
>line??

Do describe-function lisp-interaction-mode
It's usually the default mode in the *scratch* buffer.
<LFD> evaluates the previous s-expression, with the results
displayed in the buffer.

-- 
Mike Clarkson,		  ...!allegra \			BITNET:	mike@YUYETTI or
CRESS, York University,	  ...!decvax   \			SYMALG@YUSOL
4700 Keele Street,	  ...!ihnp4     > !utzoo!yetti!mike
North York, Ontario,	  ...!linus    /		     
CANADA M3J 1P3.		  ...!watmath /		Phone: +1 (416) 736-2100 x 7767


"...the most inevitable business communications system on the planet."
						- ROLM magazine advertisement
 which planet?