annotate lisp/info-look.el @ 24419:30e478cd167e

(shell-command-default-error-buffer): Renamed from shell-command-on-region-default-error-buffer. (shell-command-on-region): Mention in echo area when there is some error output. Mention success or failure, too. Accumulate multiple error outputs going forward, with formfeed in between. Display the error buffer when we have put something in it. (shell-command): Add the ERROR-BUFFER argument feature.
author Karl Heuer <kwzh@gnu.org>
date Mon, 01 Mar 1999 03:19:32 +0000
parents d400637428d1
children 28aea9fa43e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; info-look.el --- major-mode-sensitive Info index lookup facility.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2 ;; An older version of this was known as libc.el.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
3
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
4 ;; Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
5
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6 ;; Author: Ralph Schleicher <rs@purple.UL.BaWue.DE>
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7 ;; Keywords: help languages
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14 ;; any later version.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; GNU General Public License for more details.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;;; Code:
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28 (require 'info)
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
29 (eval-and-compile
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
30 (condition-case nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
31 (require 'custom)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
32 (error
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
33 (defmacro defgroup (&rest arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
34 nil)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
35 (defmacro defcustom (symbol value doc &rest arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
36 `(defvar ,symbol ,value ,doc ,@arg)))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
37
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
38 (defgroup info-lookup nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
39 "Major mode sensitive help agent."
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
40 :group 'help :group 'languages)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
41
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
42 (defvar info-lookup-mode nil
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
43 "Symbol of the current buffer's help mode.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
44 Help is provided according to the buffer's major mode if value is nil.
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
45 Automatically becomes buffer local when set in any fashion.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
46 (make-variable-buffer-local 'info-lookup-mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
48 (defcustom info-lookup-other-window-flag t
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
49 "Non-nil means pop up the Info buffer in another window."
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
50 :group 'info-lookup :type 'boolean)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
51
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
52 (defcustom info-lookup-highlight-face 'highlight
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
53 "Face for highlighting looked up help items.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
54 Setting this variable to nil disables highlighting."
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
55 :group 'info-lookup :type 'face)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
56
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
57 (defvar info-lookup-highlight-overlay nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
58 "Overlay object used for highlighting.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
59
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
60 (defcustom info-lookup-file-name-alist
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
61 '(("\\`configure\\.in\\'" . autoconf-mode)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
62 ("\\`aclocal\\.m4\\'" . autoconf-mode)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
63 ("\\`acsite\\.m4\\'" . autoconf-mode)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
64 ("\\`acinclude\\.m4\\'" . autoconf-mode))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
65 "Alist of file names handled specially.
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
66 List elements are cons cells of the form
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
67
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
68 (REGEXP . MODE)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
69
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
70 If a file name matches REGEXP, then use help mode MODE instead of the
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
71 buffer's major mode."
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
72 :group 'info-lookup :type '(repeat (cons (string :tag "Regexp")
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
73 (symbol :tag "Mode"))))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
74
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (defvar info-lookup-history nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 "History of previous input lines.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
78 (defvar info-lookup-alist nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
79 "Alist of known help topics.
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80 Cons cells are of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
82 (HELP-TOPIC . HELP-DATA)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 HELP-TOPIC is the symbol of a help topic.
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
85 HELP-DATA is a HELP-TOPIC's public data set.
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 Value is an alist with elements of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 (HELP-MODE REGEXP IGNORE-CASE DOC-SPEC PARSE-RULE OTHER-MODES)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
89
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 HELP-MODE is a mode's symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 REGEXP is a regular expression matching those help items whose
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 documentation can be looked up via DOC-SPEC.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 IGNORE-CASE is non-nil if help items are case insensitive.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 DOC-SPEC is a list of documentation specifications of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (INFO-NODE TRANS-FUNC PREFIX SUFFIX)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
98 INFO-NODE is the name (including file name part) of an Info index.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 TRANS-FUNC is a function translating index entries into help items;
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 nil means add only those index entries matching REGEXP, a string
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 means prepend string to the first word of all index entries.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
102 PREFIX and SUFFIX are parts of a regular expression. If one of
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103 them is non-nil then search the help item's Info node for the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
104 first occurrence of the regular expression `PREFIX ITEM SUFFIX'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ITEM will be highlighted with `info-lookup-highlight-face' if this
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 variable is not nil.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 PARSE-RULE is either the symbol name of a function or a regular
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 expression for guessing the default help item at point. Fuzzy
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 regular expressions like \"[_a-zA-Z0-9]+\" do a better job if
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 there are no clear delimiters; do not try to write too complex
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 expressions. PARSE-RULE defaults to REGEXP.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 OTHER-MODES is a list of cross references to other help modes.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (defsubst info-lookup->topic-value (topic)
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
115 (cdr (assoc topic info-lookup-alist)))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
116
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (defsubst info-lookup->mode-value (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (assoc mode (info-lookup->topic-value topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (defsubst info-lookup->regexp (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (nth 1 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (defsubst info-lookup->ignore-case (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (nth 2 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (defsubst info-lookup->doc-spec (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (nth 3 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129 (defsubst info-lookup->parse-rule (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
130 (nth 4 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 (defsubst info-lookup->other-modes (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 (nth 5 (info-lookup->mode-value topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
135 (eval-and-compile
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
136 (mapcar (lambda (keyword)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
137 (or (boundp keyword)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
138 (set keyword keyword)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
139 '(:topic :mode :regexp :ignore-case
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
140 :doc-spec :parse-rule :other-modes)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
141
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
142 (defun info-lookup-add-help (&rest arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
143 "Add or update a help specification.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
144 Function arguments are one or more options of the form
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
145
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
146 KEYWORD ARGUMENT
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
147
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
148 KEYWORD is either `:topic', `:mode', `:regexp', `:ignore-case',
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
149 `:doc-spec', `:parse-rule', or `:other-modes'.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
150 ARGUMENT has a value as explained in the documentation of the
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
151 variable `info-lookup-alist'.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
152
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
153 If no topic or mode option has been specified, then the help topic defaults
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
154 to `symbol', and the help mode defaults to the current major mode."
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
155 (apply 'info-lookup-add-help* nil arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
156
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
157 (defun info-lookup-maybe-add-help (&rest arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
158 "Add a help specification iff no one is defined.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
159 See the documentation of the function `info-lookup-add-help'
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
160 for more details."
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
161 (apply 'info-lookup-add-help* t arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
162
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
163 (defun info-lookup-add-help* (maybe &rest arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
164 (let (topic mode regexp ignore-case doc-spec
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
165 parse-rule other-modes keyword value)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
166 (setq topic 'symbol
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
167 mode major-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
168 regexp "\\w+")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
169 (while arg
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
170 (setq keyword (car arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
171 (or (symbolp keyword)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
172 (error "Junk in argument list \"%S\"" arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
173 (setq arg (cdr arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
174 (and (null arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
175 (error "Keyword \"%S\" is missing an argument" keyword))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
176 (setq value (car arg)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
177 arg (cdr arg))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
178 (cond ((eq keyword :topic)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
179 (setq topic value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
180 ((eq keyword :mode)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
181 (setq mode value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
182 ((eq keyword :regexp)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
183 (setq regexp value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
184 ((eq keyword :ignore-case)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
185 (setq ignore-case value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
186 ((eq keyword :doc-spec)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
187 (setq doc-spec value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
188 ((eq keyword :parse-rule)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
189 (setq parse-rule value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
190 ((eq keyword :other-modes)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
191 (setq other-modes value))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
192 (t
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
193 (error "Unknown keyword \"%S\"" keyword))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
194 (or (and maybe (info-lookup->mode-value topic mode))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
195 (let* ((data (list regexp ignore-case doc-spec parse-rule other-modes))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
196 (topic-cell (or (assoc topic info-lookup-alist)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
197 (car (setq info-lookup-alist
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
198 (cons (cons topic nil)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
199 info-lookup-alist)))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
200 (mode-cell (assoc mode topic-cell)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
201 (if (null mode-cell)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
202 (setcdr topic-cell (cons (cons mode data) (cdr topic-cell)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
203 (setcdr mode-cell data))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
204 nil))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
205
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
206 (defvar info-lookup-cache nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
207 "Cache storing data maintained automatically by the program.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
208 Value is an alist with cons cell of the form
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (HELP-TOPIC . ((HELP-MODE INITIALIZED COMPLETIONS REFER-MODES) ...))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
211
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
212 HELP-TOPIC is the symbol of a help topic.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
213 HELP-MODE is a mode's symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
214 INITIALIZED is nil if HELP-MODE is uninitialized, t if
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
215 HELP-MODE is initialized, and `0' means HELP-MODE is
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216 initialized but void.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 COMPLETIONS is an alist of documented help items.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
218 REFER-MODES is a list of other help modes to use.")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
219
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (defsubst info-lookup->cache (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
221 (or (assoc topic info-lookup-cache)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
222 (car (setq info-lookup-cache
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
223 (cons (cons topic nil)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
224 info-lookup-cache)))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
225
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
226 (defun info-lookup->topic-cache (topic)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
227 (cdr (info-lookup->cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
228
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
229 (defun info-lookup->mode-cache (topic mode)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
230 (assoc mode (info-lookup->topic-cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
231
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
232 (defun info-lookup->initialized (topic mode)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
233 (nth 1 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
235 (defun info-lookup->completions (topic mode)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
237 (info-lookup-setup-mode topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (nth 2 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
240 (defun info-lookup->refer-modes (topic mode)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
241 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242 (info-lookup-setup-mode topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243 (nth 3 (info-lookup->mode-cache topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
245 (defun info-lookup->all-modes (topic mode)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (cons mode (info-lookup->refer-modes topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
248 (defun info-lookup-quick-all-modes (topic mode)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
249 (cons mode (info-lookup->other-modes topic mode)))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
250
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (defun info-lookup-reset ()
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 "Throw away all cached data.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
254 This command is useful if the user wants to start at the beginning without
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 quitting Emacs, for example, after some Info documents were updated on the
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 system."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (interactive)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (setq info-lookup-cache nil))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
260 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (defun info-lookup-symbol (symbol &optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 "Display the documentation of a symbol.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 If called interactively, SYMBOL will be read from the mini-buffer.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 Prefix argument means unconditionally insert the default symbol name
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 into the mini-buffer so that it can be edited.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 The default symbol is the one found at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267 (interactive
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268 (info-lookup-interactive-arguments 'symbol))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
269 (info-lookup 'symbol symbol mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
270
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
271 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
272 (defun info-lookup-file (file &optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
273 "Display the documentation of a file.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
274 If called interactively, FILE will be read from the mini-buffer.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
275 Prefix argument means unconditionally insert the default file name
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
276 into the mini-buffer so that it can be edited.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
277 The default file name is the one found at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
278 (interactive
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
279 (info-lookup-interactive-arguments 'file))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
280 (info-lookup 'file file mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
281
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
282 (defun info-lookup-interactive-arguments (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
283 "Return default value and help mode for help topic TOPIC."
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
284 (let* ((mode (if (info-lookup->mode-value topic (info-lookup-select-mode))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
285 info-lookup-mode
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 (info-lookup-change-mode topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 (completions (info-lookup->completions topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 (default (info-lookup-guess-default topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 (input (if (or current-prefix-arg (not (assoc default completions)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290 default))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (completion-ignore-case (info-lookup->ignore-case topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 (enable-recursive-minibuffers t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
293 (value (completing-read
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
294 (if (and default (not input))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
295 (format "Describe %s (default %s): " topic default)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
296 (format "Describe %s: " topic))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
297 completions nil nil input 'info-lookup-history)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
298 (list (if (equal value "") default value) mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
299
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
300 (defun info-lookup-select-mode ()
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
301 (when (and (not info-lookup-mode) (buffer-file-name))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
302 (let ((file-name (file-name-nondirectory (buffer-file-name)))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
303 (file-name-alist info-lookup-file-name-alist))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
304 (while (and (not info-lookup-mode) file-name-alist)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
305 (when (string-match (caar file-name-alist) file-name)
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
306 (setq info-lookup-mode (cdar file-name-alist)))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
307 (setq file-name-alist (cdr file-name-alist)))))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
308 (or info-lookup-mode (setq info-lookup-mode major-mode)))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
309
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
310 (defun info-lookup-change-mode (topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
311 (let* ((completions (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
312 (cons (symbol-name (car arg)) (car arg)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
313 (info-lookup->topic-value topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
314 (mode (completing-read
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
315 (format "Use %s help mode: " topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316 completions nil t nil 'info-lookup-history)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317 (or (setq mode (cdr (assoc mode completions)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
318 (error "No %s help available" topic))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
319 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
320 (error "No %s help available for `%s'" topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
321 (setq info-lookup-mode mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
323 (defun info-lookup (topic item mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
324 "Display the documentation of a help item."
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
325 (or mode (setq mode (info-lookup-select-mode)))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
326 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
327 (error "No %s help available for `%s'" topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
328 (let ((entry (or (assoc (if (info-lookup->ignore-case topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
329 (downcase item) item)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
330 (info-lookup->completions topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
331 (error "Not documented as a %s: %s" topic (or item ""))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
332 (modes (info-lookup->all-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
333 (window (selected-window))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
334 found doc-spec node prefix suffix doc-found)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
335 (if (not info-lookup-other-window-flag)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
336 (info)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
337 (save-window-excursion (info))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
338 (switch-to-buffer-other-window "*info*"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
339 (while (and (not found) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
340 (setq doc-spec (info-lookup->doc-spec topic (car modes)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
341 (while (and (not found) doc-spec)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
342 (setq node (nth 0 (car doc-spec))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
343 prefix (nth 2 (car doc-spec))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
344 suffix (nth 3 (car doc-spec)))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
345 (when (condition-case error-data
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
346 (progn
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
347 (Info-goto-node node)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
348 (setq doc-found t))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
349 (error
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
350 (message "Cannot access Info node %s" node)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
351 (sit-for 1)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
352 nil))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
353 (condition-case nil
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
354 (progn
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
355 (Info-menu (or (cdr entry) item))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
356 (setq found t)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
357 (if (or prefix suffix)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
358 (let ((case-fold-search
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
359 (info-lookup->ignore-case topic (car modes)))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
360 (buffer-read-only nil))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
361 (goto-char (point-min))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
362 (re-search-forward
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
363 (concat prefix (regexp-quote item) suffix))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
364 (goto-char (match-beginning 0))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
365 (and window-system info-lookup-highlight-face
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
366 ;; Search again for ITEM so that the first
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
367 ;; occurence of ITEM will be highlighted.
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
368 (re-search-forward (regexp-quote item))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
369 (let ((start (match-beginning 0))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
370 (end (match-end 0)))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
371 (if (overlayp info-lookup-highlight-overlay)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
372 (move-overlay info-lookup-highlight-overlay
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
373 start end (current-buffer))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
374 (setq info-lookup-highlight-overlay
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
375 (make-overlay start end))))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
376 (overlay-put info-lookup-highlight-overlay
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
377 'face info-lookup-highlight-face)))))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
378 (error nil)))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
379 (setq doc-spec (cdr doc-spec)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
380 (setq modes (cdr modes)))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
381 (or doc-found
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
382 (error "Info documentation for lookup was not found"))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
383 ;; Don't leave the Info buffer if the help item couldn't be looked up.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
384 (if (and info-lookup-other-window-flag found)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
385 (select-window window))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
386
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
387 (defun info-lookup-setup-mode (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
388 "Initialize the internal data structure."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
389 (or (info-lookup->initialized topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
390 (let (cell data (initialized 0) completions refer-modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
391 (if (not (info-lookup->mode-value topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
392 (message "No %s help available for `%s'" topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
393 ;; Recursively setup cross references.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
394 ;; But refer only to non-void modes.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
395 (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
396 (or (info-lookup->initialized topic arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
397 (info-lookup-setup-mode topic arg))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
398 (and (eq (info-lookup->initialized topic arg) t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
399 (setq refer-modes (cons arg refer-modes))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
400 (info-lookup->other-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
401 (setq refer-modes (nreverse refer-modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
402 ;; Build the full completion alist.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
403 (setq completions
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
404 (nconc (info-lookup-make-completions topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
405 (apply 'append
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
406 (mapcar (lambda (arg)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
407 (info-lookup->completions topic arg))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
408 refer-modes))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
409 (setq initialized t))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
410 ;; Update `info-lookup-cache'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
411 (setq cell (info-lookup->mode-cache topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
412 data (list initialized completions refer-modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
413 (if (not cell)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
414 (setcdr (info-lookup->cache topic)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 (cons (cons mode data) (info-lookup->topic-cache topic)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 (setcdr cell data))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 initialized)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 (defun info-lookup-make-completions (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420 "Create a unique alist from all index entries."
20519
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
421 (let ((doc-spec (info-lookup->doc-spec topic mode))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
422 (regexp (concat "^\\(" (info-lookup->regexp topic mode)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
423 "\\)\\([ \t].*\\)?$"))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
424 node trans entry item prefix result doc-found
20519
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
425 (buffer (get-buffer-create " temp-info-look")))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
426 (with-current-buffer buffer
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
427 (Info-mode))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
428 (while doc-spec
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
429 (setq node (nth 0 (car doc-spec))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
430 trans (cond ((eq (nth 1 (car doc-spec)) nil)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
431 (lambda (arg)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
432 (if (string-match regexp arg)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
433 (match-string 1 arg))))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
434 ((stringp (nth 1 (car doc-spec)))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
435 (setq prefix (nth 1 (car doc-spec)))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
436 (lambda (arg)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
437 (if (string-match "^\\([^: \t\n]+\\)" arg)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
438 (concat prefix (match-string 1 arg)))))
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
439 (t (nth 1 (car doc-spec)))))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
440 (with-current-buffer buffer
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
441 (message "Processing Info node `%s'..." node)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
442 (when (condition-case error-data
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
443 (progn
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
444 (Info-goto-node node)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
445 (setq doc-found t))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
446 (error
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
447 (message "Cannot access Info node `%s'" node)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
448 (sit-for 1)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
449 nil))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
450 (condition-case nil
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
451 (progn
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
452 (goto-char (point-min))
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
453 (and (search-forward "\n* Menu:" nil t)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
454 (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
455 (setq entry (match-string 1)
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
456 item (funcall trans entry))
23365
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
457 ;; `trans' can return nil if the regexp doesn't match.
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
458 (when (and item
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
459 ;; Sometimes there's more than one Menu:
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
460 (not (string= entry "Menu")))
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
461 (and (info-lookup->ignore-case topic mode)
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
462 (setq item (downcase item)))
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
463 (and (string-equal entry item)
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
464 (setq entry nil))
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
465 (and (or (assoc item result)
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
466 (setq result (cons (cons item entry)
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
467 result))))))))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
468 (error nil))))
20519
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
469 (message "Processing Info node `%s'...done" node)
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
470 (setq doc-spec (cdr doc-spec)))
20690
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
471 (or doc-found
a51c71dd5cda (info-lookup): Report if Info-goto-node fails.
Richard M. Stallman <rms@gnu.org>
parents: 20519
diff changeset
472 (error "Info documentation for lookup was not found"))
20519
c7b3ef0ed1ad (info-lookup-symbol-alist): Handle Emacs Lisp mode.
Richard M. Stallman <rms@gnu.org>
parents: 18323
diff changeset
473 result))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
474
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
475 (defun info-lookup-guess-default (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
476 "Pick up default item at point (with favor to look back).
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
477 Return nil if there is nothing appropriate."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
478 (let ((modes (info-lookup->all-modes topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
479 (start (point)) guess whitespace)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
480 (while (and (not guess) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
481 (setq guess (info-lookup-guess-default* topic (car modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
482 modes (cdr modes))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
483 (goto-char start))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
484 ;; Collapse whitespace characters.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
485 (and guess (concat (delete nil (mapcar (lambda (ch)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
486 (if (or (char-equal ch ? )
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
487 (char-equal ch ?\t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
488 (char-equal ch ?\n))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
489 (if (not whitespace)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
490 (setq whitespace ? ))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
491 (setq whitespace nil) ch))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
492 guess))))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
493
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
494 (defun info-lookup-guess-default* (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
495 (let ((case-fold-search (info-lookup->ignore-case topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
496 (rule (or (info-lookup->parse-rule topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
497 (info-lookup->regexp topic mode)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
498 (start (point)) end regexp subexp result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
499 (if (symbolp rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
500 (setq result (funcall rule))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
501 (if (consp rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
502 (setq regexp (car rule)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
503 subexp (cdr rule))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
504 (setq regexp rule
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
505 subexp 0))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
506 (skip-chars-backward " \t\n") (setq end (point))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
507 (while (and (re-search-backward regexp nil t)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
508 (looking-at regexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
509 (>= (match-end 0) end))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
510 (setq result (match-string subexp)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
511 (if (not result)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
512 (progn
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
513 (goto-char start)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
514 (skip-chars-forward " \t\n")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
515 (and (looking-at regexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
516 (setq result (match-string subexp))))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
517 result))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
518
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
519 (defun info-lookup-guess-c-symbol ()
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
520 "Get the C symbol at point."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
521 (condition-case nil
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
522 (progn
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
523 (backward-sexp)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
524 (let ((start (point)) prefix name)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
525 ;; Test for a leading `struct', `union', or `enum' keyword
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
526 ;; but ignore names like `foo_struct'.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
527 (setq prefix (and (< (skip-chars-backward " \t\n") 0)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
528 (< (skip-chars-backward "_a-zA-Z0-9") 0)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
529 (looking-at "\\(struct\\|union\\|enum\\)\\s ")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
530 (concat (match-string 1) " ")))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
531 (goto-char start)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
532 (and (looking-at "[_a-zA-Z][_a-zA-Z0-9]*")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
533 (setq name (match-string 0)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
534 ;; Caveat! Look forward if point is at `struct' etc.
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
535 (and (not prefix)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
536 (or (string-equal name "struct")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
537 (string-equal name "union")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
538 (string-equal name "enum"))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
539 (looking-at "[a-z]+\\s +\\([_a-zA-Z][_a-zA-Z0-9]*\\)")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
540 (setq prefix (concat name " ")
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
541 name (match-string 1)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
542 (and (or prefix name)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
543 (concat prefix name))))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
544 (error nil)))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
545
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
546 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
547 (defun info-complete-symbol (&optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
548 "Perform completion on symbol preceding point."
18323
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
549 (interactive)
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
550 (info-complete 'symbol
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
551 (or mode
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
552 (if (info-lookup->mode-value
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
553 'symbol (info-lookup-select-mode))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
554 info-lookup-mode
18323
64d728fb396a (info-complete-symbol): If MODE is nil, use the default value.
Richard M. Stallman <rms@gnu.org>
parents: 18322
diff changeset
555 (info-lookup-change-mode 'symbol)))))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
556
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
557 ;;;###autoload
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
558 (defun info-complete-file (&optional mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
559 "Perform completion on file preceding point."
20973
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
560 (interactive)
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
561 (info-complete 'file
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
562 (or mode
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
563 (if (info-lookup->mode-value
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
564 'file (info-lookup-select-mode))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
565 info-lookup-mode
20973
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
566 (info-lookup-change-mode 'file)))))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
567
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
568 (defun info-complete (topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
569 "Try to complete a help item."
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
570 (barf-if-buffer-read-only)
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
571 (or mode (setq mode (info-lookup-select-mode)))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
572 (or (info-lookup->mode-value topic mode)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
573 (error "No %s completion available for `%s'" topic mode))
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
574 (let ((modes (info-lookup-quick-all-modes topic mode))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
575 (start (point))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
576 try)
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
577 (while (and (not try) modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578 (setq mode (car modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
579 modes (cdr modes)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
580 try (info-lookup-guess-default* topic mode))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
581 (goto-char start))
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
582 (and (not try)
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
583 (error "Found no %S to complete" topic))
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
584 (let ((completions (info-lookup->completions topic mode))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
585 (completion-ignore-case (info-lookup->ignore-case topic mode))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
586 completion)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
587 (setq completion (try-completion try completions))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
588 (cond ((not completion)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
589 (ding)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
590 (message "No match"))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
591 ((stringp completion)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
592 (or (assoc completion completions)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
593 (setq completion (completing-read
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
594 (format "Complete %S: " topic)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
595 completions nil t completion
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
596 info-lookup-history)))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
597 (delete-region (- start (length try)) start)
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
598 (insert completion))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
599 (t
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
600 (message "%s is complete"
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
601 (capitalize (prin1-to-string topic))))))))
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
602
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
603
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
604 ;;; Initialize some common modes.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
605
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
606 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
607 :mode 'c-mode :topic 'symbol
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
608 :regexp "\\(struct \\|union \\|enum \\)?[_a-zA-Z][_a-zA-Z0-9]*"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
609 :doc-spec '(("(libc)Function Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
610 "^[ \t]+- \\(Function\\|Macro\\): .*\\<" "\\>")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
611 ("(libc)Variable Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
612 "^[ \t]+- \\(Variable\\|Macro\\): .*\\<" "\\>")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
613 ("(libc)Type Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
614 "^[ \t]+- Data Type: \\<" "\\>")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
615 ("(termcap)Var Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
616 "^[ \t]*`" "'"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
617 :parse-rule 'info-lookup-guess-c-symbol)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
618
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
619 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
620 :mode 'c-mode :topic 'file
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
621 :regexp "[_a-zA-Z0-9./+-]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
622 :doc-spec '(("(libc)File Index")))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
623
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
624 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
625 :mode 'bison-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
626 :regexp "[:;|]\\|%\\([%{}]\\|[_a-z]+\\)\\|YY[_A-Z]+\\|yy[_a-z]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
627 :doc-spec '(("(bison)Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
628 "`" "'"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
629 :parse-rule "[:;|]\\|%\\([%{}]\\|[_a-zA-Z][_a-zA-Z0-9]*\\)"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
630 :other-modes '(c-mode))
20899
d1f6ac340403 (info-complete): Display completions on second invocation at same point
Richard M. Stallman <rms@gnu.org>
parents: 20690
diff changeset
631
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
632 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
633 :mode 'makefile-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
634 :regexp "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z][_a-zA-Z0-9-]*"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
635 :doc-spec '(("(make)Name Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
636 "^[ \t]*`" "'"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
637 :parse-rule "\\$[^({]\\|\\.[_A-Z]*\\|[_a-zA-Z0-9-]+")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
638
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
639 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
640 :mode 'texinfo-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
641 :regexp "@\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
642 :doc-spec '(("(texinfo)Command and Variable Index"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
643 ;; Ignore Emacs commands and prepend a `@'.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
644 (lambda (item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
645 (if (string-match "^\\([a-zA-Z]+\\|[^a-zA-Z]\\)\\( .*\\)?$" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
646 (concat "@" (match-string 1 item))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
647 "`" "'")))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
648
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
649 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
650 :mode 'm4-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
651 :regexp "[_a-zA-Z][_a-zA-Z0-9]*"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
652 :doc-spec '(("(m4)Macro index"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
653 :parse-rule "[_a-zA-Z0-9]+")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
654
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
655 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
656 :mode 'autoconf-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
657 :regexp "A[CM]_[_A-Z0-9]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
658 :doc-spec '(("(autoconf)Macro Index" "AC_"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
659 "^[ \t]+- \\(Macro\\|Variable\\): .*\\<" "\\>")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
660 ("(automake)Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
661 "^[ \t]*`" "'"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
662 ;; Autoconf symbols are M4 macros. Thus use M4's parser.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
663 :parse-rule 'ignore
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
664 :other-modes '(m4-mode))
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
666 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
667 :mode 'awk-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
668 :regexp "[_a-zA-Z]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
669 :doc-spec '(("(gawk)Index"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
670 (lambda (item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
671 (let ((case-fold-search nil))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
672 (cond
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
673 ;; `BEGIN' and `END'.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
674 ((string-match "^\\([A-Z]+\\) special pattern\\b" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
675 (match-string 1 item))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
676 ;; `if', `while', `do', ...
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
677 ((string-match "^\\([a-z]+\\) statement\\b" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
678 (if (not (string-equal (match-string 1 item) "control"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
679 (match-string 1 item)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
680 ;; `NR', `NF', ...
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
681 ((string-match "^[A-Z]+$" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
682 item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
683 ;; Built-in functions (matches to many entries).
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
684 ((string-match "^[a-z]+$" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
685 item))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
686 "`" "\\([ \t]*([^)]*)\\)?'")))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
687
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
688 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
689 :mode 'perl-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
690 :regexp "[$@%][^a-zA-Z]\\|\\$\\^[A-Z]\\|[$@%]?[a-zA-Z][_a-zA-Z0-9]*"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
691 :doc-spec '(("(perl5)Function Index"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
692 (lambda (item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
693 (if (string-match "^\\([a-zA-Z0-9]+\\)" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
694 (match-string 1 item)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
695 "^" "\\b")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
696 ("(perl5)Variable Index"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
697 (lambda (item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
698 ;; Work around bad formatted array variables.
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
699 (let ((sym (cond ((or (string-match "^\\$\\(.\\|@@\\)$" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
700 (string-match "^\\$\\^[A-Z]$" item))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
701 item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
702 ((string-match
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
703 "^\\([$%@]\\|@@\\)?[_a-zA-Z0-9]+" item)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
704 (match-string 0 item))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
705 (t ""))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
706 (if (string-match "@@" sym)
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
707 (setq sym (concat (substring sym 0 (match-beginning 0))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
708 (substring sym (1- (match-end 0))))))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
709 (if (string-equal sym "") nil sym)))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
710 "^" "\\b"))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
711 :parse-rule "[$@%]?\\([_a-zA-Z0-9]+\\|[^a-zA-Z]\\)")
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
712
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
713 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
714 :mode 'latex-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
715 :regexp "\\\\\\([a-zA-Z]+\\|[^a-zA-Z]\\)"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
716 :doc-spec '(("(latex2e)Command Index" nil
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
717 "`" "\\({[^}]*}\\)?'")))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
718
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
719 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
720 :mode 'emacs-lisp-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
721 :regexp "[^()' \t\n]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
722 :doc-spec '(("(emacs)Command Index")
20973
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
723 ("(emacs)Variable Index")
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
724 ("(elisp)Index"
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
725 (lambda (item)
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
726 (let ((sym (intern-soft item)))
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
727 (cond ((null sym)
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
728 (if (string-equal item "nil") item))
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
729 ((or (boundp sym) (fboundp sym))
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
730 item))))
b7e7f7c9685a Added support for the Emacs Lisp manual.
Karl Heuer <kwzh@gnu.org>
parents: 20909
diff changeset
731 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
732
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
733 (info-lookup-maybe-add-help
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
734 :mode 'lisp-interaction-mode
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
735 :regexp "[^()' \t\n]+"
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
736 :parse-rule 'ignore
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
737 :other-modes '(emacs-lisp-mode))
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
738
21334
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
739 (info-lookup-maybe-add-help
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
740 :mode 'lisp-mode
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
741 :regexp "[^()' \t\n]+"
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
742 :parse-rule 'ignore
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
743 :other-modes '(emacs-lisp-mode))
66b3b9fe3e3c (info-lookup->topic-cache): Use defun, not defsubst.
Richard M. Stallman <rms@gnu.org>
parents: 20973
diff changeset
744
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
745 (info-lookup-maybe-add-help
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
746 :mode 'scheme-mode
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
747 :regexp "[^()' \t\n]+"
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
748 :ignore-case t
23365
d400637428d1 Remove duplicate scheme-mode entry.
Dave Love <fx@gnu.org>
parents: 23346
diff changeset
749 ;; Aubrey Jaffer's rendition from <URL:ftp://ftp-swiss.ai.mit.edu/pub/scm>
22281
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
750 :doc-spec '(("(r5rs)Index" nil
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
751 "^[ \t]+- [^:]+:[ \t]*" "\\b")))
fa2cf768a61a Added support for Scheme.
Karl Heuer <kwzh@gnu.org>
parents: 22266
diff changeset
752
23346
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
753 (info-lookup-maybe-add-help
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
754 :mode 'octave-mode
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
755 :regexp "[_a-zA-Z0-9]+"
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
756 :doc-spec '(("(octave)Function Index" nil "^ - [^:]+:[ ]+" nil)
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
757 ("(octave)Variable Index" nil "^ - [^:]+:[ ]+" nil)
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
758 ;; Catch lines of the form "xyz statement"
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
759 ("(octave)Concept Index"
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
760 (lambda (item)
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
761 (cond
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
762 ((string-match "^\\([A-Z]+\\) statement\\b" item)
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
763 (match-string 1 item))
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
764 (t nil)))
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
765 nil; "^ - [^:]+:[ ]+" don't think this prefix is useful here.
4db659df7407 Add support for Octave.
Stephen Eglen <stephen@gnu.org>
parents: 22281
diff changeset
766 nil)))
20909
542ae65815fb (info-complete): Rewrite minibuffer completion code.
Richard M. Stallman <rms@gnu.org>
parents: 20899
diff changeset
767
18322
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (provide 'info-look)
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769
02f932c91db2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 ;;; info-look.el ends here