From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#64855: 30.0.50; ERC 5.6: Make scrolltobottom less erratic Date: Wed, 13 Sep 2023 07:05:52 -0700 Message-ID: <871qf2183j.fsf__25818.7643181131$1694614046$gmane$org@neverwas.me> References: <87h6psyurb.fsf@neverwas.me> <87il948r8x.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40534"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 64855@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 16:07:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qgQWU-000AMp-Cc for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 16:07:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgQWB-0004Jn-9w; Wed, 13 Sep 2023 10:06:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgQW9-0004JN-Qv for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 10:06:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgQW9-0003NU-Hh for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 10:06:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgQWE-0000rv-OO for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 10:07:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 14:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64855 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64855-submit@debbugs.gnu.org id=B64855.16946139723259 (code B ref 64855); Wed, 13 Sep 2023 14:07:02 +0000 Original-Received: (at 64855) by debbugs.gnu.org; 13 Sep 2023 14:06:12 +0000 Original-Received: from localhost ([127.0.0.1]:35479 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgQVQ-0000qU-0P for submit@debbugs.gnu.org; Wed, 13 Sep 2023 10:06:12 -0400 Original-Received: from mail-108-mta23.mxroute.com ([136.175.108.23]:40197) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgQVK-0000qF-Dg for 64855@debbugs.gnu.org; Wed, 13 Sep 2023 10:06:10 -0400 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta23.mxroute.com (ZoneMTA) with ESMTPSA id 18a8edce637000d7b6.001 for <64855@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 13 Sep 2023 14:05:56 +0000 X-Zone-Loop: 90c5c59a52b3539093201b1140068d7c047dbf1ee633 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=SjhFyF60ZXs0WYxlMMA2d4FDRJsOX7k/koUMUi36278=; b=be+oCtlgTEXZr+SZsDUSgBhwcO TMcrmqYeFv4RTUpnP1HdrUWScc4oqwunbqDa2soMBtScgCs32/VRA1+PXdPDTZgqIvRCfk3jxHh21 pJeNDBihJskAWx38b38IEyrb/ku/1eYtlKdL0y7Le0WnkOGB2sweS0r5ahUI0DO+B99JNkgsiveQe XrPd0UbAvuwqGvbLp+gUjQNvIG2bkTcPeJS6Jy2IQwaB37Knd6AW7hXbZxjQM/gCXS+lq9VHBL+mI oD9yTaFqhTWalDyERKXm/osNAFSOcfYDdWasVoYza7v1SVIAqARzpjFd56B7jBs2UfIcG8NMPrzNX RNz4oNSQ==; In-Reply-To: <87il948r8x.fsf@neverwas.me> (J. P.'s message of "Thu, 24 Aug 2023 07:11:26 -0700") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:270287 Archived-At: --=-=-= Content-Type: text/plain "J.P." writes: > v5. Make new behavior hinge on new option, disabled by default. Assign > some module functions explicit hook depths. Add news and tests. I've added a version of this as commit 617ddb808999a71c925b68f5369d77aebfcd9254 Consider all windows in erc-scrolltobottom-mode But it comes with a few known problems. The first can be observed during the rapid insertion of newly arriving messages, like you get with history playback or large swaths of help text. Basically, when point is away from the prompt and you issue a command that changes `window-start' significantly (e.g., M-<), point hardly moves at all, maybe half a screenful at most. Another issue is only noticeable if you have code running that suppresses message insertion after prompt submissions (see bug#49860's `echo-message' for one example). Basically, if you've got `erc-scrolltobottom-relaxed' enabled and you stare long enough, you'll notice that the prompt drifts downward with every submitted round of multi-line input. Attached is a patch that attempts to address both of these issues, along with a couple more to get at some unrelated odds and ends. I'm also sort of thinking we ought to temporarily change the default of the new option `erc-scrolltobottom-all' to t for a few weeks to help flush out any other glaring bugs introduced by this feature. If anyone thinks that's a bad idea, please say so. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-doc-misc-erc.texi-Fix-display-buffer-example.patch >From 88430ddf866031366ccda5439d007fef6b579d8b Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sun, 10 Sep 2023 22:55:16 -0700 Subject: [PATCH 1/4] ; * doc/misc/erc.texi: Fix display-buffer example. --- doc/misc/erc.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi index 6d7785a9b54..1cbecfa891d 100644 --- a/doc/misc/erc.texi +++ b/doc/misc/erc.texi @@ -1821,7 +1821,7 @@ display-buffer (defun my-erc-disp-chan-p (_ action) (or (assq 'erc-autojoin-mode action) - (and (memq (cdr (assq 'erc-buffer-display alist)) 'JOIN) + (and (eq (cdr (assq 'erc-buffer-display action)) 'JOIN) (member (erc-default-target) '("#emacs" "#fsf"))))) @end lisp -- 2.41.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-5.6-Simplify-erc-fill-module-docstring.patch >From 118e2e4aea66d0c54f0966d5e658086654e9807a Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 13 Sep 2023 02:50:28 -0700 Subject: [PATCH 2/4] [5.6] Simplify erc--fill-module-docstring * lisp/erc/erc-common.el (erc--fill-module-docstring): Don't run hooks for major mode when filling. Prefer `lisp-data-mode' to `emacs-lisp-mode'. --- lisp/erc/erc-common.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 85971797c2f..67c2cf8535b 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -270,18 +270,20 @@ erc--prepare-custom-module-type " above.")))))) (defun erc--fill-module-docstring (&rest strings) + "Concatenate STRINGS and fill as a doc string." + ;; Perhaps it's better to mimic `internal--format-docstring-line' + ;; and use basic filling instead of applying a major mode? (with-temp-buffer - (emacs-lisp-mode) - (insert "(defun foo ()\n" - (format "%S" (apply #'concat strings)) - "\n(ignore))") + (delay-mode-hooks + (if (fboundp 'lisp-data-mode) (lisp-data-mode) (emacs-lisp-mode))) + (insert (format "%S" (apply #'concat strings))) (goto-char (point-min)) - (forward-line 2) - (let ((emacs-lisp-docstring-fill-column 65) + (forward-line) + (let ((fill-column 65) (sentence-end-double-space t)) (fill-paragraph)) (goto-char (point-min)) - (nth 3 (read (current-buffer))))) + (read (current-buffer)))) (defmacro erc--find-feature (name alias) `(pcase (erc--find-group ',name ,(and alias (list 'quote alias))) -- 2.41.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-5.6-Skip-erc-ignored-user-p-when-erc-ignore-list-is-.patch >From 801306861920124a4ca68d925829f957d748aa37 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 11 Sep 2023 21:21:42 -0700 Subject: [PATCH 3/4] [5.6] Skip erc-ignored-user-p when erc-ignore-list is empty * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't bother with `erc-ignored-user-p' and `erc-ignored-reply-p' when their associated options are null. * lisp/erc/erc-common.el (erc-get-server-user): Rearrange so `erc-with-server-buffer' doesn't have to switch to the server buffer because `erc-downcase' can run in channels as well. * lisp/erc/erc.el (erc-ignored-user-p): Add comment. * test/lisp/erc/erc-scenarios-base-buffer-display.el (erc-scenarios-base-buffer-display--defwin-recbury-intbuf): Extend timeout. --- lisp/erc/erc-backend.el | 7 ++++--- lisp/erc/erc-common.el | 5 +++-- lisp/erc/erc.el | 2 ++ test/lisp/erc/erc-scenarios-base-buffer-display.el | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 9e121ec1e92..596e504b39f 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -113,6 +113,8 @@ erc-ensure-target-buffer-on-privmsg (defvar erc-format-nick-function) (defvar erc-format-query-as-channel-p) (defvar erc-hide-prompt) +(defvar erc-ignore-list) +(defvar erc-ignore-reply-list) (defvar erc-input-marker) (defvar erc-insert-marker) (defvar erc-invitation) @@ -1902,8 +1904,8 @@ erc--server-determine-join-display-context (cmd (erc-response.command parsed)) (tgt (car (erc-response.command-args parsed))) (msg (erc-response.contents parsed))) - (if (or (erc-ignored-user-p sender-spec) - (erc-ignored-reply-p msg tgt proc)) + (if (or (and erc-ignore-list (erc-ignored-user-p sender-spec)) + (and erc-ignore-reply-list (erc-ignored-reply-p msg tgt proc))) (when erc-minibuffer-ignored (message "Ignored %s from %s to %s" cmd sender-spec tgt)) (let* ((sndr (erc-parse-user sender-spec)) @@ -1918,7 +1920,6 @@ erc--server-determine-join-display-context ,@erc--display-context)) s buffer fnick) - (setf (erc-response.contents parsed) msg) (setq buffer (erc-get-buffer (if privp nick tgt) proc)) ;; Even worth checking for empty target here? (invalid anyway) (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0)) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 67c2cf8535b..e680666156b 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -472,8 +472,9 @@ erc-get-channel-user (define-inline erc-get-server-user (nick) "Find NICK in the current server's `erc-server-users' hash table." (inline-letevals (nick) - (inline-quote (erc-with-server-buffer - (gethash (erc-downcase ,nick) erc-server-users))))) + (inline-quote + (gethash (erc-downcase ,nick) + (erc-with-server-buffer erc-server-users))))) (defmacro erc--with-dependent-type-match (type &rest features) "Massage Custom :type TYPE with :match function that pre-loads FEATURES." diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 07ba32d1cca..a65739cf861 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -6832,6 +6832,8 @@ erc-delete-query (setq erc-default-recipients d2) (error "Current target is not a QUERY")))) +;; FIXME spin this ignore stuff off into its own module, enabled by +;; default until some major version change. (defun erc-ignored-user-p (spec) "Return non-nil if SPEC matches something in `erc-ignore-list'. diff --git a/test/lisp/erc/erc-scenarios-base-buffer-display.el b/test/lisp/erc/erc-scenarios-base-buffer-display.el index df292a8c113..ef544b4dcd0 100644 --- a/test/lisp/erc/erc-scenarios-base-buffer-display.el +++ b/test/lisp/erc/erc-scenarios-base-buffer-display.el @@ -109,7 +109,7 @@ erc-scenarios-base-buffer-display--defwin-recbury-intbuf (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) (should (eq (window-buffer) (get-buffer "#spam"))) ;; Option `buffer' replaces entire window (no split) - (erc-d-t-wait-for 5 (frame-root-window-p (selected-window))))))))) + (erc-d-t-wait-for 10 (frame-root-window-p (selected-window))))))))) (ert-deftest erc-scenarios-base-buffer-display--defwino-recbury-intbuf () :tags '(:expensive-test) -- 2.41.0 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-5.6-Run-erc-scrolltobottom-on-pre-insert-uncondition.patch >From 88681f79c2a6fcfb9343c85e2d8ba58ed8090680 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 13 Sep 2023 05:42:24 -0700 Subject: [PATCH 4/4] [5.6] Run erc--scrolltobottom-on-pre-insert unconditionally * lisp/erc/erc-goodies.el (erc--scrolltobottom-all): Pass `no-force' argument to `set-window-start'. (erc--scrolltobottom-on-pre-insert): Convert function from generic to normal and drop `erc-input' method completely. A non-nil `insertp' slot means a message is marked for insertion in the read-only portion of the buffer, above the prompt. But conditioning the restoring of window parameters on the latter is not enough: the window still needs adjusting whenever input is typed, regardless of whether it's erased or "inserted." (Bug#64855) --- lisp/erc/erc-goodies.el | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 6353b813805..6eb015fdd64 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -223,7 +223,7 @@ erc--scrolltobottom-all ((erc--scrolltobottom-window-info) (found (assq window erc--scrolltobottom-window-info)) ((not (erc--scrolltobottom-confirm (nth 2 found))))) - (setf (window-start window) (cadr found))))) + (set-window-start window (cadr found) 'no-force)))) ;; Necessary unless we're sure `erc--scrolltobottom-on-pre-insert' ;; always runs between calls to this function. (setq erc--scrolltobottom-window-info nil)) @@ -280,7 +280,7 @@ erc--scrolltobottom-setup (kill-local-variable 'erc--scrolltobottom-relaxed-commands) (kill-local-variable 'erc--scrolltobottom-window-info))) -(cl-defmethod erc--scrolltobottom-on-pre-insert (_input-or-string) +(defun erc--scrolltobottom-on-pre-insert (_) "Remember the `window-start' before inserting a message." (setq erc--scrolltobottom-window-info (mapcar (lambda (w) @@ -293,11 +293,6 @@ erc--scrolltobottom-on-pre-insert (if (= ?\n (char-before (point-max))) (1+ c) c)))) (get-buffer-window-list nil nil 'visible)))) -(cl-defmethod erc--scrolltobottom-on-pre-insert ((input erc-input)) - "Remember the `window-start' before inserting a message." - (when (erc-input-insertp input) - (cl-call-next-method))) - (defun erc--scrolltobottom-confirm (&optional scroll-to) "Like `erc-scroll-to-bottom', but use `window-point'. Position current line (with `recenter') SCROLL-TO lines below -- 2.41.0 --=-=-=--