[Top][All Lists]

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

master 77de40a: Audit `string-match' usage in shr.el

From: Lars Ingebrigtsen
Subject: master 77de40a: Audit `string-match' usage in shr.el
Date: Sun, 5 Dec 2021 19:16:37 -0500 (EST)

branch: master
commit 77de40aed31d7c12569d05474f85e1d70b55d35e
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Audit `string-match' usage in shr.el
    * lisp/net/shr.el (shr-descend):
    (shr-render-td-1): Prefer string-match-p and string-search over
    string-match where possible.
 lisp/net/shr.el | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lisp/net/shr.el b/lisp/net/shr.el
index ee0e824..63522b0 100644
--- a/lisp/net/shr.el
+++ b/lisp/net/shr.el
@@ -582,7 +582,7 @@ size, and full-buffer size."
         (setq shr-warning
               "Not rendering the complete page because of too-deep nesting")
       (when style
-       (if (string-match "color\\|display\\|border-collapse" style)
+       (if (string-match-p "color\\|display\\|border-collapse" style)
            (setq shr-stylesheet (nconc (shr-parse-style style)
          (setq style nil)))
@@ -685,7 +685,7 @@ size, and full-buffer size."
        (goto-char (point-max)))))
     (let ((font-start (point)))
-      (when (and (string-match "\\`[ \t\n\r]" text)
+      (when (and (string-match-p "\\`[ \t\n\r]" text)
                 (not (bolp))
                 (not (eq (char-after (1- (point))) ? )))
        (insert " "))
@@ -843,7 +843,7 @@ size, and full-buffer size."
   (cond ((zerop (length url))
          (nth 3 base))
         ((or (not base)
-            (string-match "\\`[a-z]*:" url))
+            (string-match-p "\\`[a-z]*:" url))
         ;; Absolute or empty URI
        ((eq (aref url 0) ?/)
@@ -1028,7 +1028,7 @@ the mouse click event."
     (let ((param (match-string 4 data))
          (payload (url-unhex-string (match-string 5 data))))
       (when (and param
-                 (string-match "^.*\\(;[ \t]*base64\\)$" param))
+                 (string-match-p "^.*\\(;[ \t]*base64\\)$" param))
        (setq payload (ignore-errors
                         (base64-decode-string payload))))
@@ -1345,7 +1345,7 @@ ones, in case fg and bg are nil."
            ;; Filter out blocked elements inside the SVG image.
            (not (setq url (dom-attr elem ':xlink:href)))
            (not shr-blocked-images)
-           (not (string-match shr-blocked-images url)))
+           (not (string-match-p shr-blocked-images url)))
        (insert " ")
        (shr-dom-print elem)))))
   (insert (format "</%s>" (dom-tag dom))))
@@ -1432,7 +1432,7 @@ ones, in case fg and bg are nil."
 (defun shr-parse-style (style)
   (when style
-      (when (string-match "\n" style)
+      (when (string-search "\n" style)
         (setq style (replace-match " " t t style))))
     (let ((plist nil))
       (dolist (elem (split-string style ";"))
@@ -1491,7 +1491,7 @@ ones, in case fg and bg are nil."
     (let ((start (point))
          url multimedia image)
       (when-let* ((type (dom-attr dom 'type)))
-       (when (string-match "\\`image/svg" type)
+       (when (string-match-p "\\`image/svg" type)
          (setq url (dom-attr dom 'data)
                image t)))
       (dolist (child (dom-non-text-children dom))
@@ -1654,7 +1654,7 @@ The preference is a float determined from 
                        (list :width width :height height)))))
         ((or shr-inhibit-images
              (and shr-blocked-images
-                  (string-match shr-blocked-images url)))
+                  (string-match-p shr-blocked-images url)))
          (setq shr-start (point))
           (shr-insert alt))
         ((and (not shr-ignore-cache)
@@ -2463,7 +2463,7 @@ flags that control whether to collect or render objects."
          (max-width 0)
       (when style
-       (setq style (and (string-match "color" style)
+       (setq style (and (string-search "color" style)
                         (shr-parse-style style))))
       (when bgcolor
        (setq style (nconc (list (cons 'background-color bgcolor))

reply via email to

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