From db7096a532ca031687f9411df621900e869e9e98 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 22 Feb 2023 06:24:17 -0800 Subject: [PATCH] Yield to erc-move-to-prompt before unhiding prompt * lisp/erc/erc-backend.el (erc--hide-prompt): Change hook depth from 0 to 91 to allow the `move-to-prompt' module to do its thing. This feature was added by bug#54826 and first appeared in Emacs 29. * lisp/erc/erc-common.el (erc-server-user): Remove erroneous comment. The `buffers' field is a list of buffers. * test/lisp/erc/erc-tests.el (erc-hide-prompt): Use `erc--target' instead of `erc-default-recipients' because this is new code. --- lisp/erc/erc-backend.el | 34 ++++++++++++++++------------------ lisp/erc/erc-common.el | 3 --- test/lisp/erc/erc-tests.el | 4 ++-- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index cf0b734bd28..567443f5329 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -883,24 +883,22 @@ Conditionally try to reconnect and take appropriate action." (erc--unhide-prompt))) (defun erc--hide-prompt (proc) - (erc-with-all-buffers-of-server - proc nil ; sorta wish this was indent 2 - (when (and erc-hide-prompt - (or (eq erc-hide-prompt t) - ;; FIXME use `erc--target' after bug#48598 - (memq (if (erc-default-target) - (if (erc-channel-p (car erc-default-recipients)) - 'channel - 'query) - 'server) - erc-hide-prompt)) - (marker-position erc-insert-marker) - (marker-position erc-input-marker) - (get-text-property erc-insert-marker 'erc-prompt)) - (with-silent-modifications - (add-text-properties erc-insert-marker (1- erc-input-marker) - `(display ,erc-prompt-hidden))) - (add-hook 'pre-command-hook #'erc--unhide-prompt-on-self-insert 0 t)))) + (erc-with-all-buffers-of-server proc nil + (when (and erc-hide-prompt + (or (eq erc-hide-prompt t) + (memq (if erc--target + (if (erc--target-channel-p erc--target) + 'channel + 'query) + 'server) + erc-hide-prompt)) + (marker-position erc-insert-marker) + (marker-position erc-input-marker) + (get-text-property erc-insert-marker 'erc-prompt)) + (with-silent-modifications + (add-text-properties erc-insert-marker (1- erc-input-marker) + `(display ,erc-prompt-hidden))) + (add-hook 'pre-command-hook #'erc--unhide-prompt-on-self-insert 91 t)))) (defun erc-process-sentinel (cproc event) "Sentinel function for ERC process." diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 994555acecf..0279b0a0bc4 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -48,9 +48,6 @@ ;; User data nickname host login full-name info ;; Buffers - ;; - ;; This is an alist of the form (BUFFER . CHANNEL-DATA), where - ;; CHANNEL-DATA is either nil or an erc-channel-user struct. (buffers nil)) (cl-defstruct (erc-channel-user (:type vector) :named) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 40a2d2de657..d6c63934163 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -147,7 +147,7 @@ (should (looking-at-p (regexp-quote erc-prompt))) (setq erc-server-process (buffer-local-value 'erc-server-process (get-buffer "ServNet")) - erc-default-recipients '("#chan"))) + erc--target (erc--target-from-string "#chan"))) (with-current-buffer (get-buffer-create "bob") (erc-tests--send-prep) @@ -155,7 +155,7 @@ (should (looking-at-p (regexp-quote erc-prompt))) (setq erc-server-process (buffer-local-value 'erc-server-process (get-buffer "ServNet")) - erc-default-recipients '("bob"))) + erc--target (erc--target-from-string "bob"))) (ert-info ("Value: t (default)") (should (eq erc-hide-prompt t)) -- 2.39.2