diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 29892b78a39..6f091668087 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -461,10 +461,14 @@ erc-compat--28-split-string-shell-command (defmacro erc-compat--split-string-shell-command (string) ;; Autoloaded in Emacs 28. - (list (if (fboundp 'split-string-shell-command) - 'split-string-shell-command - 'erc-compat--28-split-string-shell-command) - string)) + `(progn + (advice-add 'shell-backward-command :override #'goto-char) + (unwind-protect + ,(list (if (fboundp 'split-string-shell-command) + 'split-string-shell-command + 'erc-compat--28-split-string-shell-command) + string) + (advice-remove 'shell-backward-command #'goto-char)))) (provide 'erc-compat)