summaryrefslogtreecommitdiff
path: root/elisp/geiser-doc.el
blob: 9dcb95177e3ab351f011c048afdd24b5366e8b39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 (or (not (stringp ds)) (zerop (length ds)))
            (message "No documentation 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