unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Ivan Shmakov <ivan@siamics.net>
To: 32470@debbugs.gnu.org
Cc: Noam Postavsky <npostavs@gmail.com>
Subject: 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	[thread overview]
Message-ID: <87pnxfgart.fsf@violet.siamics.net> (raw)
In-Reply-To: <87d0tgs1z4.fsf@gmail.com> (Noam Postavsky's message of "Fri, 14 Sep 2018 08:22:23 -0400")

[-- Attachment #1: Type: text/plain, Size: 2256 bytes --]

>>>>> Noam Postavsky <npostavs@gmail.com> writes:
>>>>> Ivan Shmakov <ivan@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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/patch, Size: 1741 bytes --]

From: Ivan Shmakov <ivan@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")

  reply	other threads:[~2018-09-14 19:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-18  8:57 bug#32470: rcirc-debug: ignore read-only; do not move point if mid-buffer; use %F Ivan Shmakov
2018-09-14 12:22 ` Noam Postavsky
2018-09-14 19:05   ` Ivan Shmakov [this message]
2018-09-18 22:46     ` Noam Postavsky
2019-05-16 11:26       ` Noam Postavsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pnxfgart.fsf@violet.siamics.net \
    --to=ivan@siamics.net \
    --cc=32470@debbugs.gnu.org \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).