emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/xr e77aa97: Postfix ops are literal after ^ but not aft


From: Mattias Engdegård
Subject: [elpa] externals/xr e77aa97: Postfix ops are literal after ^ but not after \(?:^\)
Date: Tue, 19 Feb 2019 15:14:42 -0500 (EST)

branch: externals/xr
commit e77aa97e184525fea4fdcb4aa365a73418d4d1b7
Author: Mattias Engdegård <address@hidden>
Commit: Mattias Engdegård <address@hidden>

    Postfix ops are literal after ^ but not after \(?:^\)
    
    ^* means (seq bol "*"), but \(?:^\)* means (zero-or-more bol).
---
 xr-test.el | 12 ++++++++++++
 xr.el      | 10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index e9aee46..c7fc6f7 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -224,6 +224,18 @@
                  '(seq bol "{xy")))
   (should (equal (xr "\\{2,3\\}")
                  "{2,3}"))
+  (should (equal (xr "\\(?:^\\)*")
+                 '(zero-or-more bol)))
+  (should (equal (xr "\\(?:^\\)\\{3\\}")
+                 '(= 3 bol)))
+  (should (equal (xr "\\^+")
+                 '(one-or-more "^")))
+  (should (equal (xr "\\c^?")
+                 '(opt (category combining-diacritic))))
+  (should (equal (xr "a^*")
+                 '(seq "a" (zero-or-more "^"))))
+  (should (equal (xr "a^\\{2,7\\}")
+                 '(seq "a" (repeat 2 7 "^"))))
   )
 
 (ert-deftest xr-simplify ()
diff --git a/xr.el b/xr.el
index 35e10d0..2a3570d 100644
--- a/xr.el
+++ b/xr.el
@@ -286,7 +286,10 @@
        ;; * ? + (and non-greedy variants)
        ;; - not special at beginning of sequence or after ^
        ((and (looking-at (rx (any "*?+") (opt "?")))
-             sequence (not (eq (car sequence) 'bol)))
+             sequence
+             (not (and (eq (car sequence) 'bol)
+                       (string-equal (buffer-substring (1- (point)) (point))
+                                     "^"))))
         (let ((operator (match-string 0)))
           (goto-char (match-end 0))
           (setq sequence (cons (xr--postfix operator (car sequence))
@@ -294,7 +297,10 @@
 
        ;; \{..\} - not special at beginning of sequence or after ^
        ((and (looking-at (rx "\\{"))
-             sequence (not (eq (car sequence) 'bol)))
+             sequence
+             (not (and (eq (car sequence) 'bol)
+                       (string-equal (buffer-substring (1- (point)) (point))
+                                     "^"))))
         (forward-char 2)
         (if (looking-at (rx (opt (group (one-or-more digit)))
                             (opt (group ",")



reply via email to

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