From b91775c9a778ffbb91a9539ed2b1236ae06c68a6 Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 13 Oct 2022 03:45:51 +0100 Subject: support for recognising current library (not yet used) --- geiser-chez.el | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/geiser-chez.el b/geiser-chez.el index 92bede7..af3f11d 100644 --- a/geiser-chez.el +++ b/geiser-chez.el @@ -143,23 +143,25 @@ Return its local name." ((car args) (concat "'" (car args))) (t "#f")))) (format "(geiser:eval %s '%s)" module form))) - ((load-file compile-file) - (format "(geiser:load-file %s)" (car args))) - ((no-values) - "(geiser:no-values)") - (t - (let ((form (mapconcat 'identity args " "))) - (format "(geiser:%s %s)" proc form))))) + ((load-file compile-file) (format "(geiser:load-file %s)" (car args))) + ((no-values) "(geiser:no-values)") + (t (let ((form (mapconcat 'identity args " "))) + (format "(geiser:%s %s)" proc form))))) + +(defun geiser-chez--current-library () + "Find current library." + (save-excursion + (geiser-syntax--pop-to-top) + (when (looking-at "(library[ \n]+\\(([^)]+)\\)") + (geiser-chez--get-module (match-string 1))))) (defun geiser-chez--get-module (&optional module) - "Find current module, or normalize MODULE." - (cond ((null module) - :f) + "Find current module (libraries for Chez), or normalize MODULE." + (cond ((null module) :f) + ;; ((null module) (or (geiser-chez--current-library) :f)) ((listp module) module) - ((stringp module) - (condition-case nil - (car (geiser-syntax--read-from-string module)) - (error :f))) + ((and (stringp module) + (ignore-errors (car (geiser-syntax--read-from-string module))))) (t :f))) (defun geiser-chez--symbol-begin (module) -- cgit v1.2.3