[elpa] externals/xr 0331e00 10/13: Recognise \sW as alias for \sw

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 0331e0055f964218d068e99c8aeb09225a8afe41
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Recognise \sW as alias for \sw

The syntax class W appears to be an undocumented alternative to w,
and \sW has been spotted at least once in the wild.
---
 xr-test.el | 3 ++-
 xr.el  | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/xr-test.el b/xr-test.el
index 7929e2a..9f48d28 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -79,8 +79,9 @@
   )
 
 (ert-deftest xr-syntax ()
-  (should (equal (xr "\\s-\\s \\sw\\s_\\s.\\s(\\s)\\s\"")
+  (should (equal (xr "\\s-\\s \\sw\\sW\\s_\\s.\\s(\\s)\\s\"")
  '(seq (syntax whitespace) (syntax whitespace) (syntax word)
+  (syntax word)
(syntax symbol) (syntax punctuation)
(syntax open-parenthesis) (syntax close-parenthesis)
(syntax string-quote
diff --git a/xr.el b/xr.el
index d7d28e3..d77b78c 100644
--- a/xr.el
+++ b/xr.el
@@ -208,6 +208,7 @@
  (?\s . whitespace)
  (?.  . punctuation)
  (?w  . word)
+ (?W  . word)  ; undocumented
  (?_  . symbol)
  (?\( . open-parenthesis)
  (?\) . close-parenthesis)



[elpa] externals/xr 37b2bcb 06/13: Merge branch 'master' of https://github.com/mattiase/xr

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 37b2bcbe45f6f06c18109ae071567f436c079541
Merge: 4bf6043 4e2bd17
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Merge branch 'master' of https://github.com/mattiase/xr



[elpa] externals/xr 2a1de75 03/13: Correct parsing of group and backref

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 2a1de75f192e351cd2ea7e4302756dbb9e995384
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Correct parsing of group and backref

Parse groups and backrefs more carefully. In particular, there
is no group 0; (?0:) is illegal and \0 means 0.
---
 xr-test.el | 11 +--
 xr.el  | 26 +++---
 2 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index ea3d9b4..b0e52d3 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -61,6 +61,13 @@
 (ert-deftest xr-backref ()
   (should (equal (xr "\\(ab\\)\\(?3:cd\\)\\1\\3")
  '(seq (group "ab") (group-n 3 "cd") (backref 1) (backref 3
+  (should (equal (xr "\\01")
+ "01"))
+  (should-error (xr "\\(?abc\\)"))
+  (should-error (xr "\\(?2\\)"))
+  (should-error (xr "\\(?0:xy\\)"))
+  (should (equal (xr "\\(?29:xy\\)")
+ '(group-n 29 "xy")))
   )
 
 (ert-deftest xr-misc ()
@@ -191,8 +198,8 @@
  '(or "*a" (seq "*b" (group "*c")
   (should (equal (xr "+a\\|+b\\(+c\\)")
  '(or "+a" (seq "+b" (group "+c")
-  (should (equal (xr "?a\\|?b\\(?c\\)")
- '(or "?a" (seq "?b" (group "?c")
+  (should (equal (xr "?a\\|?b\\(^?c\\)")
+ '(or "?a" (seq "?b" (group bol "?c")
   (should (equal (xr "^**")
  '(seq bol (zero-or-more "*"
   (should (equal (xr "^+")
diff --git a/xr.el b/xr.el
index 6ad306f..e28b986 100644
--- a/xr.el
+++ b/xr.el
@@ -313,12 +313,16 @@
   (push (xr--parse-char-alt negated) sequence)))
 
;; group
-   ((looking-at (rx "\\("
-(opt (group "?" (group (zero-or-more digit)) ":"
+   ((looking-at (rx "\\(" (opt (group "?")
+   (opt (opt (group (any "1-9")
+(zero-or-more digit)))
+(group ":")
 (let ((question (match-string 1))
   (number (match-string 2))
-  (end (match-end 0)))
-  (goto-char end)
+  (colon (match-string 3)))
+  (when (and question (not colon))
+(error "Invalid \\(? syntax"))
+  (goto-char (match-end 0))
   (let* ((group (xr--parse-alt))
  ;; simplify - group has an implicit seq
  (operand (if (and (listp group) (eq (car group) 'seq))
@@ -327,17 +331,17 @@
 (when (not (looking-at (rx "\\)")))
   (error "Missing \\)"))
 (forward-char 2)
-(let ((item (cond ((not question)   ; plain subgroup
-   (cons 'group operand))
-  ((zerop (length number))  ; shy group
-   group)
-  (t
+(let ((item (cond (number   ; numbered group
(append (list 'group-n (string-to-number 
number))
-   operand)
+   operand))
+  (question ; shy group
+   group)
+  (t; plain group
+   (cons 'group operand)
   (push item sequence)
 
;; back-reference
-   ((looking-at (rx "\\" (group digit)))
+   ((looking-at (rx "\\" (group (any "1-9"
 (forward-char 2)
 (push (list 'backref (string-to-number (match-string 1)))
   sequence))



[elpa] externals/xr 4e2bd17 04/13: Export xr-pp-rx-to-str and fix a typo

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 4e2bd17df0e370ab6fd24c29711aa278575ca29b
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Export xr-pp-rx-to-str and fix a typo

Rename xr--pp-rx-to-str to xr-pp-rx-to-str for external use,
and fix a typo in the doc string of xr-pp.

Requested and reported by Michael Heerdegen.
---
 xr-test.el |  6 +++---
 xr.el  | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index b0e52d3..bd04bcb 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -222,11 +222,11 @@
   )
 
 (ert-deftest xr-pretty ()
-  (should (equal (xr--pp-rx-to-str "A\e\r\n\t\0 \x7f\x80\ B\xff\x02")
+  (should (equal (xr-pp-rx-to-str "A\e\r\n\t\0 \x7f\x80\ B\xff\x02")
  "\"A\\e\\r\\n\\t\\x00 \\x7f\\200B\\xff\\x02\"\n"))
-  (should (equal (xr--pp-rx-to-str '(?? nonl))
+  (should (equal (xr-pp-rx-to-str '(?? nonl))
  "(?? nonl)\n"))
-  (should (equal (xr--pp-rx-to-str '(repeat 1 63 "a"))
+  (should (equal (xr-pp-rx-to-str '(repeat 1 63 "a"))
  "(repeat 1 63 \"a\")\n"))
   )
 
diff --git a/xr.el b/xr.el
index e28b986..761cac7 100644
--- a/xr.el
+++ b/xr.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2019 Free Software Foundation, Inc.
 
 ;; Author: Mattias Engdegård 
-;; Version: 1.0
+;; Version: 1.1
 ;; Keywords: lisp, maint, regexps
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -464,9 +464,9 @@ equivalent to RE-STRING."
 "\""))
(t (prin1-to-string rx
 
-;; Pretty-print a regexp (in rx notation) to a string.
-;; It does a slightly better job than standard `pp' for rx purposes.
-(defun xr--pp-rx-to-str (rx)
+(defun xr-pp-rx-to-str (rx)
+  "Pretty-print the regexp RX (in rx notation) to a string.
+It does a slightly better job than standard `pp' for rx purposes."
   (with-temp-buffer
 (insert (xr--rx-to-string rx) "\n")
 (pp-buffer)
@@ -487,10 +487,10 @@ equivalent to RE-STRING."
 ;;;###autoload
 (defun xr-pp (re-string)
   "Convert to `rx' notation and pretty-print.
-This basically does `(pp (rx RE-STRING))', but in a slightly more readable
+This basically does `(pp (xr RE-STRING))', but in a slightly more readable
 way.  It is intended for use from an interactive elisp session.
 Returns nil."
-  (insert (xr--pp-rx-to-str (xr re-string
+  (insert (xr-pp-rx-to-str (xr re-string
 
 (provide 'xr)
 



[elpa] externals/xr 8d052d6 09/13: Check for errors in \_

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 8d052d617f1e604143856b3b2b6657cac707d4c6
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Check for errors in \_
---
 xr-test.el |  1 +
 xr.el  | 14 +++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index bd04bcb..7929e2a 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -75,6 +75,7 @@
  '(seq bol nonl wordchar not-wordchar bos eos point
word-boundary not-word-boundary bow eow
symbol-start symbol-end eol)))
+  (should-error (xr "\\_a"))
   )
 
 (ert-deftest xr-syntax ()
diff --git a/xr.el b/xr.el
index 3133906..d7d28e3 100644
--- a/xr.el
+++ b/xr.el
@@ -356,7 +356,7 @@
 
;; various simple substitutions
((looking-at (rx (or "." "\\w" "\\W" "\\`" "\\'" "\\="
-"\\b" "\\B" "\\<" "\\>" "\\_<" "\\_>")))
+"\\b" "\\B" "\\<" "\\>")))
 (goto-char (match-end 0))
 (let ((sym (cdr (assoc
  (match-string 0)
@@ -365,10 +365,18 @@
("\\`" . bos) ("\\'" . eos)
("\\=" . point)
("\\b" . word-boundary) ("\\B" . not-word-boundary)
-   ("\\<" . bow) ("\\>" . eow)
-   ("\\_<" . symbol-start) ("\\_>" . symbol-end))
+   ("\\<" . bow) ("\\>" . eow))
   (push sym sequence)))
 
+   ;; symbol-start, symbol-end
+   ((looking-at (rx "\\_" (opt (group (any "<>")
+(let ((arg (match-string 1)))
+  (unless arg
+(error "Invalid \\_ sequence"))
+  (forward-char 3)
+  (push (if (string-equal arg "<") 'symbol-start 'symbol-end)
+sequence)))
+
;; character syntax
((looking-at (rx "\\" (group (any "sS")) (group anything)))
 (let ((negated (string-equal (match-string 1) "S"))



[elpa] externals/xr e1c7734 13/13: Merge branch 'externals/xr' of elpa.git (no actual change)

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit e1c7734639bf7afe9c848e81d6240d357a9d1242
Merge: f79d50c 7ba1fc6
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Merge branch 'externals/xr' of elpa.git (no actual change)



[elpa] externals/xr updated (7ba1fc6 -> e1c7734)

2019-02-13 Thread Mattias Engdeg�rd
mattiase pushed a change to branch externals/xr.

  from  7ba1fc6   * xr.el: Fix compilation and use valid email address
   new  8425772   Sync with ELPA: compilation workaround
   new  8532df8   Move tests to separate file
   new  2a1de75   Correct parsing of group and backref
   new  4bf6043   Export xr-pp-rx-to-str and fix a typo
   new  4e2bd17   Export xr-pp-rx-to-str and fix a typo
   new  37b2bcb   Merge branch 'master' of https://github.com/mattiase/xr
   new  e8ec2d9   Add reference to the pcre2el package
   new  c2ede95   Improved errors for bad \s and \c sequences
   new  8d052d6   Check for errors in \_
   new  0331e00   Recognise \sW as alias for \sw
   new  41474cb   Accept unknown character categories
   new  f79d50c   Add categories L, R, . and SPC
   new  e1c7734   Merge branch 'externals/xr' of elpa.git (no actual change)


Summary of changes:
 xr-test.el | 243 +++
 xr.el  | 270 +
 2 files changed, 297 insertions(+), 216 deletions(-)
 create mode 100644 xr-test.el



[elpa] externals/xr 8425772 01/13: Sync with ELPA: compilation workaround

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 84257724a851a4cfd515f6c98dc840c437720b1c
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Sync with ELPA: compilation workaround
---
 xr.el | 21 +
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/xr.el b/xr.el
index 3c8e3d3..199f0e3 100644
--- a/xr.el
+++ b/xr.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2019 Free Software Foundation, Inc.
 
-;; Author: Mattias Engdegård 
+;; Author: Mattias Engdegård 
 ;; Version: 1.0
 ;; Keywords: lisp, maint, regexps
 
@@ -50,6 +50,10 @@
 ;; maximum readability, consistency and personal preference when
 ;; replacing existing regexps in elisp code.
 
+;; Similar functionality is provided by the `lex' package in the form of the
+;; `lex-parse-re' function, but `xr' does not depend on `lex' and does
+;; a more thorough job of handling all corner cases of Elisp's regexp syntax.
+
 ;;; Code:
 
 (require 'rx)
@@ -500,7 +504,18 @@ Returns nil."
   "Verify (xr--pp-rx-to-str RX) against EXPECTED-STR."
   (xr--expect-result 'xr--pp-rx-to-str rx expected-str))
 
+(provide 'xr)
+
 (eval-when-compile
+  ;; FIXME: When byte-compiling the file, this `eval-when-compile' block
+  ;; will be executed at a time where the above functions have been compiled
+  ;; but they're not necessarily known by the current Emacs session yet
+  ;; (because the neither `xr.el' nor `xr.elc' has been loaded yet).
+  ;; As a quick fix, we (require 'xr) here to load the `xr' file (and fail
+  ;; silently if the file is not in `load-path').
+  ;; Maybe a better fix is to move those tests to a separate file, and/or
+  ;; to wrap them in an `ert-deftest'.
+  (when (require 'xr nil 'noerror)
   (xr--expect "a\\$bc\\[\\]\\q"
   "a$b\\c[]q")
   (xr--expect "\\(?:ab\\|c*d\\)?"
@@ -660,8 +675,6 @@ Returns nil."
  "(?? nonl)\n")
   (xr--expect-pp '(repeat 1 63 "a")
  "(repeat 1 63 \"a\")\n")
-  )
-
-(provide 'xr)
+  ))
 
 ;;; xr.el ends here



[elpa] externals/xr e8ec2d9 07/13: Add reference to the pcre2el package

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit e8ec2d9d7a0e65aeb888da353b9d079285787c07
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Add reference to the pcre2el package
---
 xr.el | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/xr.el b/xr.el
index 761cac7..5a32a52 100644
--- a/xr.el
+++ b/xr.el
@@ -50,9 +50,17 @@
 ;; maximum readability, consistency and personal preference when
 ;; replacing existing regexps in elisp code.
 
-;; Similar functionality is provided by the `lex' package in the form of the
-;; `lex-parse-re' function, but `xr' does not depend on `lex' and does
-;; a more thorough job of handling all corner cases of Elisp's regexp syntax.
+;; Related work:
+;;
+;; The `lex' package, a lexical analyser generator, provides the
+;; `lex-parse-re' function which performs a similar task, but does not
+;; attempt to handle all the edge cases of Elisp's regexp syntax or
+;; pretty-print the result.
+;;
+;; The `pcre2el' package, a regexp syntax converter and interactive regexp
+;; explainer, could also be used for the same tasks. `xr' is narrower in
+;; scope but more accurate for the purpose of parsing Emacs regexps and
+;; printing the results in rx form.
 
 ;;; Code:
 



[elpa] externals/xr c2ede95 08/13: Improved errors for bad \s and \c sequences

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit c2ede958dec3e13a28549ae00782bf4f5d11a6fc
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Improved errors for bad \s and \c sequences
---
 xr.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xr.el b/xr.el
index 5a32a52..3133906 100644
--- a/xr.el
+++ b/xr.el
@@ -198,7 +198,7 @@
  (?y . cyrillic)  
  (?| . can-break)
 (when (not sym)
-  (error "Unknown category code: %s" category-code))
+  (error "Unknown category code: %c" category-code))
 (let ((item (list 'category (cdr sym
   (if negated (list 'not item) item
 
@@ -221,7 +221,7 @@
  (?|  . string-delimiter)
  (?!  . comment-delimiter)
 (when (not sym)
-  (error "Unknown syntax code: %s" syntax-code))
+  (error "Unknown syntax code: %c" syntax-code))
 (let ((item (list 'syntax (cdr sym
   (if negated (list 'not item) item
 



[elpa] externals/xr 4bf6043 05/13: Export xr-pp-rx-to-str and fix a typo

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 4bf6043ef79024c27149611c09b8b602f4590b5b
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Export xr-pp-rx-to-str and fix a typo

Rename xr--pp-rx-to-str to xr-pp-rx-to-str for external use,
and fix a typo in the doc string of xr-pp.

Increment version to 1.1.

Requested and reported by Michael Heerdegen.
---
 xr-test.el |  6 +++---
 xr.el  | 12 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index b0e52d3..bd04bcb 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -222,11 +222,11 @@
   )
 
 (ert-deftest xr-pretty ()
-  (should (equal (xr--pp-rx-to-str "A\e\r\n\t\0 \x7f\x80\ B\xff\x02")
+  (should (equal (xr-pp-rx-to-str "A\e\r\n\t\0 \x7f\x80\ B\xff\x02")
  "\"A\\e\\r\\n\\t\\x00 \\x7f\\200B\\xff\\x02\"\n"))
-  (should (equal (xr--pp-rx-to-str '(?? nonl))
+  (should (equal (xr-pp-rx-to-str '(?? nonl))
  "(?? nonl)\n"))
-  (should (equal (xr--pp-rx-to-str '(repeat 1 63 "a"))
+  (should (equal (xr-pp-rx-to-str '(repeat 1 63 "a"))
  "(repeat 1 63 \"a\")\n"))
   )
 
diff --git a/xr.el b/xr.el
index e28b986..761cac7 100644
--- a/xr.el
+++ b/xr.el
@@ -3,7 +3,7 @@
 ;; Copyright (C) 2019 Free Software Foundation, Inc.
 
 ;; Author: Mattias Engdegård 
-;; Version: 1.0
+;; Version: 1.1
 ;; Keywords: lisp, maint, regexps
 
 ;; This program is free software; you can redistribute it and/or modify
@@ -464,9 +464,9 @@ equivalent to RE-STRING."
 "\""))
(t (prin1-to-string rx
 
-;; Pretty-print a regexp (in rx notation) to a string.
-;; It does a slightly better job than standard `pp' for rx purposes.
-(defun xr--pp-rx-to-str (rx)
+(defun xr-pp-rx-to-str (rx)
+  "Pretty-print the regexp RX (in rx notation) to a string.
+It does a slightly better job than standard `pp' for rx purposes."
   (with-temp-buffer
 (insert (xr--rx-to-string rx) "\n")
 (pp-buffer)
@@ -487,10 +487,10 @@ equivalent to RE-STRING."
 ;;;###autoload
 (defun xr-pp (re-string)
   "Convert to `rx' notation and pretty-print.
-This basically does `(pp (rx RE-STRING))', but in a slightly more readable
+This basically does `(pp (xr RE-STRING))', but in a slightly more readable
 way.  It is intended for use from an interactive elisp session.
 Returns nil."
-  (insert (xr--pp-rx-to-str (xr re-string
+  (insert (xr-pp-rx-to-str (xr re-string
 
 (provide 'xr)
 



[elpa] externals/xr f79d50c 12/13: Add categories L, R, . and SPC

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit f79d50cca60f9ce242a52ac1eac8d9fc9beb282f
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Add categories L, R, . and SPC

The predefined categories L, R, . and SPC were recently added to rx.
Add them here as well.
---
 xr-test.el | 4 
 xr.el  | 6 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/xr-test.el b/xr-test.el
index 97559fb..87ae21a 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -124,6 +124,10 @@
   (should (equal (xr "\\C2\\C^")
  '(seq (not (category upper-diacritical-mark))
(not (category combining-diacritic)
+  (should (equal (xr "\\cR\\C.\\cL\\C ")
+'(seq (category strong-right-to-left)
+  (not (category base)) (category strong-left-to-right)
+  (not (category space-for-indent)
   (should (equal (xr "\\c%\\C+")
  '(seq (regexp "\\c%") (regexp "\\C+"
   )
diff --git a/xr.el b/xr.el
index 9d201ad..9ad19c7 100644
--- a/xr.el
+++ b/xr.el
@@ -158,7 +158,9 @@
 
 (defun xr--char-category (negated category-code)
   (let ((sym (assq category-code
-   '((?0 . consonant)
+   '((?\s . space-for-indent)
+ (?. . base)
+ (?0 . consonant)
  (?1 . base-vowel)
  (?2 . upper-diacritical-mark)
  (?3 . lower-diacritical-mark)
@@ -176,7 +178,9 @@
  (?H . japanese-hiragana-two-byte)
  (?I . indian-two-byte)   
  (?K . japanese-katakana-two-byte)
+ (?L . strong-left-to-right)
  (?N . korean-hangul-two-byte)
+ (?R . strong-right-to-left)
  (?Y . cyrillic-two-byte) 
  (?^ . combining-diacritic)   
  (?a . ascii) 



[elpa] externals/xr 8532df8 02/13: Move tests to separate file

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 8532df85cc9a65fde2afdfff2c7b8c8c6ec56dd2
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Move tests to separate file

Put all tests in a separate file, xr-test.el, and use ert.
Byte-compilation is now clean.
---
 xr-test.el | 228 +
 xr.el  | 187 --
 2 files changed, 228 insertions(+), 187 deletions(-)

diff --git a/xr-test.el b/xr-test.el
new file mode 100644
index 000..ea3d9b4
--- /dev/null
+++ b/xr-test.el
@@ -0,0 +1,228 @@
+;;; xr-test.el --- Tests for xr.el   -*- lexical-binding: t -*-
+
+;; Copyright (C) 2019 Free Software Foundation, Inc.
+
+;; Author: Mattias Engdegård 
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see .
+
+
+(require 'xr)
+(require 'ert)
+
+
+(ert-deftest xr-basic ()
+  (should (equal (xr "a\\$bc\\[\\]\\q")
+ "a$b\\c[]q"))
+  (should (equal (xr "\\(?:ab\\|c*d\\)?")
+ '(opt (or "ab" (seq (zero-or-more "c") "d")
+  (should (equal (xr ".+")
+ '(one-or-more nonl)))
+  )
+
+(ert-deftest xr-repeat ()
+  (should (equal (xr "\\(?:x?y\\)\\{3\\}")
+ '(= 3 (opt "x") "y")))
+  (should (equal (xr "\\(?:x?y\\)\\{3,8\\}")
+ '(repeat 3 8 (opt "x") "y")))
+  (should (equal (xr "\\(?:x?y\\)\\{3,\\}")
+ '(>= 3 (opt "x") "y")))
+  (should (equal (xr "\\(?:x?y\\)\\{,8\\}")
+ '(repeat 0 8 (opt "x") "y")))
+  (should (equal (xr "\\(?:xy\\)\\{4,4\\}")
+ '(= 4 "xy")))
+  (should (equal (xr "a\\{,\\}")
+ '(zero-or-more "a")))
+  (should (equal (xr "a\\{0\\}")
+ '(repeat 0 0 "a")))
+  (should (equal (xr "a\\{0,\\}")
+ '(zero-or-more "a")))
+  (should (equal (xr "a\\{0,0\\}")
+ '(repeat 0 0 "a")))
+  (should (equal (xr "a\\{\\}")
+ '(repeat 0 0 "a")))
+  (should (equal (xr "a\\{,1\\}")
+ '(repeat 0 1 "a")))
+  (should (equal (xr "a\\{1,\\}")
+ '(>= 1 "a")))
+  )
+
+(ert-deftest xr-backref ()
+  (should (equal (xr "\\(ab\\)\\(?3:cd\\)\\1\\3")
+ '(seq (group "ab") (group-n 3 "cd") (backref 1) (backref 3
+  )
+
+(ert-deftest xr-misc ()
+  (should (equal (xr "^.\\w\\W\\`\\'\\=\\b\\B\\<\\>\\_<\\_>$")
+ '(seq bol nonl wordchar not-wordchar bos eos point
+   word-boundary not-word-boundary bow eow
+   symbol-start symbol-end eol)))
+  )
+
+(ert-deftest xr-syntax ()
+  (should (equal (xr "\\s-\\s \\sw\\s_\\s.\\s(\\s)\\s\"")
+ '(seq (syntax whitespace) (syntax whitespace) (syntax word)
+   (syntax symbol) (syntax punctuation)
+   (syntax open-parenthesis) (syntax close-parenthesis)
+   (syntax string-quote
+  (should (equal (xr "\\ss/\\s$\\s'\\s<\\s>\\s!\\s|")
+ '(seq (syntax escape) (syntax character-quote)
+   (syntax paired-delimiter) (syntax expression-prefix)
+   (syntax comment-start) (syntax comment-end)
+   (syntax comment-delimiter) (syntax string-delimiter
+  (should (equal (xr "\\S-\\S<")
+ '(seq (not (syntax whitespace))
+   (not (syntax comment-start)
+  )
+
+(ert-deftest xr-category ()
+  (should (equal (xr "\\c0\\c1\\c2\\c3\\c4\\c5\\c6\\c7\\c8\\c9\\c<\\c>")
+ '(seq (category consonant) (category base-vowel)
+   (category upper-diacritical-mark)
+   (category lower-diacritical-mark)
+   (category tone-mark) (category symbol) (category digit)
+   (category vowel-modifying-diacritical-mark)
+   (category vowel-sign) (category semivowel-lower)
+   (category not-at-end-of-line)
+   (category not-at-beginning-of-line
+  (should (equal (xr "\\cA\\cC\\cG\\cH\\cI\\cK\\cN\\cY\\c^")
+  '(seq (category alpha-numeric-two-byte) (category chinese-two-byte)
+(category greek-two-byte) (category japanese-hiragana-two-byte)
+(category indian-two-byte)
+(category japanese-katakana-two-byte)
+(catego

[elpa] externals/xr 41474cb 11/13: Accept unknown character categories

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 41474cbc8bcab67c097a8e111de01832b6fd4f97
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

Accept unknown character categories

New categories can be defined, so an unknown category code is not
necessarily an error. Assume the best and use a raw (regexp ...)
construct.
---
 xr-test.el |  4 +++-
 xr.el  | 10 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index 9f48d28..97559fb 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -81,7 +81,7 @@
 (ert-deftest xr-syntax ()
   (should (equal (xr "\\s-\\s \\sw\\sW\\s_\\s.\\s(\\s)\\s\"")
  '(seq (syntax whitespace) (syntax whitespace) (syntax word)
-  (syntax word)
+   (syntax word)
(syntax symbol) (syntax punctuation)
(syntax open-parenthesis) (syntax close-parenthesis)
(syntax string-quote
@@ -124,6 +124,8 @@
   (should (equal (xr "\\C2\\C^")
  '(seq (not (category upper-diacritical-mark))
(not (category combining-diacritic)
+  (should (equal (xr "\\c%\\C+")
+ '(seq (regexp "\\c%") (regexp "\\C+"
   )
 
 (ert-deftest xr-lazy ()
diff --git a/xr.el b/xr.el
index d77b78c..9d201ad 100644
--- a/xr.el
+++ b/xr.el
@@ -197,10 +197,10 @@
  (?w . hebrew)
  (?y . cyrillic)  
  (?| . can-break)
-(when (not sym)
-  (error "Unknown category code: %c" category-code))
-(let ((item (list 'category (cdr sym
-  (if negated (list 'not item) item
+(if sym
+(let ((item (list 'category (cdr sym
+  (if negated (list 'not item) item))
+  (list 'regexp (format "\\%c%c" (if negated ?C ?c) category-code)
 
 (defun xr--char-syntax (negated syntax-code)
   (let ((sym (assq syntax-code
@@ -208,7 +208,7 @@
  (?\s . whitespace)
  (?.  . punctuation)
  (?w  . word)
- (?W  . word)  ; undocumented
+ (?W  . word)   ; undocumented
  (?_  . symbol)
  (?\( . open-parenthesis)
  (?\) . close-parenthesis)



[elpa] externals/xr 09fe373: More careful error handling of \s and \c

2019-02-13 Thread Mattias Engdeg�rd
branch: externals/xr
commit 09fe37383ba81358fe9680c1bbf679b00da1d07d
Author: Mattias Engdegård 
Commit: Mattias Engdegård 

More careful error handling of \s and \c

\s and \c without a character following is an error, and should
not result in a literal s or c.
---
 xr-test.el | 10 +++---
 xr.el  | 22 ++
 2 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/xr-test.el b/xr-test.el
index 87ae21a..e9aee46 100644
--- a/xr-test.el
+++ b/xr-test.el
@@ -93,6 +93,8 @@
   (should (equal (xr "\\S-\\S<")
  '(seq (not (syntax whitespace))
(not (syntax comment-start)
+  (should-error (xr "\\s"))
+  (should-error (xr "\\S"))
   )
 
 (ert-deftest xr-category ()
@@ -125,11 +127,13 @@
  '(seq (not (category upper-diacritical-mark))
(not (category combining-diacritic)
   (should (equal (xr "\\cR\\C.\\cL\\C ")
-'(seq (category strong-right-to-left)
-  (not (category base)) (category strong-left-to-right)
-  (not (category space-for-indent)
+ '(seq (category strong-right-to-left)
+   (not (category base)) (category strong-left-to-right)
+   (not (category space-for-indent)
   (should (equal (xr "\\c%\\C+")
  '(seq (regexp "\\c%") (regexp "\\C+"
+  (should-error (xr "\\c"))
+  (should-error (xr "\\C"))
   )
 
 (ert-deftest xr-lazy ()
diff --git a/xr.el b/xr.el
index 9ad19c7..35e10d0 100644
--- a/xr.el
+++ b/xr.el
@@ -86,7 +86,7 @@
'(ascii alnum alpha blank cntrl digit graph
  lower multibyte nonascii print punct space
  unibyte upper word xdigit)))
-(error "No such character class: %s" sym))
+(error "No character class `%s'" sym))
   (push sym set)
   (goto-char (match-end 0
;; character range
@@ -226,7 +226,7 @@
  (?|  . string-delimiter)
  (?!  . comment-delimiter)
 (when (not sym)
-  (error "Unknown syntax code: %c" syntax-code))
+  (error "Unknown syntax code `%c'" syntax-code))
 (let ((item (list 'syntax (cdr sym
   (if negated (list 'not item) item
 
@@ -383,18 +383,24 @@
 sequence)))
 
;; character syntax
-   ((looking-at (rx "\\" (group (any "sS")) (group anything)))
+   ((looking-at (rx "\\" (group (any "sS")) (opt (group anything
 (let ((negated (string-equal (match-string 1) "S"))
-  (syntax-code (string-to-char (match-string 2
+  (syntax-code (match-string 2)))
+  (unless syntax-code
+(error "Incomplete \\%s sequence" (match-string 1)))
   (goto-char (match-end 0))
-  (push (xr--char-syntax negated syntax-code) sequence)))
+  (push (xr--char-syntax negated (string-to-char syntax-code))
+sequence)))
 
;; character categories
-   ((looking-at (rx "\\" (group (any "cC")) (group anything)))
+   ((looking-at (rx "\\" (group (any "cC")) (opt (group anything
 (let ((negated (string-equal (match-string 1) "C"))
-  (category-code (string-to-char (match-string 2
+  (category-code (match-string 2)))
+  (unless category-code
+(error "Incomplete \\%s sequence" (match-string 1)))
   (goto-char (match-end 0))
-  (push (xr--char-category negated category-code) sequence)))
+  (push (xr--char-category negated (string-to-char category-code))
+sequence)))
 
;; Escaped character. Only \*+?.^$[ really need escaping, but we accept
;; any not otherwise handled character after the backslash since



[elpa] master eae4541: [el-search] Add accessible buffer area to a validity check

2019-02-13 Thread Michael Heerdegen
branch: master
commit eae4541cf820bab52d1577f6deb7c894f28ebe38
Author: Michael Heerdegen 
Commit: Michael Heerdegen 

[el-search] Add accessible buffer area to a validity check

Add (POINT-MIN POINT-MAX) to the 'el-search--buffer-match-count-data'
validity checks to ensure that the count data is dismissed when
narrowing has changed.

* packages/el-search/el-search.el
(el-search--buffer-match-count-data): Update docstring.
(el-search-display-match-count): Change to make
'el-search--buffer-match-count-data' support that additional check.
---
 packages/el-search/el-search.el | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index db039de..2a389e1 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -2475,12 +2475,10 @@ absolute name must be matched by all of them."
   "Holds information for displaying a match count.
 The value is a list of elements
 
-   \(SEARCH BUFFER-CHARS-MOD-TICK BUFFER-MATCHES\)
+  \(SEARCH BUFFER-CHARS-MOD-TICK (POINT-MIN POINT-MAX) MATCHES\)
 
-BUFFER-MATCHES is a stream of matches in this buffer.  SEARCH is
-the active search and BUFFER-CHARS-MOD-TICK the return value of
-`buffer-chars-modified-tick' from when this stream had been
-created.")
+MATCHES is a stream of matches in this buffer.  The other values
+are used to check validity.")
 
 (defun el-search-display-match-count ()
   "Display an x/y-style match count in the echo area."
@@ -2489,7 +2487,9 @@ created.")
 
   ;; Check whether cached stream of buffer matches is still valid
   (pcase el-search--buffer-match-count-data
-(`(,(pred (eq el-search--current-search))  ,(pred (eq 
(buffer-chars-modified-tick)))  . ,_))
+(`(,(pred (eq el-search--current-search))
+   ,(pred (eq (buffer-chars-modified-tick)))
+   (,(pred (eq (point-min))) ,(pred (eq (point-max  . ,_))
 (_
  ;; (message "Refreshing match count data") (sit-for 1)
  (redisplay) ;don't delay highlighting
@@ -2504,13 +2504,14 @@ created.")
(list
 el-search--current-search
 (buffer-chars-modified-tick)
+`(,(point-min) ,(point-max))
 stream-of-buffer-matches)
 
   (let ((pos-here (point)) (matches-<=-here 1) total-matches
 (defun-bounds (or (el-search--bounds-of-defun) (cons (point) 
(point
 (matches-<=-here-in-defun 1) (total-matches-in-defun 0)
 (largest-match-start-not-after-pos-here nil))
-(pcase-let ((`(,_ ,_ ,matches) el-search--buffer-match-count-data))
+(pcase-let ((`(,_ ,_ ,_ ,matches) el-search--buffer-match-count-data))
   (setq total-matches (let ((inhibit-message t)) (seq-length matches)))
   (while (and (not (stream-empty-p matches)) (< (stream-first matches) 
(cdr defun-bounds)))
 (when (<= (stream-first matches) pos-here)



[elpa] master c0ccea9: [el-search] Minibuffer pattern prompt hints part 1: preparations

2019-02-13 Thread Michael Heerdegen
branch: master
commit c0ccea931b063ffebd30a10b63c89d6335c77e7d
Author: Michael Heerdegen 
Commit: Michael Heerdegen 

[el-search] Minibuffer pattern prompt hints part 1: preparations

* packages/el-search/el-search.el
(el-search--pattern-is-unquoted-symbol-p): New helper function
factored out of 'el-search--maybe-warn-about-unquoted-symbol'.
(el-search--maybe-warn-about-unquoted-symbol): Use it.
(el-search--all-matches): When the new optional argument DONT-COPY is
non-nil, don't use a copy of the given search object to build the
match stream, use the given search directly.
(el-search-display-mb-hints, el-search-mb-hints-delay)
(el-search-mb-hints-timeout): New user options.
(el-search--make-display-animation-function): New helper function to
construct animation functions.
(el-search-query-replace--read-args): Bind new special var
'el-search--reading-input-for-query-replace' non-nil when reading
FROM pattern.
(el-search--search-pattern-1-do-fun): New variable that will be used
to display animations in the minibuffer or echo area.
(el-search--search-pattern-1): Call value of new variable
'el-search--search-pattern-1-do-fun' when non-nil repeatedly while
searching.
---
 packages/el-search/el-search.el | 54 +++--
 1 file changed, 47 insertions(+), 7 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index 2a389e1..f3a25b0 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -474,6 +474,21 @@
   "Expression based search and replace for Emacs Lisp."
   :group 'lisp)
 
+(defcustom el-search-display-mb-hints t
+  "Whether to show hints in the search pattern prompt."
+  :type 'boolean)
+
+(defcustom el-search-mb-hints-delay 0.8
+  "Time before displaying minibuffer hints.
+
+Setting this has only an effect if `el-search-display-mb-hints'
+is non-nil."
+  :type 'number)
+
+(defcustom el-search-mb-hints-timeout 15
+  "How long to display minibuffer hints."
+  :type 'number)
+
 (defface el-search-match 'class color) (min-colors 88) (background dark))
 (:background "#60"))
   (((class color) (min-colors 88) (background light))
@@ -863,10 +878,13 @@ nil."
   input)
 (symbol-value histvar)
 
+(defun el-search--pattern-is-unquoted-symbol-p (pattern)
+  (and (symbolp pattern)
+   (not (eq pattern '_))
+   (not (keywordp pattern
+
 (defun el-search--maybe-warn-about-unquoted-symbol (pattern)
-  (when (and (symbolp pattern)
- (not (eq pattern '_))
- (not (keywordp pattern)))
+  (when (el-search--pattern-is-unquoted-symbol-p pattern)
 (message "Free variable `%S' (missing a quote?)" pattern)
 (sit-for 2.)))
 
@@ -876,6 +894,25 @@ nil."
 (el-search--pushnew-to-history input histvar)
 (if (not (string= input "")) input (car (symbol-value histvar)
 
+(defvar el-search--reading-input-for-query-replace nil)
+
+(defvar el-search--search-pattern-1-do-fun nil)
+(defvar el-search--busy-animation
+  ;; '("." "o" "O" "o" "." " ")
+  ;; '("|" "/" "-" "\\")
+  '("*   " " *  " "  * " "   *" "  * " " *  "))
+(defvar el-search-mb-anim-time .33)
+
+(defun el-search--make-display-animation-function (display-fun)
+  (let ((last-update (seconds-to-time 0))
+(anim (copy-sequence el-search--busy-animation)))
+(setcdr (last anim) anim)
+(lambda ()
+  (let ((now (current-time)))
+(when (< el-search-mb-anim-time (float-time (time-subtract now 
last-update)))
+  (setq last-update now)
+  (funcall display-fun (pop anim)))
+
 (defun el-search-read-pattern-for-interactive (&optional prompt)
   "Read an \"el-search\" pattern from the minibuffer, prompting with PROMPT.
 
@@ -1154,6 +1191,8 @@ be specified as fourth argument, and COUNT becomes the 
fifth argument."
 (let ((match-beg nil) current-expr)
   (if (catch 'no-match
 (while (not match-beg)
+  (when el-search--search-pattern-1-do-fun
+(funcall el-search--search-pattern-1-do-fun))
   (condition-case nil
   (setq current-expr (el-search--ensure-sexp-start))
 (end-of-buffer (throw 'no-match t)))
@@ -1654,7 +1693,7 @@ With ALLOW-LEADING-WHITESPACE non-nil, the match may
 be preceded by whitespace."
   (el-search--looking-at-1 (el-search-make-matcher pattern) 
allow-leading-whitespace))
 
-(defun el-search--all-matches (search)
+(defun el-search--all-matches (search &optional dont-copy)
   "Return a stream of all matches of SEARCH.
 The returned stream will always start searching from the
 beginning anew even when SEARCH has been used interactively or
@@ -1668,7 +1707,7 @@ The elements of the returned stream will have the form
 where BUFFER or FILE is the buffer or file where a match has been
 found (ex

[elpa] master 11843e2: [el-search] Minibuffer pattern prompt hints part 2

2019-02-13 Thread Michael Heerdegen
branch: master
commit 11843e2db4a24aaec2ad9a827ed4f079588dcf58
Author: Michael Heerdegen 
Commit: Michael Heerdegen 

[el-search] Minibuffer pattern prompt hints part 2

Implement displaying hints when prompting for a search pattern.  This
includes pointing to errors in the pattern and showing a preview of
match counts when appropriate.
We also fix the case when a search pattern fails later in the search
and force a cleanup in this case.

* packages/el-search/el-search.el
(el-search-read-pattern-trigger-mb-hints)
(el-search-read-pattern-setup-mb): New helpers.
(el-search--set-this-command-refresh-message-maybe): New helper to set
'this-command' and refresh the last shown message to avoid echo area
stuttering.  Use where appropriate.
(el-search-read-display-mb-hints): The new main function for
displaying the hints in the minibuffer.
(el-search-read-pattern-for-interactive): If user option
'el-search-display-mb-hints' is on, display hints for errors.
Additionally: if the new optional arg DISPLAY-MATCH-COUNT is non-nil,
display a match count in the minibuffer.
(el-search-pattern--interactive): Likewise: new argument
DISPLAY-MATCH-COUNT.  Change all callers that want to display a match
count in the minibuffer when prompting for the search pattern (mostly,
search starting commands that always search the current buffer).
(el-search-query-replace--read-args): Call
'el-search-read-pattern-setup-mb'.
(el-search-hl-post-command-fun): New optional argument STOP; when
non-nil, unconditionally cleanup.  Change all callers that call this
for cleanup to use that new arg.  Display animation when counting
matches.
(el-search-display-match-count): New optional argument JUST-COUNT that
let's the function only return a string.  Minor tweaks.
(el-search-continue-search): Call
'el-search--set-this-command-refresh-message-maybe' to avoid a
stuttering match count.  Force cleanup in case of unexpected errors.
---
 packages/el-search/el-search.el | 527 ++--
 1 file changed, 342 insertions(+), 185 deletions(-)

diff --git a/packages/el-search/el-search.el b/packages/el-search/el-search.el
index f3a25b0..b4981fe 100644
--- a/packages/el-search/el-search.el
+++ b/packages/el-search/el-search.el
@@ -803,11 +803,18 @@ nil."
  (unless ,done
,@unwindforms)
 
+(defvar el-search--last-message nil
+  "Internal var helping to avoid echo area stuttering ")
+
 (defun el-search--message-no-log (format-string &rest args)
   "Like `message' but with `message-log-max' bound to nil."
   (let ((message-log-max nil))
 (apply #'message format-string args)))
 
+(defun el-search--set-this-command-refresh-message-maybe ()
+  (when (eq (setq this-command 'el-search-pattern) last-command)
+(message "%s" el-search--last-message)))
+
 (defalias 'el-search-read
   (if (boundp 'force-new-style-backquotes)
   (lambda (&optional stream)
@@ -894,8 +901,28 @@ nil."
 (el-search--pushnew-to-history input histvar)
 (if (not (string= input "")) input (car (symbol-value histvar)
 
+(defvar el-search--display-match-count-in-prompt nil)
+(defvar el-search--mb-hints-timer nil)
 (defvar el-search--reading-input-for-query-replace nil)
 
+(defun el-search-read-pattern-trigger-mb-hints ()
+  (if (not (timerp el-search--mb-hints-timer))
+  (setq el-search--mb-hints-timer (run-at-time 3 nil 
#'el-search-read-display-mb-hints))
+(timer-set-time el-search--mb-hints-timer (time-add (current-time) 
el-search-mb-hints-delay))
+(timer-activate el-search--mb-hints-timer)))
+
+(defvar el-search--this-session-match-count-data nil)
+
+(defun el-search-read-pattern-setup-mb ()
+  ;; This is for minibuffer-setup-hook.
+  ;; Note: this doesn't care about stopping the
+  ;; 'el-search--mb-hints-timer'.
+  (when el-search-display-mb-hints
+(setq el-search--this-session-match-count-data nil)
+(when (timerp el-search--mb-hints-timer) (cancel-timer 
el-search--mb-hints-timer))
+(setq el-search--mb-hints-timer nil)
+(add-hook 'post-command-hook #'el-search-read-pattern-trigger-mb-hints t 
t)))
+
 (defvar el-search--search-pattern-1-do-fun nil)
 (defvar el-search--busy-animation
   ;; '("." "o" "O" "o" "." " ")
@@ -913,7 +940,76 @@ nil."
   (setq last-update now)
   (funcall display-fun (pop anim)))
 
-(defun el-search-read-pattern-for-interactive (&optional prompt)
+(defun el-search-read-display-mb-hints ()
+  (when (minibufferp)
+(while-no-input
+  (let (err)
+(cl-macrolet ((try (&rest body)
+   (let ((err-data (make-symbol "err-data")))
+ `(condition-case ,err-data
+  (progn ,@body)
+(error (setq err ,err-data)
+   nil)
+  (let* ((input (minibuffer-con