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#73443: Fwd: bug#73443: 29.4; ERC 5.6.1-git: erc-track mode line face color broken with left timestamps Date: Tue, 24 Sep 2024 17:36:10 -0700 Message-ID: <87v7ykvabp.fsf__15485.2181601868$1727224866$gmane$org@neverwas.me> References: <87h6a63zmj.fsf@trevarch.mail-host-address-is-not-set> <87tte5zvzl.fsf@neverwas.me> <87r0998tqe.fsf@trevarch.mail-host-address-is-not-set> <871q19y1lz.fsf@neverwas.me> <87ed59o4nq.fsf@gmail.com> 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="965"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org, 73443@debbugs.gnu.org To: Trevor Arjeski Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 25 02:40:57 2024 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 1stG5Q-000AdO-V7 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Sep 2024 02:40:57 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1stG59-0001GJ-7I; Tue, 24 Sep 2024 20:40:39 -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 1stG57-0001Fu-HC for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 20:40:37 -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 1stG57-0007ss-7N for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 20:40:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=t5nTlBf7VDqNeey+MSheRFbR2Nf92uTZ6UN/NuaRUeg=; b=tf3pN0Yaj/1AmZOBYNXtr+h0qLNtVzO5z+KEIieHXDPR102MFALvnTnsX70rWWCswuoQTEls/ungflZCcrQaHpqTNamHJImnCmkkx6UN6PiVKzfCYvH/aidNaYj+ALki7CCA5auaJ9X0GBOI0K1v80xu4wM6vBGL9b5A0A3NqPHxJ49T0P4hEj7MYqvvziZgSx0YIhMSXyqtrGQjVPAXrCO9KQImCl65jBnxc41q12W8aukYVj6FdNYMdRpd1ZGgSRM4I6ACfM1BG7/b2iEqvg/5Uje3fr34/wwnrg0fLe3is5PPi9gV+OyPBamGfy0TV1N4UERfZXgA1pOESBe9iQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1stG5W-0006qv-1D for bug-gnu-emacs@gnu.org; Tue, 24 Sep 2024 20:41: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, 25 Sep 2024 00:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73443 X-GNU-PR-Package: emacs Original-Received: via spool by 73443-submit@debbugs.gnu.org id=B73443.172722481625709 (code B ref 73443); Wed, 25 Sep 2024 00:41:01 +0000 Original-Received: (at 73443) by debbugs.gnu.org; 25 Sep 2024 00:40:16 +0000 Original-Received: from localhost ([127.0.0.1]:53710 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stG4m-0006gY-0d for submit@debbugs.gnu.org; Tue, 24 Sep 2024 20:40:16 -0400 Original-Received: from mail-108-mta206.mxroute.com ([136.175.108.206]:42675) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1stG1Q-0006Xm-0G for 73443@debbugs.gnu.org; Tue, 24 Sep 2024 20:36:49 -0400 Original-Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta206.mxroute.com (ZoneMTA) with ESMTPSA id 192269b7c590003e01.001 for <73443@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 25 Sep 2024 00:36:17 +0000 X-Zone-Loop: 901402d6eb84d0f12bc7146ba5b850750f5aeabe3696 X-Originating-IP: [136.175.111.3] 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=t5nTlBf7VDqNeey+MSheRFbR2Nf92uTZ6UN/NuaRUeg=; b=ZifjTJ+yVR72wWq+jw5KbaPi31 YYf0Mgr7PeKOwMUR8k4GxGhBCPwLA/sfKnAN0TB3Xzm8B4foXk50mv+APNPHBF+B83Khsqmfcg7U1 zOGiMvDMnOhfqChNqXQh+I3paAmrgbuUUvP/zn8DMUKHQWsWK3dyF+34v1vobbDgHYYcwSBdMSPli WT87UDE6eL6Yzyq6YUKtX+lpeJ/cm56g5AFxxH0h1h/G3qDuu0AWhsiL5SuUcZqmMky5A4UTqV155 9IHyDmwVLOSV+z0IP6JlG9a1zc/xNeupuN/M5xr3IhHivFO4TJjmNOzAh2YstQIzGG18/pSGhj5Wa 6bkyit5g==; In-Reply-To: <87ed59o4nq.fsf@gmail.com> (Trevor Arjeski's message of "Tue, 24 Sep 2024 11:08:09 +0300") 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:292371 Archived-At: --=-=-= Content-Type: text/plain Trevor Arjeski writes: > "J.P." writes: > >> You could start by "bisecting" the non-ERC parts of your config or the >> non-ERC modes listed in the gathered facts from your initial report >> (default stuff commented out): > > After a bisect, I was able to find the culprit: > > (erc-fill-function 'erc-fill-static) > > Toggling this to and from the default - 'erc-fill-variable - allows me > to reproduce the issue consistently. Thanks for getting to the bottom of this. I was indeed able to reproduce it with user options alone. > > My guess is that the track parser does not like the extra padding > between the timestamp and nick, but I haven't yet looked into the code. Yes, that's essentially what's happening. The new internal function that extracts all faces in a message acted too aggressively in abandoning its search after encountering a region without any face properties. So while this issue is most visible when using `nicks' highlighting, it's actually always present and therefore somewhat pernicious. The attached patch should fix the problem. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-5.6.1-Skip-indentation-when-gathering-faces-in-erc-t.patch >From c9c74f6f3691ffe9a35558bcbd764381d127f36d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 23 Sep 2024 13:48:19 -0700 Subject: [PATCH] [5.6.1] Skip indentation when gathering faces in erc-track * lisp/erc/erc-nicks.el (erc-nicks-mode, erc-nicks-enable) (erc-nicks-disable): Use correct name for `track' module hook. * lisp/erc/erc-track.el (erc-make-mode-line-buffer-name): Don't error when optional COUNT is nil. (erc-track-modified-channels): Use new name for face-finding function. (erc-track--get-faces-in-current-message, erc-track--collect-faces-in): Rename former to latter to better reflect expanded utility, which can span gaps, including newlines and indentation that don't have face-related properties. * test/lisp/erc/erc-track-tests.el (erc-track--collect-faces-in): New test. (Bug#73443) --- lisp/erc/erc-nicks.el | 3 +- lisp/erc/erc-track.el | 42 +++++------ test/lisp/erc/erc-track-tests.el | 126 ++++++++++++++++++++++++++++++- 3 files changed, 148 insertions(+), 23 deletions(-) diff --git a/lisp/erc/erc-nicks.el b/lisp/erc/erc-nicks.el index ccf65f15abd..65a12c927bd 100644 --- a/lisp/erc/erc-nicks.el +++ b/lisp/erc/erc-nicks.el @@ -580,7 +580,7 @@ nicks (setf (alist-get "Edit face" erc-button--nick-popup-alist nil nil #'equal) #'erc-nicks-customize-face) (erc-nicks--setup-track-integration) - (add-hook 'erc-track-mode #'erc-nicks--setup-track-integration 50 t) + (add-hook 'erc-track-mode-hook #'erc-nicks--setup-track-integration 50 t) (advice-add 'widget-create-child-and-convert :filter-args #'erc-nicks--redirect-face-widget-link)) ((kill-local-variable 'erc-nicks--face-table) @@ -598,6 +598,7 @@ nicks #'erc-nicks--highlight-button) (remove-function (local 'erc-track--alt-normals-function) #'erc-nicks--check-normals) + (remove-hook 'erc-track-mode-hook #'erc-nicks--setup-track-integration t) (setf (alist-get "Edit face" erc-button--nick-popup-alist nil 'remove #'equal) nil) diff --git a/lisp/erc/erc-track.el b/lisp/erc/erc-track.el index 39a4775ddca..f40960e4a22 100644 --- a/lisp/erc/erc-track.el +++ b/lisp/erc/erc-track.el @@ -768,7 +768,7 @@ erc-make-mode-line-buffer-name ;; (really?), 3. the defun needs to switch to BUFFER, so we would ;; need to save that value somewhere. (let ((map (make-sparse-keymap)) - (name (if erc-track-showcount + (name (if (and count erc-track-showcount) (concat string erc-track-showcount-string (int-to-string count)) @@ -992,7 +992,7 @@ erc-track-modified-channels (when-let ((faces (if erc-track-ignore-normal-contenders-p (erc-faces-in (buffer-string)) - (erc-track--get-faces-in-current-message))) + (erc-track--collect-faces-in))) (normals erc-track--normal-faces) (erc-track-faces-priority-list `(,@erc-track--attn-faces ,@erc-track-faces-priority-list)) @@ -1057,25 +1057,25 @@ erc-faces-in (defvar erc-track--face-reject-function nil "Function called with face in current buffer to massage or reject.") -(defun erc-track--get-faces-in-current-message () - "Collect all faces in the narrowed buffer. -Return a cons of a hash table and a list ordered from most -recently seen to earliest seen." - (let ((i (text-property-not-all (point-min) (point-max) 'font-lock-face nil)) - (seen (make-hash-table :test #'equal)) - ;; - (rfaces ()) - (faces (make-hash-table :test #'equal))) - (while-let ((i) - (cur (get-text-property i 'face))) - (unless (gethash cur seen) - (puthash cur t seen) - (when erc-track--face-reject-function - (setq cur (funcall erc-track--face-reject-function cur))) - (when cur - (push cur rfaces) - (puthash cur t faces))) - (setq i (next-single-property-change i 'font-lock-face))) +(defun erc-track--collect-faces-in () + "Collect all faces in the (presumably narrowed) current buffer. +Return a cons cell of a hash table and a list ordered from most recently +seen to least." + (let* ((prop (if noninteractive 'font-lock-face 'face)) + (p (text-property-not-all (point-min) (point-max) prop nil)) + (seen (and p (make-hash-table :test #'equal))) + (faces (make-hash-table :test #'equal)) + (rfaces ())) + (while p + (when-let ((cur (get-text-property p prop))) + (unless (gethash cur seen) + (puthash cur t seen) + (when erc-track--face-reject-function + (setq cur (funcall erc-track--face-reject-function cur))) + (when cur + (push cur rfaces) + (puthash cur t faces)))) + (setq p (next-single-property-change p prop))) (cons faces rfaces))) ;;; Buffer switching diff --git a/test/lisp/erc/erc-track-tests.el b/test/lisp/erc/erc-track-tests.el index 3288c42a42e..8149138a971 100644 --- a/test/lisp/erc/erc-track-tests.el +++ b/test/lisp/erc/erc-track-tests.el @@ -22,8 +22,12 @@ ;;; Code: -(require 'ert) (require 'erc-track) +(require 'ert-x) +(eval-and-compile + (let ((load-path (cons (ert-resource-directory) load-path))) + (require 'erc-tests-common))) + (ert-deftest erc-track--shorten-aggressive-nil () "Test non-aggressive erc track buffer name shortening." @@ -286,4 +290,124 @@ erc-track--select-mode-line-face (a b (b a)) (a b (a b))))) +(ert-deftest erc-track--collect-faces-in () + (with-current-buffer (get-buffer-create "*erc-track--get-faces-in*") + (erc-tests-common-prep-for-insertion) + (goto-char (point-min)) + (skip-chars-forward "\n") + + (let ((ts #("[04:37]" + 0 1 ( erc--msg 0 field erc-timestamp + font-lock-face erc-timestamp-face) + 1 7 ( field erc-timestamp + font-lock-face erc-timestamp-face))) + bounds) + + (with-silent-modifications + + (push (list (point)) bounds) + (insert ; JOIN + ts " " ; iniital `fill' indentation lacks properties + #("*** You have joined channel #chan" 0 33 + (font-lock-face erc-notice-face)) + "\n") + (setcdr (car bounds) (point)) + + (push (list (point)) bounds) + (insert ; 353 + ts " " + #("*** Users on #chan: bob alice dummy tester" + 0 30 (font-lock-face erc-notice-face) + 30 35 (font-lock-face erc-current-nick-face) + 35 42 (font-lock-face erc-notice-face)) + "\n" #(" @fsbot" ; but intervening HAS properties + 0 23 (font-lock-face erc-notice-face))) + (setcdr (car bounds) (point)) + + (push (list (point)) bounds) + (insert ; PRIVMSG + "\n" ts " " + #(" bob: Thou canst not come to me: I come to" + 0 1 (font-lock-face erc-default-face) + ;; erc-dangerous-host-face -> erc-nicks-alice-face (undefined) + 1 6 (font-lock-face (erc-dangerous-host-face erc-nick-default-face)) + 6 8 (font-lock-face erc-default-face) + ;; erc-pal-face -> erc-nicks-bob-face (undefined) + 8 11 (font-lock-face (erc-pal-face erc-default-face)) + 11 49 (font-lock-face erc-default-face)) + "\n" #(" thee." + 0 22 (font-lock-face erc-default-face)) + "\n") + (setcdr (car bounds) (point))) + + (goto-char (point-max)) + (should (equal (setq bounds (nreverse bounds)) + '((3 . 50) (50 . 129) (129 . 212)))) + + ;; For these result assertions, the insertion order of the table + ;; elements should mirror that of the consed lists. + + ;; Baseline + (narrow-to-region 1 3) + (let ((result (erc-track--collect-faces-in))) + (should-not (map-pairs (car result))) + (should-not (cdr result))) + + ;; JOIN + (narrow-to-region (car (nth 0 bounds)) (cdr (nth 0 bounds))) + (let ((result (erc-track--collect-faces-in))) + (should (seq-set-equal-p + (map-pairs (car result)) '((erc-timestamp-face . t) + (erc-notice-face . t)))) + (should (equal (cdr result) '(erc-notice-face erc-timestamp-face)))) + + ;; 353 + (narrow-to-region (car (nth 1 bounds)) (cdr (nth 1 bounds))) + (let ((result (erc-track--collect-faces-in))) + (should (seq-set-equal-p (map-pairs (car result)) + '((erc-timestamp-face . t) + (erc-notice-face . t) + (erc-current-nick-face . t)))) + (should (equal (cdr result) '(erc-current-nick-face + erc-notice-face + erc-timestamp-face)))) + + ;; PRIVMSG + (narrow-to-region (car (nth 2 bounds)) (cdr (nth 2 bounds))) + (let ((result (erc-track--collect-faces-in))) + (should (seq-set-equal-p + (map-pairs (car result)) + '((erc-timestamp-face . t) + (erc-default-face . t) + ((erc-dangerous-host-face erc-nick-default-face) . t) + ((erc-pal-face erc-default-face) . t)))) + (should (equal (cdr result) + '((erc-pal-face erc-default-face) + (erc-dangerous-host-face erc-nick-default-face) + erc-default-face + erc-timestamp-face)))) + + ;; Entire buffer. + (narrow-to-region (car (nth 0 bounds)) erc-insert-marker) + (let ((result (erc-track--collect-faces-in))) + (should (seq-set-equal-p + (map-pairs (car result)) + '((erc-timestamp-face . t) + (erc-notice-face . t) + (erc-current-nick-face . t) + (erc-default-face . t) + ((erc-dangerous-host-face erc-nick-default-face) . t) + ((erc-pal-face erc-default-face) . t)))) + (should (equal (cdr result) + '((erc-pal-face erc-default-face) + (erc-dangerous-host-face erc-nick-default-face) + erc-default-face + erc-current-nick-face + erc-notice-face + erc-timestamp-face))))) + + (widen) + (when noninteractive + (kill-buffer)))) + ;;; erc-track-tests.el ends here -- 2.46.1 --=-=-=--