summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-10-23 12:50:50 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-10-23 12:50:50 +0200
commit48333a4d4593b2d616855e50e3211537d210624f (patch)
treeddbbdd85641a2eb640e35e3c6c514216f6fdcf42
parent145c5c15cdc0345bafa0e172c68f1a481ee3a19e (diff)
downloadgeiser-chez-48333a4d4593b2d616855e50e3211537d210624f.tar.gz
geiser-chez-48333a4d4593b2d616855e50e3211537d210624f.tar.bz2
A proper (let's hope) fix for the sluggishness problem
-rw-r--r--elisp/geiser-syntax.el40
1 files changed, 25 insertions, 15 deletions
diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el
index f5d8cfa..52f0d8f 100644
--- a/elisp/geiser-syntax.el
+++ b/elisp/geiser-syntax.el
@@ -228,26 +228,36 @@
(defsubst geiser-syntax--pair-length (p)
(if (cdr (last p)) (1+ (safe-length p)) (length p)))
+(defun geiser-syntax--shallow-form (boundary)
+ (when (looking-at-p "\\s(")
+ (save-excursion
+ (forward-char)
+ (let ((elems))
+ (ignore-errors
+ (while (< (point) boundary)
+ (skip-syntax-forward "-<>")
+ (when (<= (point) boundary)
+ (forward-sexp)
+ (let ((s (symbol-at-point)))
+ (when (not (eq s '.)) (push (symbol-at-point) elems))))))
+ (nreverse elems)))))
+
(defun geiser-syntax--scan-sexps (&optional begin)
- (let* ((start (point))
- (go-on t)
- (fst (geiser-syntax--symbol-at-point))
+ (let* ((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 (and go-on (not (zerop (geiser-syntax--nesting-level))))
- (let ((boundary (1+ (point))))
+ (while (not (zerop (geiser-syntax--nesting-level)))
+ (let ((boundary (point)))
+ (geiser-syntax--skip-comment/string)
(backward-up-list)
- (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))))))))
+ (let ((form (geiser-syntax--shallow-form 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)