GNU bug report logs - #32470
rcirc-debug: ignore read-only; do not move point if mid-buffer; use %F

Previous Next

Package: emacs;

Reported by: Ivan Shmakov <ivan <at> siamics.net>

Date: Sat, 18 Aug 2018 08:58:01 UTC

Severity: wishlist

Tags: fixed, patch

Fixed in version 27.1

Done: Noam Postavsky <npostavs <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 32470 in the body.
You can then email your comments to 32470 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#32470; Package emacs. (Sat, 18 Aug 2018 08:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Shmakov <ivan <at> siamics.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 18 Aug 2018 08:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: submit <at> debbugs.gnu.org
Subject: rcirc-debug: ignore read-only; do not move point if mid-buffer;
 use %F 
Date: Sat, 18 Aug 2018 08:57:43 +0000
[Message part 1 (text/plain, inline)]
Package:  emacs
Severity: wishlist
Tags: patch

	I find it quite convenient to be able to make the *rcirc debug*
	buffer read-only, so that I won’t be able to change it by
	accident.  This of course requires the rcirc-debug function to
	use inhibit-read-only.

	Another usability tweak is to restore point after insertion –
	unless it was at the end of the (visible portion of the) buffer
	before.  (Hence allowing the buffer to scroll normally after
	end-of-buffer is used.)

	Also, while we’re at, %Y-%m-%d can be replaced with the
	equivalent %F in the format-time-string argument; and concat
	is useless as ‘insert’ effectively concatenates its string
	arguments already.

	I’m somewhat unsure if this change is NEWS-worthy; if so,
	I suggest the following entry.

** rcirc

+++
*** The 'rcirc-debug-buffer' can now be made read-only; it will be
ignored when adding debug text to it.  Also, the point will not be
moved, unless it's set to the end of the visible portion of the buffer.

	Please thus consider the patch MIMEd.

-- 
FSF associate member #7257  np. Funiculì, funiculà — Luciano Pavarotti
[Message part 2 (text/patch, inline)]
From: Ivan Shmakov <ivan <at> siamics.net>
Subject: Improve user convenience of the rcirc debug buffer
Date: Sat, 18 Aug 2018 08:57:08 +0000

