From 7cf34c0c92cac3039849b8be40b468d0c52d2472 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 5 Jun 2014 06:14:44 +0200 Subject: Possible fix for scanning problem Apparently, the nesting level returned by emacs's syntax parser can be negative (presumably when it gets confused), and we were not avoiding calling backward-up-list when that happened. Could or could not address issue #41... --- elisp/geiser-guile.el | 4 +--- elisp/geiser-racket.el | 4 +--- elisp/geiser-syntax.el | 9 ++++++--- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'elisp') diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el index fbe6075..e8eb11a 100644 --- a/elisp/geiser-guile.el +++ b/elisp/geiser-guile.el @@ -171,9 +171,7 @@ This function uses `geiser-guile-init-file' if it exists." (defun geiser-guile--get-module (&optional module) (cond ((null module) (save-excursion - (ignore-errors - (while (not (zerop (geiser-syntax--nesting-level))) - (backward-up-list))) + (geiser-syntax--pop-to-top) (if (or (re-search-backward geiser-guile--module-re nil t) (looking-at geiser-guile--library-re) (re-search-forward geiser-guile--module-re nil t)) diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el index f2cec3a..8a0d46d 100644 --- a/elisp/geiser-racket.el +++ b/elisp/geiser-racket.el @@ -119,9 +119,7 @@ using start-geiser, a procedure in the geiser/server module." (defun geiser-racket--explicit-module () (save-excursion - (ignore-errors - (while (not (zerop (geiser-syntax--nesting-level))) - (backward-up-list))) + (geiser-syntax--pop-to-top) (and (looking-at geiser-racket--module-re) (let ((mod (match-string-no-properties 1)) (lang (match-string-no-properties 2))) diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el index b9a7174..9557f5e 100644 --- a/elisp/geiser-syntax.el +++ b/elisp/geiser-syntax.el @@ -255,6 +255,10 @@ implementation-specific entries for font-lock-keywords.") (defsubst geiser-syntax--nesting-level () (or (nth 0 (syntax-ppss)) 0)) +(defun geiser-syntax--pop-to-top () + (ignore-errors + (while (> (geiser-syntax--nesting-level) 0) (backward-up-list)))) + (defsubst geiser-syntax--in-string-p () (nth 3 (syntax-ppss))) @@ -287,7 +291,7 @@ implementation-specific entries for font-lock-keywords.") (smth (or fst (not (looking-at-p "[\s \s)\s>\s<\n]")))) (path (and fst `((,fst 0))))) (save-excursion - (while (not (zerop (geiser-syntax--nesting-level))) + (while (> (or (geiser-syntax--nesting-level) 0) 0) (let ((boundary (point))) (geiser-syntax--skip-comment/string) (backward-up-list) @@ -383,8 +387,7 @@ implementation-specific entries for font-lock-keywords.") (skip-syntax-forward "->") (let ((boundary (point)) (nesting (geiser-syntax--nesting-level))) - (while (not (zerop (geiser-syntax--nesting-level))) - (backward-up-list)) + (geiser-syntax--pop-to-top) (multiple-value-bind (form end) (geiser-syntax--form-after-point boundary) (delete sym -- cgit v1.2.3