* [PATCH] lexical-binding in rx.el
@ 2019-02-14 12:31 Mattias Engdegård
2019-02-14 14:11 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Mattias Engdegård @ 2019-02-14 12:31 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 37 bytes --]
One more file using lexical binding.
[-- Attachment #2: 0001-Use-lexical-binding-in-rx.el.patch --]
[-- Type: application/octet-stream, Size: 3001 bytes --]
From e8cdef252be10bfb7357758a502b829571c2b9ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mattias=20Engdeg=C3=A5rd?= <mattiase@acm.org>
Date: Thu, 14 Feb 2019 13:20:08 +0100
Subject: [PATCH] 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.
---
lisp/emacs-lisp/rx.el | 51 ++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index d00b86819c..c0a5d52788 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -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
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lexical-binding in rx.el
2019-02-14 12:31 [PATCH] lexical-binding in rx.el Mattias Engdegård
@ 2019-02-14 14:11 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2019-02-14 14:11 UTC (permalink / raw)
To: emacs-devel
> * 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.
LGTM, thanks,
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-14 14:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-14 12:31 [PATCH] lexical-binding in rx.el Mattias Engdegård
2019-02-14 14:11 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.