1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Don't preserve non-module minor modes in erc-open

* lisp/erc/erc-common.el (define-erc-module): Add symbol property
`erc-module' to minor modes defined as part of a module.
* lisp/erc/erc.el (erc--merge-local-modes): Be more conservative when
persisting local minor-mode state across ERC sessions.  User and
third-party modes that were not defined via `define-erc-modules'
should be left alone.
(erc-open): Run major-mode hooks and enable minor modes after prompt
has been set up.  This ensures that module-setup code can access a
fully initialized `erc-input-marker'.
* test/lisp/erc/erc-tests.el (erc--merge-local-modes): Add mocks for
`erc-module' symbol property and a test case covering some foreign ERC
mode.
(define-erc-module--global, define-erc-module--local): Expect the
`erc-module' symbol property to be defined for mode symbols and
aliases.  (Bug#60784.)
This commit is contained in:
F. Jason Park 2023-01-13 06:03:15 -08:00
parent 7b8322f628
commit 183e749270
3 changed files with 38 additions and 23 deletions

View file

@ -1958,7 +1958,8 @@ nil."
(let ((out (list (reverse new-modes))))
(pcase-dolist (`(,k . ,v) old-vars)
(when (and (string-prefix-p "erc-" (symbol-name k))
(string-suffix-p "-mode" (symbol-name k)))
(string-suffix-p "-mode" (symbol-name k))
(get k 'erc-module))
(if v
(cl-pushnew k (car out))
(setf (car out) (delq k (car out)))
@ -2082,9 +2083,7 @@ Returns the buffer for the given server or channel."
(erc-determine-parameters server port nick full-name user passwd)
(save-excursion (run-mode-hooks))
(dolist (mod (car delayed-modules)) (funcall mod +1))
(dolist (var (cdr delayed-modules)) (set var nil))
;; FIXME consolidate this prompt-setup logic with the pass above.
;; set up prompt
(unless continued-session
@ -2097,6 +2096,10 @@ Returns the buffer for the given server or channel."
(erc-display-prompt)
(goto-char (point-max)))
(save-excursion (run-mode-hooks)
(dolist (mod (car delayed-modules)) (funcall mod +1))
(dolist (var (cdr delayed-modules)) (set var nil)))
;; Saving log file on exit
(run-hook-with-args 'erc-connect-pre-hook buffer)