From 4877f3720b1fa9bb39a979a206fdcb2236c843ab Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sat, 23 Oct 2010 01:06:15 +0200 Subject: Temporary fix for sluggishness while scanning big forms --- elisp/geiser-syntax.el | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'elisp') diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el index f057d9d..f5d8cfa 100644 --- a/elisp/geiser-syntax.el +++ b/elisp/geiser-syntax.el @@ -229,22 +229,25 @@ (if (cdr (last p)) (1+ (safe-length p)) (length p))) (defun geiser-syntax--scan-sexps (&optional begin) - (let* ((fst (geiser-syntax--symbol-at-point)) + (let* ((start (point)) + (go-on t) + (fst (geiser-syntax--symbol-at-point)) (smth (or fst (not (looking-at-p "[\s \s)\s>\s<\n]")))) (path (and fst `((,fst 0))))) (save-excursion (geiser-syntax--skip-comment/string) - (while (not (zerop (geiser-syntax--nesting-level))) + (while (and go-on (not (zerop (geiser-syntax--nesting-level)))) (let ((boundary (1+ (point)))) (backward-up-list) - (let ((form - (nth-value 0 (geiser-syntax--form-after-point boundary)))) - (when (and (listp form) (car form) (symbolp (car form))) - (let* ((len (geiser-syntax--pair-length form)) - (pos (if smth (1- len) (progn (setq smth t) len))) - (prev (and (> pos 1) (nth (1- pos) form))) - (prev (and (keywordp prev) (list prev)))) - (push `(,(car form) ,pos ,@prev) path))))))) + (when (setq go-on (< (- start (point)) 2000)) + (let ((form + (nth-value 0 (geiser-syntax--form-after-point boundary)))) + (when (and (listp form) (car form) (symbolp (car form))) + (let* ((len (geiser-syntax--pair-length form)) + (pos (if smth (1- len) (progn (setq smth t) len))) + (prev (and (> pos 1) (nth (1- pos) form))) + (prev (and (keywordp prev) (list prev)))) + (push `(,(car form) ,pos ,@prev) path)))))))) (nreverse path))) (defsubst geiser-syntax--binding-form-p (bfs sbfs f) -- cgit v1.2.3