From 26e9c414608c3e287f736bbedffff291e46e6f40 Mon Sep 17 00:00:00 2001
From: Jose Antonio Ortega Ruiz <jao@gnu.org>
Date: Sun, 24 Jan 2010 20:31:21 +0100
Subject: Guile: Geiser now behaves correctly in buffers for unloaded modules.

---
 elisp/geiser-eval.el               |  5 +++--
 elisp/geiser-guile.el              |  3 +--
 scheme/guile/geiser/evaluation.scm | 13 ++++++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/elisp/geiser-eval.el b/elisp/geiser-eval.el
index f4ac95d..b37b7ed 100644
--- a/elisp/geiser-eval.el
+++ b/elisp/geiser-eval.el
@@ -1,6 +1,6 @@
 ;;; geiser-eval.el -- sending scheme code for evaluation
 
-;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the Modified BSD License. You should
@@ -102,7 +102,8 @@ module-exports, autodoc, callers, callees and generic-methods.")
                ((eq (car code) :ge) (geiser-eval--ge (cadr code)))
                ((eq (car code) :scm) (cadr code))
                (t (concat "("
-                          (mapconcat 'geiser-eval--scheme-str code " ") ")"))))
+                          (mapconcat 'geiser-eval--scheme-str code " ")
+                          ")"))))
         ((symbolp code) (format "%s" code))
         (t (format "%S" code))))
 
diff --git a/elisp/geiser-guile.el b/elisp/geiser-guile.el
index c173f4d..ccc048c 100644
--- a/elisp/geiser-guile.el
+++ b/elisp/geiser-guile.el
@@ -1,6 +1,6 @@
 ;; geiser-guile.el -- guile's implementation of the geiser protocols
 
-;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the Modified BSD License. You should
@@ -76,7 +76,6 @@ This function uses `geiser-guile-init-file' if it exists."
   (cond ((null module)
          (save-excursion
            (ignore-errors
-             (backward-sexp)
              (while (not (zerop (geiser-syntax--nesting-level)))
                (backward-up-list)))
            (if (re-search-backward geiser-guile--module-re nil t)
diff --git a/scheme/guile/geiser/evaluation.scm b/scheme/guile/geiser/evaluation.scm
index 3811153..3a834bb 100644
--- a/scheme/guile/geiser/evaluation.scm
+++ b/scheme/guile/geiser/evaluation.scm
@@ -1,6 +1,6 @@
 ;;; evaluation.scm -- evaluation, compilation and macro-expansion
 
-;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz
 
 ;; This program is free software; you can redistribute it and/or
 ;; modify it under the terms of the Modified BSD License. You should
@@ -31,10 +31,17 @@
      (display-error stack (current-output-port) subr msg args rest))
     (else (display (format "ERROR: ~a, args: ~a" (car args) (cdr args)))))
   `(error (key . ,(car args))))
+(nested-ref the-root-module '(%app modules geiser))
+
+(define (find-module module-name)
+  (and (list? module-name)
+       (or (nested-ref the-root-module (append '(%app modules) module-name))
+           (let ((m (resolve-module module-name)))
+             (beautify-user-module! m)
+             m))))
 
 (define (ge:compile form module-name)
-  (let* ((module (or (and (list? module-name)
-                          (resolve-module module-name))
+  (let* ((module (or (find-module module-name)
                      (current-module)))
          (result #f)
          (captured-stack #f)
-- 
cgit v1.2.3