emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 11bae96d23b 08/19: Clarify warning for process-dependent input in


From: F. Jason Park
Subject: master 11bae96d23b 08/19: Clarify warning for process-dependent input in ERC
Date: Sun, 17 Dec 2023 23:21:38 -0500 (EST)

branch: master
commit 11bae96d23b0e3c726be55c34a0493d49d57d2e8
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>

    Clarify warning for process-dependent input in ERC
    
    * lisp/erc/erc.el (erc--check-prompt-input-for-running-process):
    Resolve dissonance between content of ancient `user-error' message and
    condition that triggered it by favoring the former because it's
    supported by the underlying mechanism, which revolves around the
    `process-not-needed' symbol property.
    * test/lisp/erc/erc-tests.el (erc--check-prompt-input-functions):
    Revise expected output for error assertion.  (Bug#66073, originally
    from bug#54536, and included for discussion in bug#67677)
---
 lisp/erc/erc.el            | 17 +++++++++++++----
 test/lisp/erc/erc-tests.el |  4 ++--
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 7fbc6859584..333b762a113 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -7299,11 +7299,20 @@ a separate message."
   (when (< (point) (erc-beg-of-input-line))
     "Point is not in the input area"))
 
+;; Originally, `erc-send-current-line' inhibited sends whenever a
+;; server buffer was missing.  In 2007, this was narrowed to
+;; occurrences involving process-dependent commands.  However, the
+;; accompanying error message, which was identical to that emitted by
+;; `erc-server-send', "ERC: No process running", was always inaccurate
+;; because a server buffer can be alive and its process dead.
 (defun erc--check-prompt-input-for-running-process (string _)
-  "Return non-nil unless in an active ERC server buffer."
-  (unless (or (erc-server-buffer-live-p)
-              (erc-command-no-process-p string))
-    "ERC: No process running"))
+  "Return non-nil if STRING is a slash command missing a process.
+Also do so when the server buffer has been killed."
+  ;; Even if the server buffer has been killed, the user should still
+  ;; be able to /reconnect and recall previous commands.
+  (and (not (erc-command-no-process-p string))
+       (or (and (not (erc-server-buffer-live-p)) "Server buffer missing")
+           (and (not (erc-server-process-alive)) "Process not running"))))
 
 (defun erc--check-prompt-input-for-multiline-command (line lines)
   "Return non-nil when non-blank lines follow a command line."
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index fb4aef00c1e..ca5582885f4 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1414,9 +1414,9 @@
        (ert-info ("Input remains untouched")
          (should (save-excursion (erc-bol) (looking-at "/msg #chan hi")))))
 
-     (ert-info ("Errors when no process running")
+     (ert-info ("Errors when server buffer absent")
        (let ((e (should-error (erc-send-current-line))))
-         (should (equal "ERC: No process running" (cadr e))))
+         (should (equal "Server buffer missing" (cadr e))))
        (ert-info ("Input remains untouched")
          (should (save-excursion (erc-bol) (looking-at "/msg #chan hi")))))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]