* lisp/net/rcirc.el (rcirc-debug): Ignore rcirc-debug-buffer read-only
status.  Restore point after insertion unless it was at the end.
Replace %Y-%m-%d with the equivalent %F in format-time-string; remove
useless concat.  (Bug#-XXX-)
---

--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -670,16 +670,24 @@
   "If non-nil, write information to `rcirc-debug-buffer'.")
 (defun rcirc-debug (process text)
   "Add an entry to the debug log including PROCESS and TEXT.
-Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-flag'
-is non-nil."
+Debug text is appended to `rcirc-debug-buffer' if `rcirc-debug-flag'
+is non-nil.
+
+For convenience, the read-only state of the debug buffer is ignored.
+When the point is at the end of the visible portion of the buffer, it
+is moved to after the text inserted.  Otherwise the point is not moved."
   (when rcirc-debug-flag
     (with-current-buffer (get-buffer-create rcirc-debug-buffer)
-      (goto-char (point-max))
-      (insert (concat
-	       "["
-	       (format-time-string "%Y-%m-%dT%T ") (process-name process)
-	       "] "
-	       text)))))
+      (let ((old (set-marker (make-marker) (point))))
+        (set-marker-insertion-type old t)
+        (goto-char (point-max))
+        (let ((inhibit-read-only t))
+          (terpri (current-buffer) t)
+          (insert "["
+                  (format-time-string "%FT%T ") (process-name process)
+                  "] "
+                  text))
+        (goto-char old)))))
 
 (define-obsolete-variable-alias 'rcirc-sentinel-hooks
   'rcirc-sentinel-functions "24.3")


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32470; Package emacs. (Fri, 14 Sep 2018 12:23:01 GMT) Full text and rfc822 format available.

Message #8 received at 32470 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: 32470 <at> debbugs.gnu.org
Subject: Re: bug#32470: rcirc-debug: ignore read-only;
 do not move point if mid-buffer; use %F
Date: Fri, 14 Sep 2018 08:22:23 -0400
Ivan Shmakov <ivan <at> siamics.net> writes:

> 	I’m somewhat unsure if this change is NEWS-worthy; if so,
> 	I suggest the following entry.

The behaviour of debug tracing functions is somewhat in the gray area
between user visible and internal details, but I'd say there's no need
to update NEWS for this.

> -      (goto-char (point-max))
> -      (insert (concat
> -	       "["
> -	       (format-time-string "%Y-%m-%dT%T ") (process-name process)
> -	       "] "
> -	       text)))))
> +      (let ((old (set-marker (make-marker) (point))))

You could use (point-marker) instead.

> +        (set-marker-insertion-type old t)
> +        (goto-char (point-max))
> +        (let ((inhibit-read-only t))
> +          (terpri (current-buffer) t)

This looks like you're adding an extra newline, or was there a lack of
newlines before?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32470; Package emacs. (Fri, 14 Sep 2018 19:06:01 GMT) Full text and rfc822 format available.

Message #11 received at 32470 <at> debbugs.gnu.org (full text, mbox):

From: Ivan Shmakov <ivan <at> siamics.net>
To: 32470 <at> debbugs.gnu.org
Cc: Noam Postavsky <npostavs <at> gmail.com>
Subject: Re: bug#32470: rcirc-debug: ignore read-only;
 do not move point if mid-buffer; use %F 
Date: Fri, 14 Sep 2018 19:05:26 +0000
[Message part 1 (text/plain, inline)]
>>>>> Noam Postavsky <npostavs <at> gmail.com> writes:
>>>>> Ivan Shmakov <ivan <at> siamics.net> writes:

 >> I’m somewhat unsure if this change is NEWS-worthy; if so, I suggest
 >> the following entry.

 > The behaviour of debug tracing functions is somewhat in the gray area
 > between user visible and internal details, but I’d say there’s no
 > need to update NEWS for this.

	ACK.

 >> +      (let ((old (set-marker (make-marker) (point))))

 > You could use (point-marker) instead.

	ACK, thanks!

 >> +        (set-marker-insertion-type old t)
 >> +        (goto-char (point-max))
 >> +        (let ((inhibit-read-only t))
 >> +          (terpri (current-buffer) t)

 > This looks like you’re adding an extra newline,

	Only if there’s none already, as the second argument to terpri
	is non-nil.  Which can happen, for example, should user edit the
	buffer manually (for whatever reason.)

 > or was there a lack of newlines before?

	Actually, yes, there seem to be an issue with a “missing”
	trailing newline when rcirc-debug is called from rcirc-filter.

	AIUI, when the remote produces a large amount of data (such as
	just after the handshake), rcirc-filter gets called for each
	bufferful of data, e. g.:

(rcirc-filter #<process> "line-1\nline-2\nli")
(rcirc-filter #<process> "ne-3\nline-4\nline")
(rcirc-filter #<process> "-5\nline-6\nline-7")
; and so on…

	There, rcirc-filter will accumulate data in rcirc-process-output
	and process only when the value ends with a newline.  OTOH,
	rcirc-debug gets called once for each rcirc-debug call,
	currently resulting in the *rcirc debug* state being like:

[2018-09-14T18:35:19 process] line-1
line-2
li[2018-09-14T18:35:19 process] ne-3
line-4
line[2018-09-14T18:35:19 process] -5…

	This patch ensures a newline before every [timestamp] marker.

	Please consider the revised patch MIMEd.

	FTR, a ‘side effect’ of this change is that rcirc-debug no
	longer returns the string appended to buffer.  (Instead, it
	returns the marker coinciding with point.)  AFAICT, the return
	value of this function is never used in the Rcirc code.

-- 
FSF associate member #7257  http://softwarefreedomday.org/  15 September 2018
[Message part 2 (text/patch, inline)]
From: Ivan Shmakov <ivan <at> siamics.net>
Subject: Improve user convenience of the rcirc debug buffer
Date: Fri, 14 Sep 2018 19:05:12 +0000

* lisp/net/rcirc.el (rcirc-debug): Ignore rcirc-debug-buffer read-only
status.  Restore point after insertion unless it was at the end.
Ensure a newline before each [lead].  Replace %Y-%m-%d with the
equivalent %F in format-time-string; remove useless concat.  (Bug#32470)
---

--- a/lisp/net/rcirc.el
+++ b/lisp/net/rcirc.el
@@ -670,16 +670,24 @@
   "If non-nil, write information to `rcirc-debug-buffer'.")
 (defun rcirc-debug (process text)
   "Add an entry to the debug log including PROCESS and TEXT.
-Debug text is written to `rcirc-debug-buffer' if `rcirc-debug-flag'
-is non-nil."
+Debug text is appended to `rcirc-debug-buffer' if `rcirc-debug-flag'
+is non-nil.
+
+For convenience, the read-only state of the debug buffer is ignored.
+When the point is at the end of the visible portion of the buffer, it
+is moved to after the text inserted.  Otherwise the point is not moved."
   (when rcirc-debug-flag
     (with-current-buffer (get-buffer-create rcirc-debug-buffer)
-      (goto-char (point-max))
-      (insert (concat
-	       "["
-	       (format-time-string "%Y-%m-%dT%T ") (process-name process)
-	       "] "
-	       text)))))
+      (let ((old (point-marker)))
+        (set-marker-insertion-type old t)
+        (goto-char (point-max))
+        (let ((inhibit-read-only t))
+          (terpri (current-buffer) t)
+          (insert "["
+                  (format-time-string "%FT%T ") (process-name process)
+                  "] "
+                  text))
+        (goto-char old)))))
 
 (define-obsolete-variable-alias 'rcirc-sentinel-hooks
   'rcirc-sentinel-functions "24.3")

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32470; Package emacs. (Tue, 18 Sep 2018 22:48:01 GMT) Full text and rfc822 format available.

Message #14 received at 32470 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: 32470 <at> debbugs.gnu.org
Subject: Re: bug#32470: rcirc-debug: ignore read-only;
 do not move point if mid-buffer; use %F
Date: Tue, 18 Sep 2018 18:46:59 -0400
Ivan Shmakov <ivan <at> siamics.net> writes:

>  >> +          (terpri (current-buffer) t)
>
>  > This looks like you’re adding an extra newline,
>
> 	Only if there’s none already, as the second argument to terpri
> 	is non-nil.  Which can happen, for example, should user edit the
> 	buffer manually (for whatever reason.)

Oh, right.  I don't use terpri so much, so I'd forgotten about that
handy feature.

> 	Please consider the revised patch MIMEd.
>
> 	FTR, a ‘side effect’ of this change is that rcirc-debug no
> 	longer returns the string appended to buffer.  (Instead, it
> 	returns the marker coinciding with point.)  AFAICT, the return
> 	value of this function is never used in the Rcirc code.

I think that's fine, please push to master.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#32470; Package emacs. (Thu, 16 May 2019 11:27:02 GMT) Full text and rfc822 format available.

Message #17 received at 32470 <at> debbugs.gnu.org (full text, mbox):

From: Noam Postavsky <npostavs <at> gmail.com>
To: Ivan Shmakov <ivan <at> siamics.net>
Cc: 32470 <at> debbugs.gnu.org
Subject: Re: bug#32470: rcirc-debug: ignore read-only;
 do not move point if mid-buffer; use %F
Date: Thu, 16 May 2019 07:26:21 -0400
tags 32470 fixed
close 32470 27.1
quit

>> 	Please consider the revised patch MIMEd.
>>
>> 	FTR, a ‘side effect’ of this change is that rcirc-debug no
>> 	longer returns the string appended to buffer.  (Instead, it
>> 	returns the marker coinciding with point.)  AFAICT, the return
>> 	value of this function is never used in the Rcirc code.
>
> I think that's fine, please push to master.

I've done that now.

63a71535a8 2019-05-16T06:54:54-04:00 "Improve user convenience of the rcirc debug buffer"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=63a71535a8998ac6e8cadb9db44cf1dca650d4cb





Added tag(s) fixed. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 16 May 2019 11:27:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 27.1, send any further explanations to 32470 <at> debbugs.gnu.org and Ivan Shmakov <ivan <at> siamics.net> Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 16 May 2019 11:27:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 14 Jun 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 316 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.