all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Message buffer time-stamps
@ 2004-12-23  9:01 Yoni Rabkin
  2004-12-24  1:02 ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Yoni Rabkin @ 2004-12-23  9:01 UTC (permalink / raw)


Greetings,

It seems to me that it would be advantageous if the `*Messages*'
buffer in Emacs would have time-stamps before each message line
corresponding to the time that message had appeared.

A `message-timestamp-format' variable could allow the user to set the
format in which the time-stamp would appear.
-- 
"Cut your own wood and it will warm you twice"
	Regards, Yoni Rabkin Katzenell

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-23  9:01 Message buffer time-stamps Yoni Rabkin
@ 2004-12-24  1:02 ` Juri Linkov
  2004-12-25 15:13   ` Richard Stallman
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2004-12-24  1:02 UTC (permalink / raw)
  Cc: emacs-devel

Yoni Rabkin <yonirabkin@gmail.com> writes:
> It seems to me that it would be advantageous if the `*Messages*'
> buffer in Emacs would have time-stamps before each message line
> corresponding to the time that message had appeared.
>
> A `message-timestamp-format' variable could allow the user to set the
> format in which the time-stamp would appear.

Yes, time-stamp printing is needed sometimes.  However, adding
a special format variable would be excessive for this specific need.

There should be a more general way to achieve this.  The best way is
to use after-change-functions hook:

(with-current-buffer (get-buffer "*Messages*")
  (add-hook 'after-change-functions
	    (lambda (beg end del)
	      (if (eq del 0)
		(save-excursion
		  (goto-char beg)
		  (when (bolp)
		    (insert (format-time-string "%Y-%m-%dT%T "))))))
	    nil t))

Note that this code currently doesn't work because `message_dolog'
uses low-level functions that don't call after-change-functions hook.
I propose the patch that calls after-change-functions after *Messages*
buffer modification, i.e. when new messages are added to the
*Messages* buffer by the `message' function.

PS: The Info node "(elisp)Change Hooks" currently says that output of
messages into the `*Messages*' buffer does not call after-change-functions.
This is not true since after-change-functions is called already by
del_range_both when it deletes duplicate rows in the *Messages*
buffer.  This doesn't affect the time-stamp printing because rows with
time-stamps are never deleted, and also hooks can check for the third
argument which has non-zero value when duplicate rows get deleted.
In any case this fact should be properly documented in the Emacs Lisp
Reference Manual.  And when the following patch will be installed, the
documentation should be updated to say that after-change-functions
is called not only when text is deleted in the *Messages* buffer,
but when it is inserted as well.

Index: src/xdisp.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xdisp.c,v
retrieving revision 1.946
diff -u -r1.946 xdisp.c
--- src/xdisp.c	21 Dec 2004 11:35:18 -0000	1.946
+++ src/xdisp.c	24 Dec 2004 00:38:22 -0000
@@ -6438,6 +6445,7 @@
       int old_windows_or_buffers_changed = windows_or_buffers_changed;
       int point_at_end = 0;
       int zv_at_end = 0;
+      int opoint;
       Lisp_Object old_deactivate_mark, tem;
       struct gcpro gcpro1;
 
@@ -6465,6 +6473,8 @@
       ZV_BYTE = Z_BYTE;
       TEMP_SET_PT_BOTH (Z, Z_BYTE);
 
+      opoint = PT;
+
       /* Insert the string--maybe converting multibyte to single byte
 	 or vice versa, so that all the text fits the buffer.  */
       if (multibyte
@@ -6573,6 +6583,9 @@
 	TEMP_SET_PT_BOTH (XMARKER (oldpoint)->charpos,
 			  XMARKER (oldpoint)->bytepos);
 
+      if (opoint != PT)
+	signal_after_change (opoint, 0, PT - opoint);
+
       UNGCPRO;
       unchain_marker (XMARKER (oldpoint));
       unchain_marker (XMARKER (oldbegv));

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-24  1:02 ` Juri Linkov
@ 2004-12-25 15:13   ` Richard Stallman
  2004-12-26  2:47     ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2004-12-25 15:13 UTC (permalink / raw)
  Cc: yonirabkin, emacs-devel

    I propose the patch that calls after-change-functions after *Messages*
    buffer modification, i.e. when new messages are added to the
    *Messages* buffer by the `message' function.

That is not safe.  Messages are output from lots of places, and I
don't know if all of them can handle GC.  This patch would cause GCs
in those places.

You could make this safe by checking every call to the `message_'
functions and verifying that GC is safe in each of them.

However, I'd suggest instead using an idle timer to check that a message
has been added, and to add a timestamp.

There is another issue.  Right now there's a feature to combine
repeated messages.  If you put time stamps in the buffer, that would
break this feature, unless the time stamp code takes pains to keep
it working.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-25 15:13   ` Richard Stallman
@ 2004-12-26  2:47     ` Juri Linkov
  2004-12-27  4:09       ` Richard Stallman
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2004-12-26  2:47 UTC (permalink / raw)
  Cc: yonirabkin, emacs-devel

Richard Stallman <rms@gnu.org> writes:
>     I propose the patch that calls after-change-functions after *Messages*
>     buffer modification, i.e. when new messages are added to the
>     *Messages* buffer by the `message' function.
>
> That is not safe.  Messages are output from lots of places, and I
> don't know if all of them can handle GC.  This patch would cause GCs
> in those places.

GC can be caused even without this patch.  The `del_range_both'
function in `message_dolog' (which deletes the text from the *Messages*
buffer to combine repeated messages) calls a `after-change-functions'
hook when it is defined.

> You could make this safe by checking every call to the `message_'
> functions and verifying that GC is safe in each of them.

