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