emacs-diffs
[Top][All Lists]
Advanced

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

master 3fa4cca3d2 2/2: * lisp/url/url-util.el (url-insert-entities-in-st


From: Stefan Monnier
Subject: master 3fa4cca3d2 2/2: * lisp/url/url-util.el (url-insert-entities-in-string): Simplify
Date: Sun, 30 Oct 2022 09:41:45 -0400 (EDT)

branch: master
commit 3fa4cca3d244f51e471e7779c934278731fc21e9
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    * lisp/url/url-util.el (url-insert-entities-in-string): Simplify
---
 lisp/url/url-util.el | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el
index 147a643c9f..95c0fe14f3 100644
--- a/lisp/url/url-util.el
+++ b/lisp/url/url-util.el
@@ -63,9 +63,9 @@ If a list, it is a list of the types of messages to be 
logged."
          (and (listp url-debug) (memq tag url-debug)))
       (with-current-buffer (get-buffer-create "*URL-DEBUG*")
        (goto-char (point-max))
-       (insert (symbol-name tag) " -> " (apply 'format args) "\n")
+       (insert (symbol-name tag) " -> " (apply #'format args) "\n")
        (if (numberp url-debug)
-           (apply 'message args)))))
+           (apply #'message args)))))
 
 ;;;###autoload
 (defun url-parse-args (str &optional nodowncase)
@@ -125,23 +125,13 @@ conversion.  Replaces these characters as follows:
     <  ==>  &lt;
     >  ==>  &gt;
     \"  ==>  &quot;"
-  (if (string-match "[&<>\"]" string)
-      (with-current-buffer (get-buffer-create " *entity*")
-       (erase-buffer)
-       (buffer-disable-undo (current-buffer))
-       (insert string)
-       (goto-char (point-min))
-       (while (progn
-                (skip-chars-forward "^&<>\"")
-                (not (eobp)))
-         (insert (cdr (assq (char-after (point))
-                            '((?\" . "&quot;")
-                              (?& . "&amp;")
-                              (?< . "&lt;")
-                              (?> . "&gt;")))))
-         (delete-char 1))
-       (buffer-string))
-    string))
+  (replace-regexp-in-string "[&<>\"]"
+                            (lambda (c) (cdr (assq (aref c 0)
+                                             '((?\" . "&quot;")
+                                               (?& . "&amp;")
+                                               (?< . "&lt;")
+                                               (?> . "&gt;")))))
+                           string))
 
 ;;;###autoload
 (defun url-normalize-url (url)
@@ -169,7 +159,7 @@ Will not do anything if `url-show-status' is nil."
          (= url-lazy-message-time
             (setq url-lazy-message-time (time-convert nil 'integer))))
       nil
-    (apply 'message args)))
+    (apply #'message args)))
 
 ;;;###autoload
 (defun url-get-normalized-date (&optional specified-time)
@@ -186,7 +176,7 @@ Will not do anything if `url-show-status' is nil."
   #'string-trim-left "29.1")
 
 (define-obsolete-function-alias 'url-pretty-length
-  'file-size-human-readable "24.4")
+  #'file-size-human-readable "24.4")
 
 ;;;###autoload
 (defun url-display-message (fmt &rest args)
@@ -206,7 +196,7 @@ Will not do anything if `url-show-status' is nil."
   (round (* 100 (/ x (float y)))))
 
 ;;;###autoload
-(defalias 'url-basepath 'url-file-directory)
+(defalias 'url-basepath #'url-file-directory)
 
 ;;;###autoload
 (defun url-file-directory (file)
@@ -395,8 +385,7 @@ if character N is allowed."
                 (aref url-encoding-table byte)))
             (if (multibyte-string-p string)
                 (encode-coding-string string 'utf-8)
-              string)
-            ""))
+              string)))
 
 (defconst url-host-allowed-chars
   ;; Allow % to avoid re-encoding %-encoded sequences.



reply via email to

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