[comp.emacs] getting all the messages

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

Here's the procedure for recording all the messages written to the minibuffer,
including errors:

1.  Go to the file gnu-emacs/src/xdisp.c

2.  Just before the definiition of C function "message", add the following:

	/* contains a list of all messages written to the minibuffer */
	Lisp_Object Vmessage_list;

	/* When non-zero, save messages in "message-list" */
	int         save_messages;

3.  Go to the end of xdisp.c, inside the function "syms_of_xdisp", and
	add the following just after the initialization
	of Vglobal_mode_string:

  DEFVAR_LISP ("message-list", &Vmessage_list,
	       "List of all messages displayed with \"message\".");
  Vmessage_list = Qnil;

  DEFVAR_BOOL ("save-messages", &save_messages,
	       "*Set to T to save messages in \"message-list\".");
  save_messages = 0;

4.  Go back towards the top of xdisp.c, and in both the functions
	"message" and "message1", add the following lines just before
	the line "minibuf_message = message_buf;":

      if (save_messages)
	Vmessage_list = Fcons(build_string(message_buf),Vmessage_list);

5.  Save xdisp.c.

6.  Go to gnu-emacs/src/keyboard.c.

7.  Error messages are written by the routine "cmd_error", at about
	line 300.  In the declarations of "cmd_error", add the following:

  extern int save_messages;		/* if set, save messages */
  extern Lisp_Object Vmessage_list;	/* list to save message in */

8.  Just before the comment that reads

  /* For file-error, make error message by concatenating
     all the data items.  They are all strings.  */

insert the following:

  if (save_messages)
    {
      Lisp_Object total_error_message = Qnil;
      Lisp_Object tailptr = tail;

      if (!NULL (file_error))
	errmsg = XCONS (tailptr)->car, tailptr = XCONS (tailptr)->cdr;

      if (XTYPE (errmsg) == Lisp_String)
	total_error_message = errmsg;
      else
	total_error_message = build_string("peculiar error");

      for (i = 0; CONSP (tailptr); tailptr = Fcdr (tailptr), i++)
	{
	  total_error_message = call2 (Fconcat,
				       total_error_message,
				       build_string (i ? ", " : ": "));
	  if (!NULL (file_error))
	    total_error_message = call2 (Fconcat,
					 total_error_message,
					 Fprin1_to_string (Fcar (tailptr)));
	}

      Vmessage_list = Fcons (total_error_message, Vmessage_list);
    }

9.  Save keyboard.c.

10.  Rebuild emacs.

11.  Use (setq save-messages t) to start the messages accumulating,
	(setq save-messages nil) to stop them.

12.  Clear out message-list every so often, as it does accumulate.
	It probably really should be a ring buffer, but things like
	incremental-search fill it up so fast that anything previous
	would be lost.

Bill