diff options
author | Philipp Stephani <phst@google.com> | 2017-09-06 19:23:50 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2017-09-06 19:23:50 +0200 |
commit | c65991492033d8d9bd951c8c359b881e64584d68 (patch) | |
tree | 3c561bcbe6e6bd986391be129b1c37e6ab1e647f | |
parent | e61dee51474e61b777575b474459c582f3084f64 (diff) |
Use ‘save-match-data’ also for ‘s-reverse’.
The ‘require’ form can change the match data.
-rw-r--r-- | s.el | 25 |
1 files changed, 13 insertions, 12 deletions
@@ -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. |