summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2017-09-06 19:23:50 +0200
committerPhilipp Stephani <phst@google.com>2017-09-06 19:23:50 +0200
commitc65991492033d8d9bd951c8c359b881e64584d68 (patch)
tree3c561bcbe6e6bd986391be129b1c37e6ab1e647f
parente61dee51474e61b777575b474459c582f3084f64 (diff)
Use ‘save-match-data’ also for ‘s-reverse’.
The ‘require’ form can change the match data.
-rw-r--r--s.el25
1 files changed, 13 insertions, 12 deletions
diff --git a/s.el b/s.el
index 23994cd..4bdd970 100644
--- a/s.el
+++ b/s.el
@@ -380,18 +380,19 @@ attention to case differences."
(defun s-reverse (s)
"Return the reverse of S."
- (if (multibyte-string-p s)
- (let ((input (string-to-list s))
- output)
- (require 'ucs-normalize)
- (while input
- ;; Handle entire grapheme cluster as a single unit
- (let ((grapheme (list (pop input))))
- (while (memql (car input) ucs-normalize-combining-chars)
- (push (pop input) grapheme))
- (setq output (nconc (nreverse grapheme) output))))
- (concat output))
- (concat (nreverse (string-to-list s)))))
+ (save-match-data
+ (if (multibyte-string-p s)
+ (let ((input (string-to-list s))
+ output)
+ (require 'ucs-normalize)
+ (while input
+ ;; Handle entire grapheme cluster as a single unit
+ (let ((grapheme (list (pop input))))
+ (while (memql (car input) ucs-normalize-combining-chars)
+ (push (pop input) grapheme))
+ (setq output (nconc (nreverse grapheme) output))))
+ (concat output))
+ (concat (nreverse (string-to-list s))))))
(defun s-match-strings-all (regex string)
"Return a list of matches for REGEX in STRING.