Fix void-variable n-reb in re-builder (Bug#40409)

* lisp/emacs-lisp/re-builder.el (reb-while): Take the current value of
the counter instead of its name.
(reb-mark-non-matching-parenthesis): Bind n-reb to 0 at the start and
don't wrongly treat it as dynamicly bound.
This commit is contained in:
Noam Postavsky 2020-04-04 12:00:41 -04:00
parent 452d776a5d
commit 7e78f0d1b2

View file

@ -767,22 +767,21 @@ If SUBEXP is non-nil mark only the corresponding sub-expressions."
(reb-mark-non-matching-parenthesis)) (reb-mark-non-matching-parenthesis))
nil))) nil)))
(defsubst reb-while (limit counter where) (defsubst reb-while (limit current where)
(let ((count (symbol-value counter))) (if (< current limit)
(if (= count limit) (1+ current)
(progn
(message "Reached (while limit=%s, where=%s)" limit where) (message "Reached (while limit=%s, where=%s)" limit where)
nil) nil))
(set counter (1+ count)))))
(defun reb-mark-non-matching-parenthesis (bound) (defun reb-mark-non-matching-parenthesis (bound)
;; We have a small string, check the whole of it, but wait until ;; We have a small string, check the whole of it, but wait until
;; everything else is fontified. ;; everything else is fontified.
(when (>= bound (point-max)) (when (>= bound (point-max))
(let (left-pars (let ((n-reb 0)
left-pars
faces-here) faces-here)
(goto-char (point-min)) (goto-char (point-min))
(while (and (reb-while 100 'n-reb "mark-par") (while (and (setq n-reb (reb-while 100 n-reb "mark-par"))
(not (eobp))) (not (eobp)))
(skip-chars-forward "^()") (skip-chars-forward "^()")
(unless (eobp) (unless (eobp)