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.
This commit is contained in:
parent
959ba6ea79
commit
e205092081
1 changed files with 26 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue