[comp.emacs] Playing with the minibuffer

jr@PEBBLES.BBN.COM (John Robinson) (06/21/88)

Stephe Leake <leake@CME-DURER.ARPA> had a good idea:

> In DEC's LSE, _all_ messages (system broadcast, editor error messages,
> etc) get _appended_ to a $MESSAGE buffer, which the user can edit as a normal
> buffer. I find this _very_ useful for keeping track of what I'm doing,
> since I usually seem to be doing several things at once (waiting for
> something to compile or link, answering a mail message that just came
> in, etc). It appears that this approach would satisfy the recent
> requests for minibuffer string access. How 'bout it? Is there anyway
> to automatically capture any string written to the minibuffer, and
> stuff it in $MESSAGE? Perhaps we could just rewrite (message), or
> something. 

I tried to do this with only some success.  My code follows at the end
of this message.  It uses code Mark Weissman <apollo!weissman> posted
for adding before- and after-hooks to functions.

This does not work perfectly.  The problem is that the functions
(message) and (error) are built-in.  While the hooks are applied any
time the functions are called from ELisp, the old definitions remain
in force for calls from C (which are linked).  I am going to give up
on this for now, hoping that someone with a stronger stomach might
take on the C mods.  It may turn out that the minibuffer needs to be
rethought, so be warned.

I like Stephe's approach, though.

I apologize if this isn't the best of ELisp.

/jr
jr@bbn.com or bbn!jr
-------
(load-library "hooks")		; Mark Weissman's hooks library

(defun save-to-message-buffer (string &rest args)
  "Before-hook for (message) and (error).
Appends a copy of each minibuffer message to the buffer *messages*."
  (interactive)
  (save-window-excursion
    (set-buffer (get-buffer-create "*messages*"))
    (goto-char (point-max))
    (insert-string (format string args))
    (insert-char ?\n 1)))

(mdw:add-hooks message)
(setq mdw:message-before-hooks '(save-to-message-buffer))

(mdw:add-hooks error)
(setq mdw:error-before-hooks '(save-to-message-buffer))
-------

janssen@titan.SW.MCC.COM (Bill Janssen) (06/22/88)

In article <367.582840018@pebbles>, jr@PEBBLES.BBN.COM (John Robinson) writes:
> Stephe Leake <leake@CME-DURER.ARPA> had a good idea:
> > stuff it in $MESSAGE? Perhaps we could just rewrite (message), or
> > something. 

Seems like this should do it:

	(setq old-message-function (symbol-function 'message))

	(defvar *message-list* nil)

	(defun message (string)
	  (setq *message-list* (cons string *message-list*))
	  (funcall old-message-function string))

The problem is that any built-in functions that call message will still
get the old definition.  Shouldn't be hard to do in the C, though.

Bill

janssen@titan.SW.MCC.COM (Bill Janssen) (06/22/88)

The earlier function should have taken account of the fact that
"message" can be called with multiple args.  So:

  (setq old-message-function (symbol-function 'message))

  (defvar *message-list* nil)

  (defun message (string &rest args)
    (setq *message-list* (cons (apply 'format string args) *message-list*))
    (apply 'old-message-function string args))

  (defun view-messages ()

    "Show all the messages that have been displayed in the minibuffer."

    (interactive)
    (let ((b (get-buffer-create "*Messages*"))
	  )
      (set-buffer b)
      (erase-buffer)
      (mapcar '(lambda (string)
		 (goto-char (point-max))
		 (insert string "\n")
		 )
	      *message-list*)
      (display-buffer b)
      ))


The problem here is that this doesn't get the error messages, which are
output by another thing altogther, in keyboard.c, "cmd_error()", a C
function.

Bill

Ram-Ashwin@cs.yale.edu (Ashwin Ram) (06/22/88)

In article <367.582840018@pebbles>, jr@PEBBLES (John Robinson) writes:
> Stephe Leake <leake@CME-DURER.ARPA> had a good idea:
> 
> > In DEC's LSE, _all_ messages (system broadcast, editor error messages,
> > etc) get _appended_ to a $MESSAGE buffer, which the user can edit as a normal
> > buffer. I find this _very_ useful for keeping track of what I'm doing,
> > since I usually seem to be doing several things at once (waiting for
> > something to compile or link, answering a mail message that just came
> > in, etc). It appears that this approach would satisfy the recent
> > requests for minibuffer string access.

It sure would... I think this is a great idea.  To do it right, however, it
would have to be written in C (shouldn't be that hard).  It would also be nice
to have a user variable to determine how many messages should be kept (or
perhaps how large the buffer could be, or how large the message ring should be,
or whatever) before the oldest messages were automatically purged.  This would
avoid massive buildups of the message buffer.

-- Ashwin.

ARPA:    Ram-Ashwin@cs.yale.edu
UUCP:    {decvax,ucbvax,harvard,cmcl2,...}!yale!Ram-Ashwin
BITNET:  Ram@yalecs