diff options
| author | Stefan Kangas | 2023-08-05 17:58:19 +0200 |
|---|---|---|
| committer | Stefan Kangas | 2023-08-05 17:58:19 +0200 |
| commit | 8e20da1517aa585e6286fa8e439db10fb62aaa57 (patch) | |
| tree | 02713f4f52d1c36e43e48b67ba28fd27d356a997 | |
| parent | ed3954445045aca3cdc60dbd6b75a3a55470e28b (diff) | |
| download | emacs-8e20da1517aa585e6286fa8e439db10fb62aaa57.tar.gz emacs-8e20da1517aa585e6286fa8e439db10fb62aaa57.zip | |
Simplify rng-substq with cl-substitute
* lisp/nxml/rng-util.el (rng-substq): Simplify.
(cl-lib): Require.
| -rw-r--r-- | lisp/nxml/rng-util.el | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/lisp/nxml/rng-util.el b/lisp/nxml/rng-util.el index 27c924d960f..4f49885fc45 100644 --- a/lisp/nxml/rng-util.el +++ b/lisp/nxml/rng-util.el | |||
| @@ -24,6 +24,8 @@ | |||
| 24 | 24 | ||
| 25 | ;;; Code: | 25 | ;;; Code: |
| 26 | 26 | ||
| 27 | (require 'cl-lib) | ||
| 28 | |||
| 27 | (defun rng-make-datatypes-uri (uri) | 29 | (defun rng-make-datatypes-uri (uri) |
| 28 | (if (string-equal uri "") | 30 | (if (string-equal uri "") |
| 29 | ;; The spec doesn't say to do this, but it's perfectly conformant | 31 | ;; The spec doesn't say to do this, but it's perfectly conformant |
| @@ -39,26 +41,7 @@ | |||
| 39 | (defun rng-substq (new old list) | 41 | (defun rng-substq (new old list) |
| 40 | "Replace first member of LIST (if any) that is `eq' to OLD by NEW. | 42 | "Replace first member of LIST (if any) that is `eq' to OLD by NEW. |
| 41 | LIST is not modified." | 43 | LIST is not modified." |
| 42 | (cond ((null list) nil) | 44 | (cl-substitute new old list :count 1 :test #'eq)) |
| 43 | ((eq (car list) old) | ||
| 44 | (cons new (cdr list))) | ||
| 45 | (t | ||
| 46 | (let ((tail (cons (car list) | ||
| 47 | nil)) | ||
| 48 | (rest (cdr list))) | ||
| 49 | (setq list tail) | ||
| 50 | (while rest | ||
| 51 | (let ((item (car rest))) | ||
| 52 | (setq rest (cdr rest)) | ||
| 53 | (cond ((eq item old) | ||
| 54 | (setcdr tail | ||
| 55 | (cons new rest)) | ||
| 56 | (setq rest nil)) | ||
| 57 | (t | ||
| 58 | (setq tail | ||
| 59 | (setcdr tail | ||
| 60 | (cons item nil)))))))) | ||
| 61 | list))) | ||
| 62 | 45 | ||
| 63 | (defun rng-escape-string (s) | 46 | (defun rng-escape-string (s) |
| 64 | (replace-regexp-in-string "[&\"<>]" | 47 | (replace-regexp-in-string "[&\"<>]" |