emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 85d0ed0 2/2: ERC: Use 'string-replace' only on Emacs 28 and later


From: Amin Bandali
Subject: master 85d0ed0 2/2: ERC: Use 'string-replace' only on Emacs 28 and later
Date: Sun, 12 Sep 2021 14:35:58 -0400 (EDT)

branch: master
commit 85d0ed097efc97b8a8056150328fba998c131df9
Author: Amin Bandali <bandali@gnu.org>
Commit: Amin Bandali <bandali@gnu.org>

    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.
---
 lisp/erc/erc-dcc.el |  9 +++++++--
 lisp/erc/erc.el     | 34 ++++++++++++++++++++++++----------
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index df53270..b80f183 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 b18eb0a..f01a99a 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)))
                 "")))))
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]