emacs-diffs
[Top][All Lists]
Advanced

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

master e20bae0 1/2: ERC: Use 'string-search' only on Emacs 28 and later


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

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

    ERC: Use 'string-search' only on Emacs 28 and later
    
    * 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  | 21 ++++++++++++++++-----
 lisp/erc/erc-dcc.el      |  4 +++-
 lisp/erc/erc-speedbar.el | 25 +++++++++++++++++++------
 lisp/erc/erc.el          |  4 +++-
 4 files changed, 41 insertions(+), 13 deletions(-)

diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 6d84665..ad97193 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -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))
diff --git a/lisp/erc/erc-dcc.el b/lisp/erc/erc-dcc.el
index de72624..df53270 100644
--- a/lisp/erc/erc-dcc.el
+++ b/lisp/erc/erc-dcc.el
@@ -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
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index e61e741..84854e3 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -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")))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index e0fda41..b18eb0a 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -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)



reply via email to

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