I see several variables are protected from GC in `message_dolog'
as well as in functions that call it.  I suppose that is already done
with the expectation of possible GC in `message_dolog'.

> However, I'd suggest instead using an idle timer to check that
> a message has been added, and to add a timestamp.

I don't understand how timers can help to insert message timestamp.
When a timer calls its function it will insert too late timestamp.
And how can it find where to insert timestamps among all recently
added messages?

> There is another issue.  Right now there's a feature to combine
> repeated messages.  If you put time stamps in the buffer, that would
> break this feature, unless the time stamp code takes pains to keep
> it working.

This is right.  Time stamps should break this feature.  Every repeated
message should have its own time stamp.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-26  2:47     ` Juri Linkov
@ 2004-12-27  4:09       ` Richard Stallman
  2004-12-29  7:07         ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Richard Stallman @ 2004-12-27  4:09 UTC (permalink / raw)
  Cc: yonirabkin, emacs-devel

    I see several variables are protected from GC in `message_dolog'
    as well as in functions that call it.  I suppose that is already done
    with the expectation of possible GC in `message_dolog'.

Yes, it seems to try to protect itself.  I just examined its callers,
and they seem to be safe too.

    > However, I'd suggest instead using an idle timer to check that
    > a message has been added, and to add a timestamp.

    I don't understand how timers can help to insert message timestamp.
    When a timer calls its function it will insert too late timestamp.

It would be a little inexact, using the time when the command ends,
but it would be no big deal.

However, since your idea seems to safe, it is better to use
your idea.

    > There is another issue.  Right now there's a feature to combine
    > repeated messages.  If you put time stamps in the buffer, that would
    > break this feature, unless the time stamp code takes pains to keep
    > it working.

    This is right.  Time stamps should break this feature.  Every repeated
    message should have its own time stamp.

Well, if you're sure you want that, I won't argue.  But I would not
want that to be the default.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-27  4:09       ` Richard Stallman
@ 2004-12-29  7:07         ` Juri Linkov
  2004-12-29 17:54           ` Juri Linkov
  2004-12-30 16:43           ` Richard Stallman
  0 siblings, 2 replies; 8+ messages in thread
From: Juri Linkov @ 2004-12-29  7:07 UTC (permalink / raw)
  Cc: emacs-devel

When I looked at the code in `message_dolog' I found one problem.

After printing a message to the *Messages* buffer the code moves the
point to the end of the *Messages* buffer, if the point was at the end
before printing a message.  This is a useful feature, but currently
it works only when the *Messages* buffer is the current buffer.
If messages are printed from other buffers the point does not remain
at the end of the *Messages* buffer.  Is it the intended restriction?

In Shell buffers point remains always at the end of the buffer
if it was there before command execution.  For the *Messages* buffer
this would be useful too, no matter what buffer is the current during
message printing.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-29  7:07         ` Juri Linkov
@ 2004-12-29 17:54           ` Juri Linkov
  2004-12-30 16:43           ` Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2004-12-29 17:54 UTC (permalink / raw)
  Cc: emacs-devel

Juri Linkov <juri@jurta.org> writes:
> If messages are printed from other buffers the point does not remain
> at the end of the *Messages* buffer.

One correction: the point does not remain at the end of the *Messages*
buffer when the *Messages* buffer is displayed in another window.

-- 
Juri Linkov
http://www.jurta.org/emacs/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Message buffer time-stamps
  2004-12-29  7:07         ` Juri Linkov
  2004-12-29 17:54           ` Juri Linkov
@ 2004-12-30 16:43           ` Richard Stallman
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Stallman @ 2004-12-30 16:43 UTC (permalink / raw)
  Cc: emacs-devel

    After printing a message to the *Messages* buffer the code moves the
    point to the end of the *Messages* buffer, if the point was at the end
    before printing a message.  This is a useful feature, but currently
    it works only when the *Messages* buffer is the current buffer.
    If messages are printed from other buffers the point does not remain
    at the end of the *Messages* buffer.  Is it the intended restriction?

I think it should do this regardless of whether the buffer is current.
If you're looking at it in another window, point in that window should
behave this way.

Would you like to implement it?

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-12-30 16:43 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-23  9:01 Message buffer time-stamps Yoni Rabkin
2004-12-24  1:02 ` Juri Linkov
2004-12-25 15:13   ` Richard Stallman
2004-12-26  2:47     ` Juri Linkov
2004-12-27  4:09       ` Richard Stallman
2004-12-29  7:07         ` Juri Linkov
2004-12-29 17:54           ` Juri Linkov
2004-12-30 16:43           ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.