diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-20 17:59:02 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2011-06-20 17:59:02 -0700 |
commit | 51cab52b054aaf178743aa7775ae29e934eeba9c (patch) | |
tree | 0160ac7e20237f3a337fc35c9ba368762ef9203c /lisp/emacs-lisp | |
parent | 171e2a582e4c7d6bfd6d6ff0373720b59568bcb2 (diff) | |
parent | ca5307394f6861fc825434c268e0a44adf8a3252 (diff) | |
download | emacs-51cab52b054aaf178743aa7775ae29e934eeba9c.tar.gz emacs-51cab52b054aaf178743aa7775ae29e934eeba9c.tar.bz2 emacs-51cab52b054aaf178743aa7775ae29e934eeba9c.zip |
Merge from trunk.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/rx.el | 17 | ||||
-rw-r--r-- | lisp/emacs-lisp/syntax.el | 5 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 7122de4789c..56efd142198 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -130,6 +130,8 @@ (** . (rx-** 2 nil)) ; SRE (submatch . (rx-submatch 1 nil)) ; SRE (group . submatch) ; sregex + (submatch-n . (rx-submatch-n 2 nil)) + (group-n . submatch-n) (zero-or-more . (rx-kleene 1 nil)) (one-or-more . (rx-kleene 1 nil)) (zero-or-one . (rx-kleene 1 nil)) @@ -690,6 +692,16 @@ FORM is either `(repeat N FORM1)' or `(repeat N M FORMS...)'." (mapconcat (lambda (re) (rx-form re ':)) (cdr form) nil)) "\\)")) +(defun rx-submatch-n (form) + "Parse and produce code from FORM, which is `(submatch-n N ...)'." + (let ((n (nth 1 form))) + (concat "\\(?" (number-to-string n) ":" + (if (= 3 (length form)) + ;; Only one sub-form. + (rx-form (nth 2 form)) + ;; Several sub-forms implicitly concatenated. + (mapconcat (lambda (re) (rx-form re ':)) (cddr form) nil)) + "\\)"))) (defun rx-backref (form) "Parse and produce code from FORM, which is `(backref N)'." @@ -1072,6 +1084,11 @@ CHAR like `and', but makes the match accessible with `match-end', `match-beginning', and `match-string'. +`(submatch-n N SEXP1 SEXP2 ...)' +`(group-n N SEXP1 SEXP2 ...)' + like `group', but make it an explicitly-numbered group with + group number N. + `(or SEXP1 SEXP2 ...)' `(| SEXP1 SEXP2 ...)' matches anything that matches SEXP1 or SEXP2, etc. If all diff --git a/lisp/emacs-lisp/syntax.el b/lisp/emacs-lisp/syntax.el index 7ba7b13af44..200b3a6389b 100644 --- a/lisp/emacs-lisp/syntax.el +++ b/lisp/emacs-lisp/syntax.el @@ -398,8 +398,9 @@ point (where the PPSS is equivalent to nil).") (defun syntax-ppss (&optional pos) "Parse-Partial-Sexp State at POS, defaulting to point. -The returned value is the same as `parse-partial-sexp' except that -values 2 and 6 values of the returned state cannot be relied upon. +The returned value is the same as that of `parse-partial-sexp' +run from point-min to POS except that values at positions 2 and 6 +in the returned list (counting from 0) cannot be relied upon. Point is at POS when this function returns." ;; Default values. (unless pos (setq pos (point))) |