summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-14 20:52:27 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-02-14 20:52:27 +0100
commit5ee2ae3ccd73f5dfae68db011c581f918eea8751 (patch)
treec121a321d93bdc852ac99051be4c78b11db92348
parent13d84e514446438f0115585f3a14e36f535e2225 (diff)
downloadgeiser-chez-5ee2ae3ccd73f5dfae68db011c581f918eea8751.tar.gz
geiser-chez-5ee2ae3ccd73f5dfae68db011c581f918eea8751.tar.bz2
New command to get docstrings (C-cC-d).
-rw-r--r--elisp/geiser-completion.el4
-rw-r--r--elisp/geiser-doc.el63
-rw-r--r--elisp/geiser-mode.el2
-rw-r--r--elisp/geiser-repl.el1
-rw-r--r--scheme/guile/geiser/emacs.scm3
-rw-r--r--scheme/guile/geiser/introspection.scm5
6 files changed, 76 insertions, 2 deletions
diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el
index dd0c33c..3a36187 100644
--- a/elisp/geiser-completion.el
+++ b/elisp/geiser-completion.el
@@ -183,12 +183,14 @@ terminates a current completion."
(partial (if (eq partial t) prefix partial)))
(cons completions partial)))
+(defvar geiser-completion--symbol-history nil)
+
(defun geiser-completion--read-symbol (prompt &optional default history)
(let ((minibuffer-local-completion-map geiser-completion--minibuffer-map))
(completing-read prompt
geiser-completion--symbol-list-func
nil nil nil
- history
+ (or history geiser-completion--symbol-history)
(or default (symbol-at-point)))))
(defun geiser--respecting-message (format &rest format-args)
diff --git a/elisp/geiser-doc.el b/elisp/geiser-doc.el
new file mode 100644
index 0000000..7113b25
--- /dev/null
+++ b/elisp/geiser-doc.el
@@ -0,0 +1,63 @@
+;; geiser-doc.el -- accessing documentation
+
+;; Copyright (C) 2009 Jose Antonio Ortega Ruiz
+
+;; Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
+;; Start date: Sat Feb 14, 2009 14:09
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Comentary:
+
+;; Utilities for accessing docstrings and texinfo documentation.
+
+;;; Code:
+
+(require 'geiser-completion)
+(require 'geiser-eval)
+(require 'geiser-popup)
+(require 'geiser-base)
+
+
+;;; Documentation buffer:
+
+(geiser-popup--define doc "*Geiser documentation*" fundamental-mode)
+
+
+;;; Docstrings:
+
+(defun geiser-doc--get-docstring (symbol)
+ (geiser-eval--send/result `(:gs ((:ge docstring) ',symbol))))
+
+
+;;; Commands:
+
+(defun geiser-doc-symbol-at-point (&optional arg)
+ "Get docstring for symbol at point.
+With prefix argument, ask for symbol (with completion)."
+ (interactive "P")
+ (let ((symbol (or (and (not arg) (symbol-at-point))
+ (geiser-completion--read-symbol "Symbol: " (symbol-at-point)))))
+ (when symbol
+ (let ((ds (geiser-doc--get-docstring symbol)))
+ (if (not (stringp ds))
+ (message "No docstring available for '%s'" symbol)
+ (geiser-doc--with-buffer
+ (erase-buffer)
+ (insert ds))
+ (geiser-doc--pop-to-buffer))))))
+
+
+(provide 'geiser-doc)
+;;; geiser-doc.el ends here
diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el
index aed018f..812810a 100644
--- a/elisp/geiser-mode.el
+++ b/elisp/geiser-mode.el
@@ -25,6 +25,7 @@
;;; Code:
+(require 'geiser-doc)
(require 'geiser-compile)
(require 'geiser-completion)
(require 'geiser-edit)
@@ -154,6 +155,7 @@ interacting with the Geiser REPL is at your disposal.
(define-key geiser-mode-map "\C-c\M-r" 'geiser-send-region-and-go)
(define-key geiser-mode-map "\C-c\C-a" 'geiser-autodoc-mode)
+(define-key geiser-mode-map "\C-c\C-d" 'geiser-doc-symbol-at-point)
(define-key geiser-mode-map "\C-c\M-c" 'geiser-compile-definition)
(define-key geiser-mode-map "\C-c\C-c" 'geiser-compile-definition-and-go)
diff --git a/elisp/geiser-repl.el b/elisp/geiser-repl.el
index 80b637a..671c798 100644
--- a/elisp/geiser-repl.el
+++ b/elisp/geiser-repl.el
@@ -143,6 +143,7 @@ the Geiser REPL buffer."
(define-key geiser-repl-mode-map "\C-c\C-z" 'run-guile)
(define-key geiser-repl-mode-map "\C-a" 'geiser-repl--bol)
(define-key geiser-repl-mode-map "\C-ca" 'geiser-autodoc-mode)
+(define-key geiser-repl-mode-map "\C-cd" 'geiser-doc-symbol-at-point)
(define-key geiser-repl-mode-map "\C-ck" 'geiser-compile-file)
(define-key geiser-repl-mode-map "\C-cl" 'geiser-load-file)
diff --git a/scheme/guile/geiser/emacs.scm b/scheme/guile/geiser/emacs.scm
index 79da237..1458c73 100644
--- a/scheme/guile/geiser/emacs.scm
+++ b/scheme/guile/geiser/emacs.scm
@@ -29,7 +29,8 @@
ge:completions
ge:symbol-location
ge:compile-file
- ge:load-file)
+ ge:load-file
+ ge:docstring)
#:use-module ((geiser introspection)
:renamer (symbol-prefix-proc 'ge:))
#:use-module ((geiser eval)
diff --git a/scheme/guile/geiser/introspection.scm b/scheme/guile/geiser/introspection.scm
index cd48740..14cd021 100644
--- a/scheme/guile/geiser/introspection.scm
+++ b/scheme/guile/geiser/introspection.scm
@@ -28,6 +28,7 @@
#:export (arguments completions symbol-location docstring)
#:use-module (system vm program)
#:use-module (ice-9 session)
+ #:use-module (ice-9 documentation)
#:use-module (srfi srfi-1))
(define (arguments sym . syms)
@@ -118,4 +119,8 @@
(define (make-location-from-module-name name)
(make-location (module-filename name) #f))
+
+(define (docstring sym)
+ (object-documentation (symbol->obj sym)))
+
;;; introspection.scm ends here