summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2023-05-07 19:43:57 -0700
committerF. Jason Park <jp@neverwas.me>2023-05-13 07:05:22 -0700
commit38706abdf7f6d919640e8e14f0e0dc6cf34aa555 (patch)
tree7ecbbb2950fd191356ed55f61a5ffd4c8434440d /test
parentc96c8a9a7d22b59af40bf7e963245ae271159bfe (diff)
downloademacs-38706abdf7f6d919640e8e14f0e0dc6cf34aa555.tar.gz
Add helper for restoring local session vars in ERC
* lisp/erc/erc-common.el (erc--input-split): Suppress warning for obsolete variable `erc-send-this' in init form. * lisp/erc/erc-goodies.el (erc--keep-place-indicator-setup): Use macro `erc--restore-initialize-priors' to preserve last session's indicator position, if any. (erc-keep-place-indicator-mode, erc-keep-place-indicator-enable): Use convenience function to show missing-dependency notice. * lisp/erc/erc-sasl.el (erc-sasl-auth-source-password-as-host): Merge redundant `when' forms for clarity. (erc-sasl--init): Remove unused function. (erc-sasl-mode, erc-sasl-enable): Use helper to restore `erc-sasl--options', essentially inlining the body of the now defunct `erc-sasl--init'. * lisp/erc/erc.el (erc--restore-initialize-priors): New macro to help local modules and mode hooks prefer existing state over initializing anew. (erc--warn-once-before-connect): Add helper function to display an "error notice" just after module setup. (erc-accidental-paste-threshold-seconds) Improve doc string. * test/lisp/erc/erc-goodies-tests.el (erc-controls-highlight--examples, erc-controls-highlight--inverse, erc-controls-highlight--motd, erc-keep-place-indicator-mode): Remove feature check. For the latter, also start fake process and shadow `erc-connect-pre-hook'. * test/lisp/erc/erc-tests.el (erc--restore-initialize-priors): New test. Also see test/lisp/erc/erc-scenarios-base-local-modules.el for a more realistic exercising of this functionality. (Bug#60936)
Diffstat (limited to 'test')
-rw-r--r--test/lisp/erc/erc-goodies-tests.el17
-rw-r--r--test/lisp/erc/erc-tests.el15
2 files changed, 19 insertions, 13 deletions
diff --git a/test/lisp/erc/erc-goodies-tests.el b/test/lisp/erc/erc-goodies-tests.el
index a1f53c5bf88..7acacb319f1 100644
--- a/test/lisp/erc/erc-goodies-tests.el
+++ b/test/lisp/erc/erc-goodies-tests.el
@@ -21,7 +21,6 @@
;;; Code:
(require 'ert-x)
(require 'erc-goodies)
-(declare-function erc--initialize-markers "erc" (old-point continued) t)
(defun erc-goodies-tests--assert-face (beg end-str present &optional absent)
(setq beg (+ beg (point-min)))
@@ -44,9 +43,6 @@
;; https://modern.ircdocs.horse/formatting.html
(ert-deftest erc-controls-highlight--examples ()
- ;; FIXME remove after adding
- (unless (fboundp 'erc--initialize-markers)
- (ert-skip "Missing required function"))
(should (eq t erc-interpret-controls-p))
(let ((erc-insert-modify-hook '(erc-controls-highlight))
erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
@@ -130,9 +126,6 @@
;; in a high-contrast face.
(ert-deftest erc-controls-highlight--inverse ()
- ;; FIXME remove after adding
- (unless (fboundp 'erc--initialize-markers)
- (ert-skip "Missing required function"))
(should (eq t erc-interpret-controls-p))
(let ((erc-insert-modify-hook '(erc-controls-highlight))
erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
@@ -212,9 +205,6 @@
(":- ")))
(ert-deftest erc-controls-highlight--motd ()
- ;; FIXME remove after adding
- (unless (fboundp 'erc--initialize-markers)
- (ert-skip "Missing required function"))
(should (eq t erc-interpret-controls-p))
(let ((erc-insert-modify-hook '(erc-controls-highlight))
erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
@@ -256,12 +246,12 @@
;; needed.
(ert-deftest erc-keep-place-indicator-mode ()
- ;; FIXME remove after adding
- (unless (fboundp 'erc--initialize-markers)
- (ert-skip "Missing required function"))
(with-current-buffer (get-buffer-create "*erc-keep-place-indicator-mode*")
(erc-mode)
(erc--initialize-markers (point) nil)
+ (setq erc-server-process
+ (start-process "sleep" (current-buffer) "sleep" "1"))
+ (set-process-query-on-exit-flag erc-server-process nil)
(let ((assert-off
(lambda ()
(should-not erc-keep-place-indicator-mode)
@@ -275,6 +265,7 @@
(should erc-keep-place-mode)))
;;
erc-insert-pre-hook
+ erc-connect-pre-hook
erc-modules)
(funcall assert-off)
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index be5a566a268..b624186d88d 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -868,6 +868,21 @@
(should-not (erc--valid-local-channel-p "#chan"))
(should (erc--valid-local-channel-p "&local")))))
+(ert-deftest erc--restore-initialize-priors ()
+ ;; This `pcase' expands to 100+k. Guess we could do something like
+ ;; (and `(,_ ((,e . ,_) . ,_) . ,_) v) first and then return a
+ ;; (equal `(if-let* ((,e ...)...)...) v) to cut it down to < 1k.
+ (should (pcase (macroexpand-1 '(erc--restore-initialize-priors erc-my-mode
+ foo (ignore 1 2 3)
+ bar #'spam))
+ (`(if-let* ((,e (or erc--server-reconnecting erc--target-priors))
+ ((alist-get 'erc-my-mode ,e)))
+ (setq foo (alist-get 'foo ,e)
+ bar (alist-get 'bar ,e))
+ (setq foo (ignore 1 2 3)
+ bar #'spam))
+ t))))
+
(ert-deftest erc--target-from-string ()
(should (equal (erc--target-from-string "#chan")
#s(erc--target-channel "#chan" \#chan)))