Mercurial > emacs
annotate lisp/speedbar.el @ 24449:2428731823fd
(bdf-directory-list): Different value for ms-dos.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sun, 07 Mar 1999 13:31:58 +0000 |
parents | 0e5b7bb19ddc |
children | 1e20dcb26ff7 |
rev | line source |
---|---|
22735 | 1 ;;; speedbar --- quick access to files and tags in a frame |
21650 | 2 |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3 ;;; Copyright (C) 1996, 97, 98, 99 Free Software Foundation |
22735 | 4 |
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
6 ;; Version: 0.8.1 |
22735 | 7 ;; Keywords: file, tags, tools |
24321
0e5b7bb19ddc
(speedbar-item-info-tag-helper): Scan the whole line.
Richard M. Stallman <rms@gnu.org>
parents:
24232
diff
changeset
|
8 ;; X-RCS: $Id: speedbar.el,v 1.20 1999/01/31 04:39:37 rms Exp rms $ |
22735 | 9 |
21650 | 10 ;; This file is part of GNU Emacs. |
22735 | 11 |
21650 | 12 ;; GNU Emacs is free software; you can redistribute it and/or modify |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
22735 | 16 |
21650 | 17 ;; GNU Emacs is distributed in the hope that it will be useful, |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
22735 | 21 |
21650 | 22 ;; You should have received a copy of the GNU General Public License |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
25 ;; Boston, MA 02111-1307, USA. | |
26 | |
27 ;;; Commentary: | |
28 ;; | |
29 ;; The speedbar provides a frame in which files, and locations in | |
30 ;; files are displayed. These items can be clicked on with mouse-2 | |
31 ;; in order to make the last active frame display that file location. | |
32 ;; | |
33 ;; Starting Speedbar: | |
34 ;; | |
35 ;; If speedbar came to you as a part of Emacs, simply type | |
22735 | 36 ;; `M-x speedbar', and it will be autoloaded for you. |
21650 | 37 ;; |
38 ;; If speedbar is not a part of your distribution, then add | |
39 ;; this to your .emacs file: | |
40 ;; | |
41 ;; (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t) | |
42 ;; (autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t) | |
43 ;; | |
22735 | 44 ;; If you want to choose it from a menu, such as "Tools", you can do this: |
21650 | 45 ;; |
46 ;; Emacs: | |
47 ;; (define-key-after (lookup-key global-map [menu-bar tools]) | |
48 ;; [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar]) | |
49 ;; | |
50 ;; XEmacs: | |
51 ;; (add-menu-button '("Tools") | |
52 ;; ["Speedbar" speedbar-frame-mode | |
53 ;; :style toggle | |
54 ;; :selected (and (boundp 'speedbar-frame) | |
55 ;; (frame-live-p speedbar-frame) | |
56 ;; (frame-visible-p speedbar-frame))] | |
57 ;; "--") | |
58 ;; | |
59 ;; If you want to access speedbar using only the keyboard, do this: | |
60 ;; | |
61 ;; (global-set-key [(f4)] 'speedbar-get-focus) | |
62 ;; | |
63 ;; This will let you hit f4 (or whatever key you choose) to jump | |
64 ;; focus to the speedbar frame. Pressing it again will bring you back | |
65 ;; to the attached frame. Pressing RET or e to jump to a file | |
66 ;; or tag will move you back to the attached frame. The command | |
67 ;; `speedbar-get-focus' will also create a speedbar frame if it does | |
68 ;; not exist. | |
69 ;; | |
70 ;; Customizing Speedbar: | |
71 ;; | |
72 ;; Once a speedbar frame is active, it takes advantage of idle time | |
73 ;; to keep its contents updated. The contents is usually a list of | |
74 ;; files in the directory of the currently active buffer. When | |
75 ;; applicable, tags in the active file can be expanded. | |
76 ;; | |
77 ;; To add new supported files types into speedbar, use the function | |
78 ;; `speedbar-add-supported-extension' If speedbar complains that the | |
79 ;; file type is not supported, that means there is no built in | |
80 ;; support from imenu, and the etags part wasn't set up correctly. You | |
81 ;; may add elements to `speedbar-supported-extension-expressions' as long | |
82 ;; as it is done before speedbar is loaded. | |
83 ;; | |
84 ;; To prevent speedbar from following you into certain directories | |
85 ;; use the function `speedbar-add-ignored-path-regexp' too add a new | |
86 ;; regular expression matching a type of path. You may add list | |
87 ;; elements to `speedbar-ignored-path-expressions' as long as it is | |
88 ;; done before speedbar is loaded. | |
89 ;; | |
90 ;; To add new file types to imenu, see the documentation in the | |
22735 | 91 ;; file imenu.el that comes with Emacs. To add new file types which |
21650 | 92 ;; etags supports, you need to modify the variable |
93 ;; `speedbar-fetch-etags-parse-list'. | |
94 ;; | |
95 ;; If the updates are going too slow for you, modify the variable | |
96 ;; `speedbar-update-speed' to a longer idle time before updates. | |
97 ;; | |
98 ;; If you navigate directories, you will probably notice that you | |
99 ;; will navigate to a directory which is eventually replaced after | |
100 ;; you go back to editing a file (unless you pull up a new file.) | |
101 ;; The delay time before this happens is in | |
102 ;; `speedbar-navigating-speed', and defaults to 10 seconds. | |
103 ;; | |
22735 | 104 ;; To enable mouse tracking with information in the minibuffer of |
105 ;; the attached frame, use the variable `speedbar-track-mouse-flag'. | |
106 ;; | |
107 ;; Tag layout can be modified through `speedbar-tag-hierarchy-method', | |
108 ;; which controls how tags are layed out. It is actually a list of | |
109 ;; functions that filter the data. The default groups large tag lists | |
110 ;; into sub-lists. A long flat list can be used instead if needed. | |
111 ;; Other filters could be easily added. | |
112 ;; | |
113 ;; Users of XEmacs previous to 20 may want to change the default | |
21650 | 114 ;; timeouts for `speedbar-update-speed' to something longer as XEmacs |
115 ;; doesn't have idle timers, the speedbar timer keeps going off | |
116 ;; arbitrarily while you're typing. It's quite pesky. | |
117 ;; | |
118 ;; Users of really old emacsen without the needed timers will not | |
119 ;; have speedbar updating automatically. Use "r" to refresh the | |
120 ;; display after changing directories. Remember, do not interrupt the | |
121 ;; stealthy updates or your display may not be completely refreshed. | |
122 ;; | |
123 ;; AUC-TEX users: The imenu tags for AUC-TEX mode don't work very | |
124 ;; well. Use the imenu keywords from tex-mode.el for better results. | |
125 ;; | |
126 ;; This file requires the library package assoc (association lists) | |
127 ;; and the package custom (for easy configuration of speedbar) | |
128 ;; http://www.dina.kvl.dk/~abraham/custom/ | |
129 ;; | |
22735 | 130 ;;; Developing for speedbar |
131 ;; | |
132 ;; Adding a speedbar specialized display mode: | |
133 ;; | |
134 ;; Speedbar can be configured to create a special display for certain | |
135 ;; modes that do not display tradition file/tag data. Rmail, Info, | |
136 ;; and the debugger are examples. These modes can, however, benefit | |
137 ;; from a speedbar style display in their own way. | |
21650 | 138 ;; |
22735 | 139 ;; If your `major-mode' is `foo-mode', the only requirement is to |
140 ;; create a function called `foo-speedbar-buttons' which takes one | |
141 ;; argument, BUFFER. BUFFER will be the buffer speedbar wants filled. | |
142 ;; In `foo-speedbar-buttons' there are several functions that make | |
143 ;; building a speedbar display easy. See the documentation for | |
144 ;; `speedbar-with-writable' (needed because the buffer is usually | |
145 ;; read-only) `speedbar-make-tag-line', `speedbar-insert-button', and | |
146 ;; `speedbar-insert-generic-list'. If you use | |
147 ;; `speedbar-insert-generic-list', also read the doc for | |
148 ;; `speedbar-tag-hierarchy-method' in case you wish to override it. | |
149 ;; The function `speedbar-with-attached-buffer' brings you back to the | |
150 ;; buffer speedbar is displaying for. | |
21650 | 151 ;; |
22735 | 152 ;; For those functions that make buttons, the "function" should be a |
153 ;; symbol that is the function to call when clicked on. The "token" | |
154 ;; is extra data you can pass along. The "function" must take three | |
155 ;; parameters. They are (TEXT TOKEN INDENT). TEXT is the text of the | |
156 ;; button clicked on. TOKEN is the data passed in when you create the | |
157 ;; button. INDENT is an indentation level, or 0. You can store | |
158 ;; indentation levels with `speedbar-make-tag-line' which creates a | |
159 ;; line with an expander (eg. [+]) and a text button. | |
160 ;; | |
161 ;; Some useful functions when writing expand functions, and click | |
162 ;; functions are `speedbar-change-expand-button-char', | |
163 ;; `speedbar-delete-subblock', and `speedbar-center-buffer-smartly'. | |
164 ;; The variable `speedbar-power-click' is set to t in your functions | |
165 ;; when the user shift-clicks. This indications anything from | |
166 ;; refreshing cached data to making a buffer appear in a new frame. | |
167 ;; | |
168 ;; If you wish to add to the default speedbar menu for the case of | |
169 ;; `foo-mode', create a variable `foo-speedbar-menu-items'. This | |
170 ;; should be a list compatible with the `easymenu' package. It will | |
171 ;; be spliced into the main menu. (Available with click-mouse-3). If | |
172 ;; you wish to have extra key bindings in your special mode, create a | |
173 ;; variable `foo-speedbar-key-map'. Instead of using `make-keymap', | |
174 ;; or `make-sparse-keymap', use the function | |
175 ;; `speedbar-make-specialized-keymap'. This lets you inherit all of | |
176 ;; speedbar's default bindings with low overhead. | |
177 ;; | |
178 ;; Adding a speedbar top-level display mode: | |
179 ;; | |
180 ;; Unlike the specialized modes, there are no name requirements, | |
181 ;; however the methods for writing a button display, menu, and keymap | |
182 ;; are the same. Once you create these items, you can call the | |
183 ;; function `speedbar-add-expansion-list'. It takes one parameter | |
184 ;; which is a list element of the form (NAME MENU KEYMAP &rest | |
185 ;; BUTTON-FUNCTIONS). NAME is a string that will show up in the | |
186 ;; Displays menu item. MENU is a symbol containing the menu items to | |
187 ;; splice in. KEYMAP is a symbol holding the keymap to use, and | |
188 ;; BUTTON-FUNCTIONS are the function names to call, in order, to create | |
189 ;; the display. | |
21650 | 190 |
191 ;;; TODO: | |
192 ;; - More functions to create buttons and options | |
193 ;; - Timeout directories we haven't visited in a while. | |
194 ;; - Remeber tags when refreshing the display. (Refresh tags too?) | |
195 ;; - More 'special mode support. | |
196 | |
197 (require 'assoc) | |
198 (require 'easymenu) | |
199 | |
22735 | 200 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version) |
201 "Non-nil if we are running in the XEmacs environment.") | |
202 (defvar speedbar-xemacs20p (and speedbar-xemacsp | |
203 (= emacs-major-version 20))) | |
204 | |
21650 | 205 ;; From custom web page for compatibility between versions of custom: |
206 (eval-and-compile | |
207 (condition-case () | |
208 (require 'custom) | |
209 (error nil)) | |
22735 | 210 (if (and (featurep 'custom) (fboundp 'custom-declare-variable) |
211 ;; Some XEmacsen w/ custom don't have :set keyword. | |
212 ;; This protects them against custom. | |
213 (fboundp 'custom-initialize-set)) | |
21650 | 214 nil ;; We've got what we needed |
215 ;; We have the old custom-library, hack around it! | |
216 (defmacro defgroup (&rest args) | |
217 nil) | |
218 (defmacro defface (var values doc &rest args) | |
219 (` (progn | |
220 (defvar (, var) (quote (, var))) | |
221 ;; To make colors for your faces you need to set your .Xdefaults | |
222 ;; or set them up ahead of time in your .emacs file. | |
223 (make-face (, var)) | |
224 ))) | |
225 (defmacro defcustom (var value doc &rest args) | |
226 (` (defvar (, var) (, value) (, doc)))))) | |
227 | |
228 ;; customization stuff | |
229 (defgroup speedbar nil | |
230 "File and tag browser frame." | |
231 :group 'tags | |
21658
d8a81542dbf9
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21650
diff
changeset
|
232 :group 'tools |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21658
diff
changeset
|
233 :group 'convenience |
21658
d8a81542dbf9
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21650
diff
changeset
|
234 :version "20.3") |
21650 | 235 |
236 (defgroup speedbar-faces nil | |
237 "Faces used in speedbar." | |
238 :prefix "speedbar-" | |
239 :group 'speedbar | |
240 :group 'faces) | |
241 | |
242 (defgroup speedbar-vc nil | |
243 "Version control display in speedbar." | |
244 :prefix "speedbar-" | |
245 :group 'speedbar) | |
246 | |
247 ;;; Code: | |
22735 | 248 (defvar speedbar-initial-expansion-mode-alist |
249 '(("buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map | |
250 speedbar-buffer-buttons) | |
251 ("quick buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map | |
252 speedbar-buffer-buttons-temp) | |
253 ;; Files last, means first in the Displays menu | |
254 ("files" speedbar-easymenu-definition-special speedbar-file-key-map | |
255 speedbar-directory-buttons speedbar-default-directory-list) | |
256 ) | |
257 "List of named expansion elements for filling the speedbar frame. | |
258 These expansion lists are only valid for regular files. Special modes | |
259 still get to override this list on a mode-by-mode basis. This list of | |
260 lists is of the form (NAME MENU KEYMAP FN1 FN2 ...). NAME is a string | |
261 representing the types of things to be displayed. MENU is an easymenu | |
262 structure used when in this mode. KEYMAP is a local keymap to install | |
263 over the regular speedbar keymap. FN1 ... are functions that will be | |
264 called in order. These functions will always get the default | |
265 directory to use passed in as the first parameter, and a 0 as the | |
266 second parameter. The 0 indicates the uppermost indentation level. | |
267 They must assume that the cursor is at the position where they start | |
268 inserting buttons.") | |
21650 | 269 |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
270 (defvar speedbar-initial-expansion-list-name "files" |
22735 | 271 "A symbol name representing the expansion list to use. |
272 The expansion list `speedbar-initial-expansion-mode-alist' contains | |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
273 the names and associated functions to use for buttons in speedbar.") |
22735 | 274 |
275 (defvar speedbar-previously-used-expansion-list-name "files" | |
276 "Save the last expansion list method. | |
277 This is used for returning to a previous expansion list method when | |
278 the user is done with the current expansion list.") | |
21650 | 279 |
280 (defvar speedbar-stealthy-function-list | |
22735 | 281 '(("files" |
282 speedbar-update-current-file speedbar-check-vc speedbar-check-objects) | |
283 ) | |
21650 | 284 "List of functions to periodically call stealthily. |
22735 | 285 This list is of the form: |
286 '( (\"NAME\" FUNCTION ...) | |
287 ...) | |
288 where NAME is the name of the major display mode these functions are | |
289 for, and the remaining elements FUNCTION are functions to call in order. | |
21650 | 290 Each function must return nil if interrupted, or t if completed. |
291 Stealthy functions which have a single operation should always return | |
292 t. Functions which take a long time should maintain a state (where | |
293 they are in their speedbar related calculations) and permit | |
294 interruption. See `speedbar-check-vc' as a good example.") | |
295 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
296 (defvar speedbar-mode-functions-list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
297 '(("files" (speedbar-item-info . speedbar-files-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
298 (speedbar-line-path . speedbar-files-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
299 ("buffers" (speedbar-item-info . speedbar-buffers-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
300 (speedbar-line-path . speedbar-buffers-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
301 ("quick buffers" (speedbar-item-info . speedbar-buffers-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
302 (speedbar-line-path . speedbar-buffers-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
303 ) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
304 "List of function tables to use for different major display modes. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
305 It is not necessary to define any functions for a specialized mode. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
306 This just provides a simple way of adding lots of customizations. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
307 Each sublist is of the form: |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
308 (\"NAME\" (FUNCTIONSYMBOL . REPLACEMENTFUNCTION) ...) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
309 Where NAME is the name of the specialized mode. The rest of the list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
310 is a set of dotted pairs of the form FUNCTIONSYMBOL, which is the name |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
311 of a function you would like to replace, and REPLACEMENTFUNCTION, |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
312 which is a function you can call instead. Not all functions can be |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
313 replaced this way. Replaceable functions must provide that |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
314 functionality individually.") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
315 |
21650 | 316 (defcustom speedbar-mode-specific-contents-flag t |
317 "*Non-nil means speedbar will show special mode contents. | |
318 This permits some modes to create customized contents for the speedbar | |
319 frame." | |
320 :group 'speedbar | |
321 :type 'boolean) | |
322 | |
323 (defvar speedbar-special-mode-expansion-list nil | |
22735 | 324 "Default function list for creating specialized button lists. |
325 This list is set by modes that wish to have special speedbar displays. | |
326 The list is of function names. Each function is called with one | |
327 parameter BUFFER, the originating buffer. The current buffer is the | |
328 speedbar buffer.") | |
21650 | 329 |
22735 | 330 (defvar speedbar-special-mode-key-map nil |
331 "Default keymap used when identifying a specialized display mode. | |
332 This keymap is local to each buffer that wants to define special keybindings | |
333 effective when it's display is shown.") | |
21650 | 334 |
335 (defcustom speedbar-visiting-file-hook nil | |
336 "Hooks run when speedbar visits a file in the selected frame." | |
337 :group 'speedbar | |
338 :type 'hook) | |
339 | |
340 (defcustom speedbar-visiting-tag-hook nil | |
341 "Hooks run when speedbar visits a tag in the selected frame." | |
342 :group 'speedbar | |
343 :type 'hook) | |
344 | |
345 (defcustom speedbar-load-hook nil | |
346 "Hooks run when speedbar is loaded." | |
347 :group 'speedbar | |
348 :type 'hook) | |
349 | |
350 (defcustom speedbar-show-unknown-files nil | |
351 "*Non-nil show files we can't expand with a ? in the expand button. | |
352 nil means don't show the file in the list." | |
353 :group 'speedbar | |
354 :type 'boolean) | |
355 | |
356 (defcustom speedbar-update-speed | |
357 (if speedbar-xemacsp | |
358 (if speedbar-xemacs20p | |
359 2 ; 1 is too obrusive in XEmacs | |
360 5) ; when no idleness, need long delay | |
361 1) | |
362 "*Idle time in seconds needed before speedbar will update itself. | |
363 Updates occur to allow speedbar to display directory information | |
364 relevant to the buffer you are currently editing." | |
365 :group 'speedbar | |
366 :type 'integer) | |
367 | |
22735 | 368 ;; When I moved to a repeating timer, I had the horrible missfortune |
369 ;; of loosing the ability for adaptive speed choice. This update | |
370 ;; speed currently causes long delays when it should have been turned off. | |
371 (defcustom speedbar-navigating-speed speedbar-update-speed | |
21650 | 372 "*Idle time to wait after navigation commands in speedbar are executed. |
373 Navigation commands included expanding/contracting nodes, and moving | |
374 between different directories." | |
375 :group 'speedbar | |
376 :type 'integer) | |
377 | |
378 (defcustom speedbar-frame-parameters '((minibuffer . nil) | |
379 (width . 20) | |
380 (border-width . 0) | |
381 (menu-bar-lines . 0) | |
382 (unsplittable . t)) | |
383 "*Parameters to use when creating the speedbar frame in Emacs. | |
384 Parameters not listed here which will be added automatically are | |
385 `height' which will be initialized to the height of the frame speedbar | |
386 is attached to." | |
387 :group 'speedbar | |
388 :type '(repeat (sexp :tag "Parameter:"))) | |
389 | |
390 ;; These values by Hrvoje Niksic <hniksic@srce.hr> | |
391 (defcustom speedbar-frame-plist | |
392 '(minibuffer nil width 20 border-width 0 | |
393 internal-border-width 0 unsplittable t | |
394 default-toolbar-visible-p nil has-modeline-p nil | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
395 menubar-visible-p nil) |
21650 | 396 "*Parameters to use when creating the speedbar frame in XEmacs. |
397 Parameters not listed here which will be added automatically are | |
398 `height' which will be initialized to the height of the frame speedbar | |
399 is attached to." | |
400 :group 'speedbar | |
401 :type '(repeat (group :inline t | |
402 (symbol :tag "Property") | |
403 (sexp :tag "Value")))) | |
404 | |
405 (defcustom speedbar-use-imenu-flag (stringp (locate-library "imenu")) | |
406 "*Non-nil means use imenu for file parsing. nil to use etags. | |
407 XEmacs prior to 20.4 doesn't support imenu, therefore the default is to | |
408 use etags instead. Etags support is not as robust as imenu support." | |
409 :tag "User Imenu" | |
410 :group 'speedbar | |
411 :type 'boolean) | |
412 | |
22735 | 413 (defcustom speedbar-track-mouse-flag t |
414 "*Non-nil means to display info about the line under the mouse." | |
415 :group 'speedbar | |
416 :type 'boolean) | |
417 | |
21650 | 418 (defcustom speedbar-sort-tags nil |
22735 | 419 "*If Non-nil, sort tags in the speedbar display. *Obsolete*." |
21650 | 420 :group 'speedbar |
421 :type 'boolean) | |
422 | |
22735 | 423 (defcustom speedbar-tag-hierarchy-method |
424 '(prefix-group trim-words) | |
425 "*List of methods which speedbar will use to organize tags into groups. | |
426 Groups are defined as expandable meta-tags. Imenu supports such | |
427 things in some languages, such as separating variables from functions. | |
428 Available methods are: | |
429 sort - Sort tags. (sometimes unnecessary) | |
430 trim-words - Trim all tags by a common prefix, broken @ word sections. | |
431 prefix-group - Try to guess groups by prefix. | |
432 simple-group - If imenu already returned some meta groups, stick all | |
433 tags that are not in a group into a sub-group." | |
434 :group 'speedbar | |
435 :type '(repeat | |
436 (radio | |
437 (const :tag "Sort the tags." sort) | |
438 (const :tag "Trim words to common prefix." trim-words) | |
439 (const :tag "Create groups from common prefixes." prefix-group) | |
440 (const :tag "Group loose tags into their own group." simple-group)) | |
441 )) | |
442 | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
443 (defcustom speedbar-tag-group-name-minimum-length 4 |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
444 "*The minimum length of a prefix group name before expanding. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
445 Thus, if the `speedbar-tag-hierarchy-method' includes `prefix-group' |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
446 and one such groups common characters is less than this number of |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
447 characters, then the group name will be changed to the form of: |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
448 worda to wordb |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
449 instead of just |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
450 word |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
451 This way we won't get silly looking listings." |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
452 :group 'speedbar |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
453 :type 'integer) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
454 |
22735 | 455 (defcustom speedbar-tag-split-minimum-length 20 |
456 "*Minimum length before we stop trying to create sub-lists in tags. | |
457 This is used by all tag-hierarchy methods that break large lists into | |
458 sub-lists." | |
459 :group 'speedbar | |
460 :type 'integer) | |
461 | |
462 (defcustom speedbar-tag-regroup-maximum-length 10 | |
463 "*Maximum length of submenus that are regrouped. | |
464 If the regrouping option is used, then if two or more short subgroups | |
465 are next to each other, then they are combined until this number of | |
466 items is reached." | |
467 :group 'speedbar | |
468 :type 'integer) | |
469 | |
21650 | 470 (defcustom speedbar-activity-change-focus-flag nil |
471 "*Non-nil means the selected frame will change based on activity. | |
472 Thus, if a file is selected for edit, the buffer will appear in the | |
473 selected frame and the focus will change to that frame." | |
474 :group 'speedbar | |
475 :type 'boolean) | |
476 | |
477 (defcustom speedbar-directory-button-trim-method 'span | |
478 "*Indicates how the directory button will be displayed. | |
479 Possible values are: | |
480 'span - span large directories over multiple lines. | |
481 'trim - trim large directories to only show the last few. | |
482 nil - no trimming." | |
483 :group 'speedbar | |
484 :type '(radio (const :tag "Span large directories over mutiple lines." | |
485 span) | |
486 (const :tag "Trim large directories to only show the last few." | |
487 trim) | |
488 (const :tag "No trimming." nil))) | |
489 | |
490 (defcustom speedbar-smart-directory-expand-flag t | |
491 "*Non-nil means speedbar should use smart expansion. | |
492 Smart expansion only affects when speedbar wants to display a | |
493 directory for a file in the attached frame. When smart expansion is | |
494 enabled, new directories which are children of a displayed directory | |
495 are expanded in the current framework. If nil, then the current | |
496 hierarchy would be replaced with the new directory." | |
497 :group 'speedbar | |
498 :type 'boolean) | |
499 | |
22735 | 500 (defvar speedbar-hide-button-brackets-flag nil |
501 "*Non-nil means speedbar will hide the brackets around the + or -.") | |
502 | |
21650 | 503 (defcustom speedbar-before-popup-hook nil |
504 "*Hooks called before popping up the speedbar frame." | |
505 :group 'speedbar | |
506 :type 'hook) | |
507 | |
508 (defcustom speedbar-before-delete-hook nil | |
509 "*Hooks called before deleting the speedbar frame." | |
510 :group 'speedbar | |
511 :type 'hook) | |
512 | |
513 (defcustom speedbar-mode-hook nil | |
514 "*Hooks called after creating a speedbar buffer." | |
515 :group 'speedbar | |
516 :type 'hook) | |
517 | |
518 (defcustom speedbar-timer-hook nil | |
519 "*Hooks called after running the speedbar timer function." | |
520 :group 'speedbar | |
521 :type 'hook) | |
522 | |
523 (defcustom speedbar-verbosity-level 1 | |
524 "*Verbosity level of the speedbar. 0 means say nothing. | |
525 1 means medium level verbosity. 2 and higher are higher levels of | |
526 verbosity." | |
527 :group 'speedbar | |
528 :type 'integer) | |
529 | |
22735 | 530 (defvar speedbar-indicator-separator " " |
531 "String separating file text from indicator characters.") | |
532 | |
21650 | 533 (defcustom speedbar-vc-do-check t |
534 "*Non-nil check all files in speedbar to see if they have been checked out. | |
535 Any file checked out is marked with `speedbar-vc-indicator'" | |
536 :group 'speedbar-vc | |
537 :type 'boolean) | |
538 | |
22735 | 539 (defvar speedbar-vc-indicator "*" |
21650 | 540 "Text used to mark files which are currently checked out. |
541 Currently only RCS is supported. Other version control systems can be | |
542 added by examining the function `speedbar-this-file-in-vc' and | |
543 `speedbar-vc-check-dir-p'") | |
544 | |
545 (defcustom speedbar-vc-path-enable-hook nil | |
546 "*Return non-nil if the current path should be checked for Version Control. | |
547 Functions in this hook must accept one parameter which is the path | |
548 being checked." | |
549 :group 'speedbar-vc | |
550 :type 'hook) | |
551 | |
552 (defcustom speedbar-vc-in-control-hook nil | |
553 "*Return non-nil if the specified file is under Version Control. | |
554 Functions in this hook must accept two parameters. The PATH of the | |
555 current file, and the FILENAME of the file being checked." | |
556 :group 'speedbar-vc | |
557 :type 'hook) | |
558 | |
559 (defvar speedbar-vc-to-do-point nil | |
560 "Local variable maintaining the current version control check position.") | |
561 | |
22735 | 562 (defcustom speedbar-obj-do-check t |
563 "*Non-nil check all files in speedbar to see if they have an object file. | |
564 Any file checked out is marked with `speedbar-obj-indicator', and the | |
565 marking is based on `speedbar-obj-alist'" | |
566 :group 'speedbar-vc | |
567 :type 'boolean) | |
568 | |
569 (defvar speedbar-obj-to-do-point nil | |
570 "Local variable maintaining the current version control check position.") | |
571 | |
572 (defvar speedbar-obj-indicator '("#" . "!") | |
573 "Text used to mark files that have a corresponding hidden object file. | |
574 The car is for an up-to-date object. The cdr is for an out of date object. | |
575 The expression `speedbar-obj-alist' defines who gets tagged.") | |
576 | |
577 (defvar speedbar-obj-alist | |
578 '(("\\.\\([cpC]\\|cpp\\|cc\\)$" . ".o") | |
579 ("\\.el$" . ".elc") | |
580 ("\\.java$" . ".class") | |
581 ("\\.f\\(or\\|90\\|77\\)?$" . ".o") | |
582 ("\\.tex$" . ".dvi") | |
583 ("\\.texi$" . ".info")) | |
584 "Alist of file extensions, and their corresponding object file type.") | |
585 | |
586 (defvar speedbar-indicator-regex | |
587 (concat (regexp-quote speedbar-indicator-separator) | |
588 "\\(" | |
589 (regexp-quote speedbar-vc-indicator) | |
590 "\\|" | |
591 (regexp-quote (car speedbar-obj-indicator)) | |
592 "\\|" | |
593 (regexp-quote (cdr speedbar-obj-indicator)) | |
594 "\\)*") | |
595 "Regular expression used when identifying files. | |
596 Permits stripping of indicator characters from a line.") | |
597 | |
598 (defcustom speedbar-scanner-reset-hook nil | |
599 "*Hook called whenever generic scanners are reset. | |
600 Set this to implement your own scanning / rescan safe functions with | |
601 state data." | |
602 :group 'speedbar | |
603 :type 'hook) | |
604 | |
21650 | 605 (defvar speedbar-ignored-modes nil |
606 "*List of major modes which speedbar will not switch directories for.") | |
607 | |
608 (defun speedbar-extension-list-to-regex (extlist) | |
609 "Takes EXTLIST, a list of extensions and transforms it into regexp. | |
22735 | 610 All the preceding `.' are stripped for an optimized expression starting |
611 with `.' followed by extensions, followed by full-filenames." | |
21650 | 612 (let ((regex1 nil) (regex2 nil)) |
613 (while extlist | |
614 (if (= (string-to-char (car extlist)) ?.) | |
615 (setq regex1 (concat regex1 (if regex1 "\\|" "") | |
616 (substring (car extlist) 1))) | |
617 (setq regex2 (concat regex2 (if regex2 "\\|" "") (car extlist)))) | |
618 (setq extlist (cdr extlist))) | |
619 ;; concat all the sub-exressions together, making sure all types | |
620 ;; of parts exist during concatination. | |
621 (concat "\\(" | |
622 (if regex1 (concat "\\(\\.\\(" regex1 "\\)\\)") "") | |
623 (if (and regex1 regex2) "\\|" "") | |
624 (if regex2 (concat "\\(" regex2 "\\)") "") | |
625 "\\)$"))) | |
626 | |
627 (defvar speedbar-ignored-path-regexp nil | |
628 "Regular expression matching paths speedbar will not switch to. | |
629 Created from `speedbar-ignored-path-expressions' with the function | |
630 `speedbar-extension-list-to-regex' (A misnamed function in this case.) | |
631 Use the function `speedbar-add-ignored-path-regexp', or customize the | |
632 variable `speedbar-ignored-path-expressions' to modify this variable.") | |
633 | |
634 (defcustom speedbar-ignored-path-expressions | |
635 '("/logs?/\\'") | |
636 "*List of regular expressions matching directories speedbar will ignore. | |
637 They should included paths to directories which are notoriously very | |
638 large and take a long time to load in. Use the function | |
639 `speedbar-add-ignored-path-regexp' to add new items to this list after | |
640 speedbar is loaded. You may place anything you like in this list | |
641 before speedbar has been loaded." | |
642 :group 'speedbar | |
643 :type '(repeat (regexp :tag "Path Regexp")) | |
644 :set (lambda (sym val) | |
645 (setq speedbar-ignored-path-expressions val | |
646 speedbar-ignored-path-regexp | |
647 (speedbar-extension-list-to-regex val)))) | |
648 | |
22735 | 649 (defcustom speedbar-directory-unshown-regexp "^\\(CVS\\|RCS\\|SCCS\\)\\'" |
650 "*Regular expression matching directories not to show in speedbar. | |
651 They should include commonly existing directories which are not | |
652 useful, such as version control." | |
653 :group 'speedbar | |
654 :type 'string) | |
655 | |
21650 | 656 (defvar speedbar-file-unshown-regexp |
657 (let ((nstr "") (noext completion-ignored-extensions)) | |
658 (while noext | |
659 (setq nstr (concat nstr (regexp-quote (car noext)) "\\'" | |
660 (if (cdr noext) "\\|" "")) | |
661 noext (cdr noext))) | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
662 ;; backup refdir lockfile |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
663 (concat nstr "\\|#[^#]+#$\\|\\.\\.?\\'\\|\\.#")) |
21650 | 664 "*Regexp matching files we don't want displayed in a speedbar buffer. |
665 It is generated from the variable `completion-ignored-extensions'") | |
666 | |
667 ;; this is dangerous to customize, because the defaults will probably | |
668 ;; change in the future. | |
669 (defcustom speedbar-supported-extension-expressions | |
22735 | 670 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" |
671 ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".f\\(90\\|77\\|or\\)?") | |
21650 | 672 (if speedbar-use-imenu-flag |
22735 | 673 '(".ada" ".pl" ".tcl" ".m" ".scm" ".pm" ".py" |
674 ;; html is not supported by default, but an imenu tags package | |
675 ;; is available. Also, html files are nice to be able to see. | |
676 ".s?html" | |
21650 | 677 "Makefile\\(\\.in\\)?"))) |
678 "*List of regular expressions which will match files supported by tagging. | |
679 Do not prefix the `.' char with a double \\ to quote it, as the period | |
680 will be stripped by a simplified optimizer when compiled into a | |
681 singular expression. This variable will be turned into | |
682 `speedbar-file-regexp' for use with speedbar. You should use the | |
683 function `speedbar-add-supported-extension' to add a new extension at | |
684 runtime, or use the configuration dialog to set it in your .emacs | |
685 file." | |
686 :group 'speedbar | |
687 :type '(repeat (regexp :tag "Extension Regexp")) | |
688 :set (lambda (sym val) | |
689 (setq speedbar-supported-extension-expressions val | |
690 speedbar-file-regexp (speedbar-extension-list-to-regex val))) | |
691 ) | |
692 | |
693 (defvar speedbar-file-regexp | |
694 (speedbar-extension-list-to-regex speedbar-supported-extension-expressions) | |
695 "Regular expression matching files we know how to expand. | |
696 Created from `speedbar-supported-extension-expression' with the | |
697 function `speedbar-extension-list-to-regex'") | |
698 | |
699 (defun speedbar-add-supported-extension (extension) | |
700 "Add EXTENSION as a new supported extension for speedbar tagging. | |
701 This should start with a `.' if it is not a complete file name, and | |
702 the dot should NOT be quoted in with \\. Other regular expression | |
703 matchers are allowed however. EXTENSION may be a single string or a | |
704 list of strings." | |
22735 | 705 (interactive "sExtionsion: ") |
21650 | 706 (if (not (listp extension)) (setq extension (list extension))) |
707 (while extension | |
708 (if (member (car extension) speedbar-supported-extension-expressions) | |
709 nil | |
710 (setq speedbar-supported-extension-expressions | |
711 (cons (car extension) speedbar-supported-extension-expressions))) | |
712 (setq extension (cdr extension))) | |
713 (setq speedbar-file-regexp (speedbar-extension-list-to-regex | |
714 speedbar-supported-extension-expressions))) | |
715 | |
716 (defun speedbar-add-ignored-path-regexp (path-expression) | |
717 "Add PATH-EXPRESSION as a new ignored path for speedbar tracking. | |
718 This function will modify `speedbar-ignored-path-regexp' and add | |
719 PATH-EXPRESSION to `speedbar-ignored-path-expressions'." | |
22735 | 720 (interactive "sPath regex: ") |
21650 | 721 (if (not (listp path-expression)) |
722 (setq path-expression (list path-expression))) | |
723 (while path-expression | |
724 (if (member (car path-expression) speedbar-ignored-path-expressions) | |
725 nil | |
726 (setq speedbar-ignored-path-expressions | |
727 (cons (car path-expression) speedbar-ignored-path-expressions))) | |
728 (setq path-expression (cdr path-expression))) | |
729 (setq speedbar-ignored-path-regexp (speedbar-extension-list-to-regex | |
730 speedbar-ignored-path-expressions))) | |
731 | |
732 ;; If we don't have custom, then we set it here by hand. | |
733 (if (not (fboundp 'custom-declare-variable)) | |
734 (setq speedbar-file-regexp (speedbar-extension-list-to-regex | |
735 speedbar-supported-extension-expressions) | |
736 speedbar-ignored-path-regexp (speedbar-extension-list-to-regex | |
737 speedbar-ignored-path-expressions))) | |
738 | |
22735 | 739 (defvar speedbar-update-flag (and |
740 (or (fboundp 'run-with-idle-timer) | |
741 (fboundp 'start-itimer) | |
742 (boundp 'post-command-idle-hook)) | |
743 window-system) | |
21650 | 744 "*Non-nil means to automatically update the display. |
745 When this is nil then speedbar will not follow the attached frame's path. | |
746 When speedbar is active, use: | |
747 | |
748 \\<speedbar-key-map> `\\[speedbar-toggle-updates]' | |
749 | |
750 to toggle this value.") | |
751 | |
752 (defvar speedbar-syntax-table nil | |
753 "Syntax-table used on the speedbar.") | |
754 | |
755 (if speedbar-syntax-table | |
756 nil | |
757 (setq speedbar-syntax-table (make-syntax-table)) | |
758 ;; turn off paren matching around here. | |
759 (modify-syntax-entry ?\' " " speedbar-syntax-table) | |
760 (modify-syntax-entry ?\" " " speedbar-syntax-table) | |
761 (modify-syntax-entry ?( " " speedbar-syntax-table) | |
762 (modify-syntax-entry ?) " " speedbar-syntax-table) | |
763 (modify-syntax-entry ?[ " " speedbar-syntax-table) | |
764 (modify-syntax-entry ?] " " speedbar-syntax-table)) | |
765 | |
766 (defvar speedbar-key-map nil | |
767 "Keymap used in speedbar buffer.") | |
768 | |
769 (if speedbar-key-map | |
770 nil | |
771 (setq speedbar-key-map (make-keymap)) | |
772 (suppress-keymap speedbar-key-map t) | |
773 | |
774 ;; control | |
775 (define-key speedbar-key-map "g" 'speedbar-refresh) | |
776 (define-key speedbar-key-map "t" 'speedbar-toggle-updates) | |
777 (define-key speedbar-key-map "q" 'speedbar-close-frame) | |
23080
8b7bb810f362
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
23073
diff
changeset
|
778 (define-key speedbar-key-map "Q" 'delete-frame) |
21650 | 779 |
780 ;; navigation | |
781 (define-key speedbar-key-map "n" 'speedbar-next) | |
782 (define-key speedbar-key-map "p" 'speedbar-prev) | |
22735 | 783 (define-key speedbar-key-map "\M-n" 'speedbar-restricted-next) |
784 (define-key speedbar-key-map "\M-p" 'speedbar-restricted-prev) | |
785 (define-key speedbar-key-map "\C-\M-n" 'speedbar-forward-list) | |
786 (define-key speedbar-key-map "\C-\M-p" 'speedbar-backward-list) | |
21650 | 787 (define-key speedbar-key-map " " 'speedbar-scroll-up) |
788 (define-key speedbar-key-map [delete] 'speedbar-scroll-down) | |
789 | |
22735 | 790 ;; Short cuts I happen to find useful |
791 (define-key speedbar-key-map "r" | |
792 (lambda () (interactive) | |
793 (speedbar-change-initial-expansion-list | |
794 speedbar-previously-used-expansion-list-name))) | |
795 (define-key speedbar-key-map "b" | |
796 (lambda () (interactive) | |
797 (speedbar-change-initial-expansion-list "quick buffers"))) | |
798 (define-key speedbar-key-map "f" | |
799 (lambda () (interactive) | |
800 (speedbar-change-initial-expansion-list "files"))) | |
801 | |
802 ;; Overrides | |
803 (substitute-key-definition 'switch-to-buffer | |
804 'speedbar-switch-buffer-attached-frame | |
805 speedbar-key-map global-map) | |
21650 | 806 |
807 (if speedbar-xemacsp | |
808 (progn | |
809 ;; mouse bindings so we can manipulate the items on each line | |
810 (define-key speedbar-key-map 'button2 'speedbar-click) | |
811 (define-key speedbar-key-map '(shift button2) 'speedbar-power-click) | |
22735 | 812 ;; Info doc fix from Bob Weiner |
813 (if (featurep 'infodoc) | |
814 nil | |
815 (define-key speedbar-key-map 'button3 'speedbar-xemacs-popup-kludge)) | |
816 (define-key speedbar-key-map '(meta button3) 'speedbar-mouse-item-info) | |
817 ) | |
818 | |
21650 | 819 ;; mouse bindings so we can manipulate the items on each line |
820 (define-key speedbar-key-map [down-mouse-1] 'speedbar-double-click) | |
821 (define-key speedbar-key-map [mouse-2] 'speedbar-click) | |
822 ;; This is the power click for new frames, or refreshing a cache | |
823 (define-key speedbar-key-map [S-mouse-2] 'speedbar-power-click) | |
824 ;; This adds a small unecessary visual effect | |
825 ;;(define-key speedbar-key-map [down-mouse-2] 'speedbar-quick-mouse) | |
826 (define-key speedbar-key-map [M-mouse-2] 'speedbar-mouse-item-info) | |
827 | |
828 (define-key speedbar-key-map [down-mouse-3] 'speedbar-emacs-popup-kludge) | |
829 | |
830 ;; This lets the user scroll as if we had a scrollbar... well maybe not | |
831 (define-key speedbar-key-map [mode-line mouse-2] 'speedbar-mouse-hscroll) | |
22735 | 832 ;; another handy place users might click to get our menu. |
833 (define-key speedbar-key-map [mode-line down-mouse-1] | |
834 'speedbar-emacs-popup-kludge) | |
835 | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
836 ;; We can't switch buffers with the buffer mouse menu. Lets hack it. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
837 (define-key speedbar-key-map [C-down-mouse-1] 'speedbar-hack-buffer-menu) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
838 |
22735 | 839 ;; Lastly, we want to track the mouse. Play here |
840 (define-key speedbar-key-map [mouse-movement] 'speedbar-track-mouse) | |
841 )) | |
842 | |
843 (defun speedbar-make-specialized-keymap () | |
844 "Create a keymap for use w/ a speedbar major or minor display mode. | |
845 This basically creates a sparse keymap, and makes it's parent be | |
846 `speedbar-key-map'." | |
847 (let ((k (make-sparse-keymap))) | |
848 (set-keymap-parent k speedbar-key-map) | |
849 k)) | |
850 | |
851 (defvar speedbar-file-key-map nil | |
852 "Keymap used in speedbar buffer while files are displayed.") | |
853 | |
854 (if speedbar-file-key-map | |
855 nil | |
856 (setq speedbar-file-key-map (speedbar-make-specialized-keymap)) | |
857 | |
858 ;; Basic tree features | |
859 (define-key speedbar-file-key-map "e" 'speedbar-edit-line) | |
860 (define-key speedbar-file-key-map "\C-m" 'speedbar-edit-line) | |
861 (define-key speedbar-file-key-map "+" 'speedbar-expand-line) | |
862 (define-key speedbar-file-key-map "-" 'speedbar-contract-line) | |
863 | |
864 ;; file based commands | |
865 (define-key speedbar-file-key-map "U" 'speedbar-up-directory) | |
866 (define-key speedbar-file-key-map "I" 'speedbar-item-info) | |
867 (define-key speedbar-file-key-map "B" 'speedbar-item-byte-compile) | |
868 (define-key speedbar-file-key-map "L" 'speedbar-item-load) | |
869 (define-key speedbar-file-key-map "C" 'speedbar-item-copy) | |
870 (define-key speedbar-file-key-map "D" 'speedbar-item-delete) | |
871 (define-key speedbar-file-key-map "O" 'speedbar-item-object-delete) | |
872 (define-key speedbar-file-key-map "R" 'speedbar-item-rename) | |
873 ) | |
21650 | 874 |
875 (defvar speedbar-easymenu-definition-base | |
876 '("Speedbar" | |
877 ["Update" speedbar-refresh t] | |
878 ["Auto Update" speedbar-toggle-updates | |
879 :style toggle :selected speedbar-update-flag] | |
880 ) | |
881 "Base part of the speedbar menu.") | |
882 | |
883 (defvar speedbar-easymenu-definition-special | |
884 '(["Edit Item On Line" speedbar-edit-line t] | |
885 ["Show All Files" speedbar-toggle-show-all-files | |
886 :style toggle :selected speedbar-show-unknown-files] | |
22735 | 887 ["Expand File Tags" speedbar-expand-line |
21650 | 888 (save-excursion (beginning-of-line) |
889 (looking-at "[0-9]+: *.\\+. "))] | |
22735 | 890 ["Contract File Tags" speedbar-contract-line |
21650 | 891 (save-excursion (beginning-of-line) |
892 (looking-at "[0-9]+: *.-. "))] | |
22735 | 893 ; ["Sort Tags" speedbar-toggle-sorting |
894 ; :style toggle :selected speedbar-sort-tags] | |
21650 | 895 "----" |
22735 | 896 ["File/Tag Information" speedbar-item-info t] |
21650 | 897 ["Load Lisp File" speedbar-item-load |
898 (save-excursion | |
899 (beginning-of-line) | |
22735 | 900 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\|$\\)"))] |
21650 | 901 ["Byte Compile File" speedbar-item-byte-compile |
902 (save-excursion | |
903 (beginning-of-line) | |
22735 | 904 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\|$\\)"))] |
905 ["Copy File" speedbar-item-copy | |
21650 | 906 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *\\["))] |
22735 | 907 ["Rename File" speedbar-item-rename |
908 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))] | |
909 ["Delete File" speedbar-item-delete | |
21650 | 910 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))] |
22735 | 911 ["Delete Object" speedbar-item-object-delete |
912 (save-excursion (beginning-of-line) | |
913 (looking-at "[0-9]+: *\\[[+-]\\] [^ \n]+ \\*?[!#]$"))] | |
914 ) | |
21650 | 915 "Additional menu items while in file-mode.") |
916 | |
917 (defvar speedbar-easymenu-definition-trailer | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
918 (append |
22735 | 919 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
920 (list ["Customize..." speedbar-customize t])) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
921 (list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
922 ["Close" speedbar-close-frame t] |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
923 ["Quit" delete-frame t] )) |
21650 | 924 "Menu items appearing at the end of the speedbar menu.") |
925 | |
926 (defvar speedbar-desired-buffer nil | |
927 "Non-nil when speedbar is showing buttons specific a special mode. | |
928 In this case it is the originating buffer.") | |
929 (defvar speedbar-buffer nil | |
930 "The buffer displaying the speedbar.") | |
931 (defvar speedbar-frame nil | |
932 "The frame displaying speedbar.") | |
933 (defvar speedbar-cached-frame nil | |
934 "The frame that was last created, then removed from the display.") | |
935 (defvar speedbar-full-text-cache nil | |
936 "The last open directory is saved in its entirety for ultra-fast switching.") | |
937 (defvar speedbar-timer nil | |
938 "The speedbar timer used for updating the buffer.") | |
939 (defvar speedbar-attached-frame nil | |
940 "The frame which started speedbar mode. | |
941 This is the frame from which all data displayed in the speedbar is | |
942 gathered, and in which files and such are displayed.") | |
943 | |
944 (defvar speedbar-last-selected-file nil | |
945 "The last file which was selected in speedbar buffer.") | |
946 | |
947 (defvar speedbar-shown-directories nil | |
948 "Maintain list of directories simultaneously open in the current speedbar.") | |
949 | |
950 (defvar speedbar-directory-contents-alist nil | |
951 "An association list of directories and their contents. | |
952 Each sublist was returned by `speedbar-file-lists'. This list is | |
953 maintained to speed up the refresh rate when switching between | |
954 directories.") | |
955 | |
956 (defvar speedbar-power-click nil | |
957 "Never set this by hand. Value is t when S-mouse activity occurs.") | |
958 | |
959 | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
960 ;;; Compatibility |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
961 ;; |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
962 (if (fboundp 'frame-parameter) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
963 |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
964 (defalias 'speedbar-frame-parameter 'frame-parameter) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
965 |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
966 (defun speedbar-frame-parameter (frame parameter) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
967 "Return FRAME's PARAMETER value." |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
968 (cdr (assoc parameter (frame-parameters frame))))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
969 |
21650 | 970 ;;; Mode definitions/ user commands |
971 ;; | |
972 | |
973 ;;;###autoload | |
974 (defalias 'speedbar 'speedbar-frame-mode) | |
975 ;;;###autoload | |
976 (defun speedbar-frame-mode (&optional arg) | |
977 "Enable or disable speedbar. Positive ARG means turn on, negative turn off. | |
978 nil means toggle. Once the speedbar frame is activated, a buffer in | |
979 `speedbar-mode' will be displayed. Currently, only one speedbar is | |
980 supported at a time. | |
981 `speedbar-before-popup-hook' is called before popping up the speedbar frame. | |
982 `speedbar-before-delete-hook' is called before the frame is deleted." | |
983 (interactive "P") | |
984 ;; toggle frame on and off. | |
985 (if (not arg) (if (and (frame-live-p speedbar-frame) | |
986 (frame-visible-p speedbar-frame)) | |
987 (setq arg -1) (setq arg 1))) | |
988 ;; turn the frame off on neg number | |
989 (if (and (numberp arg) (< arg 0)) | |
990 (progn | |
991 (run-hooks 'speedbar-before-delete-hook) | |
992 (if (and speedbar-frame (frame-live-p speedbar-frame)) | |
993 (progn | |
994 (setq speedbar-cached-frame speedbar-frame) | |
995 (make-frame-invisible speedbar-frame))) | |
996 (setq speedbar-frame nil) | |
997 (speedbar-set-timer nil) | |
998 ;; Used to delete the buffer. This has the annoying affect of | |
999 ;; preventing whatever took its place from ever appearing | |
1000 ;; as the default after a C-x b was typed | |
1001 ;;(if (bufferp speedbar-buffer) | |
1002 ;; (kill-buffer speedbar-buffer)) | |
1003 ) | |
1004 ;; Set this as our currently attached frame | |
1005 (setq speedbar-attached-frame (selected-frame)) | |
1006 (run-hooks 'speedbar-before-popup-hook) | |
1007 ;; Get the frame to work in | |
1008 (if (frame-live-p speedbar-cached-frame) | |
1009 (progn | |
1010 (setq speedbar-frame speedbar-cached-frame) | |
1011 (make-frame-visible speedbar-frame) | |
1012 ;; Get the buffer to play with | |
1013 (speedbar-mode) | |
1014 (select-frame speedbar-frame) | |
1015 (if (not (eq (current-buffer) speedbar-buffer)) | |
1016 (switch-to-buffer speedbar-buffer)) | |
1017 (set-window-dedicated-p (selected-window) t) | |
1018 (raise-frame speedbar-frame) | |
1019 (speedbar-set-timer speedbar-update-speed) | |
1020 ) | |
1021 (if (frame-live-p speedbar-frame) | |
1022 (raise-frame speedbar-frame) | |
1023 (setq speedbar-frame | |
1024 (if speedbar-xemacsp | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1025 ;; Only guess height if it is not specified. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1026 (if (member 'height speedbar-frame-plist) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1027 (make-frame speedbar-frame-plist) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1028 (make-frame (nconc (list 'height |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1029 (speedbar-needed-height)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1030 speedbar-frame-plist))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1031 (let* ((mh (speedbar-frame-parameter nil 'menu-bar-lines)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1032 (cfx (speedbar-frame-parameter nil 'left)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1033 (cfy (speedbar-frame-parameter nil 'top)) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1034 (cfw (frame-pixel-width)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1035 (params |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1036 ;; Only add a guessed height if one is not specified |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1037 ;; in the input parameters. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1038 (if (assoc 'height speedbar-frame-parameters) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1039 speedbar-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1040 (append |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1041 speedbar-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1042 (list (cons 'height (+ mh (frame-height))))))) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1043 (frame |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1044 (if (or (< emacs-major-version 20) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1045 (not (eq window-system 'x))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1046 (make-frame params) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1047 (let ((x-pointer-shape x-pointer-top-left-arrow) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1048 (x-sensitive-text-pointer-shape |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1049 x-pointer-hand2)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1050 (make-frame params))))) |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1051 ;; Position speedbar frame. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1052 (if (or (not window-system) (eq window-system 'pc) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1053 (assoc 'left speedbar-frame-parameters) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1054 (assoc 'top speedbar-frame-parameters)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1055 ;; Do no positioning if not on a windowing system, |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1056 ;; or if left/top were specified in the parameters. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1057 frame |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1058 (let ((cfx |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1059 (if (not (consp cfx)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1060 cfx |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1061 ;; If cfx is a list, that means we grow |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1062 ;; from a specific edge of the display. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1063 ;; Convert that to the distance from the |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1064 ;; left side of the display. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1065 (if (eq (car cfx) '-) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1066 ;; A - means distance from the right edge |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1067 ;; of the display, or DW - cfx - framewidth |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1068 (- (x-display-pixel-width) (car (cdr cfx)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1069 (frame-pixel-width)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1070 (car (cdr cfx)))))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1071 (modify-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1072 frame |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1073 (list |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1074 (cons |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1075 'left |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1076 ;; Decide which side to put it |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1077 ;; on. 200 is just a buffer |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1078 ;; for the left edge of the |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1079 ;; screen. The extra 10 is just |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1080 ;; dressings for window decorations. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1081 (let ((sfw (frame-pixel-width frame))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1082 (let ((left-guess (- cfx 10 sfw)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1083 (right-guess (+ cfx cfw 5))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1084 (let ((left-margin left-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1085 (right-margin |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1086 (- (x-display-pixel-width) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1087 right-guess 5 sfw))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1088 (cond ((>= left-margin 0) left-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1089 ((>= right-margin 0) right-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1090 ;; otherwise choose side we overlap less |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1091 ((> left-margin right-margin) 0) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1092 (t (- (x-display-pixel-width) sfw 5))))))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1093 (cons 'top cfy))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1094 frame))))) |
21650 | 1095 ;; reset the selection variable |
1096 (setq speedbar-last-selected-file nil) | |
1097 ;; Put the buffer into the frame | |
1098 (save-window-excursion | |
1099 ;; Get the buffer to play with | |
1100 (speedbar-mode) | |
1101 (select-frame speedbar-frame) | |
1102 (switch-to-buffer speedbar-buffer) | |
1103 (set-window-dedicated-p (selected-window) t)) | |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
1104 (if (and (or (null window-system) (eq window-system 'pc)) |
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
1105 (fboundp 'set-frame-name)) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1106 (progn |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1107 (select-frame speedbar-frame) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1108 (set-frame-name "Speedbar"))) |
21650 | 1109 (speedbar-set-timer speedbar-update-speed))))) |
1110 | |
1111 ;;;###autoload | |
1112 (defun speedbar-get-focus () | |
1113 "Change frame focus to or from the speedbar frame. | |
1114 If the selected frame is not speedbar, then speedbar frame is | |
1115 selected. If the speedbar frame is active, then select the attached frame." | |
1116 (interactive) | |
1117 (if (eq (selected-frame) speedbar-frame) | |
1118 (if (frame-live-p speedbar-attached-frame) | |
1119 (select-frame speedbar-attached-frame)) | |
22735 | 1120 ;; If updates are off, then refresh the frame (they want it now...) |
1121 (if (not speedbar-update-flag) | |
1122 (let ((speedbar-update-flag t)) | |
1123 (speedbar-timer-fn))) | |
21650 | 1124 ;; make sure we have a frame |
1125 (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1)) | |
1126 ;; go there | |
22735 | 1127 (select-frame speedbar-frame) |
1128 ) | |
21650 | 1129 (other-frame 0)) |
1130 | |
1131 (defun speedbar-close-frame () | |
1132 "Turn off a currently active speedbar." | |
1133 (interactive) | |
1134 (speedbar-frame-mode -1) | |
1135 (select-frame speedbar-attached-frame) | |
1136 (other-frame 0)) | |
1137 | |
22735 | 1138 (defun speedbar-switch-buffer-attached-frame (&optional buffer) |
1139 "Switch to BUFFER in speedbar's attached frame, and raise that frame. | |
1140 This overrides the default behavior of `switch-to-buffer' which is | |
1141 broken because of the dedicated speedbar frame." | |
1142 (interactive) | |
1143 ;; Assume we are in the speedbar frame. | |
1144 (speedbar-get-focus) | |
1145 ;; Now switch buffers | |
1146 (if buffer | |
1147 (switch-to-buffer buffer) | |
1148 (call-interactively 'switch-to-buffer nil nil))) | |
1149 | |
21650 | 1150 (defmacro speedbar-frame-width () |
1151 "Return the width of the speedbar frame in characters. | |
1152 nil if it doesn't exist." | |
1153 '(frame-width speedbar-frame)) | |
1154 | |
1155 ;; XEmacs function only. | |
1156 (defun speedbar-needed-height (&optional frame) | |
1157 "The needed height for the tool bar FRAME (in characters)." | |
1158 (or frame (setq frame (selected-frame))) | |
1159 ;; The 1 is the missing modeline/minibuffer | |
1160 (+ 1 (/ (frame-pixel-height frame) | |
1161 (face-height 'default frame)))) | |
1162 | |
1163 (defun speedbar-mode () | |
1164 "Major mode for managing a display of directories and tags. | |
1165 \\<speedbar-key-map> | |
1166 The first line represents the default path of the speedbar frame. | |
1167 Each directory segment is a button which jumps speedbar's default | |
1168 directory to that path. Buttons are activated by clicking `\\[speedbar-click]'. | |
1169 In some situations using `\\[speedbar-power-click]' is a `power click' which will | |
1170 rescan cached items, or pop up new frames. | |
1171 | |
1172 Each line starting with <+> represents a directory. Click on the <+> | |
1173 to insert the directory listing into the current tree. Click on the | |
1174 <-> to retract that list. Click on the directory name to go to that | |
1175 directory as the default. | |
1176 | |
1177 Each line starting with [+] is a file. If the variable | |
1178 `speedbar-show-unknown-files' is t, the lines starting with [?] are | |
1179 files which don't have imenu support, but are not expressly ignored. | |
1180 Files are completely ignored if they match `speedbar-file-unshown-regexp' | |
1181 which is generated from `completion-ignored-extensions'. | |
1182 | |
1183 Files with a `*' character after their name are files checked out of a | |
1184 version control system. (currently only RCS is supported.) New | |
1185 version control systems can be added by examining the documentation | |
1186 for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p' | |
1187 | |
22735 | 1188 Files with a `#' or `!' character after them are source files that |
1189 have an object file associated with them. The `!' indicates that the | |
1190 files is out of date. You can control what source/object associations | |
1191 exist through the variable `speedbar-obj-alist'. | |
1192 | |
21650 | 1193 Click on the [+] to display a list of tags from that file. Click on |
1194 the [-] to retract the list. Click on the file name to edit the file | |
1195 in the attached frame. | |
1196 | |
1197 If you open tags, you might find a node starting with {+}, which is a | |
1198 category of tags. Click the {+} to expand the category. Jump-able | |
1199 tags start with >. Click the name of the tag to go to that position | |
1200 in the selected file. | |
1201 | |
1202 \\{speedbar-key-map}" | |
1203 ;; NOT interactive | |
1204 (save-excursion | |
1205 (setq speedbar-buffer (set-buffer (get-buffer-create " SPEEDBAR"))) | |
1206 (kill-all-local-variables) | |
1207 (setq major-mode 'speedbar-mode) | |
1208 (setq mode-name "Speedbar") | |
1209 (set-syntax-table speedbar-syntax-table) | |
1210 (setq font-lock-keywords nil) ;; no font-locking please | |
1211 (setq truncate-lines t) | |
1212 (make-local-variable 'frame-title-format) | |
1213 (setq frame-title-format "Speedbar") | |
1214 ;; Set this up special just for the speedbar buffer | |
22735 | 1215 ;; Terminal minibuffer stuff does not require this. |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1216 (if (and window-system (not (eq window-system 'pc)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1217 (null default-minibuffer-frame)) |
21650 | 1218 (progn |
1219 (make-local-variable 'default-minibuffer-frame) | |
1220 (setq default-minibuffer-frame speedbar-attached-frame))) | |
22735 | 1221 ;; Correct use of `temp-buffer-show-function': Bob Weiner |
1222 (if (and (boundp 'temp-buffer-show-hook) | |
1223 (boundp 'temp-buffer-show-function)) | |
1224 (progn (make-local-variable 'temp-buffer-show-hook) | |
1225 (setq temp-buffer-show-hook temp-buffer-show-function))) | |
21650 | 1226 (make-local-variable 'temp-buffer-show-function) |
1227 (setq temp-buffer-show-function 'speedbar-temp-buffer-show-function) | |
1228 (if speedbar-xemacsp | |
1229 (progn | |
1230 ;; Argh! mouse-track-click-hook doesn't understand the | |
1231 ;; make-local-hook conventions. | |
1232 (make-local-variable 'mouse-track-click-hook) | |
1233 (add-hook 'mouse-track-click-hook | |
1234 (lambda (event count) | |
1235 (if (/= (event-button event) 1) | |
1236 nil ; Do normal operations. | |
1237 (cond ((eq count 1) | |
1238 (speedbar-quick-mouse event)) | |
1239 ((or (eq count 2) | |
1240 (eq count 3)) | |
1241 (mouse-set-point event) | |
1242 (speedbar-do-function-pointer) | |
1243 (speedbar-quick-mouse event))) | |
1244 ;; Don't do normal operations. | |
1245 t))))) | |
1246 (make-local-hook 'kill-buffer-hook) | |
1247 (add-hook 'kill-buffer-hook (lambda () (let ((skilling (boundp 'skilling))) | |
1248 (if skilling | |
1249 nil | |
1250 (if (eq (current-buffer) | |
1251 speedbar-buffer) | |
1252 (speedbar-frame-mode -1))))) | |
1253 t t) | |
23083
2dea437fe88a
(speedbar-with-writable): remove `toggle-read-only'.
Eric M. Ludlam <zappo@gnu.org>
parents:
23080
diff
changeset
|
1254 (toggle-read-only 1) |
21650 | 1255 (speedbar-set-mode-line-format) |
22735 | 1256 (if speedbar-xemacsp |
1257 (progn | |
1258 (make-local-variable 'mouse-motion-handler) | |
1259 (setq mouse-motion-handler 'speedbar-track-mouse-xemacs)) | |
1260 (if speedbar-track-mouse-flag | |
1261 (progn | |
1262 (make-local-variable 'track-mouse) | |
1263 (setq track-mouse t))) ;this could be messy. | |
1264 (setq auto-show-mode nil)) ;no auto-show for Emacs | |
21650 | 1265 (run-hooks 'speedbar-mode-hook)) |
1266 (speedbar-update-contents) | |
1267 speedbar-buffer) | |
1268 | |
22735 | 1269 (defun speedbar-show-info-under-mouse (&optional event) |
1270 "Call the info function for the line under the mouse. | |
1271 Optional EVENT is currently not used." | |
1272 (let ((pos (mouse-position))) ; we ignore event until I use it later. | |
1273 (if (equal (car pos) speedbar-frame) | |
1274 (save-excursion | |
1275 (save-window-excursion | |
1276 (apply 'set-mouse-position pos) | |
1277 (speedbar-item-info)))))) | |
1278 | |
21650 | 1279 (defun speedbar-set-mode-line-format () |
1280 "Set the format of the mode line based on the current speedbar environment. | |
1281 This gives visual indications of what is up. It EXPECTS the speedbar | |
1282 frame and window to be the currently active frame and window." | |
1283 (if (and (frame-live-p speedbar-frame) | |
1284 (or (not speedbar-xemacsp) | |
1285 (specifier-instance has-modeline-p))) | |
1286 (save-excursion | |
1287 (set-buffer speedbar-buffer) | |
1288 (let* ((w (or (speedbar-frame-width) 20)) | |
1289 (p1 "<<") | |
1290 (p5 ">>") | |
1291 (p3 (if speedbar-update-flag "SPEEDBAR" "SLOWBAR")) | |
1292 (blank (- w (length p1) (length p3) (length p5) | |
1293 (if line-number-mode 4 0))) | |
1294 (p2 (if (> blank 0) | |
1295 (make-string (/ blank 2) ? ) | |
1296 "")) | |
1297 (p4 (if (> blank 0) | |
1298 (make-string (+ (/ blank 2) (% blank 2)) ? ) | |
1299 "")) | |
1300 (tf | |
1301 (if line-number-mode | |
1302 (list (concat p1 p2 p3) '(line-number-mode " %3l") | |
1303 (concat p4 p5)) | |
1304 (list (concat p1 p2 p3 p4 p5))))) | |
1305 (if (not (equal mode-line-format tf)) | |
1306 (progn | |
1307 (setq mode-line-format tf) | |
1308 (force-mode-line-update))))))) | |
1309 | |
1310 (defun speedbar-temp-buffer-show-function (buffer) | |
1311 "Placed in the variable `temp-buffer-show-function' in `speedbar-mode'. | |
1312 If a user requests help using \\[help-command] <Key> the temp BUFFER will be | |
1313 redirected into a window on the attached frame." | |
1314 (if speedbar-attached-frame (select-frame speedbar-attached-frame)) | |
1315 (pop-to-buffer buffer nil) | |
1316 (other-window -1) | |
23084
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1317 ;; Fix for using this hook on some platforms: Bob Weiner |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1318 (cond ((not speedbar-xemacsp) |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1319 (run-hooks 'temp-buffer-show-hook)) |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1320 ((fboundp 'run-hook-with-args) |
22735 | 1321 (run-hook-with-args 'temp-buffer-show-hook buffer)) |
1322 ((and (boundp 'temp-buffer-show-hook) | |
1323 (listp temp-buffer-show-hook)) | |
1324 (mapcar (function (lambda (hook) (funcall hook buffer))) | |
1325 temp-buffer-show-hook)))) | |
21650 | 1326 |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1327 (defvar speedbar-previous-menu nil |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1328 "The menu before the last `speedbar-reconfigure-keymaps' was called.") |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1329 |
22735 | 1330 (defun speedbar-reconfigure-keymaps () |
21650 | 1331 "Reconfigure the menu-bar in a speedbar frame. |
1332 Different menu items are displayed depending on the current display mode | |
1333 and the existence of packages." | |
22735 | 1334 (let ((md (append |
1335 speedbar-easymenu-definition-base | |
1336 (if speedbar-shown-directories | |
1337 ;; file display mode version | |
1338 (speedbar-initial-menu) | |
1339 (save-excursion | |
1340 (select-frame speedbar-attached-frame) | |
1341 (if (local-variable-p | |
1342 'speedbar-easymenu-definition-special | |
1343 (current-buffer)) | |
1344 ;; If bound locally, we can use it | |
1345 speedbar-easymenu-definition-special))) | |
1346 ;; Dynamic menu stuff | |
1347 '("-") | |
1348 (list (cons "Displays" | |
1349 (let ((displays nil) | |
1350 (alist speedbar-initial-expansion-mode-alist)) | |
1351 (while alist | |
1352 (setq displays | |
1353 (cons | |
1354 (vector | |
1355 (capitalize (car (car alist))) | |
1356 (list | |
1357 'speedbar-change-initial-expansion-list | |
1358 (car (car alist))) | |
1359 t) | |
1360 displays)) | |
1361 (setq alist (cdr alist))) | |
1362 displays))) | |
1363 ;; The trailer | |
1364 speedbar-easymenu-definition-trailer)) | |
1365 (localmap (save-excursion | |
1366 (let ((cf (selected-frame))) | |
1367 (prog2 | |
1368 (select-frame speedbar-attached-frame) | |
1369 (if (local-variable-p | |
1370 'speedbar-special-mode-key-map | |
1371 (current-buffer)) | |
1372 speedbar-special-mode-key-map) | |
1373 (select-frame cf)))))) | |
1374 (save-excursion | |
1375 (set-buffer speedbar-buffer) | |
1376 (use-local-map (or localmap | |
1377 (speedbar-initial-keymap) | |
1378 ;; This creates a small keymap we can glom the | |
1379 ;; menu adjustments into. | |
1380 (speedbar-make-specialized-keymap))) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1381 ;; Delete the old menu if applicable. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1382 (if speedbar-previous-menu (easy-menu-remove speedbar-previous-menu)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1383 (setq speedbar-previous-menu md) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1384 ;; Now add the new menu |
22735 | 1385 (if (not speedbar-xemacsp) |
1386 (easy-menu-define speedbar-menu-map (current-local-map) | |
1387 "Speedbar menu" md) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1388 (easy-menu-add md (current-local-map)) |
22735 | 1389 (set-buffer-menubar (list md)))))) |
21650 | 1390 |
1391 | |
1392 ;;; User Input stuff | |
1393 ;; | |
1394 | |
1395 ;; XEmacs: this can be implemented using modeline keymaps, but there | |
1396 ;; is no use, as we have horizontal scrollbar (as the docstring | |
1397 ;; hints.) | |
1398 (defun speedbar-mouse-hscroll (e) | |
1399 "Read a mouse event E from the mode line, and horizontally scroll. | |
1400 If the mouse is being clicked on the far left, or far right of the | |
1401 mode-line. This is only useful for non-XEmacs" | |
1402 (interactive "e") | |
1403 (let* ((xp (car (nth 2 (car (cdr e))))) | |
1404 (cpw (/ (frame-pixel-width) | |
1405 (frame-width))) | |
1406 (oc (1+ (/ xp cpw))) | |
1407 ) | |
1408 (cond ((< oc 3) | |
1409 (scroll-left 2)) | |
1410 ((> oc (- (window-width) 3)) | |
1411 (scroll-right 2)) | |
1412 (t (message "Click on the edge of the modeline to scroll left/right"))) | |
1413 ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc) | |
1414 )) | |
1415 | |
1416 (defun speedbar-customize () | |
1417 "Customize speedbar using the Custom package." | |
1418 (interactive) | |
1419 (let ((sf (selected-frame))) | |
1420 (select-frame speedbar-attached-frame) | |
1421 (customize-group 'speedbar) | |
1422 (select-frame sf)) | |
1423 (speedbar-maybee-jump-to-attached-frame)) | |
1424 | |
22735 | 1425 (defun speedbar-track-mouse (event) |
1426 "For motion EVENT, display info about the current line." | |
1427 (interactive "e") | |
1428 (if (not speedbar-track-mouse-flag) | |
1429 nil | |
1430 (save-excursion | |
1431 (let ((char (nth 1 (car (cdr event))))) | |
1432 (if (not (numberp char)) | |
1433 (message nil) | |
1434 (goto-char char) | |
1435 ;; (message "%S" event) | |
1436 (speedbar-item-info) | |
1437 ))))) | |
1438 | |
1439 (defun speedbar-track-mouse-xemacs (event) | |
1440 "For motion EVENT, display info about the current line." | |
1441 (if (functionp (default-value 'mouse-motion-handler)) | |
1442 (funcall (default-value 'mouse-motion-handler) event)) | |
1443 (if speedbar-track-mouse-flag | |
1444 (save-excursion | |
1445 (save-window-excursion | |
1446 (condition-case () | |
1447 (progn (mouse-set-point event) | |
1448 ;; Prevent focus-related bugs. | |
1449 (if (eq major-mode 'speedbar-mode) | |
1450 (speedbar-item-info))) | |
1451 (error nil)))))) | |
1452 | |
21650 | 1453 ;; In XEmacs, we make popup menus work on the item over mouse (as |
1454 ;; opposed to where the point happens to be.) We attain this by | |
1455 ;; temporarily moving the point to that place. | |
1456 ;; Hrvoje Niksic <hniksic@srce.hr> | |
1457 (defun speedbar-xemacs-popup-kludge (event) | |
1458 "Pop up a menu related to the clicked on item. | |
1459 Must be bound to EVENT." | |
1460 (interactive "e") | |
22735 | 1461 (select-frame speedbar-frame) |
21650 | 1462 (save-excursion |
1463 (goto-char (event-closest-point event)) | |
1464 (beginning-of-line) | |
1465 (forward-char (min 5 (- (save-excursion (end-of-line) (point)) | |
1466 (save-excursion (beginning-of-line) (point))))) | |
1467 (popup-mode-menu) | |
1468 ;; Wait for menu to bail out. `popup-mode-menu' (and other popup | |
1469 ;; menu functions) return immediately. | |
1470 (let (new) | |
1471 (while (not (misc-user-event-p (setq new (next-event)))) | |
1472 (dispatch-event new)) | |
1473 (dispatch-event new)))) | |
1474 | |
1475 (defun speedbar-emacs-popup-kludge (e) | |
1476 "Pop up a menu related to the clicked on item. | |
1477 Must be bound to event E." | |
1478 (interactive "e") | |
1479 (save-excursion | |
1480 (mouse-set-point e) | |
1481 ;; This gets the cursor where the user can see it. | |
1482 (if (not (bolp)) (forward-char -1)) | |
1483 (sit-for 0) | |
1484 (if (< emacs-major-version 20) | |
1485 (mouse-major-mode-menu e) | |
1486 (mouse-major-mode-menu e nil)))) | |
1487 | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1488 (defun speedbar-hack-buffer-menu (e) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1489 "Control mouse 1 is buffer menu. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1490 This hack overrides it so that the right thing happens in the main |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1491 Emacs frame, not in the speedbar frame. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1492 Argument E is the event causing this activity." |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1493 (interactive "e") |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1494 (let ((fn (lookup-key global-map (if speedbar-xemacsp |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1495 '(control button1) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1496 [C-down-mouse-1]))) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1497 (newbuff nil)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1498 (unwind-protect |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1499 (save-excursion |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1500 (set-window-dedicated-p (selected-window) nil) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1501 (call-interactively fn) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1502 (setq newbuff (current-buffer))) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1503 (switch-to-buffer " SPEEDBAR") |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1504 (set-window-dedicated-p (selected-window) t)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1505 (speedbar-with-attached-buffer |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1506 (switch-to-buffer newbuff)))) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1507 |
21650 | 1508 (defun speedbar-next (arg) |
1509 "Move to the next ARGth line in a speedbar buffer." | |
1510 (interactive "p") | |
1511 (forward-line (or arg 1)) | |
1512 (speedbar-item-info) | |
1513 (speedbar-position-cursor-on-line)) | |
1514 | |
1515 (defun speedbar-prev (arg) | |
1516 "Move to the previous ARGth line in a speedbar buffer." | |
1517 (interactive "p") | |
1518 (speedbar-next (if arg (- arg) -1))) | |
1519 | |
22735 | 1520 (defun speedbar-restricted-move (arg) |
1521 "Move to the next ARGth line in a speedbar buffer at the same depth. | |
1522 This means that movement is restricted to a subnode, and that siblings | |
1523 of intermediate nodes are skipped." | |
1524 (if (not (numberp arg)) (signal 'wrong-type-argument (list arg 'numberp))) | |
1525 ;; First find the extent for which we are allowed to move. | |
1526 (let ((depth (save-excursion (beginning-of-line) | |
1527 (if (looking-at "[0-9]+:") | |
1528 (string-to-int (match-string 0)) | |
1529 0))) | |
1530 (crement (if (< arg 0) 1 -1)) ; decrement or increment | |
1531 (lastmatch (point))) | |
1532 (while (/= arg 0) | |
1533 (forward-line (- crement)) | |
1534 (let ((subdepth (save-excursion (beginning-of-line) | |
1535 (if (looking-at "[0-9]+:") | |
1536 (string-to-int (match-string 0)) | |
1537 0)))) | |
1538 (cond ((or (< subdepth depth) | |
1539 (progn (end-of-line) (eobp)) | |
1540 (progn (beginning-of-line) (bobp))) | |
1541 ;; We have reached the end of this block. | |
1542 (goto-char lastmatch) | |
1543 (setq arg 0) | |
1544 (error "End of sub-list")) | |
1545 ((= subdepth depth) | |
1546 (setq lastmatch (point) | |
1547 arg (+ arg crement)))))) | |
1548 (speedbar-position-cursor-on-line))) | |
1549 | |
1550 (defun speedbar-restricted-next (arg) | |
1551 "Move to the next ARGth line in a speedbar buffer at the same depth. | |
1552 This means that movement is restricted to a subnode, and that siblings | |
1553 of intermediate nodes are skipped." | |
1554 (interactive "p") | |
1555 (speedbar-restricted-move (or arg 1)) | |
1556 (speedbar-item-info)) | |
1557 | |
1558 | |
1559 (defun speedbar-restricted-prev (arg) | |
1560 "Move to the previous ARGth line in a speedbar buffer at the same depth. | |
1561 This means that movement is restricted to a subnode, and that siblings | |
1562 of intermediate nodes are skipped." | |
1563 (interactive "p") | |
1564 (speedbar-restricted-move (if arg (- arg) -1)) | |
1565 (speedbar-item-info)) | |
1566 | |
1567 (defun speedbar-navigate-list (arg) | |
1568 "Move across ARG groups of similarly typed items in speedbar. | |
1569 Stop on the first line of the next type of item, or on the last or first item | |
1570 if we reach a buffer boundary." | |
1571 (interactive "p") | |
1572 (beginning-of-line) | |
1573 (if (looking-at "[0-9]+: *[[<{][-+?][]>}] ") | |
1574 (let ((str (regexp-quote (match-string 0)))) | |
1575 (while (looking-at str) | |
1576 (speedbar-restricted-move arg) | |
1577 (beginning-of-line)))) | |
1578 (speedbar-position-cursor-on-line)) | |
1579 | |
1580 (defun speedbar-forward-list () | |
1581 "Move forward over the current list. | |
1582 A LIST in speedbar is a group of similarly typed items, such as directories, | |
1583 files, or the directory button." | |
1584 (interactive) | |
1585 (speedbar-navigate-list 1) | |
1586 (speedbar-item-info)) | |
1587 | |
1588 (defun speedbar-backward-list () | |
1589 "Move backward over the current list. | |
1590 A LIST in speedbar is a group of similarly typed items, such as directories, | |
1591 files, or the directory button." | |
1592 (interactive) | |
1593 (speedbar-navigate-list -1) | |
1594 (speedbar-item-info)) | |
1595 | |
21650 | 1596 (defun speedbar-scroll-up (&optional arg) |
1597 "Page down one screen-full of the speedbar, or ARG lines." | |
1598 (interactive "P") | |
1599 (scroll-up arg) | |
1600 (speedbar-position-cursor-on-line)) | |
1601 | |
1602 (defun speedbar-scroll-down (&optional arg) | |
1603 "Page up one screen-full of the speedbar, or ARG lines." | |
1604 (interactive "P") | |
1605 (scroll-down arg) | |
1606 (speedbar-position-cursor-on-line)) | |
1607 | |
1608 (defun speedbar-up-directory () | |
1609 "Keyboard accelerator for moving the default directory up one. | |
1610 Assumes that the current buffer is the speedbar buffer" | |
1611 (interactive) | |
1612 (setq default-directory (expand-file-name (concat default-directory "../"))) | |
1613 (speedbar-update-contents)) | |
1614 | |
1615 ;;; Speedbar file activity (aka creeping featurism) | |
1616 ;; | |
1617 (defun speedbar-refresh () | |
1618 "Refresh the current speedbar display, disposing of any cached data." | |
1619 (interactive) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1620 (let ((dl speedbar-shown-directories) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1621 (dm (and (boundp 'deactivate-mark) deactivate-mark))) |
21650 | 1622 (while dl |
1623 (adelete 'speedbar-directory-contents-alist (car dl)) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1624 (setq dl (cdr dl))) |
22906
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
1625 (if (<= 1 speedbar-verbosity-level) |
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
1626 (message "Refreshing speedbar...")) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1627 (speedbar-update-contents) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1628 (speedbar-stealthy-updates) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1629 ;; Reset the timer in case it got really hosed for some reason... |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1630 (speedbar-set-timer speedbar-update-speed) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1631 (if (<= 1 speedbar-verbosity-level) |
22906
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
1632 (message "Refreshing speedbar...done")) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1633 (if (boundp 'deactivate-mark) (setq deactivate-mark dm)))) |
21650 | 1634 |
1635 (defun speedbar-item-load () | |
22735 | 1636 "Load the item under the cursor or mouse if it is a Lisp file." |
21650 | 1637 (interactive) |
1638 (let ((f (speedbar-line-file))) | |
1639 (if (and (file-exists-p f) (string-match "\\.el\\'" f)) | |
1640 (if (and (file-exists-p (concat f "c")) | |
1641 (y-or-n-p (format "Load %sc? " f))) | |
1642 ;; If the compiled version exists, load that instead... | |
1643 (load-file (concat f "c")) | |
1644 (load-file f)) | |
22735 | 1645 (error "Not a loadable file")))) |
21650 | 1646 |
1647 (defun speedbar-item-byte-compile () | |
22735 | 1648 "Byte compile the item under the cursor or mouse if it is a Lisp file." |
21650 | 1649 (interactive) |
1650 (let ((f (speedbar-line-file)) | |
1651 (sf (selected-frame))) | |
1652 (if (and (file-exists-p f) (string-match "\\.el\\'" f)) | |
1653 (progn | |
1654 (select-frame speedbar-attached-frame) | |
1655 (byte-compile-file f nil) | |
22735 | 1656 (select-frame sf) |
1657 (speedbar-reset-scanners))) | |
21650 | 1658 )) |
1659 | |
1660 (defun speedbar-mouse-item-info (event) | |
1661 "Provide information about what the user clicked on. | |
1662 This should be bound to a mouse EVENT." | |
1663 (interactive "e") | |
1664 (mouse-set-point event) | |
1665 (speedbar-item-info)) | |
1666 | |
22735 | 1667 (defun speedbar-generic-item-info () |
1668 "Attempt to derive, and then display information about thils line item. | |
1669 File style information is displayed with `speedbar-item-info'." | |
1670 (save-excursion | |
1671 (beginning-of-line) | |
1672 ;; Skip invisible number info. | |
1673 (if (looking-at "\\([0-9]+\\):") (goto-char (match-end 0))) | |
1674 ;; Skip items in "folder" type text characters. | |
1675 (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0))) | |
1676 ;; Get the text | |
1677 (message "Text: %s" (buffer-substring-no-properties | |
1678 (point) (progn (end-of-line) (point)))))) | |
1679 | |
21650 | 1680 (defun speedbar-item-info () |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1681 "Display info in the mini-buffer about the button the mouse is over. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1682 This function can be replaced in `speedbar-mode-functions-list' as |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1683 `speedbar-item-info'" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1684 (interactive) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1685 (funcall (or (speedbar-fetch-replacement-function 'speedbar-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1686 'speedbar-generic-item-info))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1687 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1688 (defun speedbar-item-info-file-helper (&optional filename) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1689 "Display info about a file that is on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1690 nil if not applicable. If FILENAME, then use that instead of reading |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1691 it from the speedbar buffer." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1692 (let* ((item (or filename (speedbar-line-file))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1693 (attr (if item (file-attributes item) nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1694 (if (and item attr) (message "%s %-6d %s" (nth 8 attr) (nth 7 attr) item) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1695 nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1696 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1697 (defun speedbar-item-info-tag-helper () |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1698 "Display info about a tag that is on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1699 nil if not applicable." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1700 (save-excursion |
24321
0e5b7bb19ddc
(speedbar-item-info-tag-helper): Scan the whole line.
Richard M. Stallman <rms@gnu.org>
parents:
24232
diff
changeset
|
1701 (beginning-of-line) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1702 (if (re-search-forward " > \\([^ ]+\\)$" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1703 (save-excursion(end-of-line)(point)) t) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1704 (let ((tag (match-string 1)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1705 (attr (get-text-property (match-beginning 1) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1706 'speedbar-token)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1707 (item nil)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1708 (looking-at "\\([0-9]+\\):") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1709 (setq item (speedbar-line-path (string-to-int (match-string 1)))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1710 (message "Tag: %s in %s @ %s" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1711 tag item (if attr |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1712 (if (markerp attr) (marker-position attr) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1713 attr) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1714 0))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1715 (if (re-search-forward "{[+-]} \\([^\n]+\\)$" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1716 (save-excursion(end-of-line)(point)) t) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1717 (message "Group of tags \"%s\"" (match-string 1)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1718 nil)))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1719 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1720 (defun speedbar-files-item-info () |
21650 | 1721 "Display info in the mini-buffer about the button the mouse is over." |
1722 (if (not speedbar-shown-directories) | |
22735 | 1723 (speedbar-generic-item-info) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1724 (or (speedbar-item-info-file-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1725 (speedbar-item-info-tag-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1726 (speedbar-generic-item-info)))) |
21650 | 1727 |
1728 (defun speedbar-item-copy () | |
1729 "Copy the item under the cursor. | |
1730 Files can be copied to new names or places." | |
1731 (interactive) | |
1732 (let ((f (speedbar-line-file))) | |
22735 | 1733 (if (not f) (error "Not a file")) |
21650 | 1734 (if (file-directory-p f) |
22735 | 1735 (error "Cannot copy directory") |
21650 | 1736 (let* ((rt (read-file-name (format "Copy %s to: " |
1737 (file-name-nondirectory f)) | |
1738 (file-name-directory f))) | |
1739 (refresh (member (expand-file-name (file-name-directory rt)) | |
1740 speedbar-shown-directories))) | |
1741 ;; Create the right file name part | |
1742 (if (file-directory-p rt) | |
1743 (setq rt | |
1744 (concat (expand-file-name rt) | |
1745 (if (string-match "/$" rt) "" "/") | |
1746 (file-name-nondirectory f)))) | |
1747 (if (or (not (file-exists-p rt)) | |
1748 (y-or-n-p (format "Overwrite %s with %s? " rt f))) | |
1749 (progn | |
1750 (copy-file f rt t t) | |
1751 ;; refresh display if the new place is currently displayed. | |
1752 (if refresh | |
1753 (progn | |
1754 (speedbar-refresh) | |
1755 (if (not (speedbar-goto-this-file rt)) | |
1756 (speedbar-goto-this-file f)))) | |
1757 )))))) | |
1758 | |
1759 (defun speedbar-item-rename () | |
1760 "Rename the item under the cursor or mouse. | |
1761 Files can be renamed to new names or moved to new directories." | |
1762 (interactive) | |
1763 (let ((f (speedbar-line-file))) | |
1764 (if f | |
1765 (let* ((rt (read-file-name (format "Rename %s to: " | |
1766 (file-name-nondirectory f)) | |
1767 (file-name-directory f))) | |
1768 (refresh (member (expand-file-name (file-name-directory rt)) | |
1769 speedbar-shown-directories))) | |
1770 ;; Create the right file name part | |
1771 (if (file-directory-p rt) | |
1772 (setq rt | |
1773 (concat (expand-file-name rt) | |
1774 (if (string-match "/\\'" rt) "" "/") | |
1775 (file-name-nondirectory f)))) | |
1776 (if (or (not (file-exists-p rt)) | |
1777 (y-or-n-p (format "Overwrite %s with %s? " rt f))) | |
1778 (progn | |
1779 (rename-file f rt t) | |
1780 ;; refresh display if the new place is currently displayed. | |
1781 (if refresh | |
1782 (progn | |
1783 (speedbar-refresh) | |
1784 (speedbar-goto-this-file rt) | |
1785 ))))) | |
22735 | 1786 (error "Not a file")))) |
21650 | 1787 |
1788 (defun speedbar-item-delete () | |
1789 "Delete the item under the cursor. Files are removed from disk." | |
1790 (interactive) | |
1791 (let ((f (speedbar-line-file))) | |
22735 | 1792 (if (not f) (error "Not a file")) |
21650 | 1793 (if (y-or-n-p (format "Delete %s? " f)) |
1794 (progn | |
1795 (if (file-directory-p f) | |
1796 (delete-directory f) | |
1797 (delete-file f)) | |
1798 (message "Okie dokie..") | |
1799 (let ((p (point))) | |
1800 (speedbar-refresh) | |
1801 (goto-char p)) | |
1802 )) | |
1803 )) | |
1804 | |
22735 | 1805 (defun speedbar-item-object-delete () |
1806 "Delete the object associated from the item under the cursor. | |
1807 The file is removed from disk. The object is determined from the | |
1808 variable `speedbar-obj-alist'." | |
1809 (interactive) | |
1810 (let* ((f (speedbar-line-file)) | |
1811 (obj nil) | |
1812 (oa speedbar-obj-alist)) | |
1813 (if (not f) (error "Not a file")) | |
1814 (while (and oa (not (string-match (car (car oa)) f))) | |
1815 (setq oa (cdr oa))) | |
1816 (setq obj (concat (file-name-sans-extension f) (cdr (car oa)))) | |
1817 (if (and oa (file-exists-p obj) | |
1818 (y-or-n-p (format "Delete %s? " obj))) | |
1819 (progn | |
1820 (delete-file obj) | |
1821 (speedbar-reset-scanners))))) | |
1822 | |
21650 | 1823 (defun speedbar-enable-update () |
1824 "Enable automatic updating in speedbar via timers." | |
1825 (interactive) | |
1826 (setq speedbar-update-flag t) | |
1827 (speedbar-set-mode-line-format) | |
1828 (speedbar-set-timer speedbar-update-speed)) | |
1829 | |
1830 (defun speedbar-disable-update () | |
1831 "Disable automatic updating and stop consuming resources." | |
1832 (interactive) | |
1833 (setq speedbar-update-flag nil) | |
1834 (speedbar-set-mode-line-format) | |
1835 (speedbar-set-timer nil)) | |
1836 | |
1837 (defun speedbar-toggle-updates () | |
1838 "Toggle automatic update for the speedbar frame." | |
1839 (interactive) | |
1840 (if speedbar-update-flag | |
1841 (speedbar-disable-update) | |
1842 (speedbar-enable-update))) | |
1843 | |
1844 (defun speedbar-toggle-sorting () | |
1845 "Toggle automatic update for the speedbar frame." | |
1846 (interactive) | |
1847 (setq speedbar-sort-tags (not speedbar-sort-tags))) | |
1848 | |
1849 (defun speedbar-toggle-show-all-files () | |
1850 "Toggle display of files speedbar can not tag." | |
1851 (interactive) | |
1852 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files)) | |
1853 (speedbar-refresh)) | |
1854 | |
1855 ;;; Utility functions | |
1856 ;; | |
1857 (defun speedbar-set-timer (timeout) | |
1858 "Apply a timer with TIMEOUT, or remove a timer if TIMOUT is nil. | |
1859 TIMEOUT is the number of seconds until the speedbar timer is called | |
1860 again. When TIMEOUT is nil, turn off all timeouts. | |
1861 This function will also enable or disable the `vc-checkin-hook' used | |
1862 to track file check ins, and will change the mode line to match | |
1863 `speedbar-update-flag'." | |
1864 (cond | |
1865 ;; XEmacs | |
1866 (speedbar-xemacsp | |
1867 (if speedbar-timer | |
1868 (progn (delete-itimer speedbar-timer) | |
1869 (setq speedbar-timer nil))) | |
1870 (if timeout | |
1871 (if (and speedbar-xemacsp | |
1872 (or (>= emacs-major-version 20) | |
1873 (>= emacs-minor-version 15))) | |
1874 (setq speedbar-timer (start-itimer "speedbar" | |
1875 'speedbar-timer-fn | |
1876 timeout | |
1877 timeout | |
1878 t)) | |
1879 (setq speedbar-timer (start-itimer "speedbar" | |
1880 'speedbar-timer-fn | |
1881 timeout | |
1882 nil))))) | |
1883 ;; Post 19.31 Emacs | |
1884 ((fboundp 'run-with-idle-timer) | |
1885 (if speedbar-timer | |
1886 (progn (cancel-timer speedbar-timer) | |
1887 (setq speedbar-timer nil))) | |
1888 (if timeout | |
1889 (setq speedbar-timer | |
1890 (run-with-idle-timer timeout t 'speedbar-timer-fn)))) | |
1891 ;; Emacs 19.30 (Thanks twice: ptype@dra.hmg.gb) | |
1892 ((fboundp 'post-command-idle-hook) | |
1893 (if timeout | |
1894 (add-hook 'post-command-idle-hook 'speedbar-timer-fn) | |
1895 (remove-hook 'post-command-idle-hook 'speedbar-timer-fn))) | |
1896 ;; Older or other Emacsen with no timers. Set up so that its | |
1897 ;; obvious this emacs can't handle the updates | |
1898 (t | |
1899 (setq speedbar-update-flag nil))) | |
1900 ;; Apply a revert hook that will reset the scanners. We attach to revert | |
1901 ;; because most reverts occur during VC state change, and this lets our | |
1902 ;; VC scanner fix itself. | |
1903 (if timeout | |
1904 (add-hook 'after-revert-hook 'speedbar-reset-scanners) | |
1905 (remove-hook 'after-revert-hook 'speedbar-reset-scanners) | |
1906 ) | |
1907 ;; change this if it changed for some reason | |
1908 (speedbar-set-mode-line-format)) | |
1909 | |
1910 (defmacro speedbar-with-writable (&rest forms) | |
1911 "Allow the buffer to be writable and evaluate FORMS." | |
1912 (list 'let '((inhibit-read-only t)) | |
1913 (cons 'progn forms))) | |
1914 (put 'speedbar-with-writable 'lisp-indent-function 0) | |
1915 | |
1916 (defun speedbar-select-window (buffer) | |
22735 | 1917 "Select a window in which BUFFER is shown. |
21650 | 1918 If it is not shown, force it to appear in the default window." |
1919 (let ((win (get-buffer-window buffer speedbar-attached-frame))) | |
1920 (if win | |
1921 (select-window win) | |
22735 | 1922 (set-window-buffer (selected-window) buffer)))) |
21650 | 1923 |
1924 (defmacro speedbar-with-attached-buffer (&rest forms) | |
1925 "Execute FORMS in the attached frame's special buffer. | |
1926 Optionally select that frame if necessary." | |
1927 ;; Reset the timer with a new timeout when cliking a file | |
1928 ;; in case the user was navigating directories, we can cancel | |
1929 ;; that other timer. | |
1930 (list | |
1931 'progn | |
1932 '(speedbar-set-timer speedbar-update-speed) | |
1933 (list | |
1934 'let '((cf (selected-frame))) | |
1935 '(select-frame speedbar-attached-frame) | |
1936 '(speedbar-select-window speedbar-desired-buffer) | |
1937 (cons 'progn forms) | |
1938 '(select-frame cf) | |
1939 '(speedbar-maybee-jump-to-attached-frame) | |
1940 ))) | |
1941 | |
1942 (defun speedbar-insert-button (text face mouse function | |
1943 &optional token prevline) | |
1944 "Insert TEXT as the next logical speedbar button. | |
1945 FACE is the face to put on the button, MOUSE is the highlight face to use. | |
1946 When the user clicks on TEXT, FUNCTION is called with the TOKEN parameter. | |
1947 This function assumes that the current buffer is the speedbar buffer. | |
1948 If PREVLINE, then put this button on the previous line. | |
1949 | |
1950 This is a convenience function for special mode that create their own | |
1951 specialized speedbar displays." | |
1952 (goto-char (point-max)) | |
1953 (if (/= (current-column) 0) (insert "\n")) | |
1954 (if prevline (progn (delete-char -1) (insert " "))) ;back up if desired... | |
1955 (let ((start (point))) | |
1956 (insert text) | |
1957 (speedbar-make-button start (point) face mouse function token)) | |
1958 (let ((start (point))) | |
1959 (insert "\n") | |
1960 (put-text-property start (point) 'face nil) | |
1961 (put-text-property start (point) 'mouse-face nil))) | |
1962 | |
1963 (defun speedbar-make-button (start end face mouse function &optional token) | |
1964 "Create a button from START to END, with FACE as the display face. | |
1965 MOUSE is the mouse face. When this button is clicked on FUNCTION | |
22735 | 1966 will be run with the TOKEN parameter (any Lisp object)" |
21650 | 1967 (put-text-property start end 'face face) |
1968 (put-text-property start end 'mouse-face mouse) | |
1969 (put-text-property start end 'invisible nil) | |
1970 (if function (put-text-property start end 'speedbar-function function)) | |
1971 (if token (put-text-property start end 'speedbar-token token)) | |
1972 ) | |
1973 | |
22735 | 1974 ;;; Initial Expansion list management |
1975 ;; | |
1976 (defun speedbar-initial-expansion-list () | |
1977 "Return the current default expansion list. | |
1978 This is based on `speedbar-initial-expansion-list-name' referencing | |
1979 `speedbar-initial-expansion-mode-alist'." | |
1980 ;; cdr1 - name, cdr2 - menu | |
1981 (cdr (cdr (cdr (assoc speedbar-initial-expansion-list-name | |
1982 speedbar-initial-expansion-mode-alist))))) | |
1983 | |
1984 (defun speedbar-initial-menu () | |
1985 "Return the current default menu data. | |
1986 This is based on `speedbar-initial-expansion-list-name' referencing | |
1987 `speedbar-initial-expansion-mode-alist'." | |
1988 (symbol-value | |
1989 (car (cdr (assoc speedbar-initial-expansion-list-name | |
1990 speedbar-initial-expansion-mode-alist))))) | |
1991 | |
1992 (defun speedbar-initial-keymap () | |
1993 "Return the current default menu data. | |
1994 This is based on `speedbar-initial-expansion-list-name' referencing | |
1995 `speedbar-initial-expansion-mode-alist'." | |
1996 (symbol-value | |
1997 (car (cdr (cdr (assoc speedbar-initial-expansion-list-name | |
1998 speedbar-initial-expansion-mode-alist)))))) | |
1999 | |
2000 (defun speedbar-initial-stealthy-functions () | |
2001 "Return a list of functions to call stealthily. | |
2002 This is based on `speedbar-initial-expansion-list-name' referencing | |
2003 `speedbar-stealthy-function-list'." | |
2004 (cdr (assoc speedbar-initial-expansion-list-name | |
2005 speedbar-stealthy-function-list))) | |
2006 | |
2007 (defun speedbar-add-expansion-list (new-list) | |
2008 "Add NEW-LIST to the list of expansion lists." | |
2009 (add-to-list 'speedbar-initial-expansion-mode-alist new-list)) | |
2010 | |
2011 (defun speedbar-change-initial-expansion-list (new-default) | |
2012 "Change speedbar's default expansion list to NEW-DEFAULT." | |
2013 (interactive | |
2014 (list | |
2015 (completing-read (format "Speedbar Mode (default %s): " | |
2016 speedbar-previously-used-expansion-list-name) | |
2017 speedbar-initial-expansion-mode-alist | |
2018 nil t "" nil | |
2019 speedbar-previously-used-expansion-list-name))) | |
2020 (setq speedbar-previously-used-expansion-list-name | |
2021 speedbar-initial-expansion-list-name | |
2022 speedbar-initial-expansion-list-name new-default) | |
2023 (speedbar-refresh) | |
2024 (speedbar-reconfigure-keymaps)) | |
2025 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2026 (defun speedbar-fetch-replacement-function (function) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2027 "Return a current mode specific replacement for function, or nil. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2028 Scans `speedbar-mode-functions-list' first for the current mode, then |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2029 for FUNCTION." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2030 (cdr (assoc function |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2031 (cdr (assoc speedbar-initial-expansion-list-name |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2032 speedbar-mode-functions-list))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2033 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2034 (defun speedbar-add-mode-functions-list (new-list) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2035 "Add NEW-LIST to the list of mode functions. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2036 See `speedbar-mode-functions-list' for details." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2037 (add-to-list 'speedbar-mode-functions-list new-list)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2038 |
22735 | 2039 |
2040 ;;; Special speedbar display management | |
2041 ;; | |
2042 (defun speedbar-maybe-add-localized-support (buffer) | |
2043 "Quick check function called on BUFFERs by the speedbar timer function. | |
2044 Maintains the value of local variables which control speedbars use | |
2045 of the special mode functions." | |
2046 (or speedbar-special-mode-expansion-list | |
2047 (speedbar-add-localized-speedbar-support buffer))) | |
2048 | |
2049 (defun speedbar-add-localized-speedbar-support (buffer) | |
2050 "Add localized speedbar support to BUFFER's mode if it is available." | |
2051 (interactive "bBuffer: ") | |
2052 (if (stringp buffer) (setq buffer (get-buffer buffer))) | |
2053 (if (not (buffer-live-p buffer)) | |
2054 nil | |
2055 (save-excursion | |
2056 (set-buffer buffer) | |
2057 (save-match-data | |
2058 (let ((ms (symbol-name major-mode)) v) | |
2059 (if (not (string-match "-mode$" ms)) | |
2060 nil ;; do nothing to broken mode | |
2061 (setq ms (substring ms 0 (match-beginning 0))) | |
2062 (setq v (intern-soft (concat ms "-speedbar-buttons"))) | |
2063 (make-local-variable 'speedbar-special-mode-expansion-list) | |
2064 (if (not v) | |
2065 (setq speedbar-special-mode-expansion-list t) | |
2066 ;; If it is autoloaded, we need to load it now so that | |
2067 ;; we have access to the varialbe -speedbar-menu-items. | |
2068 ;; Is this XEmacs safe? | |
2069 (let ((sf (symbol-function v))) | |
2070 (if (and (listp sf) (eq (car sf) 'autoload)) | |
2071 (load-library (car (cdr sf))))) | |
2072 (setq speedbar-special-mode-expansion-list (list v)) | |
2073 (setq v (intern-soft (concat ms "-speedbar-key-map"))) | |
2074 (if (not v) | |
2075 nil ;; don't add special keymap | |
2076 (make-local-variable 'speedbar-special-mode-key-map) | |
2077 (setq speedbar-special-mode-key-map | |
2078 (symbol-value v))) | |
2079 (setq v (intern-soft (concat ms "-speedbar-menu-items"))) | |
2080 (if (not v) | |
2081 nil ;; don't add special menus | |
2082 (make-local-variable 'speedbar-easymenu-definition-special) | |
2083 (setq speedbar-easymenu-definition-special | |
2084 (symbol-value v))) | |
2085 ))))))) | |
2086 | |
2087 (defun speedbar-remove-localized-speedbar-support (buffer) | |
2088 "Remove any traces that BUFFER supports speedbar in a specialized way." | |
2089 (save-excursion | |
2090 (set-buffer buffer) | |
2091 (kill-local-variable 'speedbar-special-mode-expansion-list) | |
2092 (kill-local-variable 'speedbar-special-mode-key-map) | |
2093 (kill-local-variable 'speedbar-easymenu-definition-special))) | |
2094 | |
21650 | 2095 ;;; File button management |
2096 ;; | |
2097 (defun speedbar-file-lists (directory) | |
2098 "Create file lists for DIRECTORY. | |
2099 The car is the list of directories, the cdr is list of files not | |
2100 matching ignored headers. Cache any directory files found in | |
2101 `speedbar-directory-contents-alist' and use that cache before scanning | |
2102 the file-system" | |
2103 (setq directory (expand-file-name directory)) | |
2104 ;; If in powerclick mode, then the directory we are getting | |
2105 ;; should be rescanned. | |
2106 (if speedbar-power-click | |
2107 (adelete 'speedbar-directory-contents-alist directory)) | |
2108 ;; find the directory, either in the cache, or build it. | |
2109 (or (cdr-safe (assoc directory speedbar-directory-contents-alist)) | |
2110 (let ((default-directory directory) | |
2111 (dir (directory-files directory nil)) | |
2112 (dirs nil) | |
2113 (files nil)) | |
2114 (while dir | |
22735 | 2115 (if (not |
2116 (or (string-match speedbar-file-unshown-regexp (car dir)) | |
2117 (string-match speedbar-directory-unshown-regexp (car dir)))) | |
21650 | 2118 (if (file-directory-p (car dir)) |
2119 (setq dirs (cons (car dir) dirs)) | |
2120 (setq files (cons (car dir) files)))) | |
2121 (setq dir (cdr dir))) | |
2122 (let ((nl (cons (nreverse dirs) (list (nreverse files))))) | |
2123 (aput 'speedbar-directory-contents-alist directory nl) | |
2124 nl)) | |
2125 )) | |
2126 | |
2127 (defun speedbar-directory-buttons (directory index) | |
2128 "Insert a single button group at point for DIRECTORY. | |
2129 Each directory path part is a different button. If part of the path | |
2130 matches the user directory ~, then it is replaced with a ~. | |
2131 INDEX is not used, but is required by the caller." | |
2132 (let* ((tilde (expand-file-name "~")) | |
2133 (dd (expand-file-name directory)) | |
2134 (junk (string-match (regexp-quote tilde) dd)) | |
2135 (displayme (if junk | |
2136 (concat "~" (substring dd (match-end 0))) | |
2137 dd)) | |
2138 (p (point))) | |
2139 (if (string-match "^~/?\\'" displayme) (setq displayme (concat tilde "/"))) | |
2140 (insert displayme) | |
2141 (save-excursion | |
2142 (goto-char p) | |
2143 (while (re-search-forward "\\([^/]+\\)/" nil t) | |
2144 (speedbar-make-button (match-beginning 1) (match-end 1) | |
2145 'speedbar-directory-face | |
2146 'speedbar-highlight-face | |
2147 'speedbar-directory-buttons-follow | |
2148 (if (= (match-beginning 1) p) | |
2149 (expand-file-name "~/") ;the tilde | |
2150 (buffer-substring-no-properties | |
2151 p (match-end 0))))) | |
2152 ;; Nuke the beginning of the directory if it's too long... | |
2153 (cond ((eq speedbar-directory-button-trim-method 'span) | |
2154 (beginning-of-line) | |
2155 (let ((ww (or (speedbar-frame-width) 20))) | |
2156 (move-to-column ww nil) | |
2157 (while (>= (current-column) ww) | |
2158 (re-search-backward "/" nil t) | |
2159 (if (<= (current-column) 2) | |
2160 (progn | |
2161 (re-search-forward "/" nil t) | |
2162 (if (< (current-column) 4) | |
2163 (re-search-forward "/" nil t)) | |
2164 (forward-char -1))) | |
2165 (if (looking-at "/?$") | |
2166 (beginning-of-line) | |
2167 (insert "/...\n ") | |
2168 (move-to-column ww nil))))) | |
2169 ((eq speedbar-directory-button-trim-method 'trim) | |
2170 (end-of-line) | |
2171 (let ((ww (or (speedbar-frame-width) 20)) | |
2172 (tl (current-column))) | |
2173 (if (< ww tl) | |
2174 (progn | |
2175 (move-to-column (- tl ww)) | |
2176 (if (re-search-backward "/" nil t) | |
2177 (progn | |
2178 (delete-region (point-min) (point)) | |
2179 (insert "$") | |
2180 ))))))) | |
2181 ) | |
2182 (if (string-match "\\`/[^/]+/\\'" displayme) | |
2183 (progn | |
2184 (insert " ") | |
2185 (let ((p (point))) | |
2186 (insert "<root>") | |
2187 (speedbar-make-button p (point) | |
2188 'speedbar-directory-face | |
2189 'speedbar-highlight-face | |
2190 'speedbar-directory-buttons-follow | |
2191 "/")))) | |
2192 (end-of-line) | |
2193 (insert-char ?\n 1 nil))) | |
2194 | |
2195 (defun speedbar-make-tag-line (exp-button-type | |
2196 exp-button-char exp-button-function | |
2197 exp-button-data | |
2198 tag-button tag-button-function tag-button-data | |
2199 tag-button-face depth) | |
2200 "Create a tag line with EXP-BUTTON-TYPE for the small expansion button. | |
2201 This is the button that expands or contracts a node (if applicable), | |
2202 and EXP-BUTTON-CHAR the character in it (+, -, ?, etc). EXP-BUTTON-FUNCTION | |
2203 is the function to call if it's clicked on. Button types are | |
2204 'bracket, 'angle, 'curly, or nil. EXP-BUTTON-DATA is extra data | |
2205 attached to the text forming the expansion button. | |
2206 | |
2207 Next, TAG-BUTTON is the text of the tag. TAG-BUTTON-FUNCTION is the | |
2208 function to call if clicked on, and TAG-BUTTON-DATA is the data to | |
2209 attach to the text field (such a tag positioning, etc). | |
2210 TAG-BUTTON-FACE is a face used for this type of tag. | |
2211 | |
2212 Lastly, DEPTH shows the depth of expansion. | |
2213 | |
2214 This function assumes that the cursor is in the speedbar window at the | |
2215 position to insert a new item, and that the new item will end with a CR" | |
2216 (let ((start (point)) | |
2217 (end (progn | |
2218 (insert (int-to-string depth) ":") | |
2219 (point)))) | |
2220 (put-text-property start end 'invisible t) | |
2221 ) | |
2222 (insert-char ? depth nil) | |
2223 (put-text-property (- (point) depth) (point) 'invisible nil) | |
2224 (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]") | |
2225 ((eq exp-button-type 'angle) "<%c>") | |
2226 ((eq exp-button-type 'curly) "{%c}") | |
2227 (t ">"))) | |
2228 (buttxt (format exp-button exp-button-char)) | |
2229 (start (point)) | |
2230 (end (progn (insert buttxt) (point))) | |
2231 (bf (if exp-button-type 'speedbar-button-face nil)) | |
2232 (mf (if exp-button-function 'speedbar-highlight-face nil)) | |
2233 ) | |
2234 (speedbar-make-button start end bf mf exp-button-function exp-button-data) | |
22735 | 2235 (if speedbar-hide-button-brackets-flag |
2236 (progn | |
2237 (put-text-property start (1+ start) 'invisible t) | |
2238 (put-text-property end (1- end) 'invisible t))) | |
21650 | 2239 ) |
2240 (insert-char ? 1 nil) | |
2241 (put-text-property (1- (point)) (point) 'invisible nil) | |
2242 (let ((start (point)) | |
2243 (end (progn (insert tag-button) (point)))) | |
2244 (insert-char ?\n 1 nil) | |
2245 (put-text-property (1- (point)) (point) 'invisible nil) | |
2246 (speedbar-make-button start end tag-button-face | |
2247 (if tag-button-function 'speedbar-highlight-face nil) | |
2248 tag-button-function tag-button-data)) | |
2249 ) | |
2250 | |
2251 (defun speedbar-change-expand-button-char (char) | |
2252 "Change the expansion button character to CHAR for the current line." | |
2253 (save-excursion | |
2254 (beginning-of-line) | |
2255 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line) | |
2256 (point)) t) | |
2257 (speedbar-with-writable | |
2258 (goto-char (match-beginning 1)) | |
2259 (delete-char 1) | |
22735 | 2260 (insert-char char 1 t) |
2261 (put-text-property (point) (1- (point)) 'invisible nil))))) | |
21650 | 2262 |
2263 | |
2264 ;;; Build button lists | |
2265 ;; | |
2266 (defun speedbar-insert-files-at-point (files level) | |
2267 "Insert list of FILES starting at point, and indenting all files to LEVEL. | |
2268 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we | |
2269 don't know how to manage them. The input parameter FILES is a cons | |
22735 | 2270 cell of the form ( 'DIRLIST . 'FILELIST )" |
21650 | 2271 ;; Start inserting all the directories |
2272 (let ((dirs (car files))) | |
2273 (while dirs | |
2274 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs) | |
2275 (car dirs) 'speedbar-dir-follow nil | |
2276 'speedbar-directory-face level) | |
2277 (setq dirs (cdr dirs)))) | |
22735 | 2278 (let ((lst (car (cdr files))) |
2279 (case-fold-search t)) | |
21650 | 2280 (while lst |
2281 (let* ((known (string-match speedbar-file-regexp (car lst))) | |
2282 (expchar (if known ?+ ??)) | |
2283 (fn (if known 'speedbar-tag-file nil))) | |
2284 (if (or speedbar-show-unknown-files (/= expchar ??)) | |
2285 (speedbar-make-tag-line 'bracket expchar fn (car lst) | |
2286 (car lst) 'speedbar-find-file nil | |
2287 'speedbar-file-face level))) | |
2288 (setq lst (cdr lst))))) | |
2289 | |
2290 (defun speedbar-default-directory-list (directory index) | |
2291 "Insert files for DIRECTORY with level INDEX at point." | |
2292 (speedbar-insert-files-at-point | |
2293 (speedbar-file-lists directory) index) | |
2294 (speedbar-reset-scanners) | |
2295 (if (= index 0) | |
2296 ;; If the shown files variable has extra directories, then | |
2297 ;; it is our responsibility to redraw them all | |
2298 ;; Luckilly, the nature of inserting items into this list means | |
2299 ;; that by reversing it, we can easilly go in the right order | |
2300 (let ((sf (cdr (reverse speedbar-shown-directories)))) | |
2301 (setq speedbar-shown-directories | |
2302 (list (expand-file-name default-directory))) | |
2303 ;; exand them all as we find them | |
2304 (while sf | |
2305 (if (speedbar-goto-this-file (car sf)) | |
2306 (progn | |
2307 (beginning-of-line) | |
2308 (if (looking-at "[0-9]+:[ ]*<") | |
2309 (progn | |
2310 (goto-char (match-end 0)) | |
2311 (speedbar-do-function-pointer))) | |
2312 (setq sf (cdr sf))))) | |
2313 ))) | |
2314 | |
22735 | 2315 (defun speedbar-apply-one-tag-hierarchy-method (lst method) |
2316 "Adjust the tag hierarchy LST by METHOD." | |
2317 (cond | |
2318 ((eq method 'sort) | |
2319 (sort (copy-alist lst) | |
2320 (lambda (a b) (string< (car a) (car b))))) | |
2321 ((eq method 'prefix-group) | |
2322 (let ((newlst nil) | |
2323 (sublst nil) | |
2324 (work-list nil) | |
2325 (junk-list nil) | |
2326 (short-group-list nil) | |
2327 (short-start-name nil) | |
2328 (short-end-name nil) | |
2329 (num-shorts-grouped 0) | |
2330 (bins (make-vector 256 nil)) | |
2331 (diff-idx 0)) | |
2332 ;; Break out sub-lists | |
2333 (while lst | |
2334 (if (listp (cdr-safe (car-safe lst))) | |
2335 (setq newlst (cons (car lst) newlst)) | |
2336 (setq sublst (cons (car lst) sublst))) | |
2337 (setq lst (cdr lst))) | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2338 ;; Reverse newlst because it was made backwards. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2339 ;; Sublist doesn't need reversing because the act |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2340 ;; of binning things will reverse it for us. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2341 (setq newlst (nreverse newlst)) |
22735 | 2342 ;; Now, first find out how long our list is. Never let a |
2343 ;; list get-shorter than our minimum. | |
2344 (if (<= (length sublst) speedbar-tag-split-minimum-length) | |
2345 (setq work-list (nreverse sublst)) | |
2346 (setq diff-idx (length (try-completion "" sublst))) | |
2347 ;; Sort the whole list into bins. | |
2348 (while sublst | |
2349 (let ((e (car sublst)) | |
2350 (s (car (car sublst)))) | |
2351 (cond ((<= (length s) diff-idx) | |
2352 ;; 0 storage bin for shorty. | |
2353 (aset bins 0 (cons e (aref bins 0)))) | |
2354 (t | |
2355 ;; stuff into a bin based on ascii value at diff | |
2356 (aset bins (aref s diff-idx) | |
2357 (cons e (aref bins (aref s diff-idx))))))) | |
2358 (setq sublst (cdr sublst))) | |
2359 ;; Go through all our bins Stick singles into our | |
2360 ;; junk-list, everything else as sublsts in work-list. | |
2361 ;; If two neighboring lists are both small, make a grouped | |
2362 ;; group combinding those two sub-lists. | |
2363 (setq diff-idx 0) | |
2364 (while (> 256 diff-idx) | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2365 (let ((l (nreverse ;; Reverse the list since they are stuck in |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2366 ;; backwards. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2367 (aref bins diff-idx)))) |
22735 | 2368 (if l |
2369 (let ((tmp (cons (try-completion "" l) l))) | |
2370 (if (or (> (length l) speedbar-tag-regroup-maximum-length) | |
2371 (> (+ (length l) (length short-group-list)) | |
2372 speedbar-tag-split-minimum-length)) | |
2373 (progn | |
2374 ;; We have reached a longer list, so we | |
2375 ;; must finish off a grouped group. | |
2376 (cond | |
2377 ((and short-group-list | |
2378 (= (length short-group-list) | |
2379 num-shorts-grouped)) | |
2380 ;; All singles? Junk list | |
2381 (setq junk-list (append short-group-list | |
2382 junk-list))) | |
2383 ((= num-shorts-grouped 1) | |
2384 ;; Only one short group? Just stick it in | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2385 ;; there by itself. Make a group, and find |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2386 ;; a subexpression |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2387 (let ((subexpression (try-completion |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2388 "" short-group-list))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2389 (if (< (length subexpression) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2390 speedbar-tag-group-name-minimum-length) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2391 (setq subexpression |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2392 (concat short-start-name |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2393 " (" |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2394 (substring |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2395 (car (car short-group-list)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2396 (length short-start-name)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2397 ")"))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2398 (setq work-list |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2399 (cons (cons subexpression |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2400 short-group-list) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2401 work-list)))) |
22735 | 2402 (short-group-list |
2403 ;; Multiple groups to be named in a special | |
2404 ;; way by displaying the range over which we | |
2405 ;; have grouped them. | |
2406 (setq work-list | |
2407 (cons (cons (concat short-start-name | |
2408 " to " | |
2409 short-end-name) | |
2410 (nreverse short-group-list)) | |
2411 work-list)))) | |
2412 ;; Reset short group list information every time. | |
2413 (setq short-group-list nil | |
2414 short-start-name nil | |
2415 short-end-name nil | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2416 num-shorts-grouped 0))) |
22735 | 2417 ;; Ok, now that we cleaned up the short-group-list, |
2418 ;; we can deal with this new list, to decide if it | |
2419 ;; should go on one of these sub-lists or not. | |
2420 (if (< (length l) speedbar-tag-regroup-maximum-length) | |
2421 (setq short-group-list (append short-group-list l) | |
2422 num-shorts-grouped (1+ num-shorts-grouped) | |
2423 short-end-name (car tmp) | |
2424 short-start-name (if short-start-name | |
2425 short-start-name | |
2426 (car tmp))) | |
2427 (setq work-list (cons tmp work-list)))))) | |
2428 (setq diff-idx (1+ diff-idx)))) | |
2429 ;; Did we run out of things? Drop our new list onto the end. | |
2430 (cond | |
2431 ((and short-group-list (= (length short-group-list) num-shorts-grouped)) | |
2432 ;; All singles? Junk list | |
2433 (setq junk-list (append short-group-list junk-list))) | |
2434 ((= num-shorts-grouped 1) | |
2435 ;; Only one short group? Just stick it in | |
2436 ;; there by itself. | |
2437 (setq work-list | |
2438 (cons (cons (try-completion "" short-group-list) | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2439 short-group-list) |
22735 | 2440 work-list))) |
2441 (short-group-list | |
2442 ;; Multiple groups to be named in a special | |
2443 ;; way by displaying the range over which we | |
2444 ;; have grouped them. | |
2445 (setq work-list | |
2446 (cons (cons (concat short-start-name " to " short-end-name) | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2447 short-group-list) |
22735 | 2448 work-list)))) |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2449 ;; Reverse the work list nreversed when consing. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2450 (setq work-list (nreverse work-list)) |
22735 | 2451 ;; Now, stick our new list onto the end of |
2452 (if work-list | |
2453 (if junk-list | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2454 (append newlst work-list junk-list) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2455 (append newlst work-list)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2456 (append newlst junk-list)))) |
22735 | 2457 ((eq method 'trim-words) |
2458 (let ((newlst nil) | |
2459 (sublst nil) | |
2460 (trim-prefix nil) | |
2461 (trim-chars 0) | |
2462 (trimlst nil)) | |
2463 (while lst | |
2464 (if (listp (cdr-safe (car-safe lst))) | |
2465 (setq newlst (cons (car lst) newlst)) | |
2466 (setq sublst (cons (car lst) sublst))) | |
2467 (setq lst (cdr lst))) | |
2468 ;; Get the prefix to trim by. Make sure that we don't trim | |
2469 ;; off silly pieces, only complete understandable words. | |
2470 (setq trim-prefix (try-completion "" sublst)) | |
2471 (if (or (= (length sublst) 1) | |
2472 (not trim-prefix) | |
2473 (not (string-match "\\(\\w+\\W+\\)+" trim-prefix))) | |
2474 (append (nreverse newlst) (nreverse sublst)) | |
2475 (setq trim-prefix (substring trim-prefix (match-beginning 0) | |
2476 (match-end 0))) | |
2477 (setq trim-chars (length trim-prefix)) | |
2478 (while sublst | |
2479 (setq trimlst (cons | |
2480 (cons (substring (car (car sublst)) trim-chars) | |
2481 (cdr (car sublst))) | |
2482 trimlst) | |
2483 sublst (cdr sublst))) | |
2484 ;; Put the lists together | |
2485 (append (nreverse newlst) trimlst)))) | |
2486 ((eq method 'simple-group) | |
2487 (let ((newlst nil) | |
2488 (sublst nil)) | |
2489 (while lst | |
2490 (if (listp (cdr-safe (car-safe lst))) | |
2491 (setq newlst (cons (car lst) newlst)) | |
2492 (setq sublst (cons (car lst) sublst))) | |
2493 (setq lst (cdr lst))) | |
2494 (if (not newlst) | |
2495 (nreverse sublst) | |
2496 (setq newlst (cons (cons "Tags" (nreverse sublst)) newlst)) | |
2497 (nreverse newlst)))) | |
2498 (t lst))) | |
2499 | |
2500 (defun speedbar-create-tag-hierarchy (lst) | |
2501 "Adjust the tag hierarchy in LST, and return it. | |
2502 This uses `speedbar-tag-hierarchy-method' to determine how to adjust | |
2503 the list. See it's value for details." | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2504 (let* ((f (save-excursion |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2505 (forward-line -1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2506 (speedbar-line-path))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2507 (methods (if (get-file-buffer f) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2508 (save-excursion (set-buffer (get-file-buffer f)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2509 speedbar-tag-hierarchy-method) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2510 speedbar-tag-hierarchy-method))) |
22735 | 2511 (while methods |
2512 (setq lst (speedbar-apply-one-tag-hierarchy-method lst (car methods)) | |
2513 methods (cdr methods))) | |
2514 lst)) | |
2515 | |
21650 | 2516 (defun speedbar-insert-generic-list (level lst expand-fun find-fun) |
2517 "At LEVEL, insert a generic multi-level alist LST. | |
2518 Associations with lists get {+} tags (to expand into more nodes) and | |
2519 those with positions just get a > as the indicator. {+} buttons will | |
2520 have the function EXPAND-FUN and the token is the CDR list. The token | |
2521 name will have the function FIND-FUN and not token." | |
2522 ;; Remove imenu rescan button | |
2523 (if (string= (car (car lst)) "*Rescan*") | |
2524 (setq lst (cdr lst))) | |
22735 | 2525 ;; Adjust the list. |
2526 (setq lst (speedbar-create-tag-hierarchy lst)) | |
21650 | 2527 ;; insert the parts |
2528 (while lst | |
2529 (cond ((null (car-safe lst)) nil) ;this would be a separator | |
2530 ((or (numberp (cdr-safe (car-safe lst))) | |
2531 (markerp (cdr-safe (car-safe lst)))) | |
2532 (speedbar-make-tag-line nil nil nil nil ;no expand button data | |
2533 (car (car lst)) ;button name | |
2534 find-fun ;function | |
2535 (cdr (car lst)) ;token is position | |
2536 'speedbar-tag-face | |
2537 (1+ level))) | |
2538 ((listp (cdr-safe (car-safe lst))) | |
2539 (speedbar-make-tag-line 'curly ?+ expand-fun (cdr (car lst)) | |
2540 (car (car lst)) ;button name | |
2541 nil nil 'speedbar-tag-face | |
2542 (1+ level))) | |
2543 (t (message "Ooops!"))) | |
2544 (setq lst (cdr lst)))) | |
2545 | |
2546 ;;; Timed functions | |
2547 ;; | |
2548 (defun speedbar-update-contents () | |
2549 "Generically update the contents of the speedbar buffer." | |
2550 (interactive) | |
2551 ;; Set the current special buffer | |
2552 (setq speedbar-desired-buffer nil) | |
22735 | 2553 ;; Check for special modes |
2554 (speedbar-maybe-add-localized-support (current-buffer)) | |
2555 ;; Choose the correct method of doodling. | |
21650 | 2556 (if (and speedbar-mode-specific-contents-flag |
22735 | 2557 (listp speedbar-special-mode-expansion-list) |
21650 | 2558 speedbar-special-mode-expansion-list |
2559 (local-variable-p | |
2560 'speedbar-special-mode-expansion-list | |
2561 (current-buffer))) | |
2562 ;;(eq (get major-mode 'mode-class 'special))) | |
2563 (speedbar-update-special-contents) | |
2564 (speedbar-update-directory-contents))) | |
2565 | |
2566 (defun speedbar-update-directory-contents () | |
2567 "Update the contents of the speedbar buffer based on the current directory." | |
2568 (let ((cbd (expand-file-name default-directory)) | |
2569 cbd-parent | |
22735 | 2570 (funclst (speedbar-initial-expansion-list)) |
21650 | 2571 (cache speedbar-full-text-cache) |
2572 ;; disable stealth during update | |
2573 (speedbar-stealthy-function-list nil) | |
2574 (use-cache nil) | |
2575 (expand-local nil) | |
2576 ;; Because there is a bug I can't find just yet | |
2577 (inhibit-quit nil)) | |
2578 (save-excursion | |
2579 (set-buffer speedbar-buffer) | |
2580 ;; If we are updating contents to where we are, then this is | |
2581 ;; really a request to update existing contents, so we must be | |
2582 ;; careful with our text cache! | |
2583 (if (member cbd speedbar-shown-directories) | |
22735 | 2584 (progn |
2585 (setq cache nil) | |
2586 ;; If the current directory is not the last element in the dir | |
2587 ;; list, then we ALSO need to zap the list of expanded directories | |
2588 (if (/= (length (member cbd speedbar-shown-directories)) 1) | |
2589 (setq speedbar-shown-directories (list cbd)))) | |
21650 | 2590 |
2591 ;; Build cbd-parent, and see if THAT is in the current shown | |
2592 ;; directories. First, go through pains to get the parent directory | |
2593 (if (and speedbar-smart-directory-expand-flag | |
2594 (save-match-data | |
2595 (setq cbd-parent cbd) | |
2596 (if (string-match "/$" cbd-parent) | |
22735 | 2597 (setq cbd-parent (substring cbd-parent 0 |
2598 (match-beginning 0)))) | |
21650 | 2599 (setq cbd-parent (file-name-directory cbd-parent))) |
2600 (member cbd-parent speedbar-shown-directories)) | |
2601 (setq expand-local t) | |
2602 | |
2603 ;; If this directory is NOT in the current list of available | |
2604 ;; paths, then use the cache, and set the cache to our new | |
2605 ;; value. Make sure to unhighlight the current file, or if we | |
2606 ;; come back to this directory, it might be a different file | |
2607 ;; and then we get a mess! | |
2608 (if (> (point-max) 1) | |
2609 (progn | |
2610 (speedbar-clear-current-file) | |
2611 (setq speedbar-full-text-cache | |
2612 (cons speedbar-shown-directories (buffer-string))))) | |
2613 | |
2614 ;; Check if our new directory is in the list of directories | |
2615 ;; shown in the text-cache | |
2616 (if (member cbd (car cache)) | |
2617 (setq speedbar-shown-directories (car cache) | |
2618 use-cache t) | |
2619 ;; default the shown directories to this list... | |
2620 (setq speedbar-shown-directories (list cbd))) | |
2621 )) | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2622 (if (not expand-local) (setq speedbar-last-selected-file nil)) |
21650 | 2623 (speedbar-with-writable |
2624 (if (and expand-local | |
2625 ;; Find this directory as a speedbar node. | |
2626 (speedbar-path-line cbd)) | |
2627 ;; Open it. | |
2628 (speedbar-expand-line) | |
2629 (erase-buffer) | |
2630 (cond (use-cache | |
2631 (setq default-directory | |
2632 (nth (1- (length speedbar-shown-directories)) | |
2633 speedbar-shown-directories)) | |
2634 (insert (cdr cache))) | |
2635 (t | |
2636 (while funclst | |
2637 (setq default-directory cbd) | |
2638 (funcall (car funclst) cbd 0) | |
2639 (setq funclst (cdr funclst)))))) | |
2640 (goto-char (point-min))))) | |
22735 | 2641 (speedbar-reconfigure-keymaps)) |
21650 | 2642 |
2643 (defun speedbar-update-special-contents () | |
2644 "Used the mode-specific variable to fill in the speedbar buffer. | |
2645 This should only be used by modes classified as special." | |
2646 (let ((funclst speedbar-special-mode-expansion-list) | |
2647 (specialbuff (current-buffer))) | |
2648 (save-excursion | |
2649 (setq speedbar-desired-buffer specialbuff) | |
2650 (set-buffer speedbar-buffer) | |
2651 ;; If we are leaving a directory, cache it. | |
2652 (if (not speedbar-shown-directories) | |
2653 ;; Do nothing | |
2654 nil | |
2655 ;; Clean up directory maintenance stuff | |
2656 (speedbar-clear-current-file) | |
2657 (setq speedbar-full-text-cache | |
2658 (cons speedbar-shown-directories (buffer-string)) | |
2659 speedbar-shown-directories nil)) | |
2660 ;; Now fill in the buffer with our newly found specialized list. | |
2661 (speedbar-with-writable | |
2662 (while funclst | |
2663 ;; We do not erase the buffer because these functions may | |
2664 ;; decide NOT to update themselves. | |
2665 (funcall (car funclst) specialbuff) | |
2666 (setq funclst (cdr funclst)))) | |
2667 (goto-char (point-min)))) | |
22735 | 2668 (speedbar-reconfigure-keymaps)) |
21650 | 2669 |
2670 (defun speedbar-timer-fn () | |
22735 | 2671 "Run whenever Emacs is idle to update the speedbar item." |
21650 | 2672 (if (not (and (frame-live-p speedbar-frame) |
2673 (frame-live-p speedbar-attached-frame))) | |
2674 (speedbar-set-timer nil) | |
2675 ;; Save all the match data so that we don't mess up executing fns | |
2676 (save-match-data | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2677 ;; Only do stuff if the frame is visible, not an icon, and if |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2678 ;; it is currently flagged to do something. |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2679 (if (and speedbar-update-flag |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2680 (frame-visible-p speedbar-frame) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2681 (not (eq (frame-visible-p speedbar-frame) 'icon))) |
21650 | 2682 (let ((af (selected-frame))) |
2683 (save-window-excursion | |
2684 (select-frame speedbar-attached-frame) | |
2685 ;; make sure we at least choose a window to | |
2686 ;; get a good directory from | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2687 (if (window-minibuffer-p (selected-window)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2688 nil |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2689 ;; Check for special modes |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2690 (speedbar-maybe-add-localized-support (current-buffer)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2691 ;; Update for special mode all the time! |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2692 (if (and speedbar-mode-specific-contents-flag |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2693 (listp speedbar-special-mode-expansion-list) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2694 speedbar-special-mode-expansion-list |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2695 (local-variable-p |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2696 'speedbar-special-mode-expansion-list |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2697 (current-buffer))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2698 ;;(eq (get major-mode 'mode-class 'special))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2699 (progn |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2700 (if (<= 2 speedbar-verbosity-level) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2701 (message "Updating speedbar to special mode: %s..." |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2702 major-mode)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2703 (speedbar-update-special-contents) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2704 (if (<= 2 speedbar-verbosity-level) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2705 (progn |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2706 (message "Updating speedbar to special mode: %s...done" |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2707 major-mode) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2708 (message nil)))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2709 ;; Update all the contents if directories change! |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2710 (if (or (member (expand-file-name default-directory) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2711 speedbar-shown-directories) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2712 (and speedbar-ignored-path-regexp |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2713 (string-match |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2714 speedbar-ignored-path-regexp |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2715 (expand-file-name default-directory))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2716 (member major-mode speedbar-ignored-modes) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2717 (eq af speedbar-frame) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2718 (not (buffer-file-name))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2719 nil |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2720 (if (<= 1 speedbar-verbosity-level) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2721 (message "Updating speedbar to: %s..." |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2722 default-directory)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2723 (speedbar-update-directory-contents) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2724 (if (<= 1 speedbar-verbosity-level) |
22906
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
2725 (progn |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2726 (message "Updating speedbar to: %s...done" |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2727 default-directory) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2728 (message nil))))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2729 (select-frame af))) |
21650 | 2730 ;; Now run stealthy updates of time-consuming items |
22735 | 2731 (speedbar-stealthy-updates))) |
2732 ;; Now run the mouse tracking system | |
2733 (speedbar-show-info-under-mouse))) | |
21650 | 2734 (run-hooks 'speedbar-timer-hook)) |
2735 | |
2736 | |
2737 ;;; Stealthy activities | |
2738 ;; | |
22735 | 2739 (defvar speedbar-stealthy-update-recurse nil |
2740 "Recursion avoidance variable for stealthy update.") | |
2741 | |
21650 | 2742 (defun speedbar-stealthy-updates () |
2743 "For a given speedbar, run all items in the stealthy function list. | |
2744 Each item returns t if it completes successfully, or nil if | |
2745 interrupted by the user." | |
22735 | 2746 (if (not speedbar-stealthy-update-recurse) |
2747 (let ((l (speedbar-initial-stealthy-functions)) | |
2748 (speedbar-stealthy-update-recurse t)) | |
2749 (unwind-protect | |
23085
46deaf6e62a9
(speedbar-stealthy-updates): Do all updates w/ the the buffer writable.
Eric M. Ludlam <zappo@gnu.org>
parents:
23084
diff
changeset
|
2750 (speedbar-with-writable |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2751 (while (and l (funcall (car l))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2752 ;;(sit-for 0) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2753 (setq l (cdr l)))) |
22735 | 2754 ;;(message "Exit with %S" (car l)) |
2755 )))) | |
21650 | 2756 |
2757 (defun speedbar-reset-scanners () | |
2758 "Reset any variables used by functions in the stealthy list as state. | |
2759 If new functions are added, their state needs to be updated here." | |
22735 | 2760 (setq speedbar-vc-to-do-point t |
2761 speedbar-obj-to-do-point t) | |
21650 | 2762 (run-hooks 'speedbar-scanner-reset-hook) |
2763 ) | |
2764 | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2765 (defun speedbar-find-selected-file (file) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2766 "Goto the line where FILE is." |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2767 (goto-char (point-min)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2768 (let ((m nil)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2769 (while (and (setq m (re-search-forward |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2770 (concat " \\(" (file-name-nondirectory file) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2771 "\\)\\(" speedbar-indicator-regex "\\)?\n") |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2772 nil t)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2773 (not (string= file |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2774 (concat |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2775 (speedbar-line-path |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2776 (save-excursion |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2777 (goto-char (match-beginning 0)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2778 (beginning-of-line) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2779 (save-match-data |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2780 (looking-at "[0-9]+:") |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2781 (string-to-number (match-string 0))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2782 (match-string 1)))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2783 (if m |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2784 (progn |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2785 (goto-char (match-beginning 1)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2786 (match-string 1))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2787 |
21650 | 2788 (defun speedbar-clear-current-file () |
2789 "Locate the file thought to be current, and remove its highlighting." | |
2790 (save-excursion | |
2791 (set-buffer speedbar-buffer) | |
2792 (if speedbar-last-selected-file | |
2793 (speedbar-with-writable | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2794 (if (speedbar-find-selected-file speedbar-last-selected-file) |
21650 | 2795 (put-text-property (match-beginning 1) |
2796 (match-end 1) | |
2797 'face | |
2798 'speedbar-file-face)))))) | |
2799 | |
2800 (defun speedbar-update-current-file () | |
2801 "Find the current file, and update our visuals to indicate its name. | |
2802 This is specific to file names. If the file name doesn't show up, but | |
2803 it should be in the list, then the directory cache needs to be | |
2804 updated." | |
2805 (let* ((lastf (selected-frame)) | |
2806 (newcfd (save-excursion | |
2807 (select-frame speedbar-attached-frame) | |
2808 (let ((rf (if (buffer-file-name) | |
2809 (buffer-file-name) | |
2810 nil))) | |
2811 (select-frame lastf) | |
2812 rf))) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2813 (newcf (if newcfd newcfd)) |
21650 | 2814 (lastb (current-buffer)) |
22735 | 2815 (sucf-recursive (boundp 'sucf-recursive)) |
2816 (case-fold-search t)) | |
21650 | 2817 (if (and newcf |
2818 ;; check here, that way we won't refresh to newcf until | |
2819 ;; its been written, thus saving ourselves some time | |
2820 (file-exists-p newcf) | |
2821 (not (string= newcf speedbar-last-selected-file))) | |
2822 (progn | |
2823 ;; It is important to select the frame, otherwise the window | |
2824 ;; we want the cursor to move in will not be updated by the | |
2825 ;; search-forward command. | |
2826 (select-frame speedbar-frame) | |
2827 ;; Remove the old file... | |
2828 (speedbar-clear-current-file) | |
2829 ;; now highlight the new one. | |
2830 (set-buffer speedbar-buffer) | |
2831 (speedbar-with-writable | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2832 (if (speedbar-find-selected-file newcf) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2833 ;; put the property on it |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2834 (put-text-property (match-beginning 1) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2835 (match-end 1) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2836 'face |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2837 'speedbar-selected-face) |
21650 | 2838 ;; Oops, it's not in the list. Should it be? |
2839 (if (and (string-match speedbar-file-regexp newcf) | |
2840 (string= (file-name-directory newcfd) | |
2841 (expand-file-name default-directory))) | |
2842 ;; yes, it is (we will ignore unknowns for now...) | |
2843 (progn | |
2844 (speedbar-refresh) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2845 (if (speedbar-find-selected-file newcf) |
21650 | 2846 ;; put the property on it |
2847 (put-text-property (match-beginning 1) | |
2848 (match-end 1) | |
2849 'face | |
2850 'speedbar-selected-face))) | |
2851 ;; if it's not in there now, whatever... | |
2852 )) | |
2853 (setq speedbar-last-selected-file newcf)) | |
2854 (if (not sucf-recursive) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2855 (progn |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2856 (speedbar-center-buffer-smartly) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2857 (speedbar-position-cursor-on-line) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2858 )) |
21650 | 2859 (set-buffer lastb) |
2860 (select-frame lastf) | |
2861 ))) | |
2862 ;; return that we are done with this activity. | |
2863 t) | |
2864 | |
22735 | 2865 (defun speedbar-add-indicator (indicator-string &optional replace-this) |
2866 "Add INDICATOR-STRING to the end of this speedbar line. | |
2867 If INDICATOR-STRING is space, and REPLACE-THIS is a character, then | |
2868 an the existing indicator is removed. If there is already an | |
2869 indicator, then do not add a space." | |
2870 (beginning-of-line) | |
2871 ;; The nature of the beast: Assume we are in "the right place" | |
2872 (end-of-line) | |
2873 (skip-chars-backward (concat " " speedbar-vc-indicator | |
2874 (car speedbar-obj-indicator) | |
2875 (cdr speedbar-obj-indicator))) | |
2876 (if (and (not (looking-at speedbar-indicator-regex)) | |
2877 (not (string= indicator-string " "))) | |
2878 (insert speedbar-indicator-separator)) | |
2879 (speedbar-with-writable | |
2880 (save-excursion | |
2881 (if (and replace-this | |
2882 (re-search-forward replace-this (save-excursion (end-of-line) | |
2883 (point)) | |
2884 t)) | |
2885 (delete-region (match-beginning 0) (match-end 0)))) | |
2886 (end-of-line) | |
2887 (if (not (string= " " indicator-string)) | |
2888 (insert indicator-string)))) | |
2889 | |
2890 ;; Load efs/ange-ftp only if compiling to remove byte-compiler warnings. | |
21650 | 2891 ;; Steven L Baur <steve@xemacs.org> said this was important: |
22735 | 2892 (eval-when-compile (or (featurep 'xemacs) |
2893 (condition-case () (require 'efs) | |
2894 (error (require 'ange-ftp))))) | |
21650 | 2895 |
2896 (defun speedbar-check-vc () | |
2897 "Scan all files in a directory, and for each see if it's checked out. | |
2898 See `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p' for how | |
2899 to add more types of version control systems." | |
2900 ;; Check for to-do to be reset. If reset but no RCS is available | |
2901 ;; then set to nil (do nothing) otherwise, start at the beginning | |
2902 (save-excursion | |
2903 (set-buffer speedbar-buffer) | |
2904 (if (and speedbar-vc-do-check (eq speedbar-vc-to-do-point t) | |
2905 (speedbar-vc-check-dir-p default-directory) | |
22735 | 2906 (not (or (and (featurep 'ange-ftp) |
2907 (string-match | |
2908 (car (if speedbar-xemacsp | |
2909 ange-ftp-path-format | |
2910 ange-ftp-name-format)) | |
2911 (expand-file-name default-directory))) | |
2912 ;; efs support: Bob Weiner | |
2913 (and (featurep 'efs) | |
2914 (string-match | |
2915 (car efs-path-regexp) | |
2916 (expand-file-name default-directory)))))) | |
21650 | 2917 (setq speedbar-vc-to-do-point 0)) |
2918 (if (numberp speedbar-vc-to-do-point) | |
2919 (progn | |
2920 (goto-char speedbar-vc-to-do-point) | |
2921 (while (and (not (input-pending-p)) | |
2922 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " | |
2923 nil t)) | |
2924 (setq speedbar-vc-to-do-point (point)) | |
2925 (if (speedbar-check-vc-this-line (match-string 1)) | |
22735 | 2926 (speedbar-add-indicator speedbar-vc-indicator |
2927 (regexp-quote speedbar-vc-indicator)) | |
2928 (speedbar-add-indicator " " | |
2929 (regexp-quote speedbar-vc-indicator)))) | |
21650 | 2930 (if (input-pending-p) |
2931 ;; return that we are incomplete | |
2932 nil | |
2933 ;; we are done, set to-do to nil | |
2934 (setq speedbar-vc-to-do-point nil) | |
2935 ;; and return t | |
2936 t)) | |
2937 t))) | |
2938 | |
2939 (defun speedbar-check-vc-this-line (depth) | |
2940 "Return t if the file on this line is check of of a version control system. | |
2941 Parameter DEPTH is a string with the current depth of indentation of | |
2942 the file being checked." | |
2943 (let* ((d (string-to-int depth)) | |
2944 (f (speedbar-line-path d)) | |
2945 (fn (buffer-substring-no-properties | |
2946 ;; Skip-chars: thanks ptype@dra.hmg.gb | |
2947 (point) (progn | |
2948 (skip-chars-forward "^ " | |
2949 (save-excursion (end-of-line) | |
2950 (point))) | |
2951 (point)))) | |
2952 (fulln (concat f fn))) | |
2953 (if (<= 2 speedbar-verbosity-level) | |
2954 (message "Speedbar vc check...%s" fulln)) | |
2955 (and (file-writable-p fulln) | |
2956 (speedbar-this-file-in-vc f fn)))) | |
2957 | |
2958 (defun speedbar-vc-check-dir-p (path) | |
2959 "Return t if we should bother checking PATH for version control files. | |
2960 This can be overloaded to add new types of version control systems." | |
2961 (or | |
2962 ;; Local RCS | |
2963 (file-exists-p (concat path "RCS/")) | |
2964 ;; Local SCCS | |
2965 (file-exists-p (concat path "SCCS/")) | |
2966 ;; Remote SCCS project | |
2967 (let ((proj-dir (getenv "PROJECTDIR"))) | |
2968 (if proj-dir | |
2969 (file-exists-p (concat proj-dir "/SCCS")) | |
2970 nil)) | |
2971 ;; User extension | |
2972 (run-hook-with-args 'speedbar-vc-path-enable-hook path) | |
2973 )) | |
2974 | |
2975 (defun speedbar-this-file-in-vc (path name) | |
2976 "Check to see if the file in PATH with NAME is in a version control system. | |
2977 You can add new VC systems by overriding this function. You can | |
2978 optimize this function by overriding it and only doing those checks | |
2979 that will occur on your system." | |
2980 (or | |
2981 ;; RCS file name | |
2982 (file-exists-p (concat path "RCS/" name ",v")) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2983 (file-exists-p (concat path "RCS/" name)) |
21650 | 2984 ;; Local SCCS file name |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2985 (file-exists-p (concat path "SCCS/s." name)) |
21650 | 2986 ;; Remote SCCS file name |
2987 (let ((proj-dir (getenv "PROJECTDIR"))) | |
2988 (if proj-dir | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2989 (file-exists-p (concat proj-dir "/SCCS/s." name)) |
21650 | 2990 nil)) |
2991 ;; User extension | |
2992 (run-hook-with-args 'speedbar-vc-in-control-hook path name) | |
2993 )) | |
22735 | 2994 |
2995 ;; Objet File scanning | |
2996 (defun speedbar-check-objects () | |
2997 "Scan all files in a directory, and for each see if there is an object. | |
2998 See `speedbar-check-obj-this-line' and `speedbar-obj-alist' for how | |
2999 to add more object types." | |
3000 ;; Check for to-do to be reset. If reset but no RCS is available | |
3001 ;; then set to nil (do nothing) otherwise, start at the beginning | |
3002 (save-excursion | |
3003 (set-buffer speedbar-buffer) | |
3004 (if (and speedbar-obj-do-check (eq speedbar-obj-to-do-point t)) | |
3005 (setq speedbar-obj-to-do-point 0)) | |
3006 (if (numberp speedbar-obj-to-do-point) | |
3007 (progn | |
3008 (goto-char speedbar-obj-to-do-point) | |
3009 (while (and (not (input-pending-p)) | |
3010 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " | |
3011 nil t)) | |
3012 (setq speedbar-obj-to-do-point (point)) | |
3013 (let ((ind (speedbar-check-obj-this-line (match-string 1)))) | |
3014 (if (not ind) (setq ind " ")) | |
3015 (speedbar-add-indicator ind (concat | |
3016 (car speedbar-obj-indicator) | |
3017 "\\|" | |
3018 (cdr speedbar-obj-indicator))))) | |
3019 (if (input-pending-p) | |
3020 ;; return that we are incomplete | |
3021 nil | |
3022 ;; we are done, set to-do to nil | |
3023 (setq speedbar-obj-to-do-point nil) | |
3024 ;; and return t | |
3025 t)) | |
3026 t))) | |
3027 | |
3028 (defun speedbar-check-obj-this-line (depth) | |
3029 "Return t if the file on this line has an associated object. | |
3030 Parameter DEPTH is a string with the current depth of indentation of | |
3031 the file being checked." | |
3032 (let* ((d (string-to-int depth)) | |
3033 (f (speedbar-line-path d)) | |
3034 (fn (buffer-substring-no-properties | |
3035 ;; Skip-chars: thanks ptype@dra.hmg.gb | |
3036 (point) (progn | |
3037 (skip-chars-forward "^ " | |
3038 (save-excursion (end-of-line) | |
3039 (point))) | |
3040 (point)))) | |
3041 (fulln (concat f fn))) | |
3042 (if (<= 2 speedbar-verbosity-level) | |
3043 (message "Speedbar obj check...%s" fulln)) | |
3044 (let ((oa speedbar-obj-alist)) | |
3045 (while (and oa (not (string-match (car (car oa)) fulln))) | |
3046 (setq oa (cdr oa))) | |
3047 (if (not (and oa (file-exists-p (concat (file-name-sans-extension fulln) | |
3048 (cdr (car oa)))))) | |
3049 nil | |
3050 ;; Find out if the object is out of date or not. | |
3051 (let ((date1 (nth 5 (file-attributes fulln))) | |
3052 (date2 (nth 5 (file-attributes (concat | |
3053 (file-name-sans-extension fulln) | |
3054 (cdr (car oa))))))) | |
3055 (if (or (< (car date1) (car date2)) | |
3056 (and (= (car date1) (car date2)) | |
3057 (< (nth 1 date1) (nth 1 date2)))) | |
3058 (car speedbar-obj-indicator) | |
3059 (cdr speedbar-obj-indicator))))))) | |
21650 | 3060 |
3061 ;;; Clicking Activity | |
3062 ;; | |
3063 (defun speedbar-quick-mouse (e) | |
3064 "Since mouse events are strange, this will keep the mouse nicely positioned. | |
3065 This should be bound to mouse event E." | |
3066 (interactive "e") | |
3067 (mouse-set-point e) | |
3068 (speedbar-position-cursor-on-line) | |
3069 ) | |
3070 | |
3071 (defun speedbar-position-cursor-on-line () | |
3072 "Position the cursor on a line." | |
3073 (let ((oldpos (point))) | |
3074 (beginning-of-line) | |
3075 (if (looking-at "[0-9]+:\\s-*..?.? ") | |
3076 (goto-char (1- (match-end 0))) | |
3077 (goto-char oldpos)))) | |
3078 | |
3079 (defun speedbar-power-click (e) | |
3080 "Activate any speedbar button as a power click. | |
3081 This should be bound to mouse event E." | |
3082 (interactive "e") | |
3083 (let ((speedbar-power-click t)) | |
3084 (speedbar-click e))) | |
3085 | |
3086 (defun speedbar-click (e) | |
3087 "Activate any speedbar buttons where the mouse is clicked. | |
3088 This must be bound to a mouse event. A button is any location of text | |
3089 with a mouse face that has a text property called `speedbar-function'. | |
3090 This should be bound to mouse event E." | |
3091 (interactive "e") | |
3092 (mouse-set-point e) | |
3093 (speedbar-do-function-pointer) | |
3094 (speedbar-quick-mouse e)) | |
3095 | |
3096 (defun speedbar-double-click (e) | |
3097 "Activate any speedbar buttons where the mouse is clicked. | |
3098 This must be bound to a mouse event. A button is any location of text | |
3099 with a mouse face that has a text property called `speedbar-function'. | |
3100 This should be bound to mouse event E." | |
3101 (interactive "e") | |
3102 ;; Emacs only. XEmacs handles this via `mouse-track-click-hook'. | |
3103 (cond ((eq (car e) 'down-mouse-1) | |
3104 (mouse-set-point e)) | |
3105 ((eq (car e) 'mouse-1) | |
3106 (speedbar-quick-mouse e)) | |
3107 ((or (eq (car e) 'double-down-mouse-1) | |
22735 | 3108 (eq (car e) 'triple-down-mouse-1)) |
21650 | 3109 (mouse-set-point e) |
3110 (speedbar-do-function-pointer) | |
3111 (speedbar-quick-mouse e)))) | |
3112 | |
3113 (defun speedbar-do-function-pointer () | |
3114 "Look under the cursor and examine the text properties. | |
3115 From this extract the file/tag name, token, indentation level and call | |
3116 a function if appropriate" | |
3117 (let* ((fn (get-text-property (point) 'speedbar-function)) | |
3118 (tok (get-text-property (point) 'speedbar-token)) | |
3119 ;; The 1-,+ is safe because scaning starts AFTER the point | |
3120 ;; specified. This lets the search include the character the | |
3121 ;; cursor is on. | |
3122 (tp (previous-single-property-change | |
3123 (1+ (point)) 'speedbar-function)) | |
3124 (np (next-single-property-change | |
3125 (point) 'speedbar-function)) | |
3126 (txt (buffer-substring-no-properties (or tp (point-min)) | |
3127 (or np (point-max)))) | |
3128 (dent (save-excursion (beginning-of-line) | |
3129 (string-to-number | |
3130 (if (looking-at "[0-9]+") | |
3131 (buffer-substring-no-properties | |
3132 (match-beginning 0) (match-end 0)) | |
3133 "0"))))) | |
3134 ;;(message "%S:%S:%S:%s" fn tok txt dent) | |
3135 (and fn (funcall fn txt tok dent))) | |
3136 (speedbar-position-cursor-on-line)) | |
3137 | |
3138 ;;; Reading info from the speedbar buffer | |
3139 ;; | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3140 (defun speedbar-line-text (&optional p) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3141 "Retrieve the text after prefix junk for the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3142 Optional argument P is where to start the search from." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3143 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3144 (if p (goto-char p)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3145 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3146 (if (looking-at (concat |
24232
446e5ef3f423
(speedbar-line-token): Match {...} instead of [...].
Richard M. Stallman <rms@gnu.org>
parents:
24154
diff
changeset
|
3147 "\\([0-9]+\\): *[[<{][-+?][]>}] \\([^ \n]+\\)\\(" |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3148 speedbar-indicator-regex "\\)?")) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3149 (match-string 2) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3150 nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3151 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3152 (defun speedbar-line-token (&optional p) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3153 "Retrieve the token information after the prefix junk for the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3154 Optional argument P is where to start the search from." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3155 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3156 (if p (goto-char p)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3157 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3158 (if (looking-at (concat |
24232
446e5ef3f423
(speedbar-line-token): Match {...} instead of [...].
Richard M. Stallman <rms@gnu.org>
parents:
24154
diff
changeset
|
3159 "\\([0-9]+\\): *[[<{][-+?][]>}] \\([^ \n]+\\)\\(" |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3160 speedbar-indicator-regex "\\)?")) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3161 (progn |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3162 (goto-char (match-beginning 2)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3163 (get-text-property (point) 'speedbar-token)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3164 nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3165 |
21650 | 3166 (defun speedbar-line-file (&optional p) |
3167 "Retrieve the file or whatever from the line at P point. | |
3168 The return value is a string representing the file. If it is a | |
3169 directory, then it is the directory name." | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3170 (save-match-data |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3171 (let ((f (speedbar-line-text p))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3172 (if f |
21650 | 3173 (let* ((depth (string-to-int (match-string 1))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3174 (path (speedbar-line-path depth))) |
21650 | 3175 (concat path f)) |
3176 nil)))) | |
3177 | |
3178 (defun speedbar-goto-this-file (file) | |
3179 "If FILE is displayed, goto this line and return t. | |
3180 Otherwise do not move and return nil." | |
3181 (let ((path (substring (file-name-directory (expand-file-name file)) | |
3182 (length (expand-file-name default-directory)))) | |
3183 (dest (point))) | |
3184 (save-match-data | |
3185 (goto-char (point-min)) | |
3186 ;; scan all the directories | |
3187 (while (and path (not (eq path t))) | |
3188 (if (string-match "^/?\\([^/]+\\)" path) | |
3189 (let ((pp (match-string 1 path))) | |
3190 (if (save-match-data | |
3191 (re-search-forward (concat "> " (regexp-quote pp) "$") | |
3192 nil t)) | |
3193 (setq path (substring path (match-end 1))) | |
3194 (setq path nil))) | |
3195 (setq path t))) | |
3196 ;; find the file part | |
3197 (if (or (not path) (string= (file-name-nondirectory file) "")) | |
3198 ;; only had a dir part | |
3199 (if path | |
3200 (progn | |
3201 (speedbar-position-cursor-on-line) | |
3202 t) | |
3203 (goto-char dest) nil) | |
3204 ;; find the file part | |
3205 (let ((nd (file-name-nondirectory file))) | |
3206 (if (re-search-forward | |
3207 (concat "] \\(" (regexp-quote nd) | |
22735 | 3208 "\\)\\(" speedbar-indicator-regex "\\)$") |
21650 | 3209 nil t) |
3210 (progn | |
3211 (speedbar-position-cursor-on-line) | |
3212 t) | |
3213 (goto-char dest) | |
3214 nil)))))) | |
3215 | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3216 (defun speedbar-line-path (&optional depth) |
21650 | 3217 "Retrieve the pathname associated with the current line. |
3218 This may require traversing backwards from DEPTH and combining the default | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3219 directory with these items. This function is replaceable in |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3220 `speedbar-mode-functions-list' as `speedbar-line-path'" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3221 (let ((rf (speedbar-fetch-replacement-function 'speedbar-line-path))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3222 (if rf (funcall rf depth) default-directory))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3223 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3224 (defun speedbar-files-line-path (&optional depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3225 "Retrieve the pathname associated with the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3226 This may require traversing backwards from DEPTH and combining the default |
21650 | 3227 directory with these items." |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3228 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3229 (save-match-data |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3230 (if (not depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3231 (progn |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3232 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3233 (looking-at "^\\([0-9]+\\):") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3234 (setq depth (string-to-int (match-string 1))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3235 (let ((path nil)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3236 (setq depth (1- depth)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3237 (while (/= depth -1) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3238 (if (not (re-search-backward (format "^%d:" depth) nil t)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3239 (error "Error building path of tag") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3240 (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3241 (setq path (concat (buffer-substring-no-properties |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3242 (match-beginning 1) (match-end 1)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3243 "/" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3244 path))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3245 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3246 ;; This is the start of our path. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3247 (setq path (buffer-substring-no-properties |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3248 (match-beginning 1) (match-end 1)))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3249 (setq depth (1- depth))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3250 (if (and path |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3251 (string-match (concat speedbar-indicator-regex "$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3252 path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3253 (setq path (substring path 0 (match-beginning 0)))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3254 (concat default-directory path))))) |
21650 | 3255 |
3256 (defun speedbar-path-line (path) | |
3257 "Position the cursor on the line specified by PATH." | |
3258 (save-match-data | |
3259 (if (string-match "/$" path) | |
3260 (setq path (substring path 0 (match-beginning 0)))) | |
3261 (let ((nomatch t) (depth 0) | |
3262 (fname (file-name-nondirectory path)) | |
3263 (pname (file-name-directory path))) | |
3264 (if (not (member pname speedbar-shown-directories)) | |
22735 | 3265 (error "Internal Error: File %s not shown in speedbar" path)) |
21650 | 3266 (goto-char (point-min)) |
3267 (while (and nomatch | |
3268 (re-search-forward | |
3269 (concat "[]>] \\(" (regexp-quote fname) | |
22735 | 3270 "\\)\\(" speedbar-indicator-regex "\\)?$") |
21650 | 3271 nil t)) |
3272 (beginning-of-line) | |
3273 (looking-at "\\([0-9]+\\):") | |
3274 (setq depth (string-to-int (match-string 0)) | |
3275 nomatch (not (string= pname (speedbar-line-path depth)))) | |
3276 (end-of-line)) | |
3277 (beginning-of-line) | |
3278 (not nomatch)))) | |
3279 | |
3280 (defun speedbar-edit-line () | |
3281 "Edit whatever tag or file is on the current speedbar line." | |
3282 (interactive) | |
3283 (or (save-excursion | |
3284 (beginning-of-line) | |
3285 ;; If this fails, then it is a non-standard click, and as such, | |
3286 ;; perfectly allowed. | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3287 (if (re-search-forward "[]>?}] [^ ]" |
21650 | 3288 (save-excursion (end-of-line) (point)) |
3289 t) | |
3290 (speedbar-do-function-pointer) | |
3291 nil)) | |
3292 (speedbar-do-function-pointer))) | |
3293 | |
3294 (defun speedbar-expand-line () | |
3295 "Expand the line under the cursor." | |
3296 (interactive) | |
3297 (beginning-of-line) | |
3298 (re-search-forward ":\\s-*.\\+. " (save-excursion (end-of-line) (point))) | |
3299 (forward-char -2) | |
3300 (speedbar-do-function-pointer)) | |
3301 | |
3302 (defun speedbar-contract-line () | |
3303 "Contract the line under the cursor." | |
3304 (interactive) | |
3305 (beginning-of-line) | |
3306 (re-search-forward ":\\s-*.-. " (save-excursion (end-of-line) (point))) | |
3307 (forward-char -2) | |
3308 (speedbar-do-function-pointer)) | |
3309 | |
3310 (if speedbar-xemacsp | |
3311 (defalias 'speedbar-mouse-event-p 'button-press-event-p) | |
3312 (defun speedbar-mouse-event-p (event) | |
3313 "Return t if the event is a mouse related event" | |
3314 ;; And Emacs does it this way | |
3315 (if (and (listp event) | |
3316 (member (event-basic-type event) | |
3317 '(mouse-1 mouse-2 mouse-3))) | |
3318 t | |
3319 nil))) | |
3320 | |
3321 (defun speedbar-maybee-jump-to-attached-frame () | |
3322 "Jump to the attached frame ONLY if this was not a mouse event." | |
3323 (if (or (not (speedbar-mouse-event-p last-input-event)) | |
3324 speedbar-activity-change-focus-flag) | |
3325 (progn | |
3326 (select-frame speedbar-attached-frame) | |
3327 (other-frame 0)))) | |
3328 | |
3329 (defun speedbar-find-file (text token indent) | |
3330 "Speedbar click handler for filenames. | |
3331 TEXT, the file will be displayed in the attached frame. | |
3332 TOKEN is unused, but required by the click handler. INDENT is the | |
3333 current indentation level." | |
3334 (let ((cdd (speedbar-line-path indent))) | |
3335 (speedbar-find-file-in-frame (concat cdd text)) | |
3336 (speedbar-stealthy-updates) | |
3337 (run-hooks 'speedbar-visiting-file-hook) | |
3338 ;; Reset the timer with a new timeout when cliking a file | |
3339 ;; in case the user was navigating directories, we can cancel | |
3340 ;; that other timer. | |
3341 (speedbar-set-timer speedbar-update-speed)) | |
3342 (speedbar-maybee-jump-to-attached-frame)) | |
3343 | |
3344 (defun speedbar-dir-follow (text token indent) | |
3345 "Speedbar click handler for directory names. | |
3346 Clicking a directory will cause the speedbar to list files in the | |
3347 the subdirectory TEXT. TOKEN is an unused requirement. The | |
3348 subdirectory chosen will be at INDENT level." | |
3349 (setq default-directory | |
3350 (concat (expand-file-name (concat (speedbar-line-path indent) text)) | |
3351 "/")) | |
3352 ;; Because we leave speedbar as the current buffer, | |
3353 ;; update contents will change directory without | |
22735 | 3354 ;; having to touch the attached frame. Turn off smart expand just |
3355 ;; in case. | |
3356 (let ((speedbar-smart-directory-expand-flag nil)) | |
3357 (speedbar-update-contents)) | |
21650 | 3358 (speedbar-set-timer speedbar-navigating-speed) |
3359 (setq speedbar-last-selected-file nil) | |
3360 (speedbar-stealthy-updates)) | |
3361 | |
3362 (defun speedbar-delete-subblock (indent) | |
3363 "Delete text from point to indentation level INDENT or greater. | |
3364 Handles end-of-sublist smartly." | |
3365 (speedbar-with-writable | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3366 (save-excursion |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3367 (end-of-line) (forward-char 1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3368 (let ((start (point))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3369 (while (and (looking-at "^\\([0-9]+\\):") |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3370 (> (string-to-int (match-string 1)) indent) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3371 (not (eobp))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3372 (forward-line 1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3373 (beginning-of-line)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3374 (delete-region start (point)))))) |
21650 | 3375 |
3376 (defun speedbar-dired (text token indent) | |
3377 "Speedbar click handler for directory expand button. | |
3378 Clicking this button expands or contracts a directory. TEXT is the | |
3379 button clicked which has either a + or -. TOKEN is the directory to be | |
3380 expanded. INDENT is the current indentation level." | |
3381 (cond ((string-match "+" text) ;we have to expand this dir | |
3382 (setq speedbar-shown-directories | |
3383 (cons (expand-file-name | |
3384 (concat (speedbar-line-path indent) token "/")) | |
3385 speedbar-shown-directories)) | |
3386 (speedbar-change-expand-button-char ?-) | |
3387 (speedbar-reset-scanners) | |
3388 (save-excursion | |
3389 (end-of-line) (forward-char 1) | |
3390 (speedbar-with-writable | |
3391 (speedbar-default-directory-list | |
3392 (concat (speedbar-line-path indent) token "/") | |
3393 (1+ indent))))) | |
3394 ((string-match "-" text) ;we have to contract this node | |
3395 (speedbar-reset-scanners) | |
3396 (let ((oldl speedbar-shown-directories) | |
3397 (newl nil) | |
3398 (td (expand-file-name | |
3399 (concat (speedbar-line-path indent) token)))) | |
3400 (while oldl | |
3401 (if (not (string-match (concat "^" (regexp-quote td)) (car oldl))) | |
3402 (setq newl (cons (car oldl) newl))) | |
3403 (setq oldl (cdr oldl))) | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3404 (setq speedbar-shown-directories (nreverse newl))) |
21650 | 3405 (speedbar-change-expand-button-char ?+) |
3406 (speedbar-delete-subblock indent) | |
3407 ) | |
22735 | 3408 (t (error "Ooops... not sure what to do"))) |
21650 | 3409 (speedbar-center-buffer-smartly) |
3410 (setq speedbar-last-selected-file nil) | |
3411 (save-excursion (speedbar-stealthy-updates))) | |
3412 | |
3413 (defun speedbar-directory-buttons-follow (text token indent) | |
3414 "Speedbar click handler for default directory buttons. | |
3415 TEXT is the button clicked on. TOKEN is the directory to follow. | |
3416 INDENT is the current indentation level and is unused." | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3417 (if (string-match "^[A-z]:$" token) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3418 (setq default-directory (concat token (char-to-string directory-sep-char))) |
22735 | 3419 (setq default-directory token)) |
21650 | 3420 ;; Because we leave speedbar as the current buffer, |
3421 ;; update contents will change directory without | |
3422 ;; having to touch the attached frame. | |
3423 (speedbar-update-contents) | |
3424 (speedbar-set-timer speedbar-navigating-speed)) | |
3425 | |
3426 (defun speedbar-tag-file (text token indent) | |
3427 "The cursor is on a selected line. Expand the tags in the specified file. | |
3428 The parameter TEXT and TOKEN are required, where TEXT is the button | |
3429 clicked, and TOKEN is the file to expand. INDENT is the current | |
3430 indentation level." | |
3431 (cond ((string-match "+" text) ;we have to expand this file | |
3432 (let* ((fn (expand-file-name (concat (speedbar-line-path indent) | |
3433 token))) | |
3434 (lst (if speedbar-use-imenu-flag | |
3435 (let ((tim (speedbar-fetch-dynamic-imenu fn))) | |
3436 (if (eq tim t) | |
3437 (speedbar-fetch-dynamic-etags fn) | |
3438 tim)) | |
3439 (speedbar-fetch-dynamic-etags fn)))) | |
3440 ;; if no list, then remove expando button | |
3441 (if (not lst) | |
3442 (speedbar-change-expand-button-char ??) | |
3443 (speedbar-change-expand-button-char ?-) | |
3444 (speedbar-with-writable | |
3445 (save-excursion | |
3446 (end-of-line) (forward-char 1) | |
3447 (speedbar-insert-generic-list indent | |
3448 lst 'speedbar-tag-expand | |
3449 'speedbar-tag-find)))))) | |
3450 ((string-match "-" text) ;we have to contract this node | |
3451 (speedbar-change-expand-button-char ?+) | |
3452 (speedbar-delete-subblock indent)) | |
22735 | 3453 (t (error "Ooops... not sure what to do"))) |
21650 | 3454 (speedbar-center-buffer-smartly)) |
3455 | |
3456 (defun speedbar-tag-find (text token indent) | |
3457 "For the tag TEXT in a file TOKEN, goto that position. | |
3458 INDENT is the current indentation level." | |
3459 (let ((file (speedbar-line-path indent))) | |
3460 (speedbar-find-file-in-frame file) | |
3461 (save-excursion (speedbar-stealthy-updates)) | |
3462 ;; Reset the timer with a new timeout when cliking a file | |
3463 ;; in case the user was navigating directories, we can cancel | |
3464 ;; that other timer. | |
3465 (speedbar-set-timer speedbar-update-speed) | |
3466 (goto-char token) | |
3467 (run-hooks 'speedbar-visiting-tag-hook) | |
3468 ;;(recenter) | |
3469 (speedbar-maybee-jump-to-attached-frame) | |
3470 )) | |
3471 | |
3472 (defun speedbar-tag-expand (text token indent) | |
3473 "Expand a tag sublist. Imenu will return sub-lists of specialized tag types. | |
3474 Etags does not support this feature. TEXT will be the button | |
3475 string. TOKEN will be the list, and INDENT is the current indentation | |
3476 level." | |
3477 (cond ((string-match "+" text) ;we have to expand this file | |
3478 (speedbar-change-expand-button-char ?-) | |
3479 (speedbar-with-writable | |
3480 (save-excursion | |
3481 (end-of-line) (forward-char 1) | |
22735 | 3482 (speedbar-insert-generic-list indent token 'speedbar-tag-expand |
21650 | 3483 'speedbar-tag-find)))) |
3484 ((string-match "-" text) ;we have to contract this node | |
3485 (speedbar-change-expand-button-char ?+) | |
3486 (speedbar-delete-subblock indent)) | |
22735 | 3487 (t (error "Ooops... not sure what to do"))) |
21650 | 3488 (speedbar-center-buffer-smartly)) |
3489 | |
3490 ;;; Loading files into the attached frame. | |
3491 ;; | |
3492 (defun speedbar-find-file-in-frame (file) | |
3493 "This will load FILE into the speedbar attached frame. | |
3494 If the file is being displayed in a different frame already, then raise that | |
3495 frame instead." | |
3496 (let* ((buff (find-file-noselect file)) | |
3497 (bwin (get-buffer-window buff 0))) | |
3498 (if bwin | |
3499 (progn | |
3500 (select-window bwin) | |
3501 (raise-frame (window-frame bwin))) | |
3502 (if speedbar-power-click | |
3503 (let ((pop-up-frames t)) (select-window (display-buffer buff))) | |
3504 (select-frame speedbar-attached-frame) | |
3505 (switch-to-buffer buff)))) | |
22735 | 3506 ) |
21650 | 3507 |
3508 ;;; Centering Utility | |
3509 ;; | |
3510 (defun speedbar-center-buffer-smartly () | |
3511 "Recenter a speedbar buffer so the current indentation level is all visible. | |
3512 This assumes that the cursor is on a file, or tag of a file which the user is | |
3513 interested in." | |
3514 (if (<= (count-lines (point-min) (point-max)) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3515 (1- (window-height (selected-window)))) |
21650 | 3516 ;; whole buffer fits |
3517 (let ((cp (point))) | |
3518 (goto-char (point-min)) | |
3519 (recenter 0) | |
3520 (goto-char cp)) | |
3521 ;; too big | |
3522 (let (depth start end exp p) | |
3523 (save-excursion | |
3524 (beginning-of-line) | |
3525 (setq depth (if (looking-at "[0-9]+") | |
3526 (string-to-int (buffer-substring-no-properties | |
3527 (match-beginning 0) (match-end 0))) | |
3528 0)) | |
3529 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth))) | |
3530 (save-excursion | |
3531 (end-of-line) | |
3532 (if (re-search-backward exp nil t) | |
3533 (setq start (point)) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3534 (setq start (point-min))) |
21650 | 3535 (save-excursion ;Not sure about this part. |
3536 (end-of-line) | |
3537 (setq p (point)) | |
3538 (while (and (not (re-search-forward exp nil t)) | |
3539 (>= depth 0)) | |
3540 (setq depth (1- depth)) | |
3541 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth))) | |
3542 (if (/= (point) p) | |
3543 (setq end (point)) | |
3544 (setq end (point-max))))) | |
3545 ;; Now work out the details of centering | |
3546 (let ((nl (count-lines start end)) | |
3547 (cp (point))) | |
3548 (if (> nl (window-height (selected-window))) | |
3549 ;; We can't fit it all, so just center on cursor | |
3550 (progn (goto-char start) | |
3551 (recenter 1)) | |
3552 ;; we can fit everything on the screen, but... | |
3553 (if (and (pos-visible-in-window-p start (selected-window)) | |
3554 (pos-visible-in-window-p end (selected-window))) | |
3555 ;; we are all set! | |
3556 nil | |
3557 ;; we need to do something... | |
3558 (goto-char start) | |
3559 (let ((newcent (/ (- (window-height (selected-window)) nl) 2)) | |
3560 (lte (count-lines start (point-max)))) | |
3561 (if (and (< (+ newcent lte) (window-height (selected-window))) | |
3562 (> (- (window-height (selected-window)) lte 1) | |
3563 newcent)) | |
3564 (setq newcent (- (window-height (selected-window)) | |
3565 lte 1))) | |
3566 (recenter newcent)))) | |
3567 (goto-char cp))))) | |
3568 | |
3569 | |
3570 ;;; Tag Management -- Imenu | |
3571 ;; | |
3572 (if (not speedbar-use-imenu-flag) | |
3573 | |
3574 nil | |
3575 | |
3576 (eval-when-compile (if (locate-library "imenu") (require 'imenu))) | |
3577 | |
3578 (defun speedbar-fetch-dynamic-imenu (file) | |
3579 "Load FILE into a buffer, and generate tags using Imenu. | |
3580 Returns the tag list, or t for an error." | |
3581 ;; Load this AND compile it in | |
3582 (require 'imenu) | |
3583 (save-excursion | |
3584 (set-buffer (find-file-noselect file)) | |
3585 (if speedbar-power-click (setq imenu--index-alist nil)) | |
3586 (condition-case nil | |
3587 (let ((index-alist (imenu--make-index-alist t))) | |
3588 (if speedbar-sort-tags | |
3589 (sort (copy-alist index-alist) | |
3590 (lambda (a b) (string< (car a) (car b)))) | |
3591 index-alist)) | |
3592 (error t)))) | |
3593 ) | |
3594 | |
3595 ;;; Tag Management -- etags (old XEmacs compatibility part) | |
3596 ;; | |
3597 (defvar speedbar-fetch-etags-parse-list | |
3598 '(;; Note that java has the same parse-group as c | |
3599 ("\\.\\([cChH]\\|c\\+\\+\\|cpp\\|cc\\|hh\\|java\\)\\'" . | |
3600 speedbar-parse-c-or-c++tag) | |
3601 ("^\\.emacs$\\|.\\(el\\|l\\|lsp\\)\\'" . | |
3602 "def[^i]+\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?") | |
22735 | 3603 ; ("\\.\\([fF]\\|for\\|FOR\\|77\\|90\\)\\'" . |
3604 ; speedbar-parse-fortran77-tag) | |
21650 | 3605 ("\\.tex\\'" . speedbar-parse-tex-string) |
3606 ("\\.p\\'" . | |
3607 "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?") | |
3608 ) | |
3609 "Associations of file extensions and expressions for extracting tags. | |
3610 To add a new file type, you would want to add a new association to the | |
3611 list, where the car is the file match, and the cdr is the way to | |
3612 extract an element from the tags output. If the output is complex, | |
3613 use a function symbol instead of regexp. The function should expect | |
3614 to be at the beginning of a line in the etags buffer. | |
3615 | |
3616 This variable is ignored if `speedbar-use-imenu-flag' is non-nil.") | |
3617 | |
3618 (defvar speedbar-fetch-etags-command "etags" | |
3619 "*Command used to create an etags file. | |
3620 | |
3621 This variable is ignored if `speedbar-use-imenu-flag' is t") | |
3622 | |
3623 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-") | |
3624 "*List of arguments to use with `speedbar-fetch-etags-command'. | |
3625 This creates an etags output buffer. Use `speedbar-toggle-etags' to | |
3626 modify this list conveniently. | |
3627 | |
3628 This variable is ignored if `speedbar-use-imenu-flag' is t") | |
3629 | |
3630 (defun speedbar-toggle-etags (flag) | |
3631 "Toggle FLAG in `speedbar-fetch-etags-arguments'. | |
3632 FLAG then becomes a member of etags command line arguments. If flag | |
3633 is \"sort\", then toggle the value of `speedbar-sort-tags'. If its | |
3634 value is \"show\" then toggle the value of | |
3635 `speedbar-show-unknown-files'. | |
3636 | |
3637 This function is a convenience function for XEmacs menu created by | |
3638 Farzin Guilak <farzin@protocol.com>" | |
3639 (interactive) | |
3640 (cond | |
3641 ((equal flag "sort") | |
3642 (setq speedbar-sort-tags (not speedbar-sort-tags))) | |
3643 ((equal flag "show") | |
3644 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files))) | |
3645 ((or (equal flag "-C") | |
3646 (equal flag "-S") | |
3647 (equal flag "-D")) | |
3648 (if (member flag speedbar-fetch-etags-arguments) | |
3649 (setq speedbar-fetch-etags-arguments | |
3650 (delete flag speedbar-fetch-etags-arguments)) | |
3651 (add-to-list 'speedbar-fetch-etags-arguments flag))) | |
3652 (t nil))) | |
3653 | |
3654 (defun speedbar-fetch-dynamic-etags (file) | |
3655 "For FILE, run etags and create a list of symbols extracted. | |
3656 Each symbol will be associated with its line position in FILE." | |
3657 (let ((newlist nil)) | |
3658 (unwind-protect | |
3659 (save-excursion | |
3660 (if (get-buffer "*etags tmp*") | |
3661 (kill-buffer "*etags tmp*")) ;kill to clean it up | |
3662 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags...")) | |
3663 (set-buffer (get-buffer-create "*etags tmp*")) | |
3664 (apply 'call-process speedbar-fetch-etags-command nil | |
3665 (current-buffer) nil | |
3666 (append speedbar-fetch-etags-arguments (list file))) | |
3667 (goto-char (point-min)) | |
3668 (if (<= 1 speedbar-verbosity-level) (message "Fetching etags...")) | |
3669 (let ((expr | |
3670 (let ((exprlst speedbar-fetch-etags-parse-list) | |
3671 (ans nil)) | |
3672 (while (and (not ans) exprlst) | |
3673 (if (string-match (car (car exprlst)) file) | |
3674 (setq ans (car exprlst))) | |
3675 (setq exprlst (cdr exprlst))) | |
3676 (cdr ans)))) | |
3677 (if expr | |
3678 (let (tnl) | |
3679 (while (not (save-excursion (end-of-line) (eobp))) | |
3680 (save-excursion | |
3681 (setq tnl (speedbar-extract-one-symbol expr))) | |
3682 (if tnl (setq newlist (cons tnl newlist))) | |
3683 (forward-line 1))) | |
3684 (message "Sorry, no support for a file of that extension")))) | |
3685 ) | |
3686 (if speedbar-sort-tags | |
3687 (sort newlist (lambda (a b) (string< (car a) (car b)))) | |
3688 (reverse newlist)))) | |
3689 | |
3690 ;; This bit donated by Farzin Guilak <farzin@protocol.com> but I'm not | |
3691 ;; sure it's needed with the different sorting method. | |
3692 ;; | |
3693 ;(defun speedbar-clean-etags() | |
3694 ; "Removes spaces before the ^? character, and removes `#define', | |
3695 ;return types, etc. preceding tags. This ensures that the sort operation | |
3696 ;works on the tags, not the return types." | |
3697 ; (save-excursion | |
3698 ; (goto-char (point-min)) | |
3699 ; (while | |
3700 ; (re-search-forward "(?[ \t](?\C-?" nil t) | |
3701 ; (replace-match "\C-?" nil nil)) | |
3702 ; (goto-char (point-min)) | |
3703 ; (while | |
3704 ; (re-search-forward "\\(.*[ \t]+\\)\\([^ \t\n]+.*\C-?\\)" nil t) | |
3705 ; (delete-region (match-beginning 1) (match-end 1))))) | |
3706 | |
3707 (defun speedbar-extract-one-symbol (expr) | |
22735 | 3708 "At point, return nil, or one alist in the form: (SYMBOL . POSITION) |
21650 | 3709 The line should contain output from etags. Parse the output using the |
3710 regular expression EXPR" | |
3711 (let* ((sym (if (stringp expr) | |
3712 (if (save-excursion | |
3713 (re-search-forward expr (save-excursion | |
3714 (end-of-line) | |
3715 (point)) t)) | |
3716 (buffer-substring-no-properties (match-beginning 1) | |
3717 (match-end 1))) | |
3718 (funcall expr))) | |
3719 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)" | |
3720 (save-excursion | |
3721 (end-of-line) | |
3722 (point)) | |
3723 t))) | |
3724 (if (and j sym) | |
3725 (1+ (string-to-int (buffer-substring-no-properties | |
3726 (match-beginning 2) | |
3727 (match-end 2)))) | |
3728 0)))) | |
3729 (if (/= pos 0) | |
3730 (cons sym pos) | |
3731 nil))) | |
3732 | |
3733 (defun speedbar-parse-c-or-c++tag () | |
3734 "Parse a c or c++ tag, which tends to be a little complex." | |
3735 (save-excursion | |
3736 (let ((bound (save-excursion (end-of-line) (point)))) | |
3737 (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t) | |
3738 (buffer-substring-no-properties (match-beginning 1) | |
3739 (match-end 1))) | |
3740 ((re-search-forward "\\<\\([^ \t]+\\)\\s-+new(" bound t) | |
3741 (buffer-substring-no-properties (match-beginning 1) | |
3742 (match-end 1))) | |
3743 ((re-search-forward "\\<\\([^ \t(]+\\)\\s-*(\C-?" bound t) | |
3744 (buffer-substring-no-properties (match-beginning 1) | |
3745 (match-end 1))) | |
3746 (t nil)) | |
3747 ))) | |
3748 | |
3749 (defun speedbar-parse-tex-string () | |
3750 "Parse a Tex string. Only find data which is relevant." | |
3751 (save-excursion | |
3752 (let ((bound (save-excursion (end-of-line) (point)))) | |
3753 (cond ((re-search-forward "\\(\\(sub\\)*section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t) | |
3754 (buffer-substring-no-properties (match-beginning 0) | |
3755 (match-end 0))) | |
3756 (t nil))))) | |
3757 | |
3758 | |
22735 | 3759 ;;; BUFFER DISPLAY mode. |
3760 ;; | |
3761 (defvar speedbar-buffers-key-map nil | |
3762 "Keymap used when in the buffers display mode.") | |
3763 | |
3764 (if speedbar-buffers-key-map | |
3765 nil | |
3766 (setq speedbar-buffers-key-map (speedbar-make-specialized-keymap)) | |
3767 | |
3768 ;; Basic tree features | |
3769 (define-key speedbar-buffers-key-map "e" 'speedbar-edit-line) | |
3770 (define-key speedbar-buffers-key-map "\C-m" 'speedbar-edit-line) | |
3771 (define-key speedbar-buffers-key-map "+" 'speedbar-expand-line) | |
3772 (define-key speedbar-buffers-key-map "-" 'speedbar-contract-line) | |
3773 | |
3774 ;; Buffer specific keybindings | |
3775 (define-key speedbar-buffers-key-map "k" 'speedbar-buffer-kill-buffer) | |
3776 (define-key speedbar-buffers-key-map "r" 'speedbar-buffer-revert-buffer) | |
3777 | |
3778 ) | |
3779 | |
3780 (defvar speedbar-buffer-easymenu-definition | |
3781 '(["Jump to buffer" speedbar-edit-line t] | |
3782 ["Expand File Tags" speedbar-expand-line | |
3783 (save-excursion (beginning-of-line) | |
3784 (looking-at "[0-9]+: *.\\+. "))] | |
3785 ["Contract File Tags" speedbar-contract-line | |
3786 (save-excursion (beginning-of-line) | |
3787 (looking-at "[0-9]+: *.-. "))] | |
3788 ) | |
3789 "Menu item elements shown when displaying a buffer list.") | |
3790 | |
3791 (defun speedbar-buffer-buttons (directory zero) | |
3792 "Create speedbar buttons based on the buffers currently loaded. | |
3793 DIRECTORY is the path to the currently active buffer, and ZERO is 0." | |
3794 (speedbar-buffer-buttons-engine nil)) | |
3795 | |
3796 (defun speedbar-buffer-buttons-temp (directory zero) | |
3797 "Create speedbar buttons based on the buffers currently loaded. | |
3798 DIRECTORY is the path to the currently active buffer, and ZERO is 0." | |
3799 (speedbar-buffer-buttons-engine t)) | |
3800 | |
3801 (defun speedbar-buffer-buttons-engine (temp) | |
3802 "Create speedbar buffer buttons. | |
3803 If TEMP is non-nil, then clicking on a buffer restores the previous display." | |
3804 (insert "Active Buffers:\n") | |
3805 (let ((bl (buffer-list))) | |
3806 (while bl | |
3807 (if (string-match "^[ *]" (buffer-name (car bl))) | |
3808 nil | |
3809 (let* ((known (string-match speedbar-file-regexp | |
3810 (buffer-name (car bl)))) | |
3811 (expchar (if known ?+ ??)) | |
3812 (fn (if known 'speedbar-tag-file nil)) | |
3813 (fname (save-excursion (set-buffer (car bl)) | |
3814 (buffer-file-name)))) | |
3815 (speedbar-make-tag-line 'bracket expchar fn fname | |
3816 (buffer-name (car bl)) | |
3817 'speedbar-buffer-click temp | |
3818 'speedbar-file-face 0))) | |
3819 (setq bl (cdr bl))) | |
3820 (setq bl (buffer-list)) | |
3821 (insert "Scratch Buffers:\n") | |
3822 (while bl | |
3823 (if (not (string-match "^\\*" (buffer-name (car bl)))) | |
3824 nil | |
3825 (if (eq (car bl) speedbar-buffer) | |
3826 nil | |
3827 (speedbar-make-tag-line 'bracket ?? nil nil | |
3828 (buffer-name (car bl)) | |
3829 'speedbar-buffer-click temp | |
3830 'speedbar-file-face 0))) | |
3831 (setq bl (cdr bl))) | |
3832 (setq bl (buffer-list)) | |
3833 (insert "Hidden Buffers:\n") | |
3834 (while bl | |
3835 (if (not (string-match "^ " (buffer-name (car bl)))) | |
3836 nil | |
3837 (if (eq (car bl) speedbar-buffer) | |
3838 nil | |
3839 (speedbar-make-tag-line 'bracket ?? nil nil | |
3840 (buffer-name (car bl)) | |
3841 'speedbar-buffer-click temp | |
3842 'speedbar-file-face 0))) | |
3843 (setq bl (cdr bl))))) | |
3844 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3845 (defun speedbar-buffers-item-info () |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3846 "Display information about the current buffer on the current line." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3847 (or (speedbar-item-info-tag-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3848 (let* ((item (speedbar-line-text)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3849 (buffer (if item (get-buffer item) nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3850 (and buffer |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3851 (message "%s%s %S %d %s" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3852 (if (buffer-modified-p buffer) "* " "") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3853 item (save-excursion (set-buffer buffer) major-mode) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3854 (save-excursion (set-buffer buffer) (buffer-size)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3855 (or (buffer-file-name buffer) "<No file>")))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3856 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3857 (defun speedbar-buffers-line-path (&optional depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3858 "Fetch the full path to the file (buffer) specified on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3859 Optional argument DEPTH specifies the current depth of the back search." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3860 (end-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3861 ;; Buffers are always at level 0 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3862 (if (not (re-search-backward "^0:" nil t)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3863 nil |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3864 (let* ((bn (speedbar-line-text)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3865 (buffer (if bn (get-buffer bn)))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3866 (if buffer (file-name-directory (buffer-file-name buffer)))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3867 |
22735 | 3868 (defun speedbar-buffer-click (text token indent) |
3869 "When the users clicks on a buffer-button in speedbar. | |
3870 TEXT is the buffer's name, TOKEN and INDENT are unused." | |
3871 (if speedbar-power-click | |
3872 (let ((pop-up-frames t)) (select-window (display-buffer text))) | |
3873 (select-frame speedbar-attached-frame) | |
3874 (switch-to-buffer text) | |
3875 (if token (speedbar-change-initial-expansion-list | |
3876 speedbar-previously-used-expansion-list-name)))) | |
3877 | |
3878 (defun speedbar-buffer-kill-buffer () | |
3879 "Kill the buffer the cursor is on in the speedbar buffer." | |
3880 (interactive) | |
3881 (or (save-excursion | |
3882 (beginning-of-line) | |
3883 ;; If this fails, then it is a non-standard click, and as such, | |
3884 ;; perfectly allowed. | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3885 (if (re-search-forward "[]>?}] [^ ]" |
22735 | 3886 (save-excursion (end-of-line) (point)) |
3887 t) | |
3888 (let ((text (progn | |
3889 (forward-char -1) | |
3890 (buffer-substring (point) (save-excursion | |
3891 (end-of-line) | |
3892 (point)))))) | |
3893 (if (and (get-buffer text) | |
3894 (y-or-n-p (format "Kill buffer %s? " text))) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3895 (kill-buffer text)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3896 (speedbar-refresh)))))) |
22735 | 3897 |
3898 (defun speedbar-buffer-revert-buffer () | |
3899 "Revert the buffer the cursor is on in the speedbar buffer." | |
3900 (interactive) | |
3901 (save-excursion | |
3902 (beginning-of-line) | |
3903 ;; If this fails, then it is a non-standard click, and as such, | |
3904 ;; perfectly allowed | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3905 (if (re-search-forward "[]>?}] [^ ]" |
22735 | 3906 (save-excursion (end-of-line) (point)) |
3907 t) | |
3908 (let ((text (progn | |
3909 (forward-char -1) | |
3910 (buffer-substring (point) (save-excursion | |
3911 (end-of-line) | |
3912 (point)))))) | |
3913 (if (get-buffer text) | |
3914 (progn | |
3915 (set-buffer text) | |
3916 (revert-buffer t))))))) | |
3917 | |
3918 | |
3919 | |
21650 | 3920 ;;; Color loading section This is messy *Blech!* |
3921 ;; | |
3922 (defface speedbar-button-face '((((class color) (background light)) | |
3923 (:foreground "green4")) | |
3924 (((class color) (background dark)) | |
3925 (:foreground "green3"))) | |
3926 "Face used for +/- buttons." | |
3927 :group 'speedbar-faces) | |
3928 | |
3929 (defface speedbar-file-face '((((class color) (background light)) | |
3930 (:foreground "cyan4")) | |
3931 (((class color) (background dark)) | |
3932 (:foreground "cyan")) | |
3933 (t (:bold t))) | |
3934 "Face used for file names." | |
3935 :group 'speedbar-faces) | |
3936 | |
3937 (defface speedbar-directory-face '((((class color) (background light)) | |
3938 (:foreground "blue4")) | |
3939 (((class color) (background dark)) | |
3940 (:foreground "light blue"))) | |
3941 "Faced used for directory names." | |
3942 :group 'speedbar-faces) | |
3943 (defface speedbar-tag-face '((((class color) (background light)) | |
3944 (:foreground "brown")) | |
3945 (((class color) (background dark)) | |
3946 (:foreground "yellow"))) | |
3947 "Face used for displaying tags." | |
3948 :group 'speedbar-faces) | |
3949 | |
3950 (defface speedbar-selected-face '((((class color) (background light)) | |
3951 (:foreground "red" :underline t)) | |
3952 (((class color) (background dark)) | |
3953 (:foreground "red" :underline t)) | |
3954 (t (:underline t))) | |
3955 "Face used to underline the file in the active window." | |
3956 :group 'speedbar-faces) | |
3957 | |
3958 (defface speedbar-highlight-face '((((class color) (background light)) | |
3959 (:background "green")) | |
3960 (((class color) (background dark)) | |
3961 (:background "sea green")) | |
3962 (((class grayscale monochrome) | |
3963 (background light)) | |
3964 (:background "black")) | |
3965 (((class grayscale monochrome) | |
3966 (background dark)) | |
3967 (:background "white"))) | |
3968 "Face used for highlighting buttons with the mouse." | |
3969 :group 'speedbar-faces) | |
3970 | |
3971 ;; some edebug hooks | |
3972 (add-hook 'edebug-setup-hook | |
3973 (lambda () | |
3974 (def-edebug-spec speedbar-with-writable def-body))) | |
3975 | |
3976 (provide 'speedbar) | |
3977 ;;; speedbar ends here | |
3978 | |
3979 ;; run load-time hooks | |
3980 (run-hooks 'speedbar-load-hook) |