]> git.eshelyaron.com Git - emacs.git/commitdiff
Use lexical-binding in rx.el
authorMattias Engdegård <mattiase@acm.org>
Thu, 14 Feb 2019 12:20:08 +0000 (13:20 +0100)
committerMattias Engdegård <mattiase@acm.org>
Thu, 14 Feb 2019 14:28:58 +0000 (15:28 +0100)
* 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.

lisp/emacs-lisp/rx.el

index d00b86819c98fe05e1f6075f949fca1b018c1532..c0a5d52788bfe4946548cf0b9dcc9c92e517a696 100644 (file)
@@ -1,4 +1,4 @@
-;;; rx.el --- sexp notation for regular expressions
+;;; rx.el --- sexp notation for regular expressions  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 2001-2019 Free Software Foundation, Inc.
 
@@ -841,33 +841,34 @@ If FORM is `(minimal-match FORM1)', non-greedy versions of `*',
   (rx-group-if (cadr form) rx-parent))
 
 
-(defun rx-form (form &optional rx-parent)
+(defun rx-form (form &optional parent)
   "Parse and produce code for regular expression FORM.
 FORM is a regular expression in sexp form.
-RX-PARENT shows which type of expression calls and controls putting of
+PARENT shows which type of expression calls and controls putting of
 shy groups around the result and some more in other functions."
-  (cond
-   ((stringp form)
-    (rx-group-if (regexp-quote form)
-                 (if (and (eq rx-parent '*) (< 1 (length form)))
-                     rx-parent)))
-   ((integerp form)
-    (regexp-quote (char-to-string form)))
-   ((symbolp form)
-    (let ((info (rx-info form nil)))
-      (cond ((stringp info)
-             info)
-            ((null info)
-             (error "Unknown rx form `%s'" form))
-            (t
-             (funcall (nth 0 info) form)))))
-   ((consp form)
-    (let ((info (rx-info (car form) 'head)))
-      (unless (consp info)
-        (error "Unknown rx form `%s'" (car form)))
-      (funcall (nth 0 info) form)))
-   (t
-    (error "rx syntax error at `%s'" form))))
+  (let ((rx-parent parent))
+    (cond
+     ((stringp form)
+      (rx-group-if (regexp-quote form)
+                   (if (and (eq parent '*) (< 1 (length form)))
+                       parent)))
+     ((integerp form)
+      (regexp-quote (char-to-string form)))
+     ((symbolp form)
+      (let ((info (rx-info form nil)))
+        (cond ((stringp info)
+               info)
+              ((null info)
+               (error "Unknown rx form `%s'" form))
+              (t
+               (funcall (nth 0 info) form)))))
+     ((consp form)
+      (let ((info (rx-info (car form) 'head)))
+        (unless (consp info)
+          (error "Unknown rx form `%s'" (car form)))
+        (funcall (nth 0 info) form)))
+     (t
+      (error "rx syntax error at `%s'" form)))))
 
 
 ;;;###autoload