aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2019-02-14 13:20:08 +0100
committerMattias EngdegÄrd2019-02-14 15:28:58 +0100
commite2050920819aab658171e8c6af4a9e0ad322fcfa (patch)
treecbd0c356065fc209729fd2a10c05ae030e1e346f
parent959ba6ea79f1d348b0be294656d5b5a83371f4fb (diff)
downloademacs-e2050920819aab658171e8c6af4a9e0ad322fcfa.tar.gz
emacs-e2050920819aab658171e8c6af4a9e0ad322fcfa.zip
Use lexical-binding in rx.el
* lisp/emacs-lisp/rx.el: Use lexical-binding. (rx-form): Use `let' to bind the dynamic variable `rx-parent' instead of binding it as an argument.
-rw-r--r--lisp/emacs-lisp/rx.el51
1 files changed, 26 insertions, 25 deletions
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index d00b86819c9..c0a5d52788b 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -1,4 +1,4 @@
1;;; rx.el --- sexp notation for regular expressions 1;;; rx.el --- sexp notation for regular expressions -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2001-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
4 4
@@ -841,33 +841,34 @@ If FORM is `(minimal-match FORM1)', non-greedy versions of `*',
841 (rx-group-if (cadr form) rx-parent)) 841 (rx-group-if (cadr form) rx-parent))
842 842
843 843
844(defun rx-form (form &optional rx-parent) 844(defun rx-form (form &optional parent)
845 "Parse and produce code for regular expression FORM. 845 "Parse and produce code for regular expression FORM.
846FORM is a regular expression in sexp form. 846FORM is a regular expression in sexp form.
847RX-PARENT shows which type of expression calls and controls putting of 847PARENT shows which type of expression calls and controls putting of
848shy groups around the result and some more in other functions." 848shy groups around the result and some more in other functions."
849 (cond 849 (let ((rx-parent parent))
850 ((stringp form) 850 (cond
851 (rx-group-if (regexp-quote form) 851 ((stringp form)
852 (if (and (eq rx-parent '*) (< 1 (length form))) 852 (rx-group-if (regexp-quote form)
853 rx-parent))) 853 (if (and (eq parent '*) (< 1 (length form)))
854 ((integerp form) 854 parent)))
855 (regexp-quote (char-to-string form))) 855 ((integerp form)
856 ((symbolp form) 856 (regexp-quote (char-to-string form)))
857 (let ((info (rx-info form nil))) 857 ((symbolp form)
858 (cond ((stringp info) 858 (let ((info (rx-info form nil)))
859 info) 859 (cond ((stringp info)
860 ((null info) 860 info)
861 (error "Unknown rx form `%s'" form)) 861 ((null info)
862 (t 862 (error "Unknown rx form `%s'" form))
863 (funcall (nth 0 info) form))))) 863 (t
864 ((consp form) 864 (funcall (nth 0 info) form)))))
865 (let ((info (rx-info (car form) 'head))) 865 ((consp form)
866 (unless (consp info) 866 (let ((info (rx-info (car form) 'head)))
867 (error "Unknown rx form `%s'" (car form))) 867 (unless (consp info)
868 (funcall (nth 0 info) form))) 868 (error "Unknown rx form `%s'" (car form)))
869 (t 869 (funcall (nth 0 info) form)))
870 (error "rx syntax error at `%s'" form)))) 870 (t
871 (error "rx syntax error at `%s'" form)))))
871 872
872 873
873;;;###autoload 874;;;###autoload