]> git.eshelyaron.com Git - emacs.git/commitdiff
ERC: Use 'string-search' only on Emacs 28 and later
authorAmin Bandali <bandali@gnu.org>
Sun, 12 Sep 2021 18:09:53 +0000 (14:09 -0400)
committerAmin Bandali <bandali@gnu.org>
Sun, 12 Sep 2021 18:32:12 +0000 (14:32 -0400)
* lisp/erc/erc-backend.el (erc-parse-server-response):
* lisp/erc/erc-dcc.el (erc-dcc-member):
* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server)
(erc-speedbar-expand-channel, erc-speedbar-expand-user):
* lisp/erc/erc.el (erc-send-input): Use 'string-search' only on
Emacs 28 and later, otherwise use 'string-match' on older Emacsen.

lisp/erc/erc-backend.el
lisp/erc/erc-dcc.el
lisp/erc/erc-speedbar.el
lisp/erc/erc.el

index 6d84665873ea23943dd90a718840b46258a64f1b..ad9719380a42778717d8f1383e75ead964ddf7aa 100644 (file)
@@ -950,15 +950,22 @@ PROCs `process-buffer' is `current-buffer' when this function is called."
   (unless (string= string "") ;; Ignore empty strings
     (save-match-data
       (let* ((tag-list (when (eq (aref string 0) ?@)
-                         (substring string 1 (string-search " " string))))
+                         (substring string 1
+                                    (if (>= emacs-major-version 28)
+                                        (string-search " " string)
+                                      (string-match " " string)))))
              (msg (make-erc-response :unparsed string :tags (when tag-list
                                                               (erc-parse-tags
                                                                tag-list))))
              (string (if tag-list
-                         (substring string (+ 1 (string-search " " string)))
+                         (substring string (+ 1 (if (>= emacs-major-version 28)
+                                                    (string-search " " string)
+                                                  (string-match " " string))))
                        string))
              (posn (if (eq (aref string 0) ?:)
-                       (string-search " " string)
+                       (if (>= emacs-major-version 28)
+                           (string-search " " string)
+                         (string-match " " string))
                      0)))
 
         (setf (erc-response.sender msg)
@@ -968,7 +975,9 @@ PROCs `process-buffer' is `current-buffer' when this function is called."
 
         (setf (erc-response.command msg)
               (let* ((bposn (string-match "[^ \n]" string posn))
-                     (eposn (string-search " " string bposn)))
+                     (eposn (if (>= emacs-major-version 28)
+                                (string-search " " string bposn)
+                              (string-match " " string bposn))))
                 (setq posn (and eposn
                                 (string-match "[^ \n]" string eposn)))
                 (substring string bposn eposn)))
@@ -976,7 +985,9 @@ PROCs `process-buffer' is `current-buffer' when this function is called."
         (while (and posn
                     (not (eq (aref string posn) ?:)))
           (push (let* ((bposn posn)
-                       (eposn (string-search " " string bposn)))
+                       (eposn (if (>= emacs-major-version 28)
+                                  (string-search " " string bposn)
+                                (string-match " " string bposn))))
                   (setq posn (and eposn
                                   (string-match "[^ \n]" string eposn)))
                   (substring string bposn eposn))
index de72624aaa1d88d71d1c034cdaec6478f54511a7..df53270831d01399fc080f65864375b8150d84d6 100644 (file)
@@ -187,7 +187,9 @@ compared with `erc-nick-equal-p' which is IRC case-insensitive."
                             (plist-get elt prop)))
             ;; if the property exists and is equal, we continue, else, try the
             ;; next element of the list
-            (or (and (eq prop :nick) (string-search "!" val)
+            (or (and (eq prop :nick) (if (>= emacs-major-version 28)
+                                         (string-search "!" val)
+                                       (string-match "!" val))
                      test (string-equal test val))
                 (and (eq prop :nick)
                      test val
index e61e741302d73a4a7d5edbc79fa6906f61794db7..84854e3be52e55411298036ed06f3677cd32b388 100644 (file)
@@ -139,7 +139,9 @@ This will add a speedbar major display mode."
        t))))
 
 (defun erc-speedbar-expand-server (text server indent)
-  (cond ((string-search "+" text)
+  (cond ((if (>= emacs-major-version 28)
+             (string-search "+" text)
+           (string-match "\\+" text))
         (speedbar-change-expand-button-char ?-)
         (if (speedbar-with-writable
               (save-excursion
@@ -147,7 +149,10 @@ This will add a speedbar major display mode."
                 (erc-speedbar-channel-buttons nil (1+ indent) server)))
             (speedbar-change-expand-button-char ?-)
           (speedbar-change-expand-button-char ??)))
-       ((string-search "-" text)       ;we have to contract this node
+       (;; we have to contract this node
+         (if (>= emacs-major-version 28)
+             (string-search "-" text)
+           (string-match "-" text))
         (speedbar-change-expand-button-char ?+)
         (speedbar-delete-subblock indent))
        (t (error "Ooops... not sure what to do")))
@@ -184,7 +189,9 @@ This will add a speedbar major display mode."
   "For the line matching TEXT, in CHANNEL, expand or contract a line.
 INDENT is the current indentation level."
   (cond
-   ((string-search "+" text)
+   ((if (>= emacs-major-version 28)
+        (string-search "+" text)
+      (string-match "\\+" text))
     (speedbar-change-expand-button-char ?-)
     (speedbar-with-writable
      (save-excursion
@@ -233,7 +240,9 @@ INDENT is the current indentation level."
             (speedbar-with-writable
              (dolist (entry names)
                (erc-speedbar-insert-user entry ?+ (1+ indent))))))))))
-   ((string-search "-" text)
+   ((if (>= emacs-major-version 28)
+        (string-search "-" text)
+      (string-match "-" text))
     (speedbar-change-expand-button-char ?+)
     (speedbar-delete-subblock indent))
    (t (error "Ooops... not sure what to do")))
@@ -284,7 +293,9 @@ The update is only done when the channel is actually expanded already."
        (erc-speedbar-expand-channel "+" buffer 1)))))
 
 (defun erc-speedbar-expand-user (text token indent)
-  (cond ((string-search "+" text)
+  (cond ((if (>= emacs-major-version 28)
+             (string-search "+" text)
+           (string-match "\\+" text))
         (speedbar-change-expand-button-char ?-)
         (speedbar-with-writable
           (save-excursion
@@ -307,7 +318,9 @@ The update is only done when the channel is actually expanded already."
                  nil nil nil nil
                  info nil nil nil
                  (1+ indent)))))))
-       ((string-search "-" text)
+       ((if (>= emacs-major-version 28)
+             (string-search "-" text)
+           (string-match "-" text))
         (speedbar-change-expand-button-char ?+)
         (speedbar-delete-subblock indent))
        (t (error "Ooops... not sure what to do")))
index e0fda41f8ed25cdfd549e6d679088f9f94427de2..b18eb0a228aaec45a08a1324c5bf19ddc70a3df1 100644 (file)
@@ -5587,7 +5587,9 @@ This returns non-nil only if we actually send anything."
       (when (and (erc-input-sendp state)
                 erc-send-this)
        (let ((string (erc-input-string state)))
-          (if (or (string-search "\n" string)
+          (if (or (if (>= emacs-major-version 28)
+                      (string-search "\n" string)
+                    (string-match "\n" string))
                   (not (string-match erc-command-regexp string)))
               (mapc
                (lambda (line)