From: Amin Bandali Date: Sun, 12 Sep 2021 18:12:50 +0000 (-0400) Subject: ERC: Use 'string-replace' only on Emacs 28 and later X-Git-Tag: emacs-28.0.90~1032 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=85d0ed097efc97b8a8056150328fba998c131df9;p=emacs.git ERC: Use 'string-replace' only on Emacs 28 and later * lisp/erc/erc-dcc.el (erc-dcc-unquote-filename): * lisp/erc/erc.el (erc-quit-reason-zippy, erc-part-reason-zippy) (erc-update-mode-line-buffer, erc-message-english-PART): Use 'string-replace' only on Emacs 28 and later, otherwise use 'replace-regexp-in-string' on older Emacsen. --- diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el index df53270831d..b80f1832d7c 100644 --- a/lisp/erc/erc-dcc.el +++ b/lisp/erc/erc-dcc.el @@ -632,8 +632,13 @@ that subcommand." (define-inline erc-dcc-unquote-filename (filename) (inline-quote - (string-replace "\\\\" "\\" - (string-replace "\\\"" "\"" ,filename)))) + (if (>= emacs-major-version 28) + (string-replace + "\\\\" "\\" + (string-replace "\\\"" "\"" ,filename)) + (replace-regexp-in-string + "\\\\\\\\" "\\" + (replace-regexp-in-string "\\\\\"" "\"" ,filename t t) t t)))) (defun erc-dcc-handle-ctcp-send (proc query nick login host to) "This is called if a CTCP DCC SEND subcommand is sent to the client. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index b18eb0a228a..f01a99a30a2 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3597,7 +3597,9 @@ If S is non-nil, it will be used as the quit reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (string-replace "\n" "" (yow)) + (if (>= emacs-major-version 28) + (string-replace "\n" "" (yow)) + (replace-regexp-in-string "\n" "" (yow))) (erc-quit/part-reason-default)))) (make-obsolete 'erc-quit-reason-zippy "it will be removed." "24.4") @@ -3624,7 +3626,9 @@ If S is non-nil, it will be used as the part reason." If S is non-nil, it will be used as the quit reason." (or s (if (fboundp 'yow) - (string-replace "\n" "" (yow)) + (if (>= emacs-major-version 28) + (string-replace "\n" "" (yow)) + (replace-regexp-in-string "\n" "" (yow))) (erc-quit/part-reason-default)))) (make-obsolete 'erc-part-reason-zippy "it will be removed." "24.4") @@ -6530,13 +6534,21 @@ if `erc-away' is non-nil." (fill-region (point-min) (point-max)) (buffer-string)))) (setq header-line-format - (string-replace - "%" - "%%" - (if face - (propertize header 'help-echo help-echo - 'face face) - (propertize header 'help-echo help-echo)))))) + (if (>= emacs-major-version 28) + (string-replace + "%" + "%%" + (if face + (propertize header 'help-echo help-echo + 'face face) + (propertize header 'help-echo help-echo))) + (replace-regexp-in-string + "%" + "%%" + (if face + (propertize header 'help-echo help-echo + 'face face) + (propertize header 'help-echo help-echo))))))) (t (setq header-line-format (if face (propertize header 'face face) @@ -6806,7 +6818,9 @@ functions." nick user host channel (if (not (string= reason "")) (format ": %s" - (string-replace "%" "%%" reason)) + (if (>= emacs-major-version 28) + (string-replace "%" "%%" reason) + (replace-regexp-in-string "%" "%%" reason))) "")))))