summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-15 04:08:08 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2013-04-15 04:08:08 +0200
commitc00f24907cf87589f4b28885507443d419385502 (patch)
treead53486c2f6654ec8263cf367138baba2be7261a
parent82165389e02b4ff29bade2a2b34903142e3bc73a (diff)
downloadgeiser-guile-c00f24907cf87589f4b28885507443d419385502.tar.gz
geiser-guile-c00f24907cf87589f4b28885507443d419385502.tar.bz2
Racket: better help commands
For some reason that i don't fully understand, evaluating a function in the racket/base namespace first thing after loading errortrace breaks the help macro (!). This patches provides a workaround by actually invoking help first thing when Geiser starts, with alibi that it serves to preload the help index (in a separate thread). While i was at it, i improved the message printed in the minibuffer when no help is found.
-rw-r--r--elisp/geiser-racket.el20
-rw-r--r--scheme/racket/geiser/autodoc.rkt5
-rw-r--r--scheme/racket/geiser/startup.rkt4
-rw-r--r--scheme/racket/geiser/user.rkt13
4 files changed, 24 insertions, 18 deletions
diff --git a/elisp/geiser-racket.el b/elisp/geiser-racket.el
index 24712bd..42bb219 100644
--- a/elisp/geiser-racket.el
+++ b/elisp/geiser-racket.el
@@ -89,8 +89,7 @@ This function uses `geiser-racket-init-file' if it exists."
(expand-file-name geiser-racket-init-file)))
(binary (geiser-racket--real-binary))
(rackdir (expand-file-name "racket/" geiser-scheme-dir)))
- `("-i" "-q"
- "-S" ,rackdir
+ `("-i" "-q" "-S" ,rackdir
,@(apply 'append (mapcar (lambda (p) (list "-S" p))
geiser-racket-collects))
,@(and (listp binary) (cdr binary))
@@ -203,17 +202,18 @@ using start-geiser, a procedure in the geiser/server module."
;;; External help
(defsubst geiser-racket--get-help (symbol module)
- (geiser-eval--send/wait
- `(:eval (get-help ',symbol '(:module ,module)) geiser/autodoc)))
+ (geiser-eval--send/wait `(:scm ,(format ",help %s %s" symbol module))))
(defun geiser-racket--external-help (id module)
(message "Looking up manual for '%s'..." id)
- (let ((out (geiser-eval--retort-output
- (geiser-racket--get-help id module))))
- (when (and out (string-match " but provided by:\n +\\(.+\\)\n" out))
- (geiser-racket--get-help id (match-string 1 out))))
- (minibuffer-message "%s done" (current-message))
- t)
+ (let* ((ret (geiser-racket--get-help id module))
+ (out (geiser-eval--retort-output ret))
+ (ret (if (and out (string-match " but provided by:\n +\\(.+\\)\n" out))
+ (geiser-racket--get-help id (match-string 1 out))
+ ret))
+ (msg (if (geiser-eval--retort-error ret) "not found" "done")))
+ (minibuffer-message "%s %s" (current-message) msg)
+ t))
;;; Error display
diff --git a/scheme/racket/geiser/autodoc.rkt b/scheme/racket/geiser/autodoc.rkt
index ee5c488..021a5fd 100644
--- a/scheme/racket/geiser/autodoc.rkt
+++ b/scheme/racket/geiser/autodoc.rkt
@@ -1,6 +1,6 @@
;;; autodoc.rkt -- suport for autodoc echo
-;; Copyright (C) 2009, 2010, 2011, 2012 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2011, 2012, 2013 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
@@ -25,8 +25,7 @@
(define (get-help symbol mod)
(if (eq? symbol mod)
(get-mod-help mod)
- (with-handlers ([exn? (lambda (_)
- (eval `(help ,symbol)))])
+ (with-handlers ([exn? (lambda (_) (eval `(help ,symbol)))])
(eval `(help ,symbol #:from ,(ensure-module-spec mod))))))
(define (get-mod-help mod)
diff --git a/scheme/racket/geiser/startup.rkt b/scheme/racket/geiser/startup.rkt
index 6af06da..bf9293b 100644
--- a/scheme/racket/geiser/startup.rkt
+++ b/scheme/racket/geiser/startup.rkt
@@ -1,6 +1,6 @@
;;; startup.rkt -- entry point
-;; Copyright (C) 2009, 2010 Jose Antonio Ortega Ruiz
+;; Copyright (C) 2009, 2010, 2013 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
@@ -9,8 +9,6 @@
;; Start date: Sat Apr 25, 2009 22:36
-;;; Code:
-
(require version/utils)
(unless (version<=? "5.0" (version))
(error 'geiser
diff --git a/scheme/racket/geiser/user.rkt b/scheme/racket/geiser/user.rkt
index b7519b2..6aabe5e 100644
--- a/scheme/racket/geiser/user.rkt
+++ b/scheme/racket/geiser/user.rkt
@@ -9,14 +9,16 @@
;; Start date: Wed Mar 31, 2010 22:24
-#lang racket/base
+#lang racket
(provide init-geiser-repl run-geiser-server start-geiser)
(require (for-syntax racket/base)
mzlib/thread
racket/tcp
+ racket/help
geiser
+ geiser/autodoc
geiser/images
geiser/enter
geiser/eval
@@ -79,6 +81,7 @@
[(geiser-no-values) (datum->syntax #f (void))]
[(add-to-load-path) (add-to-load-path (read))]
[(set-image-cache) (image-cache (read))]
+ [(help) (get-help (read) (read))]
[(image-cache) (image-cache)]
[(gcd) (current-directory)]
[(cd) (current-directory (read))]
@@ -93,9 +96,14 @@
(define (geiser-prompt-read prompt)
(make-repl-reader (geiser-read prompt)))
+(define (preload-help)
+ (thread (lambda ()
+ (with-output-to-string (lambda () (help meh-i-dont-exist))))))
+
(define (init-geiser-repl)
(compile-enforce-module-constants #f)
(current-load/use-compiled geiser-loader)
+ (preload-help)
(current-prompt-read (geiser-prompt-read geiser-prompt))
(current-print maybe-print-image))
@@ -124,5 +132,6 @@
lsner)))))
(define (start-geiser (port 0) (hostname #f) (enforce-module-constants #f))
- (thread (lambda () (run-geiser-server port enforce-module-constants hostname)))
+ (thread (lambda ()
+ (run-geiser-server port enforce-module-constants hostname)))
(channel-get server-channel))