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#60936: 30.0.50; ERC >5.5: Add erc-fill style based on visual-line-mode Date: Sun, 21 May 2023 21:20:57 -0700 Message-ID: <87fs7p3sk6.fsf__10537.5191474863$1684729349$gmane$org@neverwas.me> References: <87tu0nao77.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="8430"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 60936@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 22 06:22:15 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 1q0x3l-0001sk-PE for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 22 May 2023 06:22:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q0x3c-0000nh-0k; Mon, 22 May 2023 00:22:04 -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 1q0x3b-0000n8-1i for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 00:22:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q0x3a-00016n-Px for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 00:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1q0x3a-0001cj-Jo for bug-gnu-emacs@gnu.org; Mon, 22 May 2023 00:22: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: Mon, 22 May 2023 04:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60936 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60936-submit@debbugs.gnu.org id=B60936.16847292746158 (code B ref 60936); Mon, 22 May 2023 04:22:02 +0000 Original-Received: (at 60936) by debbugs.gnu.org; 22 May 2023 04:21:14 +0000 Original-Received: from localhost ([127.0.0.1]:33156 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0x2n-0001bE-Jq for submit@debbugs.gnu.org; Mon, 22 May 2023 00:21:14 -0400 Original-Received: from mail-108-mta233.mxroute.com ([136.175.108.233]:38393) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1q0x2l-0001az-2l for 60936@debbugs.gnu.org; Mon, 22 May 2023 00:21:12 -0400 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta233.mxroute.com (ZoneMTA) with ESMTPSA id 18841b07b1700074ee.001 for <60936@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Mon, 22 May 2023 04:21:04 +0000 X-Zone-Loop: 61b6e08a59b3bcbb263a8a2a66c668e4ab31d0a0950f 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=J2XNE/f5ZyAJrEvzug4AiF7mE1//Fn9rKBxf6GE8+cw=; b=GRMaAQrjaOarcBoTZnBF0bBLyb mLQrHMfnxkHCXbJb0y3UG46EUBRg1SwfQZxUXIhUHxezgyk+WFJxDsgoLZhD1+yduepDmvIOXg3Va Y8pp/oF8A0/hG4pg4G2m3408sp0K8u5/ZNOVKaqRJ1OTXXxDj5Ymvo3PNc63EHt+8E4KVD+LL0u8y 6B1CD/QqEsUa6MX4MfjpVFNXhvzXEPQepjh+lY5mxlaCWhltTZjXPlU7CExJWw4MTSsEppyC0J9nc eEpQBW4cZik6oVuJ/gxAz6mbt+GC6D38vGX83gVuOZ+HHC4ox40wymxU52l3dSiNwkV8xFFtt0vYa N8EXrKIw==; In-Reply-To: <87tu0nao77.fsf@neverwas.me> (J. P.'s message of "Wed, 18 Jan 2023 06:53:48 -0800") 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:262129 Archived-At: --=-=-= Content-Type: text/plain The following commit introduced a regression: commit 05f6fdb9e7893329baff675bd31fb36ad64c756d Author: F. Jason Park Preserve ERC prompt and its bounding markers 1 file changed, 27 insertions(+), 22 deletions(-) lisp/erc/erc.el | 49 +++++++++++++++++++++++++++---------------------- To reproduce from emacs -Q: 1. Eval: (require 'erc) (setq erc-prompt (lambda () (format-time-string "%T>")) erc-autojoin-channels-alist '((ErgoTestnet "#test"))) (erc-tls :server "testnet.ergo.chat") 2. In #test, note the timestamp in the prompt 3. Say "something" RET 4. Notice that the prompt doesn't change, whereas in ERC 5.5 and earlier, it would change on every outgoing message The attached patch fixes the regression and changes the behavior to redraw the prompt on every incoming message as well, but only when `erc-prompt' is a function. Doing this should bring us one step closer to being able to look at bug#51082 erc-prompt: support substitution patterns "%target" and "%network" However, we'd still be missing user-mode tracking, which seems fairly trivial to add. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-5.6-Recompute-erc-prompt-when-inserting-messages.patch >From 292f741020f6dc39103803d6ca0cb8b7fb9e2b61 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 18 May 2023 23:47:27 -0700 Subject: [PATCH] [5.6] Recompute erc-prompt when inserting messages * lisp/erc/erc.el (erc--refresh-prompt): New function for redrawing the prompt in a couple select places. (erc-display-line-1, erc-display-msg): Replace the prompt after inserting messages. * test/lisp/erc/erc-tests.el (erc--refresh-prompt): New test. (Bug#60936) --- lisp/erc/erc.el | 16 +++++- test/lisp/erc/erc-tests.el | 99 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+), 2 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 495e25212ce..16bb2c38b1b 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2787,6 +2787,18 @@ erc--assert-input-bounds (cl-assert (< erc-insert-marker erc-input-marker)) (cl-assert (= (field-end erc-insert-marker) erc-input-marker))))) +(defun erc--refresh-prompt () + "Re-render ERC's prompt when the option `erc-prompt' is a function." + (erc--assert-input-bounds) + (when (functionp erc-prompt) + (save-excursion + (goto-char erc-insert-marker) + ;; Avoid `erc-prompt' (the named function), which appends a + ;; space, and `erc-display-prompt', which propertizes all but + ;; that space. + (insert-and-inherit (funcall erc-prompt)) + (delete-region (point) (1- erc-input-marker))))) + (defun erc-display-line-1 (string buffer) "Display STRING in `erc-mode' BUFFER. Auxiliary function used in `erc-display-line'. The line gets filtered to @@ -2830,7 +2842,7 @@ erc-display-line-1 (when erc-remove-parsed-property (remove-text-properties (point-min) (point-max) '(erc-parsed nil)))) - (erc--assert-input-bounds))))) + (erc--refresh-prompt))))) (run-hooks 'erc-insert-done-hook) (erc-update-undo-list (- (or (marker-position erc-insert-marker) (point-max)) @@ -6452,7 +6464,7 @@ erc-display-msg (narrow-to-region insert-position (point)) (run-hooks 'erc-send-modify-hook) (run-hooks 'erc-send-post-hook)) - (erc--assert-input-bounds))))) + (erc--refresh-prompt))))) (defun erc-command-symbol (command) "Return the ERC command symbol for COMMAND if it exists and is bound." diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index b624186d88d..1c75f35e1b5 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -269,6 +269,105 @@ erc-hide-prompt (kill-buffer "bob") (kill-buffer "ServNet")))) +(ert-deftest erc--refresh-prompt () + (let* ((counter 0) + (erc-prompt (lambda () + (format "%s %d>" + (erc-format-target-and/or-network) + (cl-incf counter)))) + erc-accidental-paste-threshold-seconds + erc-insert-modify-hook + erc--input-review-functions + erc-send-completed-hook) + + (ert-info ("Server buffer") + (with-current-buffer (get-buffer-create "ServNet") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (should (looking-at-p "ServNet 3>")) + (erc-tests--set-fake-server-process "sleep" "1") + (set-process-sentinel erc-server-process #'ignore) + (setq erc-network 'ServNet + erc-server-current-nick "tester" + erc-networks--id (erc-networks--id-create nil) + erc-server-users (make-hash-table :test 'equal)) + (set-process-query-on-exit-flag erc-server-process nil) + ;; Incoming message redraws prompt + (erc-display-message nil 'notice nil "Welcome") + (should (looking-at-p "ServNet 4>")) + ;; Say something + (save-excursion (goto-char erc-input-marker) + (insert "Howdy") + (erc-send-current-line) + (forward-line -1) + (should (looking-at "No target")) + (forward-line -1) + (should (looking-at " Howdy"))) + (should (looking-at-p "ServNet 6>")) + ;; Space after prompt is unpropertized + (should (get-text-property (1- erc-input-marker) 'erc-prompt)) + (should-not (get-text-property erc-input-marker 'erc-prompt)) + ;; No sign of old prompts + (save-excursion + (goto-char (point-min)) + (should-not (search-forward (rx (any "3-5") ">") nil t))))) + + (ert-info ("Channel buffer") + (with-current-buffer (get-buffer-create "#chan") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (should (looking-at-p "#chan 9>")) + (setq erc-server-process (buffer-local-value 'erc-server-process + (get-buffer "ServNet")) + erc-networks--id (erc-with-server-buffer erc-networks--id) + erc--target (erc--target-from-string "#chan") + erc-default-recipients (list "#chan") + erc-channel-users (make-hash-table :test 'equal)) + (erc-update-current-channel-member "alice" "alice") + (erc-update-current-channel-member "bob" "bob") + (erc-update-current-channel-member "tester" "tester") + (erc-display-message nil nil (current-buffer) + (erc-format-privmessage "alice" "Hi" nil t)) + (should (looking-at-p "#chan@ServNet 10>")) + (save-excursion (goto-char erc-input-marker) + (insert "Howdy") + (erc-send-current-line) + (forward-line -1) + (should (looking-at " Howdy"))) + (should (looking-at-p "#chan@ServNet 11>")) + (save-excursion (goto-char erc-input-marker) + (insert "/query bob") + (erc-send-current-line)) + ;; Query does not redraw (nor /help, only message input) + (should (looking-at-p "#chan@ServNet 11>")) + ;; No sign of old prompts + (save-excursion + (goto-char (point-min)) + (should-not (search-forward (rx (or "9" "10") ">") nil t))))) + + (ert-info ("Query buffer") + (with-current-buffer (get-buffer "bob") + (goto-char erc-insert-marker) + (should (looking-at-p "bob@ServNet 14>")) + (erc-display-message nil nil (current-buffer) + (erc-format-privmessage "bob" "Hi" nil t)) + (should (looking-at-p "bob@ServNet 15>")) + (save-excursion (goto-char erc-input-marker) + (insert "Howdy") + (erc-send-current-line) + (forward-line -1) + (should (looking-at " Howdy"))) + (should (looking-at-p "bob@ServNet 16>")) + ;; No sign of old prompts + (save-excursion + (goto-char (point-min)) + (should-not (search-forward (rx (or "14" "15") ">") nil t))))) + + (when noninteractive + (kill-buffer "#chan") + (kill-buffer "bob") + (kill-buffer "ServNet")))) + (ert-deftest erc--initialize-markers () (let ((proc (start-process "true" (current-buffer) "true")) erc-modules -- 2.40.0 --=-=-=--