]> git.eshelyaron.com Git - emacs.git/commitdiff
ERC: Use 'string-replace' only on Emacs 28 and later
authorAmin Bandali <bandali@gnu.org>
Sun, 12 Sep 2021 18:12:50 +0000 (14:12 -0400)
committerAmin Bandali <bandali@gnu.org>
Sun, 12 Sep 2021 18:32:13 +0000 (14:32 -0400)
* 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.

lisp/erc/erc-dcc.el
lisp/erc/erc.el

index df53270831d01399fc080f65864375b8150d84d6..b80f1832d7ceb8d11e956195917fcf25700794d4 100644 (file)
@@ -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.
index b18eb0a228aaec45a08a1324c5bf19ddc70a3df1..f01a99a30a21cc2149c893dbdad401dbd2826460 100644 (file)
@@ -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)))
                 "")))))