From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ivan Shmakov Newsgroups: gmane.emacs.bugs 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 Message-ID: <87pnxfgart.fsf@violet.siamics.net> References: <87k1ooyrug.fsf@violet.siamics.net> <87d0tgs1z4.fsf@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1536951849 14087 195.159.176.226 (14 Sep 2018 19:04:09 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 14 Sep 2018 19:04:09 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: Noam Postavsky To: 32470@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Sep 14 21:04:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0tNr-0003WE-QX for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Sep 2018 21:04:04 +0200 Original-Received: from localhost ([::1]:53010 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0tPx-0003lv-Ld for geb-bug-gnu-emacs@m.gmane.org; Fri, 14 Sep 2018 15:06:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g0tPq-0003lf-JS for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2018 15:06:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g0tPm-0006Ap-Hr for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2018 15:06:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36664) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g0tPm-0006AT-4H for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2018 15:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1g0tPl-0003uq-Qt for bug-gnu-emacs@gnu.org; Fri, 14 Sep 2018 15:06:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ivan Shmakov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 14 Sep 2018 19:06:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 32470 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 32470-submit@debbugs.gnu.org id=B32470.153695193115010 (code B ref 32470); Fri, 14 Sep 2018 19:06:01 +0000 Original-Received: (at 32470) by debbugs.gnu.org; 14 Sep 2018 19:05:31 +0000 Original-Received: from localhost ([127.0.0.1]:40922 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0tPG-0003u1-VD for submit@debbugs.gnu.org; Fri, 14 Sep 2018 15:05:31 -0400 Original-Received: from fely.am-1.org ([78.47.74.50]:51180) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g0tPF-0003tt-M1 for 32470@debbugs.gnu.org; Fri, 14 Sep 2018 15:05:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=siamics.net ; s=a2013295; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:X-License:Cc:To:Subject:From:Sender:Content-Transfer-Encoding: Reply-To:Content-ID:Content-Description; bh=V2f8CnjWQ8rV0oDUhvPEkCT/dGHVySiAMK1Ah0Svfxc=; b=JIWOzOk8xFl2iGdgaTlIzHytt3 /YAnnlqh6IN+CHy8f+DlOa2LBrny2t7dNqn1W+MB2NEeJvIELQwOWVGZxswL9l1f66T0yPZXZcy7l 8RsvArKs4KDW0Pab8x5j/SHrmIo/Jc6siKWw5lIPw34czMGVJkEE8pyEuPlv60nkJ16M=; Original-Received: from tunnel35660-pt.tunnel.tserv10.par1.ipv6.he.net ([2001:470:1f12:1eb::2] helo=violet.siamics.net) by fely.am-1.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1g0tPE-0007zy-5f; Fri, 14 Sep 2018 19:05:28 +0000 Original-Received: from localhost ([::1] helo=violet.siamics.net) by violet.siamics.net with esmtp (Exim 4.84_2) (envelope-from ) id 1g0tPD-0001cg-56; Fri, 14 Sep 2018 19:05:27 +0000 X-License: CC-BY-SA-3.0+ (original contributions only) In-Reply-To: <87d0tgs1z4.fsf@gmail.com> (Noam Postavsky's message of "Fri, 14 Sep 2018 08:22:23 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:150321 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable >>>>> Noam Postavsky writes: >>>>> Ivan Shmakov writes: >> I=E2=80=99m somewhat unsure if this change is NEWS-worthy; if so, I sug= gest >> the following entry. > The behaviour of debug tracing functions is somewhat in the gray area > between user visible and internal details, but I=E2=80=99d say there=E2= =80=99s 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=E2=80=99re adding an extra newline, Only if there=E2=80=99s 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 =E2=80=9Cmissing=E2=80=9D 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 # "line-1\nline-2\nli") (rcirc-filter # "ne-3\nline-4\nline") (rcirc-filter # "-5\nline-6\nline-7") ; and so on=E2=80=A6 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=E2=80=A6 This patch ensures a newline before every [timestamp] marker. Please consider the revised patch MIMEd. FTR, a =E2=80=98side effect=E2=80=99 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. --=20 FSF associate member #7257 http://softwarefreedomday.org/ 15 September 20= 18 --=-=-= Content-Type: text/patch Content-Disposition: inline From: Ivan Shmakov 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") --=-=-=--