summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkuanyui <azazabc123@gmail.com>2016-01-20 23:24:34 +0800
committerkuanyui <azazabc123@gmail.com>2016-01-20 23:24:34 +0800
commit81db7359e1a891020ef2e65aa05c2b9e65673254 (patch)
tree3416765de0a928c65a2668bc9671adf9599b7bac
parent99c7431cccf7d21956e18cf262d018b709dd57f6 (diff)
Fix wrong amount of matched in s-matched-positions-all
;; Old version: (s-matched-positions-all "=\\(.+?\\)=" "This is a =very= simple =sample=." 1) ;;=> ((11 . 15) (16 . 24) (25 . 31)) ;; New version: (s-matched-positions-all "=\\(.+?\\)=" "This is a =very= simple =sample=." 1) ;; => ((11 . 15) (25 . 31))
-rw-r--r--dev/examples.el4
-rw-r--r--s.el2
2 files changed, 4 insertions, 2 deletions
diff --git a/dev/examples.el b/dev/examples.el
index 66d4dcb..c1ce10f 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -144,7 +144,9 @@
(s-matched-positions-all "{{\\(.+?\\)}}" "{{Hello}} World, {{Emacs}}!" 0) => '((0 . 9) (17 . 26))
(s-matched-positions-all "{{\\(.+?\\)}}" "{{Hello}} World, {{Emacs}}!" 1) => '((2 . 7) (19 . 24))
(s-matched-positions-all "l" "{{Hello}} World, {{Emacs}}!" 0) => '((4 . 5) (5 . 6) (13 . 14))
- (s-matched-positions-all "abc" "{{Hello}} World, {{Emacs}}!") => nil)
+ (s-matched-positions-all "abc" "{{Hello}} World, {{Emacs}}!") => nil
+ (s-matched-positions-all "=\\(.+?\\)=" "=Hello= World, =Emacs=!" 0) => '((0 . 7) (15 . 22))
+ (s-matched-positions-all "=\\(.+?\\)=" "=Hello= World, =Emacs=!" 1) => '((1 . 6) (16 . 21)))
(defexamples s-slice-at
(s-slice-at "-" "abc") => '("abc")
diff --git a/s.el b/s.el
index 4d85eb4..b022ecc 100644
--- a/s.el
+++ b/s.el
@@ -429,7 +429,7 @@ SUBEXP-DEPTH is 0 by default."
(< pos (length string)))
(let ((m (match-end subexp-depth)))
(push (cons (match-beginning subexp-depth) (match-end subexp-depth)) result)
- (setq pos m)))
+ (setq pos (match-end 0))))
(nreverse result)))
(defun s-match (regexp s &optional start)