diff options
-rw-r--r-- | elisp/geiser-syntax.el | 23 |
1 files changed, 13 insertions, 10 deletions
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) |