diff options
| author | Karl Heuer | 1998-07-10 16:46:59 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-07-10 16:46:59 +0000 |
| commit | 96ee3f292f61eb8448c9b6a5a25c1b50be55340f (patch) | |
| tree | fc9507860339fefa1e3d453ace32bf8ceb5f21b8 | |
| parent | b04fa5c5a016e8aaef5ebb50b6278210785b28d1 (diff) | |
| download | emacs-96ee3f292f61eb8448c9b6a5a25c1b50be55340f.tar.gz emacs-96ee3f292f61eb8448c9b6a5a25c1b50be55340f.zip | |
No longer depends on speedbspec for byte compile.
(Info-speedbar-key-map) New key map.
(Info-install-speedbar-variables) New function.
(Info-speedbar-menu-items) Update to new functions.
Install speedbar keymap only when speedbar is loaded.
(Info-speedbar-browser) New command.
(Info-speedbar-hierarchy-buttons, Info-speedbar-goto-node,
Info-speedbar-expand-node, Info-speedbar-fetch-file-nodes) New function
(Info-speedbar-buttons) Handle new node button commands.
| -rw-r--r-- | lisp/info.el | 227 |
1 files changed, 162 insertions, 65 deletions
diff --git a/lisp/info.el b/lisp/info.el index 8338401fe80..ff0aa9d73d0 100644 --- a/lisp/info.el +++ b/lisp/info.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; info.el --- info package for Emacs. | 1 | ;;; info.el --- info package for Emacs. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97 Free Software | 3 | ;; Copyright (C) 1985, 86, 92, 93, 94, 95, 96, 97, 98 Free Software |
| 4 | ;; Foundation, Inc. | 4 | ;; Foundation, Inc. |
| 5 | 5 | ||
| 6 | ;; Maintainer: FSF | 6 | ;; Maintainer: FSF |
| @@ -2119,79 +2119,176 @@ The alist key is the character the title is underlined with (?*, ?= or ?-)." | |||
| 2119 | ;;; Speedbar support: | 2119 | ;;; Speedbar support: |
| 2120 | ;; These functions permit speedbar to display the "tags" in the | 2120 | ;; These functions permit speedbar to display the "tags" in the |
| 2121 | ;; current info node. | 2121 | ;; current info node. |
| 2122 | (eval-when-compile (require 'speedbar)) | ||
| 2122 | 2123 | ||
| 2123 | (eval-when-compile (require 'speedbspec)) | 2124 | (defvar Info-speedbar-key-map nil |
| 2125 | "Keymap used when in the info display mode.") | ||
| 2124 | 2126 | ||
| 2125 | (defvar Info-last-speedbar-node nil | 2127 | (defun Info-install-speedbar-variables () |
| 2126 | "Last node viewed with speedbar in the form '(NODE FILE).") | 2128 | "Install those variables used by speedbar to enhance Info." |
| 2129 | (if Info-speedbar-key-map | ||
| 2130 | nil | ||
| 2131 | (setq Info-speedbar-key-map (speedbar-make-specialized-keymap)) | ||
| 2132 | |||
| 2133 | ;; Basic tree features | ||
| 2134 | (define-key Info-speedbar-key-map "e" 'speedbar-edit-line) | ||
| 2135 | (define-key Info-speedbar-key-map "\C-m" 'speedbar-edit-line) | ||
| 2136 | (define-key Info-speedbar-key-map "+" 'speedbar-expand-line) | ||
| 2137 | (define-key Info-speedbar-key-map "-" 'speedbar-contract-line) | ||
| 2138 | ) | ||
| 2139 | |||
| 2140 | (speedbar-add-expansion-list '("Info" Info-speedbar-menu-items | ||
| 2141 | Info-speedbar-key-map | ||
| 2142 | Info-speedbar-hierarchy-buttons))) | ||
| 2127 | 2143 | ||
| 2128 | (defvar Info-speedbar-menu-items | 2144 | (defvar Info-speedbar-menu-items |
| 2129 | '(["Browse Item On Line" speedbar-edit-line t]) | 2145 | '(["Browse Node" speedbar-edit-line t] |
| 2146 | ["Expand Node" speedbar-expand-line | ||
| 2147 | (save-excursion (beginning-of-line) | ||
| 2148 | (looking-at "[0-9]+: *.\\+. "))] | ||
| 2149 | ["Contract Node" speedbar-contract-line | ||
| 2150 | (save-excursion (beginning-of-line) | ||
| 2151 | (looking-at "[0-9]+: *.-. "))] | ||
| 2152 | ) | ||
| 2130 | "Additional menu-items to add to speedbar frame.") | 2153 | "Additional menu-items to add to speedbar frame.") |
| 2131 | 2154 | ||
| 2155 | ;; Make sure our special speedbar major mode is loaded | ||
| 2156 | (if (featurep 'speedbar) | ||
| 2157 | (Info-install-speedbar-variables) | ||
| 2158 | (add-hook 'speedbar-load-hook 'Info-install-speedbar-variables)) | ||
| 2159 | |||
| 2160 | ;;; Info hierarchy display method | ||
| 2161 | ;;;###autoload | ||
| 2162 | (defun Info-speedbar-browser () | ||
| 2163 | "Initialize speedbar to display an info node browser. | ||
| 2164 | This will add a speedbar major display mode." | ||
| 2165 | (interactive) | ||
| 2166 | (require 'speedbar) | ||
| 2167 | ;; Make sure that speedbar is active | ||
| 2168 | (speedbar-frame-mode 1) | ||
| 2169 | ;; Now, throw us into Info mode on speedbar. | ||
| 2170 | (speedbar-change-initial-expansion-list "Info") | ||
| 2171 | ) | ||
| 2172 | |||
| 2173 | (defun Info-speedbar-hierarchy-buttons (directory depth &optional node) | ||
| 2174 | "Display an Info directory hierarchy in speedbar. | ||
| 2175 | DIRECTORY is the current directory in the attached frame. | ||
| 2176 | DEPTH is the current indentation depth. | ||
| 2177 | NODE is an optional argument that is used to represent the | ||
| 2178 | specific node to expand." | ||
| 2179 | (if (and (not node) | ||
| 2180 | (save-excursion (goto-char (point-min)) | ||
| 2181 | (looking-at "Info Nodes:"))) | ||
| 2182 | ;; Update our "current node" maybe? | ||
| 2183 | nil | ||
| 2184 | ;; We cannot use the generic list code, that depends on all leaves | ||
| 2185 | ;; being known at creation time. | ||
| 2186 | (if (not node) | ||
| 2187 | (speedbar-with-writable (insert "Info Nodes:\n"))) | ||
| 2188 | (let ((completions nil)) | ||
| 2189 | (setq completions | ||
| 2190 | (Info-speedbar-fetch-file-nodes (or node '"(dir)top"))) | ||
| 2191 | (if completions | ||
| 2192 | (speedbar-with-writable | ||
| 2193 | (while completions | ||
| 2194 | (speedbar-make-tag-line 'bracket ?+ 'Info-speedbar-expand-node | ||
| 2195 | (cdr (car completions)) | ||
| 2196 | (car (car completions)) | ||
| 2197 | 'Info-speedbar-goto-node | ||
| 2198 | (cdr (car completions)) | ||
| 2199 | 'info-xref depth) | ||
| 2200 | (setq completions (cdr completions))) | ||
| 2201 | t) | ||
| 2202 | nil)))) | ||
| 2203 | |||
| 2204 | (defun Info-speedbar-goto-node (text node indent) | ||
| 2205 | "When user clicks on TEXT, goto an info NODE. | ||
| 2206 | The INDENT level is ignored." | ||
| 2207 | (select-frame speedbar-attached-frame) | ||
| 2208 | (let* ((buff (or (get-buffer "*info*") | ||
| 2209 | (progn (info) (get-buffer "*info*")))) | ||
| 2210 | (bwin (get-buffer-window buff 0))) | ||
| 2211 | (if bwin | ||
| 2212 | (progn | ||
| 2213 | (select-window bwin) | ||
| 2214 | (raise-frame (window-frame bwin))) | ||
| 2215 | (if speedbar-power-click | ||
| 2216 | (let ((pop-up-frames t)) (select-window (display-buffer buff))) | ||
| 2217 | (select-frame speedbar-attached-frame) | ||
| 2218 | (switch-to-buffer buff))) | ||
| 2219 | (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" node)) | ||
| 2220 | (file (match-string 1 node)) | ||
| 2221 | (node (match-string 2 node))) | ||
| 2222 | (Info-find-node file node) | ||
| 2223 | ;; If we do a find-node, and we were in info mode, restore | ||
| 2224 | ;; the old default method. Once we are in info mode, it makes | ||
| 2225 | ;; sense to return to whatever method the user was using before. | ||
| 2226 | (if (string= speedbar-initial-expansion-list-name "Info") | ||
| 2227 | (speedbar-change-initial-expansion-list | ||
| 2228 | speedbar-previously-used-expansion-list-name))))) | ||
| 2229 | |||
| 2230 | (defun Info-speedbar-expand-node (text token indent) | ||
| 2231 | "Expand the node the user clicked on. | ||
| 2232 | TEXT is the text of the button we clicked on, a + or - item. | ||
| 2233 | TOKEN is data related to this node (NAME . FILE). | ||
| 2234 | INDENT is the current indentation depth." | ||
| 2235 | (cond ((string-match "+" text) ;we have to expand this file | ||
| 2236 | (speedbar-change-expand-button-char ?-) | ||
| 2237 | (if (speedbar-with-writable | ||
| 2238 | (save-excursion | ||
| 2239 | (end-of-line) (forward-char 1) | ||
| 2240 | (Info-speedbar-hierarchy-buttons nil (1+ indent) token))) | ||
| 2241 | (speedbar-change-expand-button-char ?-) | ||
| 2242 | (speedbar-change-expand-button-char ??))) | ||
| 2243 | ((string-match "-" text) ;we have to contract this node | ||
| 2244 | (speedbar-change-expand-button-char ?+) | ||
| 2245 | (speedbar-delete-subblock indent)) | ||
| 2246 | (t (error "Ooops... not sure what to do"))) | ||
| 2247 | (speedbar-center-buffer-smartly)) | ||
| 2248 | |||
| 2249 | (defun Info-speedbar-fetch-file-nodes (nodespec) | ||
| 2250 | "Fetch the subnodes from the info NODESPEC. | ||
| 2251 | NODESPEC is a string of the form: (file)node. | ||
| 2252 | Optional THISFILE represends the filename of" | ||
| 2253 | (save-excursion | ||
| 2254 | ;; Set up a buffer we can use to fake-out Info. | ||
| 2255 | (set-buffer (get-buffer-create "*info-browse-tmp*")) | ||
| 2256 | (if (not (equal major-mode 'Info-mode)) | ||
| 2257 | (Info-mode)) | ||
| 2258 | ;; Get the node into this buffer | ||
| 2259 | (let ((junk (string-match "^(\\([^)]+\\))\\([^.]+\\)$" nodespec)) | ||
| 2260 | (file (match-string 1 nodespec)) | ||
| 2261 | (node (match-string 2 nodespec))) | ||
| 2262 | (Info-find-node file node)) | ||
| 2263 | ;; Scan the created buffer | ||
| 2264 | (goto-char (point-min)) | ||
| 2265 | (let ((completions nil) | ||
| 2266 | (thisfile (progn (string-match "^(\\([^)]+\\))" nodespec) | ||
| 2267 | (match-string 1 nodespec)))) | ||
| 2268 | ;; Always skip the first one... | ||
| 2269 | (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) | ||
| 2270 | (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) | ||
| 2271 | (let ((name (match-string 1))) | ||
| 2272 | (if (looking-at " *\\(([^)]+)[^.\n]+\\)\\.") | ||
| 2273 | (setq name (cons name (match-string 1))) | ||
| 2274 | (if (looking-at " *\\(([^)]+)\\)\\.") | ||
| 2275 | (setq name (cons name (concat (match-string 1) "Top"))) | ||
| 2276 | (if (looking-at " \\([^.]+\\).") | ||
| 2277 | (setq name | ||
| 2278 | (cons name (concat "(" thisfile ")" (match-string 1)))) | ||
| 2279 | (setq name (cons name (concat "(" thisfile ")" name)))))) | ||
| 2280 | (setq completions (cons name completions)))) | ||
| 2281 | (nreverse completions)))) | ||
| 2282 | |||
| 2283 | ;;; Info mode node listing | ||
| 2132 | (defun Info-speedbar-buttons (buffer) | 2284 | (defun Info-speedbar-buttons (buffer) |
| 2133 | "Create a speedbar display to help navigation in an Info file. | 2285 | "Create a speedbar display to help navigation in an Info file. |
| 2134 | BUFFER is the buffer speedbar is requesting buttons for." | 2286 | BUFFER is the buffer speedbar is requesting buttons for." |
| 2135 | (goto-char (point-min)) | 2287 | (if (save-excursion (goto-char (point-min)) |
| 2136 | (if (and (looking-at "<Directory>") | 2288 | (not (looking-at "Info Nodes:"))) |
| 2137 | (save-excursion | 2289 | (erase-buffer)) |
| 2138 | (set-buffer buffer) | 2290 | (Info-speedbar-hierarchy-buttons nil 0) |
| 2139 | (and (equal (car Info-last-speedbar-node) Info-current-node) | 2291 | ) |
| 2140 | (equal (cdr Info-last-speedbar-node) Info-current-file)))) | ||
| 2141 | nil | ||
| 2142 | (erase-buffer) | ||
| 2143 | (speedbar-insert-button "<Directory>" 'info-xref 'highlight | ||
| 2144 | 'Info-speedbar-button | ||
| 2145 | 'Info-directory) | ||
| 2146 | (speedbar-insert-button "<Top>" 'info-xref 'highlight | ||
| 2147 | 'Info-speedbar-button | ||
| 2148 | 'Info-top-node) | ||
| 2149 | (speedbar-insert-button "<Last>" 'info-xref 'highlight | ||
| 2150 | 'Info-speedbar-button | ||
| 2151 | 'Info-last) | ||
| 2152 | (speedbar-insert-button "<Up>" 'info-xref 'highlight | ||
| 2153 | 'Info-speedbar-button | ||
| 2154 | 'Info-up) | ||
| 2155 | (speedbar-insert-button "<Next>" 'info-xref 'highlight | ||
| 2156 | 'Info-speedbar-button | ||
| 2157 | 'Info-next) | ||
| 2158 | (speedbar-insert-button "<Prev>" 'info-xref 'highlight | ||
| 2159 | 'Info-speedbar-button | ||
| 2160 | 'Info-prev) | ||
| 2161 | (let ((completions nil)) | ||
| 2162 | (save-excursion | ||
| 2163 | (set-buffer buffer) | ||
| 2164 | (setq Info-last-speedbar-node | ||
| 2165 | (cons Info-current-node Info-current-file)) | ||
| 2166 | (goto-char (point-min)) | ||
| 2167 | ;; Always skip the first one... | ||
| 2168 | (re-search-forward "\n\\* +\\([^:\t\n]*\\):" nil t) | ||
| 2169 | (while (re-search-forward "\n\\* +\\([^:\t\n]*\\):" nil t) | ||
| 2170 | (setq completions (cons (buffer-substring (match-beginning 1) | ||
| 2171 | (match-end 1)) | ||
| 2172 | completions)))) | ||
| 2173 | (setq completions (nreverse completions)) | ||
| 2174 | (while completions | ||
| 2175 | (speedbar-make-tag-line nil nil nil nil | ||
| 2176 | (car completions) 'Info-speedbar-menu | ||
| 2177 | nil 'info-node 0) | ||
| 2178 | (setq completions (cdr completions)))))) | ||
| 2179 | |||
| 2180 | (defun Info-speedbar-button (text token indent) | ||
| 2181 | "Called when user clicks <Directory> from speedbar. | ||
| 2182 | TEXT, TOKEN, and INDENT are unused." | ||
| 2183 | (speedbar-with-attached-buffer | ||
| 2184 | (funcall token) | ||
| 2185 | (setq Info-last-speedbar-node nil) | ||
| 2186 | (speedbar-update-contents))) | ||
| 2187 | |||
| 2188 | (defun Info-speedbar-menu (text token indent) | ||
| 2189 | "Goto the menu node specified in TEXT. | ||
| 2190 | TOKEN and INDENT are not used." | ||
| 2191 | (speedbar-with-attached-buffer | ||
| 2192 | (Info-menu text) | ||
| 2193 | (setq Info-last-speedbar-node nil) | ||
| 2194 | (speedbar-update-contents))) | ||
| 2195 | 2292 | ||
| 2196 | (provide 'info) | 2293 | (provide 'info) |
| 2197 | 2294 | ||