changed from 't' to the more useful 'erc-prompt', although the
property of the same name has been retained.
+*** Members of insert- and send-related hooks have been reordered.
+Built-in and third-party modules rely on certain hooks for adjusting
+incoming and outgoing messages upon insertion. And some modules only
+want to do so after others have done their damage. Traditionally,
+this required various hacks and finagling to achieve. And while this
+release makes an effort to load modules in a more consistent order,
+that alone isn't enough to ensure similar predictability among
+essential members of important hooks.
+
+Luckily, ERC now leverages a feature introduced in Emacs 27, "hook
+depth," to secure the positions of a few key members of
+'erc-insert-modify-hook' and 'erc-send-modify-hook'. So far, this
+includes the functions 'erc-button-add-buttons', 'erc-fill',
+'erc-add-timestamp', and 'erc-match-message', which now appear in that
+order, when present, at depths beginning at 20 and ending below 80.
+Of most interest to module authors is the new relative positioning of
+the first two, 'erc-button-add-buttons' and 'erc-fill', which have
+been swapped with respect to their previous places in recent ERC
+versions.
+
*** ERC now manages timestamp-related properties a bit differently.
For starters, the 'cursor-sensor-functions' property no longer
contains unique closures and thus no longer proves effective for
(should (eq (erc--normalize-module-symbol 'timestamp) 'stamp))
(should (eq (erc--normalize-module-symbol 'nickserv) 'services)))
-;; Worrying about which library a module comes from is mostly not
-;; worth the hassle so long as ERC can find its minor mode. However,
-;; bugs involving multiple modules living in the same library may slip
-;; by because a module's loading problems may remain hidden on account
-;; of its place in the default ordering.
-
-(ert-deftest erc--find-mode ()
+(defun erc-tests--assert-printed-in-subprocess (code expected)
(let* ((package (if-let* ((found (getenv "ERC_PACKAGE_NAME"))
((string-prefix-p "erc-" found)))
(intern found)
'erc))
+ ;; This is for integrations testing with managed configs
+ ;; ("starter kits") that use a different package manager.
+ (init (and-let* ((found (getenv "ERC_TESTS_INIT"))
+ (files (split-string found ","))
+ ((seq-every-p #'file-exists-p files)))
+ (mapcan (lambda (f) (list "-l" f)) files)))
(prog
- `(,@(and (featurep 'compat)
- `((progn
- (require 'package)
- (let ((package-load-list '((compat t) (,package t))))
- (package-initialize)))))
- (require 'erc)
- (let ((mods (mapcar #'cadddr
- (cdddr (get 'erc-modules 'custom-type))))
- moded)
- (setq mods
- (sort mods (lambda (a b) (if (zerop (random 2)) a b))))
- (dolist (mod mods)
- (unless (keywordp mod)
- (push (if-let ((mode (erc--find-mode mod)))
- mod
- (list :missing mod))
- moded)))
- (message "%S"
- (sort moded
- (lambda (a b)
- (string< (symbol-name a) (symbol-name b))))))))
- (proc (start-process "erc--module-mode-autoloads"
- (current-buffer)
- (concat invocation-directory invocation-name)
- "-batch" "-Q"
- "-eval" (format "%S" (cons 'progn prog)))))
+ `(progn
+ ,@(and (not init) (featurep 'compat)
+ `((require 'package)
+ (let ((package-load-list '((compat t) (,package t))))
+ (package-initialize))))
+ (require 'erc)
+ (cl-assert (equal erc-version ,erc-version) t)
+ ,code))
+ (proc (apply #'start-process
+ (symbol-name (ert-test-name (ert-running-test)))
+ (current-buffer)
+ (concat invocation-directory invocation-name)
+ `("-batch" ,@(or init '("-Q"))
+ "-eval" ,(format "%S" prog)))))
(set-process-query-on-exit-flag proc t)
(while (accept-process-output proc 10))
(goto-char (point-min))
- (should (equal (read (current-buffer)) erc-tests--modules))))
+ (unless (equal (read (current-buffer)) expected)
+ (message "Exepcted: %S\nGot: %s" expected (buffer-string))
+ (ert-fail "Mismatch"))))
+
+;; Worrying about which library a module comes from is mostly not
+;; worth the hassle so long as ERC can find its minor mode. However,
+;; bugs involving multiple modules living in the same library may slip
+;; by because a module's loading problems may remain hidden on account
+;; of its place in the default ordering.
+
+(ert-deftest erc--find-mode ()
+ (erc-tests--assert-printed-in-subprocess
+ `(let ((mods (mapcar #'cadddr (cdddr (get 'erc-modules 'custom-type))))
+ moded)
+ (setq mods (sort mods (lambda (a b) (if (zerop (random 2)) a b))))
+ (dolist (mod mods)
+ (unless (keywordp mod)
+ (push (if-let ((mode (erc--find-mode mod))) mod (list :missing mod))
+ moded)))
+ (message "%S"
+ (sort moded (lambda (a b)
+ (string< (symbol-name a) (symbol-name b))))))
+ erc-tests--modules))
+
+(ert-deftest erc--essential-hook-ordering ()
+ (erc-tests--assert-printed-in-subprocess
+ '(progn
+ (erc-update-modules)
+ (message "%S"
+ (list :erc-insert-modify-hook erc-insert-modify-hook
+ :erc-send-modify-hook erc-send-modify-hook)))
+
+ '( :erc-insert-modify-hook (erc-controls-highlight ; 0
+ erc-button-add-buttons ; 30
+ erc-fill ; 40
+ erc-add-timestamp ; 50
+ erc-match-message) ; 60
+
+ :erc-send-modify-hook ( erc-controls-highlight ; 0
+ erc-button-add-buttons ; 30
+ erc-fill ; 40
+ erc-add-timestamp)))) ; 50
(ert-deftest erc-migrate-modules ()
(should (equal (erc-migrate-modules '(autojoin timestamp button))