annotate lisp/progmodes/octave-hlp.el @ 53162:9ef6052ba695

*** empty log message ***
author Stephen Eglen <stephen@gnu.org>
date Tue, 25 Nov 2003 14:41:08 +0000
parents 695cf19ef79e
children 18a818a2ee7c 375f2633d815
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17517
8f952e921136 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17149
diff changeset
1 ;;; octave-hlp.el --- getting help on Octave symbols using info
16903
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
17517
8f952e921136 Comment change.
Richard M. Stallman <rms@gnu.org>
parents: 17149
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
16903
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5 ;; Author: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: John Eaton <jwe@bevo.che.wisc.edu>
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Maintainer: Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; Keywords: languages
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; any later version.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; GNU General Public License for more details.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;;; Commentary:
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; Provides the command `octave-help' which allows index lookup of a
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; symbol in the Octave-related info files, as specified by the list
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31 ;; `octave-help-files'.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
33 ;; Other features may be added in future versions.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
34
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
35 ;;; Code:
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
36
16904
2bc5f76917e0 Require octave-mod, not octave.
Richard M. Stallman <rms@gnu.org>
parents: 16903
diff changeset
37 (require 'octave-mod)
16903
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
38 (require 'info)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
39
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
40 (defvar octave-help-files '("octave")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41 "List of info files with documentation for Octave.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 Default is (\"octave\").")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
43
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
44 (defvar octave-help-lookup-alist nil
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 "Alist of Octave index entries for lookup.")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47 (defvar octave-help-completion-alist nil
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
48 "Alist of Octave index entries for completion.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
49 The entries are of the form (VAR . VAR), where VAR runs through all
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
50 different keys in `octave-help-lookup-alist'.")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
52 ;;;###autoload
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
53 (defun octave-help (key)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
54 "Get help on Octave symbols from the Octave info files.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
55 Look up KEY in the function, operator and variable indices of the files
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56 specified by `octave-help-files'.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 If KEY is not a string, prompt for it with completion."
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 (interactive
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59 (list
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
60 (completing-read (format "Describe Octave symbol: ")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
61 (octave-help-get-completion-alist)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
62 nil t)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
63 (if (get-buffer "*info*")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
64 (set-buffer "*info*"))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65 (if (zerop (length key))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (Info-find-node (car octave-help-files) "Top")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 (let ((alist (copy-alist (octave-help-get-lookup-alist)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 entry matches)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (while (setq entry (car alist))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (if (string-match key (car entry))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
71 (add-to-list 'matches entry))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (setq alist (cdr alist)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 (if matches
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (progn
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (setq Info-index-alternatives matches)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (Info-index-next 0))))))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 (defun octave-help-get-lookup-alist ()
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 "Build the index lookup alist from all Octave info files.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 The files specified by `octave-help-files' are searched."
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 (if octave-help-lookup-alist
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 ()
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 17517
diff changeset
83 (message "Building help lookup alist...")
16903
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (let ((files octave-help-files) file key node)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 (save-window-excursion
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (while files
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 (setq file (car files))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (Info-goto-node (concat "(" file ")"))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89 (condition-case nil
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (progn
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (Info-index "")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (while
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (progn
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 (while (re-search-forward
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 "^\\* \\([^(:]+\\)[^:]*: *\\(.+\\)\\.$"
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 nil t)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (setq key (match-string 1)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 node (concat "(" file ")" (match-string 2)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (and (string-match "\\(.*\\>\\) *$" key)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (setq key (replace-match "\\1" t nil key)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (add-to-list 'octave-help-lookup-alist
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 (list key
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 node
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 (concat (concat "(" file ")")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 Info-current-node)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 0)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (and (setq node (Info-extract-pointer "next" t))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 (string-match
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (concat "\\(Function\\|Operator\\|Variable\\) "
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 "\\<Index\\>")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 node)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (Info-goto-node node)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (error nil))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (setq files (cdr files)))))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 (message "Building help lookup alist...done"))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116 octave-help-lookup-alist)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (defun octave-help-get-completion-alist ()
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 "Build the index completion alist from all Octave info files.
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 The files specified by `octave-help-files' are searched."
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (if octave-help-completion-alist
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 ()
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (message "Building help completion alist...")
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (let ((alist (octave-help-get-lookup-alist)) entry)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (while alist
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (setq entry (car alist))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (add-to-list 'octave-help-completion-alist
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (cons (car entry) (car entry)))
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (setq alist (cdr alist))))
49598
0d8b17d428b5 Trailing whitepace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 17517
diff changeset
130 (message "Building help completion alist...done"))
16903
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 octave-help-completion-alist)
b1239a1ef6f2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132
17149
b6b657de23f3 Provide octave-hlp.
Karl Heuer <kwzh@gnu.org>
parents: 16904
diff changeset
133 ;;; provide ourself
b6b657de23f3 Provide octave-hlp.
Karl Heuer <kwzh@gnu.org>
parents: 16904
diff changeset
134
b6b657de23f3 Provide octave-hlp.
Karl Heuer <kwzh@gnu.org>
parents: 16904
diff changeset
135 (provide 'octave-hlp)
b6b657de23f3 Provide octave-hlp.
Karl Heuer <kwzh@gnu.org>
parents: 16904
diff changeset
136
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49598
diff changeset
137 ;;; arch-tag: df5ef8fa-76c9-44e5-9835-cb5a502c6282
16904
2bc5f76917e0 Require octave-mod, not octave.
Richard M. Stallman <rms@gnu.org>
parents: 16903
diff changeset
138 ;;; octave-hlp.el ends here