From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 09 16:29:46 2022 Received: (at submit) by debbugs.gnu.org; 9 Apr 2022 20:29:46 +0000 Received: from localhost ([127.0.0.1]:38771 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHiL-0002xd-1n for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:29:46 -0400 Received: from lists.gnu.org ([209.51.188.17]:37640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndHi7-0002xI-Cv for submit@debbugs.gnu.org; Sat, 09 Apr 2022 16:29:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ndHi7-0003HQ-6Q for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 16:29:31 -0400 Received: from mail-108-mta10.mxroute.com ([136.175.108.10]:34199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ndHi4-000200-Cf for bug-gnu-emacs@gnu.org; Sat, 09 Apr 2022 16:29:30 -0400 Received: from filter006.mxroute.com ([140.82.40.27] 140.82.40.27.vultrusercontent.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta10.mxroute.com (ZoneMTA) with ESMTPSA id 180100467c0000fe85.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 09 Apr 2022 20:29:25 +0000 X-Zone-Loop: a3e6ba01c3c10a512d3eacd41b82407b1efb3c59dbc8 X-Originating-IP: [140.82.40.27] 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:Subject:To:From:Sender: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=qNegjiBFx0NeWtY6ohyYkhkLAojfHNEDieTmnGoXdgE=; b=WGW7HSMgFkS8rRmJM2IGdDEVsm 79XnsQRo870FlmRsojlpwp1xCjBE1WoNHck9qB1w8jcAQl1fDScmjNAcRXNUNddadjhEh1n33zf8Z hzYJWMf0rihB4EkoJ/62RWjtzqQP9sxRH1to1sBY9+0kNQsqH0ADQB9MwrDTeJODVzQvi88w62GBN qtw2hHPCpJUNbUXM4QigfS8GehkRY/Wpz0sLDrMR56buByaYvWbr4eeEqg9oLO6NDzdLpZBaxMLxX IifCNgwfKOdCJShrelrme0JdWoaUESnLwEWpyBjtcrEyiRxiPp/I0QootdM8It+PwuOyFk4dWl5sG JQ93YeWA==; From: "J.P." To: bug-gnu-emacs@gnu.org Subject: 29.0.50; Prevent duplicate prompts when reconnecting in ERC X-Debbugs-CC: emacs-erc@gnu.org Date: Sat, 09 Apr 2022 13:29:23 -0700 Message-ID: <87pmlqgfvg.fsf@neverwas.me> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-AuthUser: masked@neverwas.me Received-SPF: pass client-ip=136.175.108.10; envelope-from=jp@neverwas.me; helo=mail-108-mta10.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Tags: patch Currently, when a user disconnects from an IRC session, the input prompt in the server buffer vanishes. That probably wouldn't matter if the primary means of reconnecting didn't involve needing that very prompt. That is, the recommended way to reconnect is indeed to issue a /reconnect "slash-command" in the input area (the newly nondescript region preceding EOB). IMO, this degrades the overall user experience because a user needs prior knowledge (or must magically intuit) that the input area is in fact still viable and responsive. But that's not all. As soon as that command is issued (normally via RET), a second prompt appears before connection activities commence. Depending on a user's setup and the endpoint they're connecting to, a few things can happen. But most often, server messages start appearing between the two prompts. The proposed patch leverages a long abandoned option called `erc-hide-prompt' to help address both these concerns. Revived and repurposed, it now holds an indicator of the desired prompt behavior upon disconnecting. By default, it merely "hides" the prompt by replacing it with a user-configurable string (currently ">" by default). This happens in all buffers owned by the connection, including target buffers. When the value is 'server' or 'target', only those buffer types are affected. When the value is nil, prompts are never hidden. Hidden prompts can be revealed by typing in the input area. However, once revealed, a prompt won't be rehidden (until the next disconnection). Questions: 1. Currently, channels and queries are lumped together as 'target'. What about changing the shape of the option to a set of {'server', 'channel', 'query'} in a union with t for "all of the above" (to preserve compatibility)? 2. Currently, when the value of `erc-hide-prompt' is 'target' or t, prompts in channels are automatically revealed upon reconnecting, but in queries, they aren't. This adheres faithfully to the protocol and accurately reflects the internal state of the model. Broadly speaking, a client can't reliably tell whether a party they're corresponding with in a query is still available (unless they share a channel). Is overloading the "prompt hidden" indicator with multiple meanings too distracting? (Currently, it means both "disconnected" and "physically connected but possibly not resumable".) Should we instead just reveal the prompt for all queries upon reconnecting, even though it may not be possible to continue certain conversations? Would it be worth accommodating both behaviors via yet another knob (or perhaps different 'query' variants, when going with 1, above)? 2. Right now, the prompt looks like this when hidden: n-1 | *** ERC finished *** [04:30] n | >_ Where _ is the cursor at point max. Should we leave a space after the ">"? This particular patch may benefit from integration trials with popular external ERC modules as well as exotic values for various built-in options. Any takers, please be aware that ERC famously has trouble reassociating buffers upon reconnecting; if that's likely to interfere with your testing, please consider trying #48598 (which currently contains this patch). Volunteers (and detractors) welcome. Thanks. In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.31, cairo version 1.17.4) of 2022-04-05 built on localhost Repository revision: e2fb5ecaea67497224455fdbfe4850a5a74c9d00 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12014000 System Description: Fedora Linux 35 (Workstation Edition) Configured using: 'configure --enable-check-lisp-object-type --enable-checking=yes,glyphs 'CFLAGS=-O0 -g3' PKG_CONFIG_PATH=:/usr/lib64/pkgconfig:/usr/share/pkgconfig' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message mailcap yank-media rmc puny dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068 epg-config gnus-util text-property-search time-date seq gv subr-x byte-opt bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice simple cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 43818 5691) (symbols 48 5713 1) (strings 32 15808 1645) (string-bytes 1 527821) (vectors 16 12098) (vector-slots 8 168912 12189) (floats 8 20 34) (intervals 56 221 0) (buffers 992 10)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-some-ERC-test-helpers.patch >From 2cd0a9e768859bdb3218233bffe277b53840a56d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 5 Apr 2022 17:45:00 -0700 Subject: [PATCH 1/2] Add some ERC test helpers * test/lisp/erc/erc-tests.el (erc-tests--test-prep, erc-tests--set-fake-server-process): Factor out some common buffer-prep boilerplate involving user input and the server process. Shared with bug#54536. --- test/lisp/erc/erc-tests.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 520f10dd4e..373bed55af 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -114,6 +114,20 @@ erc-with-all-buffers-of-server (should (get-buffer "#spam")) (kill-buffer "#spam"))) +(defun erc-tests--send-prep () + (erc-mode) + (insert "\n\n") + (setq erc-input-marker (make-marker) + erc-insert-marker (make-marker)) + (set-marker erc-insert-marker (point-max)) + (erc-display-prompt) + (should (= (point) erc-input-marker))) + +(defun erc-tests--set-fake-server-process (&rest args) + (setq erc-server-process + (apply #'start-process (car args) (current-buffer) args)) + (set-process-query-on-exit-flag erc-server-process nil)) + (ert-deftest erc--switch-to-buffer () (defvar erc-modified-channels-alist) ; lisp/erc/erc-track.el @@ -197,14 +211,10 @@ erc-ring-previous-command-base-case (ert-deftest erc-ring-previous-command () (with-current-buffer (get-buffer-create "*#fake*") (erc-mode) - (insert "\n\n") + (erc-tests--send-prep) + (setq-local erc-last-input-time 0) (should-not (local-variable-if-set-p 'erc-send-completed-hook)) (set (make-local-variable 'erc-send-completed-hook) nil) ; skip t (globals) - (setq erc-input-marker (make-marker) - erc-insert-marker (make-marker)) - (set-marker erc-insert-marker (point-max)) - (erc-display-prompt) - (should (= (point) erc-input-marker)) ;; Just in case erc-ring-mode is already on (setq-local erc-pre-send-functions nil) (add-hook 'erc-pre-send-functions #'erc-add-to-input-ring) -- 2.35.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-SQUASH-ME-Remove-duplicate-ERC-prompt-on-reconnect.patch >From 500e33853f597da47a8e2ad23b1e438373058d70 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 4 Apr 2022 01:50:50 -0700 Subject: [PATCH 2/2] [SQUASH-ME] Remove duplicate ERC prompt on reconnect * lisp/erc/erc-backend.el (erc--unhide-prompt, erc--hide-prompt, erc--unhide-prompt-on-self-insert): Add functions to ensure prompt is hidden on disconnect and shown when a user types /reconnect in a disconnected server buffer. (erc-process-sentinel): Register aforementioned function with `pre-command-hook' when prompt is deleted after disconnecting. (erc-server-PRIVMSG): ensure prompt is showing when a new message arrives from target. * lisp/erc/erc.el (erc-hide-prompt): Repurpose unused option by changing meaning slightly to mean "selectively hide prompt when disconnected." Also delete obsolete, commented-out code that at some point used this option in its prior incarnation. (erc-prompt-hidden): Add new option to specify look of prompt when hidden. (erc-open): Augment earlier reconnect-detection semantics by incorporating `erc--server-reconnecting'. In existing buffers, remove prompt-related hooks and reveal prompt, if necessary. (erc-cmd-RECONNECT): allow a user to reconnect when already connected (by first disconnecting). --- lisp/erc/erc-backend.el | 35 +++++++++++++--- lisp/erc/erc.el | 56 +++++++++++-------------- test/lisp/erc/erc-tests.el | 85 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+), 38 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 398fe6cc9e..593ee735f5 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -696,6 +696,33 @@ erc-process-sentinel-1 ;; unexpected disconnect (erc-process-sentinel-2 event buffer)))) +(defun erc--unhide-prompt () + (remove-hook 'pre-command-hook #'erc--unhide-prompt-on-self-insert t) + (when (and (marker-position erc-insert-marker) + (marker-position erc-input-marker)) + (with-silent-modifications + (remove-text-properties erc-insert-marker erc-input-marker + '(display nil))))) + +(defun erc--unhide-prompt-on-self-insert () + (when (and (eq this-command #'self-insert-command) + (or (eobp) (= (point) erc-input-marker))) + (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 + (memq erc-hide-prompt + (list t (if (erc-default-target) 'target 'server))) + (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 + erc-input-marker `(display ,erc-prompt-hidden))) + (add-hook 'pre-command-hook #'erc--unhide-prompt-on-self-insert 0 t)))) + (defun erc-process-sentinel (cproc event) "Sentinel function for ERC process." (let ((buf (process-buffer cproc))) @@ -718,11 +745,8 @@ erc-process-sentinel (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc)) (with-current-buffer buf (setq erc-channel-users (make-hash-table :test 'equal)))) - ;; Remove the prompt - (goto-char (or (marker-position erc-input-marker) (point-max))) - (forward-line 0) - (erc-remove-text-properties-region (point) (point-max)) - (delete-region (point) (point-max)) + ;; Hide the prompt + (erc--hide-prompt cproc) ;; Decide what to do with the buffer ;; Restart if disconnected (erc-process-sentinel-1 event buf)))))) @@ -1470,6 +1494,7 @@ define-erc-response-handler (setq buffer (erc-get-buffer (if privp nick tgt) proc)) (when buffer (with-current-buffer buffer + (when privp (erc--unhide-prompt)) ;; update the chat partner info. Add to the list if private ;; message. We will accumulate private identities indefinitely ;; at this point. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 52fe106f2d..aab0b4c7ca 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -224,14 +224,24 @@ erc-send-whitespace-lines :group 'erc :type 'boolean) -(defcustom erc-hide-prompt nil - "If non-nil, do not display the prompt for commands. - -\(A command is any input starting with a `/'). +(defcustom erc-prompt-hidden ">" + "Text to show in lieu of the prompt when hidden." + :package-version '(ERC . "5.4.1") ; FIXME increment on next ELPA release + :group 'erc-display + :type 'string) -See also the variables `erc-prompt' and `erc-command-indicator'." +(defcustom erc-hide-prompt t + "If non-nil, hide input prompt upon disconnecting. +To unhide, type something in the input area. Once revealed, a prompt +remains unhidden until the next disconnection. Channel prompts are +unhidden upon rejoining. Query prompts remain hidden until user input +is detected or a new message arrives from the target." + :package-version '(ERC . "5.4.1") ; FIXME increment on next ELPA release :group 'erc-display - :type 'boolean) + :type '(choice (const :tag "Always hide prompt" t) + (const :tag "Never hide prompt" nil) + (const :tag "Only hide target prompt" 'target) + (const :tag "Only hide server prompt" 'server))) ;; tunable GUI stuff @@ -1996,7 +2006,7 @@ erc-open (buffer (erc-get-buffer-create server port channel)) (old-buffer (current-buffer)) old-point - continued-session) + (continued-session erc--server-reconnecting)) (when connect (run-hook-with-args 'erc-before-connect server port nick)) (erc-update-modules) (set-buffer buffer) @@ -2014,7 +2024,7 @@ erc-open ;; (the buffer may have existed) (goto-char (point-max)) (forward-line 0) - (when (get-text-property (point) 'erc-prompt) + (when (or continued-session (get-text-property (point) 'erc-prompt)) (setq continued-session t) (set-marker erc-input-marker (or (next-single-property-change (point) 'erc-prompt) @@ -2074,7 +2084,8 @@ erc-open (goto-char (point-max)) (insert "\n")) (if continued-session - (goto-char old-point) + (progn (goto-char old-point) + (erc--unhide-prompt)) (set-marker erc-insert-marker (point)) (erc-display-prompt) (goto-char (point-max))) @@ -3745,9 +3756,9 @@ erc-cmd-RECONNECT (setq erc--server-reconnecting t) (setq erc-server-reconnect-count 0) (setq process (get-buffer-process (erc-server-buffer))) - (if process - (delete-process process) - (erc-server-reconnect)) + (when process + (delete-process process)) + (erc-server-reconnect) (with-suppressed-warnings ((obsolete erc-server-reconnecting)) (setq erc-server-reconnecting nil)) (setq erc--server-reconnecting nil))) @@ -5665,27 +5676,6 @@ erc-send-input (erc-process-input-line (concat string "\n") t nil)) t)))))) -;; (defun erc-display-command (line) -;; (when erc-insert-this -;; (let ((insert-position (point))) -;; (unless erc-hide-prompt -;; (erc-display-prompt nil nil (erc-command-indicator) -;; (and (erc-command-indicator) -;; 'erc-command-indicator-face))) -;; (let ((beg (point))) -;; (insert line) -;; (erc-put-text-property beg (point) -;; 'font-lock-face 'erc-command-indicator-face) -;; (insert "\n")) -;; (when (processp erc-server-process) -;; (set-marker (process-mark erc-server-process) (point))) -;; (set-marker erc-insert-marker (point)) -;; (save-excursion -;; (save-restriction -;; (narrow-to-region insert-position (point)) -;; (run-hooks 'erc-send-modify-hook) -;; (run-hooks 'erc-send-post-hook)))))) - (defun erc-display-msg (line) "Display LINE as a message of the user to the current target at point." (when erc-insert-this diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 373bed55af..c1d2196a38 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -128,6 +128,91 @@ erc-tests--set-fake-server-process (apply #'start-process (car args) (current-buffer) args)) (set-process-query-on-exit-flag erc-server-process nil)) +(ert-deftest erc-hide-prompt () + (let (erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook) + + (with-current-buffer (get-buffer-create "ServNet") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (should (looking-at-p (regexp-quote erc-prompt))) + (erc-tests--set-fake-server-process "sleep" "1") + (set-process-sentinel erc-server-process #'ignore) + (setq erc-network 'ServNet) + (set-process-query-on-exit-flag erc-server-process nil)) + + (with-current-buffer (get-buffer-create "#chan") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (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"))) + + (ert-info ("Value: t (default)") + (should (eq erc-hide-prompt t)) + (with-current-buffer "ServNet" + (should (= (point) erc-insert-marker)) + (erc--hide-prompt erc-server-process) + (should (string= ">" (get-text-property (point) 'display)))) + + (with-current-buffer "#chan" + (goto-char erc-insert-marker) + (should (string= ">" (get-text-property (point) 'display))) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (goto-char erc-input-marker) + (ert-simulate-command '(self-insert-command 1 ?/)) + (goto-char erc-insert-marker) + (should-not (get-text-property (point) 'display)) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook))) + + (with-current-buffer "ServNet" + (should (get-text-property erc-insert-marker 'display)) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (erc--unhide-prompt) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook)) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: server") + (setq erc-hide-prompt 'server) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should (string= ">" (get-text-property erc-insert-marker 'display)))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "ServNet" + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: target") + (setq erc-hide-prompt 'target) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should (string= ">" (get-text-property erc-insert-marker 'display))) + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: nil") + (setq erc-hide-prompt nil) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display)) + (erc--unhide-prompt) ; won't blow up when prompt already showing + (should-not (get-text-property erc-insert-marker 'display)))) + + (when noninteractive + (kill-buffer "#chan") + (kill-buffer "ServNet")))) + (ert-deftest erc--switch-to-buffer () (defvar erc-modified-channels-alist) ; lisp/erc/erc-track.el -- 2.35.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 10 08:36:44 2022 Received: (at 54826) by debbugs.gnu.org; 10 Apr 2022 12:36:44 +0000 Received: from localhost ([127.0.0.1]:39688 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndWo7-0005Wi-R5 for submit@debbugs.gnu.org; Sun, 10 Apr 2022 08:36:44 -0400 Received: from quimby.gnus.org ([95.216.78.240]:52442) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ndWo6-0005WQ-PW for 54826@debbugs.gnu.org; Sun, 10 Apr 2022 08:36:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References: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=xRWb9RCii9TPfoTPjr/m9OuJlC0jgGLYOy1I6fiB+2s=; b=LL289xcX4iTkzPQDEl0vFtck5x EjOZgChv0uNIQ1aSFlpDx9crlEvQ2pMKye9y+kQcLHFOozkNTj2WMUepaqwDJ3becByHO/cOStmdA 1C/frqbGPCyn/RMkC3Z/+BKeAA95ez+mX/5AwqMQIjKC4MEk3SvK7mHkkRScTglB3jxY=; Received: from [84.212.220.105] (helo=xo) by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ndWnx-0006Vj-Sq; Sun, 10 Apr 2022 14:36:36 +0200 From: Lars Ingebrigtsen To: "J.P." Subject: Re: bug#54826: 29.0.50; Prevent duplicate prompts when reconnecting in ERC References: <87pmlqgfvg.fsf@neverwas.me> X-Now-Playing: Arto Lindsay's _Cuidado Madame_: "Tangles" Date: Sun, 10 Apr 2022 14:36:31 +0200 In-Reply-To: <87pmlqgfvg.fsf@neverwas.me> (J. P.'s message of "Sat, 09 Apr 2022 13:29:23 -0700") Message-ID: <8735ilqfn4.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: "J.P." writes: > The proposed patch leverages a long abandoned option called > `erc-hide-prompt' to help address both these concerns. Makes sense to me. Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 54826 Cc: 54826@debbugs.gnu.org, emacs-erc@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) "J.P." writes: > The proposed patch leverages a long abandoned option called > `erc-hide-prompt' to help address both these concerns. Makes sense to me. > 1. Currently, channels and queries are lumped together as 'target'. What > about changing the shape of the option to a set of {'server', > 'channel', 'query'} in a union with t for "all of the above" (to > preserve compatibility)? Sure. > Is overloading the "prompt hidden" indicator with multiple meanings > too distracting? (Currently, it means both "disconnected" and > "physically connected but possibly not resumable".) Should we instead > just reveal the prompt for all queries upon reconnecting, even though > it may not be possible to continue certain conversations? Would it be > worth accommodating both behaviors via yet another knob (or perhaps > different 'query' variants, when going with 1, above)? I think a new knob would be probably be preferable. > 2. Right now, the prompt looks like this when hidden: > > n-1 | *** ERC finished *** [04:30] > n | >_ > > Where _ is the cursor at point max. Should we leave a space after the > ">"? I think having a space there would be good. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Fri Apr 29 09:08:51 2022 Received: (at 54826) by debbugs.gnu.org; 29 Apr 2022 13:08:51 +0000 Received: from localhost ([127.0.0.1]:51221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkQMc-0000ne-6f for submit@debbugs.gnu.org; Fri, 29 Apr 2022 09:08:51 -0400 Received: from mail-108-mta101.mxroute.com ([136.175.108.101]:34867) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nkQMZ-0000nO-Hd for 54826@debbugs.gnu.org; Fri, 29 Apr 2022 09:08:48 -0400 Received: from filter006.mxroute.com ([140.82.40.27] 140.82.40.27.vultrusercontent.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta101.mxroute.com (ZoneMTA) with ESMTPSA id 18075700722000fe85.001 for <54826@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Fri, 29 Apr 2022 13:08:37 +0000 X-Zone-Loop: 5730b541dab498b033d8ed6b8579ccc63466d33ae4ae X-Originating-IP: [140.82.40.27] 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:In-Reply-To:Date:References: 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=e2sVOHkvWp1pUh657dhDyr2Lihhco1GtaU8N8qWNpNY=; b=QZA8nevRW09pIX35eUjitnQtcu y/BsBu3cyoFDwFUGv9sLvf6aQVEBh1TF3Rp4tRWsgpj+1Fz76QOFZB7XeeQD9GZGSBKcG00D9s3Dz oRnAr5dEgj2OQKEUx0QFa/+OUm8QWUFk1nU0saFiM+fPY0xdszilAWvue8LdNd01CHzTjdjOuwaqW vBGLEa3NujIAdZ/STb66p5jqF1oY/dmp/izGttsoBPxo1lxoP6QgPQZpAjFineHtkWglk2XMaxGZy iGqfCroJuGmLver+iu8V/9BfDNMd43LsHBXSrqOjbmRqyhD+oOi/oneyjs5kTGU/+I4oWRuW1bP7f WwzTWQcQ==; From: "J.P." To: Lars Ingebrigtsen Subject: Re: bug#54826: 29.0.50; Prevent duplicate prompts when reconnecting in ERC References: <87pmlqgfvg.fsf@neverwas.me> <8735ilqfn4.fsf@gnus.org> Date: Fri, 29 Apr 2022 06:08:33 -0700 In-Reply-To: <8735ilqfn4.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 10 Apr 2022 14:36:31 +0200") Message-ID: <878rro2g1a.fsf@neverwas.me> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-AuthUser: masked@neverwas.me X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 54826 Cc: 54826@debbugs.gnu.org, emacs-erc@gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: > "J.P." writes: > >> The proposed patch leverages a long abandoned option called >> `erc-hide-prompt' to help address both these concerns. > > Makes sense to me. > >> 1. Currently, channels and queries are lumped together as 'target'. What >> about changing the shape of the option to a set of {'server', >> 'channel', 'query'} in a union with t for "all of the above" (to >> preserve compatibility)? > > Sure. > >> Is overloading the "prompt hidden" indicator with multiple meanings >> too distracting? (Currently, it means both "disconnected" and >> "physically connected but possibly not resumable".) Should we instead >> just reveal the prompt for all queries upon reconnecting, even though >> it may not be possible to continue certain conversations? Would it be >> worth accommodating both behaviors via yet another knob (or perhaps >> different 'query' variants, when going with 1, above)? > > I think a new knob would be probably be preferable. > >> 2. Right now, the prompt looks like this when hidden: >> >> n-1 | *** ERC finished *** [04:30] >> n | >_ >> >> Where _ is the cursor at point max. Should we leave a space after the >> ">"? > > I think having a space there would be good. Thanks Lars. To everyone else out there: since no one has cared to comment, I've based these changes on Lars's feedback alone. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0000-v1-v2.diff >From 2476ad0cb7b8016dbef1e41080941a727d2be992 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 25 Apr 2022 22:42:10 -0700 Subject: [PATCH 0/2] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (2): Add some ERC test helpers [SQUASH-ME] Remove duplicate ERC prompt on reconnect lisp/erc/erc-backend.el | 41 ++++++++-- lisp/erc/erc.el | 74 ++++++++++-------- test/lisp/erc/erc-tests.el | 150 +++++++++++++++++++++++++++++++++++-- 3 files changed, 221 insertions(+), 44 deletions(-) Interdiff: diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index ff5c28b5d8..a09c1608f9 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -713,14 +713,20 @@ erc--hide-prompt (erc-with-all-buffers-of-server proc nil ; sorta wish this was indent 2 (when (and erc-hide-prompt - (memq erc-hide-prompt - (list t (if (erc-default-target) 'target 'server))) + (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 - erc-input-marker `(display ,erc-prompt-hidden))) + (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)))) (defun erc-process-sentinel (cproc event) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 8ce4e91812..500f8d7406 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -234,14 +234,25 @@ erc-hide-prompt "If non-nil, hide input prompt upon disconnecting. To unhide, type something in the input area. Once revealed, a prompt remains unhidden until the next disconnection. Channel prompts are -unhidden upon rejoining. Query prompts remain hidden until user input -is detected or a new message arrives from the target." +unhidden upon rejoining. See `erc-unhide-query-prompt' for behavior +concerning query prompts." :package-version '(ERC . "5.4.1") ; FIXME increment on next ELPA release :group 'erc-display :type '(choice (const :tag "Always hide prompt" t) - (const :tag "Never hide prompt" nil) - (const :tag "Only hide target prompt" 'target) - (const :tag "Only hide server prompt" 'server))) + (set (const server) + (const query) + (const channel)))) + +(defcustom erc-unhide-query-prompt nil + "When non-nil, always reveal query prompts upon reconnecting. +Otherwise, prompts in a connection's query buffers remain hidden until +the user types in the input area or a new message arrives from the +target." + :package-version '(ERC . "5.4.1") + :group 'erc-display + ;; Extensions may one day offer a way to discover whether a target + ;; is online. When that happens, this can be expanded accordingly. + :type 'boolean) ;; tunable GUI stuff @@ -4722,7 +4733,14 @@ erc-connection-established (erc-update-mode-line) (erc-set-initial-user-mode nick buffer) (erc-server-setup-periodical-ping buffer) - (run-hook-with-args 'erc-after-connect server nick))))) + (run-hook-with-args 'erc-after-connect server nick)))) + + (when erc-unhide-query-prompt + (erc-with-all-buffers-of-server proc + nil ; FIXME use `erc--target' after bug#48598 + (when (and (erc-default-target) + (not (erc-channel-p (car erc-default-recipients)))) + (erc--unhide-prompt))))) (defun erc-set-initial-user-mode (nick buffer) "If `erc-user-mode' is non-nil for NICK, set the user modes. diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index c1d2196a38..961aab4338 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -148,6 +148,14 @@ erc-hide-prompt (get-buffer "ServNet")) erc-default-recipients '("#chan"))) + (with-current-buffer (get-buffer-create "bob") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (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"))) + (ert-info ("Value: t (default)") (should (eq erc-hide-prompt t)) (with-current-buffer "ServNet" @@ -166,6 +174,17 @@ erc-hide-prompt (should-not (memq #'erc--unhide-prompt-on-self-insert pre-command-hook))) + (with-current-buffer "bob" + (goto-char erc-insert-marker) + (should (string= ">" (get-text-property (point) 'display))) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (goto-char erc-input-marker) + (ert-simulate-command '(self-insert-command 1 ?/)) + (goto-char erc-insert-marker) + (should-not (get-text-property (point) 'display)) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook))) + (with-current-buffer "ServNet" (should (get-text-property erc-insert-marker 'display)) (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) @@ -175,7 +194,7 @@ erc-hide-prompt (should-not (get-text-property erc-insert-marker 'display)))) (ert-info ("Value: server") - (setq erc-hide-prompt 'server) + (setq erc-hide-prompt '(server)) (with-current-buffer "ServNet" (erc--hide-prompt erc-server-process) (should (string= ">" (get-text-property erc-insert-marker 'display)))) @@ -183,27 +202,50 @@ erc-hide-prompt (with-current-buffer "#chan" (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "ServNet" (erc--unhide-prompt) (should-not (get-text-property erc-insert-marker 'display)))) - (ert-info ("Value: target") - (setq erc-hide-prompt 'target) + (ert-info ("Value: channel") + (setq erc-hide-prompt '(channel)) (with-current-buffer "ServNet" (erc--hide-prompt erc-server-process) (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "#chan" (should (string= ">" (get-text-property erc-insert-marker 'display))) (erc--unhide-prompt) (should-not (get-text-property erc-insert-marker 'display)))) + (ert-info ("Value: query") + (setq erc-hide-prompt '(query)) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "bob" + (should (string= ">" (get-text-property erc-insert-marker 'display))) + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display)))) + (ert-info ("Value: nil") (setq erc-hide-prompt nil) (with-current-buffer "ServNet" (erc--hide-prompt erc-server-process) (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + (with-current-buffer "#chan" (should-not (get-text-property erc-insert-marker 'display)) (erc--unhide-prompt) ; won't blow up when prompt already showing @@ -211,6 +253,7 @@ erc-hide-prompt (when noninteractive (kill-buffer "#chan") + (kill-buffer "bob") (kill-buffer "ServNet")))) (ert-deftest erc--switch-to-buffer () -- 2.35.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-some-ERC-test-helpers.patch >From 8796cf5ee37983477c7fec271d15ea74c8b7b2e9 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 5 Apr 2022 17:45:00 -0700 Subject: [PATCH 1/2] Add some ERC test helpers * test/lisp/erc/erc-tests.el (erc-tests--test-prep, erc-tests--set-fake-server-process): Factor out some common buffer-prep boilerplate involving user input and the server process. Shared with bug#54536. --- test/lisp/erc/erc-tests.el | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 520f10dd4e..373bed55af 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -114,6 +114,20 @@ erc-with-all-buffers-of-server (should (get-buffer "#spam")) (kill-buffer "#spam"))) +(defun erc-tests--send-prep () + (erc-mode) + (insert "\n\n") + (setq erc-input-marker (make-marker) + erc-insert-marker (make-marker)) + (set-marker erc-insert-marker (point-max)) + (erc-display-prompt) + (should (= (point) erc-input-marker))) + +(defun erc-tests--set-fake-server-process (&rest args) + (setq erc-server-process + (apply #'start-process (car args) (current-buffer) args)) + (set-process-query-on-exit-flag erc-server-process nil)) + (ert-deftest erc--switch-to-buffer () (defvar erc-modified-channels-alist) ; lisp/erc/erc-track.el @@ -197,14 +211,10 @@ erc-ring-previous-command-base-case (ert-deftest erc-ring-previous-command () (with-current-buffer (get-buffer-create "*#fake*") (erc-mode) - (insert "\n\n") + (erc-tests--send-prep) + (setq-local erc-last-input-time 0) (should-not (local-variable-if-set-p 'erc-send-completed-hook)) (set (make-local-variable 'erc-send-completed-hook) nil) ; skip t (globals) - (setq erc-input-marker (make-marker) - erc-insert-marker (make-marker)) - (set-marker erc-insert-marker (point-max)) - (erc-display-prompt) - (should (= (point) erc-input-marker)) ;; Just in case erc-ring-mode is already on (setq-local erc-pre-send-functions nil) (add-hook 'erc-pre-send-functions #'erc-add-to-input-ring) -- 2.35.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-SQUASH-ME-Remove-duplicate-ERC-prompt-on-reconnect.patch >From 2476ad0cb7b8016dbef1e41080941a727d2be992 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 4 Apr 2022 01:50:50 -0700 Subject: [PATCH 2/2] [SQUASH-ME] Remove duplicate ERC prompt on reconnect * lisp/erc/erc-backend.el (erc--unhide-prompt, erc--hide-prompt, erc--unhide-prompt-on-self-insert): Add functions to ensure prompt is hidden on disconnect and shown when a user types /reconnect in a disconnected server buffer. (erc-process-sentinel): Register aforementioned function with `pre-command-hook' when prompt is deleted after disconnecting. (erc-server-PRIVMSG): ensure prompt is showing when a new message arrives from target. * lisp/erc/erc.el (erc-hide-prompt): Repurpose unused option by changing meaning slightly to mean "selectively hide prompt when disconnected." Also delete obsolete, commented-out code that at some point used this option in its prior incarnation. (erc-prompt-hidden): Add new option to specify look of prompt when hidden. (erc-unhide-query-prompt): Add option to force-reveal query prompts on reconnect. (erc-open): Augment earlier reconnect-detection semantics by incorporating `erc--server-reconnecting'. In existing buffers, remove prompt-related hooks and reveal prompt, if necessary. (erc-cmd-RECONNECT): allow a user to reconnect when already connected (by first disconnecting). (erc-connection-established): Possibly unhide query prompts. --- lisp/erc/erc-backend.el | 41 ++++++++++-- lisp/erc/erc.el | 74 +++++++++++---------- test/lisp/erc/erc-tests.el | 128 +++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+), 38 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 4b21711da4..a09c1608f9 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -696,6 +696,39 @@ erc-process-sentinel-1 ;; unexpected disconnect (erc-process-sentinel-2 event buffer)))) +(defun erc--unhide-prompt () + (remove-hook 'pre-command-hook #'erc--unhide-prompt-on-self-insert t) + (when (and (marker-position erc-insert-marker) + (marker-position erc-input-marker)) + (with-silent-modifications + (remove-text-properties erc-insert-marker erc-input-marker + '(display nil))))) + +(defun erc--unhide-prompt-on-self-insert () + (when (and (eq this-command #'self-insert-command) + (or (eobp) (= (point) erc-input-marker))) + (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)))) + (defun erc-process-sentinel (cproc event) "Sentinel function for ERC process." (let ((buf (process-buffer cproc))) @@ -718,11 +751,8 @@ erc-process-sentinel (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc)) (with-current-buffer buf (setq erc-channel-users (make-hash-table :test 'equal)))) - ;; Remove the prompt - (goto-char (or (marker-position erc-input-marker) (point-max))) - (forward-line 0) - (erc-remove-text-properties-region (point) (point-max)) - (delete-region (point) (point-max)) + ;; Hide the prompt + (erc--hide-prompt cproc) ;; Decide what to do with the buffer ;; Restart if disconnected (erc-process-sentinel-1 event buf)))))) @@ -1470,6 +1500,7 @@ define-erc-response-handler (setq buffer (erc-get-buffer (if privp nick tgt) proc)) (when buffer (with-current-buffer buffer + (when privp (erc--unhide-prompt)) ;; update the chat partner info. Add to the list if private ;; message. We will accumulate private identities indefinitely ;; at this point. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 06381c5ebe..500f8d7406 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -224,13 +224,34 @@ erc-send-whitespace-lines :group 'erc :type 'boolean) -(defcustom erc-hide-prompt nil - "If non-nil, do not display the prompt for commands. - -\(A command is any input starting with a `/'). +(defcustom erc-prompt-hidden ">" + "Text to show in lieu of the prompt when hidden." + :package-version '(ERC . "5.4.1") ; FIXME increment on next ELPA release + :group 'erc-display + :type 'string) -See also the variables `erc-prompt' and `erc-command-indicator'." +(defcustom erc-hide-prompt t + "If non-nil, hide input prompt upon disconnecting. +To unhide, type something in the input area. Once revealed, a prompt +remains unhidden until the next disconnection. Channel prompts are +unhidden upon rejoining. See `erc-unhide-query-prompt' for behavior +concerning query prompts." + :package-version '(ERC . "5.4.1") ; FIXME increment on next ELPA release :group 'erc-display + :type '(choice (const :tag "Always hide prompt" t) + (set (const server) + (const query) + (const channel)))) + +(defcustom erc-unhide-query-prompt nil + "When non-nil, always reveal query prompts upon reconnecting. +Otherwise, prompts in a connection's query buffers remain hidden until +the user types in the input area or a new message arrives from the +target." + :package-version '(ERC . "5.4.1") + :group 'erc-display + ;; Extensions may one day offer a way to discover whether a target + ;; is online. When that happens, this can be expanded accordingly. :type 'boolean) ;; tunable GUI stuff @@ -1996,7 +2017,7 @@ erc-open (buffer (erc-get-buffer-create server port channel)) (old-buffer (current-buffer)) old-point - continued-session) + (continued-session erc--server-reconnecting)) (when connect (run-hook-with-args 'erc-before-connect server port nick)) (erc-update-modules) (set-buffer buffer) @@ -2014,7 +2035,7 @@ erc-open ;; (the buffer may have existed) (goto-char (point-max)) (forward-line 0) - (when (get-text-property (point) 'erc-prompt) + (when (or continued-session (get-text-property (point) 'erc-prompt)) (setq continued-session t) (set-marker erc-input-marker (or (next-single-property-change (point) 'erc-prompt) @@ -2074,7 +2095,8 @@ erc-open (goto-char (point-max)) (insert "\n")) (if continued-session - (goto-char old-point) + (progn (goto-char old-point) + (erc--unhide-prompt)) (set-marker erc-insert-marker (point)) (erc-display-prompt) (goto-char (point-max))) @@ -3745,9 +3767,9 @@ erc-cmd-RECONNECT (setq erc--server-reconnecting t) (setq erc-server-reconnect-count 0) (setq process (get-buffer-process (erc-server-buffer))) - (if process - (delete-process process) - (erc-server-reconnect)) + (when process + (delete-process process)) + (erc-server-reconnect) (with-suppressed-warnings ((obsolete erc-server-reconnecting)) (setq erc-server-reconnecting nil)) (setq erc--server-reconnecting nil))) @@ -4711,7 +4733,14 @@ erc-connection-established (erc-update-mode-line) (erc-set-initial-user-mode nick buffer) (erc-server-setup-periodical-ping buffer) - (run-hook-with-args 'erc-after-connect server nick))))) + (run-hook-with-args 'erc-after-connect server nick)))) + + (when erc-unhide-query-prompt + (erc-with-all-buffers-of-server proc + nil ; FIXME use `erc--target' after bug#48598 + (when (and (erc-default-target) + (not (erc-channel-p (car erc-default-recipients)))) + (erc--unhide-prompt))))) (defun erc-set-initial-user-mode (nick buffer) "If `erc-user-mode' is non-nil for NICK, set the user modes. @@ -5665,27 +5694,6 @@ erc-send-input (erc-process-input-line (concat string "\n") t nil)) t)))))) -;; (defun erc-display-command (line) -;; (when erc-insert-this -;; (let ((insert-position (point))) -;; (unless erc-hide-prompt -;; (erc-display-prompt nil nil (erc-command-indicator) -;; (and (erc-command-indicator) -;; 'erc-command-indicator-face))) -;; (let ((beg (point))) -;; (insert line) -;; (erc-put-text-property beg (point) -;; 'font-lock-face 'erc-command-indicator-face) -;; (insert "\n")) -;; (when (processp erc-server-process) -;; (set-marker (process-mark erc-server-process) (point))) -;; (set-marker erc-insert-marker (point)) -;; (save-excursion -;; (save-restriction -;; (narrow-to-region insert-position (point)) -;; (run-hooks 'erc-send-modify-hook) -;; (run-hooks 'erc-send-post-hook)))))) - (defun erc-display-msg (line) "Display LINE as a message of the user to the current target at point." (when erc-insert-this diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 373bed55af..961aab4338 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -128,6 +128,134 @@ erc-tests--set-fake-server-process (apply #'start-process (car args) (current-buffer) args)) (set-process-query-on-exit-flag erc-server-process nil)) +(ert-deftest erc-hide-prompt () + (let (erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook) + + (with-current-buffer (get-buffer-create "ServNet") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (should (looking-at-p (regexp-quote erc-prompt))) + (erc-tests--set-fake-server-process "sleep" "1") + (set-process-sentinel erc-server-process #'ignore) + (setq erc-network 'ServNet) + (set-process-query-on-exit-flag erc-server-process nil)) + + (with-current-buffer (get-buffer-create "#chan") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (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"))) + + (with-current-buffer (get-buffer-create "bob") + (erc-tests--send-prep) + (goto-char erc-insert-marker) + (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"))) + + (ert-info ("Value: t (default)") + (should (eq erc-hide-prompt t)) + (with-current-buffer "ServNet" + (should (= (point) erc-insert-marker)) + (erc--hide-prompt erc-server-process) + (should (string= ">" (get-text-property (point) 'display)))) + + (with-current-buffer "#chan" + (goto-char erc-insert-marker) + (should (string= ">" (get-text-property (point) 'display))) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (goto-char erc-input-marker) + (ert-simulate-command '(self-insert-command 1 ?/)) + (goto-char erc-insert-marker) + (should-not (get-text-property (point) 'display)) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook))) + + (with-current-buffer "bob" + (goto-char erc-insert-marker) + (should (string= ">" (get-text-property (point) 'display))) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (goto-char erc-input-marker) + (ert-simulate-command '(self-insert-command 1 ?/)) + (goto-char erc-insert-marker) + (should-not (get-text-property (point) 'display)) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook))) + + (with-current-buffer "ServNet" + (should (get-text-property erc-insert-marker 'display)) + (should (memq #'erc--unhide-prompt-on-self-insert pre-command-hook)) + (erc--unhide-prompt) + (should-not (memq #'erc--unhide-prompt-on-self-insert + pre-command-hook)) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: server") + (setq erc-hide-prompt '(server)) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should (string= ">" (get-text-property erc-insert-marker 'display)))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "ServNet" + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: channel") + (setq erc-hide-prompt '(channel)) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should (string= ">" (get-text-property erc-insert-marker 'display))) + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: query") + (setq erc-hide-prompt '(query)) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "bob" + (should (string= ">" (get-text-property erc-insert-marker 'display))) + (erc--unhide-prompt) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display)))) + + (ert-info ("Value: nil") + (setq erc-hide-prompt nil) + (with-current-buffer "ServNet" + (erc--hide-prompt erc-server-process) + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "bob" + (should-not (get-text-property erc-insert-marker 'display))) + + (with-current-buffer "#chan" + (should-not (get-text-property erc-insert-marker 'display)) + (erc--unhide-prompt) ; won't blow up when prompt already showing + (should-not (get-text-property erc-insert-marker 'display)))) + + (when noninteractive + (kill-buffer "#chan") + (kill-buffer "bob") + (kill-buffer "ServNet")))) + (ert-deftest erc--switch-to-buffer () (defvar erc-modified-channels-alist) ; lisp/erc/erc-track.el -- 2.35.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 19 15:04:34 2022 Received: (at control) by debbugs.gnu.org; 19 Jun 2022 19:04:34 +0000 Received: from localhost ([127.0.0.1]:53213 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o30Dq-0002hY-4z for submit@debbugs.gnu.org; Sun, 19 Jun 2022 15:04:34 -0400 Received: from mail-pj1-f42.google.com ([209.85.216.42]:32922) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o30Di-0002gf-JH for control@debbugs.gnu.org; Sun, 19 Jun 2022 15:04:27 -0400 Received: by mail-pj1-f42.google.com with SMTP id hv24-20020a17090ae41800b001e33eebdb5dso10707688pjb.0 for ; Sun, 19 Jun 2022 12:04:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:mime-version:date:message-id:subject:to; bh=K+MQ/nFaxhOlMdABYtEUf8efFW1hGolpuikwfzMqLU0=; b=M5F0Zg1RcJcKMnqxD54NNjZzu3Ft79MUnPYOK3fiFS6RRTQ3LvH55cRD0DroA2iw5+ OAR+VKISeHrCbKZ7Uh2sSePmnIyaxoimZgbnIFqjsbIkmQRToxIyBOxBThvDdkRP9ULJ ZMM12lW3SNYIG45VlXHx5vudo2EkzjMQIreP74cYNm5zO3Vl9pbvUznC/Fd6wvJW7fbR nBrlyh9yGbeXx6D1R2ZYQzsG8Y2WvKBAVGIE8P2HdEQ1n3Df60wOo3kMYmXXIwrJll14 DJGa8AQ5QnOqllWX/0CejR2kewzv0oLr9aAYNjfOcnNx68dO6ppG+Ee+TGNMRGbnYJeI Rzaw== X-Gm-Message-State: AJIora8Z516nZESOKFdH5ZPmhKJrYxuhmf/E3gyJPX+KR+mopNo51Cd7 7M7JU5FHj5whvAfL8XtX442lPkzzo7IMCwyh7CxBlMpU X-Google-Smtp-Source: AGRyM1tGB5E/fP6rDVb/Dx2sseWnJKLWvJjlmF4KSP4bgxcFGvgqCC4adiDCYtBAbwQ35o3FshrLd6WLa0zKHgrL7JQ= X-Received: by 2002:a17:90b:4f8a:b0:1e8:9018:dec9 with SMTP id qe10-20020a17090b4f8a00b001e89018dec9mr33277137pjb.89.1655665460995; Sun, 19 Jun 2022 12:04:20 -0700 (PDT) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sun, 19 Jun 2022 12:04:20 -0700 From: Stefan Kangas MIME-Version: 1.0 Date: Sun, 19 Jun 2022 12:04:20 -0700 Message-ID: Subject: control message for bug #54826 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.5 (/) severity 54826 minor quit From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 01 20:58:25 2022 Received: (at control) by debbugs.gnu.org; 2 Jul 2022 00:58:25 +0000 Received: from localhost ([127.0.0.1]:39388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7RSr-0004mA-6M for submit@debbugs.gnu.org; Fri, 01 Jul 2022 20:58:25 -0400 Received: from mail-108-mta142.mxroute.com ([136.175.108.142]:44633) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o7RSo-0004lr-MQ for control@debbugs.gnu.org; Fri, 01 Jul 2022 20:58:23 -0400 Received: from filter006.mxroute.com ([140.82.40.27] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta142.mxroute.com (ZoneMTA) with ESMTPSA id 181bc6a4e0f00095ec.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 02 Jul 2022 00:58:12 +0000 X-Zone-Loop: d7e5e14e58bcf1f6376bc6e343a98a2bdd748b53ecaa X-Originating-IP: [140.82.40.27] 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:Subject:To:From:Sender: Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gTXfxgNwhlKhfDkOQu68N6gXdf2UMPwQA1/D+dDD8ww=; b=crYN2GO3obVZswKozvwj4I2RVJ DTbJfezOfT6m6F9Oy1YUkJ9yvsh3z6BYCTC9q55nwoLY6fBYlQlFO1rUJsu3yY7ozwW7xenATZinN 9BckEB+ELm2FDuK2C62NAy3ScacVVY41/WT8fgE+l+RR6chAl3sWkmYn3X9pq8yvEZ98z6wVpvyoF 8Is3txriH2tst3jiZE2NVAlh3UtI6tOyZpaDDvGlGhj9d7sjdk3s+7R/cR5HM2GLNbnpaZSZgbWc/ nnQtJt8cLOluiFV+Ake1cxFP5rsCXBDNwbzL5EO+eoVq1r76tXBBsXNe3e02kgJKCvpu/d5gzIX7T cXv6zylA==; From: "J.P." To: control@debbugs.gnu.org Subject: control message for bug #54826 Date: Fri, 01 Jul 2022 17:58:09 -0700 Message-ID: <87k08w8h5q.fsf@neverwas.me> MIME-Version: 1.0 Content-Type: text/plain X-AuthUser: masked@neverwas.me X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) close 54826 29.1 quit From unknown Sat Jun 21 12:23:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 30 Jul 2022 11:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator