-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmi-scheme.el
122 lines (99 loc) · 3.67 KB
/
mi-scheme.el
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
;;; mi-scheme.el --- Mode-info backend for scheme
;; Copyright (C) 2002 TSUCHIYA Masatoshi <[email protected]>
;; Author: TSUCHIYA Masatoshi <[email protected]>
;; Keywords: scheme info
;; This file is a part of mode-info.
;; This program 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 2, or (at your option)
;; any later version.
;; This program 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, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;;; Commentary:
;; This file provides mode-info backend stuffs to handle Info
;; documents about Scheme.
;;
;; Info manual of SLIB is distributed with its official distribution.
;; It can be downloaded from:
;;
;; http://swissnet.ai.mit.edu/~jaffer/SLIB.html
;; http://swissnet.ai.mit.edu/ftpdir/scm/slib2d4.zip
;;; Code:
(require 'mode-info)
(eval-when-compile
(require 'cl)
(require 'mi-index))
(defgroup mode-info-scheme nil
"Various sorts of imporved help system for Scheme."
:group 'mode-info)
(defcustom mode-info-scheme-index-file
(expand-file-name "mi-scheme.idx" mode-info-index-directory)
"*Index file of functions and variables described in Info about Scheme."
:group 'mode-info-scheme
:type 'file)
(defcustom mode-info-scheme-titles
'("slib")
"*Info titles about Scheme."
:group 'mode-info-scheme
:type mode-info-titles-type)
(defconst mode-info-scheme-entry-regexp
"^ --? \\(Syntax\\|Function\\|Macro\\|Procedure\\|Variable\\):[ \t]+\\([^ \t\n]+\\)[ \t\n]")
(defconst mode-info-scheme-entry-pos 2)
(mode-info-defclass scheme)
(defun mode-info-scheme-word-at-point (class &optional variable-p)
(ignore-errors
(let ((word
(save-excursion
(cond
((looking-at "\\s(")
(skip-chars-forward "\\s("))
((looking-at "\\s)")
(backward-sexp)
(skip-chars-forward "\\s("))
(t
(backward-sexp)))
(buffer-substring-no-properties
(point) (progn (forward-sexp) (point))))))
(when (if variable-p
(mode-info-variable-described-p class word)
(mode-info-function-described-p class word))
word))))
(mode-info-defmethod function-at-point ((class scheme))
(mode-info-scheme-word-at-point class))
(mode-info-defmethod variable-at-point ((class scheme))
(mode-info-scheme-word-at-point class t))
(defun mode-info-scheme-make-index ()
"Make index of Info files listed in `mode-info-scheme-titles'."
(interactive)
(mode-info-make-index 'scheme
mode-info-scheme-titles
mode-info-scheme-entry-regexp
mode-info-scheme-entry-pos))
(mode-info-defmethod process-index-node ((class scheme) title nodename
functions variables)
(if (string= title "slib")
(when (and (string= nodename "Index")
(search-forward "\nVariable Index\n" nil t))
(narrow-to-region (point-min) (match-beginning 0))
(goto-char (point-min))
(setq nodename "Function Index")
(mode-info-method-next)
(goto-char (point-max))
(widen)
(narrow-to-region (point)
(or (search-forward "\nConcept and Feature Index\n"
nil t)
(point-max)))
(goto-char (point-min))
(setq nodename "Variable Index")
(mode-info-method-next)
(widen))
(mode-info-method-next)))
(provide 'mi-scheme)
;;; mi-scheme.el ends here