(browse-url-browser-function)
[bpt/emacs.git] / lisp / speedbar.el
index e605991..a01b9dd 100644 (file)
@@ -1,11 +1,11 @@
-;;; speedbar --- quick access to files and tags in a frame
+;;; speedbar.el --- quick access to files and tags in a frame
 
-;;; Copyright (C) 1996, 97, 98 Free Software Foundation
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2005
+;;           Free Software Foundation
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
-;; Version: 0.7.2c
+;; Version: 0.11a
 ;; Keywords: file, tags, tools
-;; X-RCS: $Id: speedbar.el,v 1.15 1998/09/12 13:58:46 zappo Exp $
 
 ;; This file is part of GNU Emacs.
 
 ;;
 ;; Starting Speedbar:
 ;;
-;;   If speedbar came to you as a part of Emacs, simply type
-;; `M-x speedbar', and it will be autoloaded for you.
-;;
-;;   If speedbar is not a part of your distribution, then add
-;; this to your .emacs file:
-;;
-;;   (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
-;;   (autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t)
-;;
+;;   Simply type `M-x speedbar', and it will be autoloaded for you.
+
 ;;   If you want to choose it from a menu, such as "Tools", you can do this:
 ;;
-;;   Emacs:
 ;;   (define-key-after (lookup-key global-map [menu-bar tools])
 ;;      [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar])
 ;;
-;;   XEmacs:
-;;   (add-menu-button '("Tools")
-;;                   ["Speedbar" speedbar-frame-mode
-;;                    :style toggle
-;;                    :selected (and (boundp 'speedbar-frame)
-;;                                   (frame-live-p speedbar-frame)
-;;                                   (frame-visible-p speedbar-frame))]
-;;                   "--")
-;;
 ;;   If you want to access speedbar using only the keyboard, do this:
 ;;
-;;   (global-set-key [(f4)] 'speedbar-get-focus)
+;;   (global-set-key [f4] 'speedbar-get-focus)
 ;;
 ;;   This will let you hit f4 (or whatever key you choose) to jump
 ;; focus to the speedbar frame.  Pressing it again will bring you back
 ;; applicable, tags in the active file can be expanded.
 ;;
 ;;   To add new supported files types into speedbar, use the function
-;; `speedbar-add-supported-extension' If speedbar complains that the
+;; `speedbar-add-supported-extension' If speedbar complains that the
 ;; file type is not supported, that means there is no built in
 ;; support from imenu, and the etags part wasn't set up correctly.  You
 ;; may add elements to `speedbar-supported-extension-expressions' as long
 ;; as it is done before speedbar is loaded.
 ;;
 ;;   To prevent speedbar from following you into certain directories
-;; use the function `speedbar-add-ignored-path-regexp' too add a new
+;; use the function `speedbar-add-ignored-path-regexp' to add a new
 ;; regular expression matching a type of path.  You may add list
 ;; elements to `speedbar-ignored-path-expressions' as long as it is
 ;; done before speedbar is loaded.
 ;; which controls how tags are layed out.  It is actually a list of
 ;; functions that filter the data.  The default groups large tag lists
 ;; into sub-lists.  A long flat list can be used instead if needed.
-;; Other filters could be easily added.
-;;
-;;    Users of XEmacs previous to 20 may want to change the default
-;; timeouts for `speedbar-update-speed' to something longer as XEmacs
-;; doesn't have idle timers, the speedbar timer keeps going off
-;; arbitrarily while you're typing.  It's quite pesky.
+;; Other filters can be easily added.
 ;;
-;;    Users of really old emacsen without the needed timers will not
-;; have speedbar updating automatically.  Use "r" to refresh the
-;; display after changing directories.  Remember, do not interrupt the
-;; stealthy updates or your display may not be completely refreshed.
-;;
-;;    AUC-TEX users: The imenu tags for AUC-TEX mode don't work very
+;;    AUCTEX users: The imenu tags for AUCTEX mode doesn't work very
 ;; well.  Use the imenu keywords from tex-mode.el for better results.
 ;;
 ;; This file requires the library package assoc (association lists)
-;; and the package custom (for easy configuration of speedbar)
-;;     http://www.dina.kvl.dk/~abraham/custom/
 ;;
 ;;; Developing for speedbar
 ;;
 ;; Adding a speedbar specialized display mode:
 ;;
 ;; Speedbar can be configured to create a special display for certain
-;; modes that do not display tradition file/tag data.  Rmail, Info,
+;; modes that do not display traditional file/tag data.  Rmail, Info,
 ;; and the debugger are examples.  These modes can, however, benefit
 ;; from a speedbar style display in their own way.
 ;;
 ;; `speedbar-insert-generic-list'.  If you use
 ;; `speedbar-insert-generic-list', also read the doc for
 ;; `speedbar-tag-hierarchy-method' in case you wish to override it.
-;; The function `speedbar-with-attached-buffer' brings you back to the
+;; The macro `speedbar-with-attached-buffer' brings you back to the
 ;; buffer speedbar is displaying for.
 ;;
 ;; For those functions that make buttons, the "function" should be a
 ;; functions are `speedbar-change-expand-button-char',
 ;; `speedbar-delete-subblock', and `speedbar-center-buffer-smartly'.
 ;; The variable `speedbar-power-click' is set to t in your functions
-;; when the user shift-clicks.  This indications anything from
+;; when the user shift-clicks.  This is an indication of anything from
 ;; refreshing cached data to making a buffer appear in a new frame.
 ;;
 ;; If you wish to add to the default speedbar menu for the case of
 ;; splice in.  KEYMAP is a symbol holding the keymap to use, and
 ;; BUTTON-FUNCTIONS are the function names to call, in order, to create
 ;; the display.
+;;  Another tweakable variable is `speedbar-stealthy-function-list'
+;; which is of the form (NAME &rest FUNCTION ...).  NAME is the string
+;; name matching `speedbar-add-expansion-list'.  (It does not need to
+;; exist.). This provides additional display info which might be
+;; time-consuming to calculate.
+;;  Lastly, `speedbar-mode-functions-list' allows you to set special
+;; function overrides.  At the moment very few functions may be
+;; overridden, but more will be added as the need is discovered.
 
 ;;; TODO:
 ;; - More functions to create buttons and options
 ;; - Timeout directories we haven't visited in a while.
-;; - Remeber tags when refreshing the display.  (Refresh tags too?)
-;; - More 'special mode support.
+
+;;; Code:
 
 (require 'assoc)
 (require 'easymenu)
 
+(condition-case nil
+    (require 'image)
+  (error nil))
+
 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version)
   "Non-nil if we are running in the XEmacs environment.")
 (defvar speedbar-xemacs20p (and speedbar-xemacsp
-                               (= emacs-major-version 20)))
-
-;; From custom web page for compatibility between versions of custom:
-(eval-and-compile
-  (condition-case ()
-      (require 'custom)
-    (error nil))
-  (if (and (featurep 'custom) (fboundp 'custom-declare-variable)
-          ;; Some XEmacsen w/ custom don't have :set keyword.
-          ;; This protects them against custom.
-          (fboundp 'custom-initialize-set))
-      nil ;; We've got what we needed
-    ;; We have the old custom-library, hack around it!
-    (defmacro defgroup (&rest args)
-      nil)
-    (defmacro defface (var values doc &rest args)
-      (` (progn
-          (defvar (, var) (quote (, var)))
-          ;; To make colors for your faces you need to set your .Xdefaults
-          ;; or set them up ahead of time in your .emacs file.
-          (make-face (, var))
-          )))
-    (defmacro defcustom (var value doc &rest args)
-      (` (defvar (, var) (, value) (, doc))))))
+                               (>= emacs-major-version 20)))
 
 ;; customization stuff
 (defgroup speedbar nil
   "File and tag browser frame."
-  :group 'tags
+  :group 'etags
   :group 'tools
   :group 'convenience
   :version "20.3")
   :prefix "speedbar-"
   :group 'speedbar)
 
-;;; Code:
 (defvar speedbar-initial-expansion-mode-alist
   '(("buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map
      speedbar-buffer-buttons)
@@ -267,15 +226,10 @@ second parameter.  The 0 indicates the uppermost indentation level.
 They must assume that the cursor is at the position where they start
 inserting buttons.")
 
-(defcustom speedbar-initial-expansion-list-name "files"
+(defvar speedbar-initial-expansion-list-name "files"
   "A symbol name representing the expansion list to use.
 The expansion list `speedbar-initial-expansion-mode-alist' contains
-the names and associated functions to use for buttons in speedbar."
-  :group 'speedbar
-  :type '(radio (const :tag "File Directories" "files")
-               (const "buffers")
-               (const "quick buffers")
-              ))
+the names and associated functions to use for buttons in speedbar.")
 
 (defvar speedbar-previously-used-expansion-list-name "files"
   "Save the last expansion list method.
@@ -298,6 +252,26 @@ t.  Functions which take a long time should maintain a state (where
 they are in their speedbar related calculations) and permit
 interruption.  See `speedbar-check-vc' as a good example.")
 
+(defvar speedbar-mode-functions-list
+  '(("files" (speedbar-item-info . speedbar-files-item-info)
+     (speedbar-line-path . speedbar-files-line-path))
+    ("buffers" (speedbar-item-info . speedbar-buffers-item-info)
+     (speedbar-line-path . speedbar-buffers-line-path))
+    ("quick buffers" (speedbar-item-info . speedbar-buffers-item-info)
+     (speedbar-line-path . speedbar-buffers-line-path))
+    )
+  "List of function tables to use for different major display modes.
+It is not necessary to define any functions for a specialized mode.
+This just provides a simple way of adding lots of customizations.
+Each sublist is of the form:
+  (\"NAME\" (FUNCTIONSYMBOL . REPLACEMENTFUNCTION) ...)
+Where NAME is the name of the specialized mode.  The rest of the list
+is a set of dotted pairs of the form FUNCTIONSYMBOL, which is the name
+of a function you would like to replace, and REPLACEMENTFUNCTION,
+which is a function you can call instead.  Not all functions can be
+replaced this way.  Replaceable functions must provide that
+functionality individually.")
+
 (defcustom speedbar-mode-specific-contents-flag t
   "*Non-nil means speedbar will show special mode contents.
 This permits some modes to create customized contents for the speedbar
@@ -315,23 +289,34 @@ speedbar buffer.")
 (defvar speedbar-special-mode-key-map nil
   "Default keymap used when identifying a specialized display mode.
 This keymap is local to each buffer that wants to define special keybindings
-effective when it's display is shown.")
+effective when its display is shown.")
 
 (defcustom speedbar-visiting-file-hook nil
   "Hooks run when speedbar visits a file in the selected frame."
   :group 'speedbar
   :type 'hook)
 
-(defcustom speedbar-visiting-tag-hook nil
+(defcustom speedbar-visiting-tag-hook '(speedbar-highlight-one-tag-line)
   "Hooks run when speedbar visits a tag in the selected frame."
   :group 'speedbar
-  :type 'hook)
+  :type 'hook
+  :version "21.1"
+  :options '(speedbar-highlight-one-tag-line
+            speedbar-recenter-to-top
+            speedbar-recenter
+            ))
 
 (defcustom speedbar-load-hook nil
   "Hooks run when speedbar is loaded."
   :group 'speedbar
   :type 'hook)
 
+(defcustom speedbar-reconfigure-keymaps-hook nil
+  "Hooks run when the keymaps are regenerated."
+  :group 'speedbar
+  :version "21.1"
+  :type 'hook)
+
 (defcustom speedbar-show-unknown-files nil
   "*Non-nil show files we can't expand with a ? in the expand button.
 nil means don't show the file in the list."
@@ -364,24 +349,23 @@ between different directories."
                                       (width . 20)
                                       (border-width . 0)
                                       (menu-bar-lines . 0)
+                                      (tool-bar-lines . 0)
                                       (unsplittable . t))
   "*Parameters to use when creating the speedbar frame in Emacs.
-Parameters not listed here which will be added automatically are
-`height' which will be initialized to the height of the frame speedbar
-is attached to."
+Any parameter supported by a frame may be added.  The parameter `height'
+will be initialized to the height of the frame speedbar is
+attached to and added to this list before the new frame is initialized."
   :group 'speedbar
-  :type '(repeat (sexp :tag "Parameter:")))
+  :type '(repeat (cons :format "%v"
+                      (symbol :tag "Parameter")
+                      (sexp :tag "Value"))))
 
 ;; These values by Hrvoje Niksic <hniksic@srce.hr>
 (defcustom speedbar-frame-plist
   '(minibuffer nil width 20 border-width 0
               internal-border-width 0 unsplittable t
               default-toolbar-visible-p nil has-modeline-p nil
-              menubar-visible-p nil
-              ;; I don't see the particular value of these three, but...
-              text-pointer-glyph [cursor-font :data "top_left_arrow"]
-              nontext-pointer-glyph [cursor-font :data "top_left_arrow"]
-              selection-pointer-glyph [cursor-font :data "hand2"])
+              menubar-visible-p nil)
   "*Parameters to use when creating the speedbar frame in XEmacs.
 Parameters not listed here which will be added automatically are
 `height' which will be initialized to the height of the frame speedbar
@@ -391,43 +375,69 @@ is attached to."
                        (symbol :tag "Property")
                        (sexp :tag "Value"))))
 
-(defcustom speedbar-use-imenu-flag (stringp (locate-library "imenu"))
+(defcustom speedbar-use-imenu-flag (fboundp 'imenu)
   "*Non-nil means use imenu for file parsing.  nil to use etags.
 XEmacs prior to 20.4 doesn't support imenu, therefore the default is to
 use etags instead.  Etags support is not as robust as imenu support."
-  :tag "User Imenu"
+  :tag "Use Imenu for tags"
   :group 'speedbar
   :type 'boolean)
 
+(defvar speedbar-dynamic-tags-function-list
+  '((speedbar-fetch-dynamic-imenu . speedbar-insert-imenu-list)
+    (speedbar-fetch-dynamic-etags . speedbar-insert-etags-list))
+  "Set to a list of functions which will return and insert a list of tags.
+Each element is of the form ( FETCH .  INSERT ) where FETCH
+is a function which takes one parameter (the file to tag) and returns a
+list of tags.  The tag list can be of any form as long as the
+corresponding insert method can handle it.  If it returns t, then an
+error occurred, and the next fetch routine is tried.
+INSERT is a function which takes an INDENTation level, and a LIST of
+tags to insert.  It will then create the speedbar buttons.")
+
 (defcustom speedbar-track-mouse-flag t
   "*Non-nil means to display info about the line under the mouse."
   :group 'speedbar
   :type 'boolean)
 
 (defcustom speedbar-sort-tags nil
-  "*If Non-nil, sort tags in the speedbar display.  *Obsolete*."
+  "*If non-nil, sort tags in the speedbar display.  *Obsolete*."
   :group 'speedbar
   :type 'boolean)
 
 (defcustom speedbar-tag-hierarchy-method
-  '(prefix-group trim-words)
-  "*List of methods which speedbar will use to organize tags into groups.
-Groups are defined as expandable meta-tags.  Imenu supports such
-things in some languages, such as separating variables from functions.
-Available methods are:
-  sort         - Sort tags.  (sometimes unnecessary)
-  trim-words   - Trim all tags by a common prefix, broken @ word sections.
-  prefix-group - Try to guess groups by prefix.
-  simple-group - If imenu already returned some meta groups, stick all
-                 tags that are not in a group into a sub-group."
+  '(speedbar-prefix-group-tag-hierarchy
+    speedbar-trim-words-tag-hierarchy)
+  "*List of hooks which speedbar will use to organize tags into groups.
+Groups are defined as expandable meta-tags.  Imenu supports
+such things in some languages, such as separating variables from
+functions.  Each hook takes one argument LST, and may destructively
+create a new list of the same form.  LST is a list of elements of the
+form:
+  (ELT1 ELT2 ... ELTn)
+where each ELT is of the form
+  (TAG-NAME-STRING . NUMBER-OR-MARKER)
+or
+  (GROUP-NAME-STRING ELT1 ELT2... ELTn)"
   :group 'speedbar
-  :type '(repeat
-         (radio
-          (const :tag "Sort the tags." sort)
-          (const :tag "Trim words to common prefix." trim-words)
-          (const :tag "Create groups from common prefixes." prefix-group)
-          (const :tag "Group loose tags into their own group." simple-group))
-         ))
+  :type 'hook
+  :options '(speedbar-sort-tag-hierarchy
+            speedbar-trim-words-tag-hierarchy
+            speedbar-prefix-group-tag-hierarchy
+            speedbar-simple-group-tag-hierarchy)
+  )
+
+(defcustom speedbar-tag-group-name-minimum-length 4
+  "*The minimum length of a prefix group name before expanding.
+Thus, if the `speedbar-tag-hierarchy-method' includes `prefix-group'
+and one such groups common characters is less than this number of
+characters, then the group name will be changed to the form of:
+  worda to wordb
+instead of just
+  word
+This way we won't get silly looking listings."
+  :group 'speedbar
+  :type 'integer)
 
 (defcustom speedbar-tag-split-minimum-length 20
   "*Minimum length before we stop trying to create sub-lists in tags.
@@ -474,8 +484,27 @@ hierarchy would be replaced with the new directory."
   :group 'speedbar
   :type 'boolean)
 
-(defvar speedbar-hide-button-brackets-flag nil
-  "*Non-nil means speedbar will hide the brackets around the + or -.")
+(defcustom speedbar-indentation-width 1
+  "*When sub-nodes are expanded, the number of spaces used for indentation."
+  :group 'speedbar
+  :version "21.1"
+  :type 'integer)
+
+(defcustom speedbar-hide-button-brackets-flag nil
+  "*Non-nil means speedbar will hide the brackets around the + or -."
+  :group 'speedbar
+  :version "21.1"
+  :type 'boolean)
+
+(defcustom speedbar-use-images (and (or (fboundp 'defimage)
+                                       (fboundp 'make-image-specifier))
+                                   (if (fboundp 'display-graphic-p)
+                                       (display-graphic-p)
+                                     window-system))
+  "*Non-nil if speedbar should display icons."
+  :group 'speedbar
+  :version "21.1"
+  :type 'boolean)
 
 (defcustom speedbar-before-popup-hook nil
   "*Hooks called before popping up the speedbar frame."
@@ -509,15 +538,14 @@ verbosity."
 
 (defcustom speedbar-vc-do-check t
   "*Non-nil check all files in speedbar to see if they have been checked out.
-Any file checked out is marked with `speedbar-vc-indicator'"
+Any file checked out is marked with `speedbar-vc-indicator'."
   :group 'speedbar-vc
   :type 'boolean)
 
 (defvar speedbar-vc-indicator "*"
   "Text used to mark files which are currently checked out.
-Currently only RCS is supported.  Other version control systems can be
-added by examining the function `speedbar-this-file-in-vc' and
-`speedbar-vc-check-dir-p'")
+Other version control systems can be added by examining the function
+`speedbar-vc-path-enable-hook' and `speedbar-vc-in-control-hook'.")
 
 (defcustom speedbar-vc-path-enable-hook nil
   "*Return non-nil if the current path should be checked for Version Control.
@@ -539,7 +567,7 @@ current file, and the FILENAME of the file being checked."
 (defcustom speedbar-obj-do-check t
   "*Non-nil check all files in speedbar to see if they have an object file.
 Any file checked out is marked with `speedbar-obj-indicator', and the
-marking is based on  `speedbar-obj-alist'"
+marking is based on `speedbar-obj-alist'."
   :group 'speedbar-vc
   :type 'boolean)
 
@@ -609,7 +637,7 @@ Use the function `speedbar-add-ignored-path-regexp', or customize the
 variable `speedbar-ignored-path-expressions' to modify this variable.")
 
 (defcustom speedbar-ignored-path-expressions
-  '("/logs?/\\'")
+  '("[/\\]logs?[/\\]\\'")
   "*List of regular expressions matching directories speedbar will ignore.
 They should included paths to directories which are notoriously very
 large and take a long time to load in.  Use the function
@@ -641,17 +669,20 @@ useful, such as version control."
   "*Regexp matching files we don't want displayed in a speedbar buffer.
 It is generated from the variable `completion-ignored-extensions'")
 
+;; Compiler silencing trick.  The real defvar comes later in this file.
+(defvar speedbar-file-regexp)
+
 ;; this is dangerous to customize, because the defaults will probably
 ;; change in the future.
 (defcustom speedbar-supported-extension-expressions
   (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?"
            ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".f\\(90\\|77\\|or\\)?")
          (if speedbar-use-imenu-flag
-             '(".ada" ".pl" ".tcl" ".m" ".scm" ".pm" ".py"
+             '(".ada" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g"
                ;; html is not supported by default, but an imenu tags package
                ;; is available.  Also, html files are nice to be able to see.
                ".s?html"
-               "Makefile\\(\\.in\\)?")))
+               "[Mm]akefile\\(\\.in\\)?")))
   "*List of regular expressions which will match files supported by tagging.
 Do not prefix the `.' char with a double \\ to quote it, as the period
 will be stripped by a simplified optimizer when compiled into a
@@ -661,11 +692,11 @@ function `speedbar-add-supported-extension' to add a new extension at
 runtime, or use the configuration dialog to set it in your .emacs
 file."
   :group 'speedbar
+  :version "21.1"
   :type '(repeat (regexp :tag "Extension Regexp"))
   :set (lambda (sym val)
         (setq speedbar-supported-extension-expressions val
-              speedbar-file-regexp (speedbar-extension-list-to-regex val)))
-  )
+              speedbar-file-regexp (speedbar-extension-list-to-regex val))))
 
 (defvar speedbar-file-regexp
   (speedbar-extension-list-to-regex speedbar-supported-extension-expressions)
@@ -673,13 +704,22 @@ file."
 Created from `speedbar-supported-extension-expression' with the
 function `speedbar-extension-list-to-regex'")
 
+(defcustom speedbar-scan-subdirs nil
+  "*Non-nil means speedbar will check if subdirs are empty.
+That way you don't have to click on them to find out.  But this
+incurs extra I/O, hence it slows down directory display
+proportionally to the number of subdirs."
+  :group 'speedbar
+  :type 'boolean
+  :version 22.1)
+
 (defun speedbar-add-supported-extension (extension)
   "Add EXTENSION as a new supported extension for speedbar tagging.
 This should start with a `.' if it is not a complete file name, and
 the dot should NOT be quoted in with \\.  Other regular expression
 matchers are allowed however.  EXTENSION may be a single string or a
 list of strings."
-  (interactive "sExtionsion: ")
+  (interactive "sExtension: ")
   (if (not (listp extension)) (setq extension (list extension)))
   (while extension
     (if (member (car extension) speedbar-supported-extension-expressions)
@@ -717,13 +757,13 @@ PATH-EXPRESSION to `speedbar-ignored-path-expressions'."
                              (or (fboundp 'run-with-idle-timer)
                                  (fboundp 'start-itimer)
                                  (boundp 'post-command-idle-hook))
-                             window-system)
+                             (if (fboundp 'display-graphic-p)
+                                 (display-graphic-p)
+                               window-system))
   "*Non-nil means to automatically update the display.
-When this is nil then speedbar will not follow the attached frame's path.
-When speedbar is active, use:
-
-\\<speedbar-key-map> `\\[speedbar-toggle-updates]'
-
+When this is nil then speedbar will not follow the attached
+frame's path.  Type \
+\\<speedbar-key-map>\\[speedbar-toggle-updates] in the speedbar \
 to toggle this value.")
 
 (defvar speedbar-syntax-table nil
@@ -737,6 +777,8 @@ to toggle this value.")
   (modify-syntax-entry ?\" " " speedbar-syntax-table)
   (modify-syntax-entry ?( " " speedbar-syntax-table)
   (modify-syntax-entry ?) " " speedbar-syntax-table)
+  (modify-syntax-entry ?{ " " speedbar-syntax-table)
+  (modify-syntax-entry ?} " " speedbar-syntax-table)
   (modify-syntax-entry ?[ " " speedbar-syntax-table)
   (modify-syntax-entry ?] " " speedbar-syntax-table))
 
@@ -818,7 +860,7 @@ to toggle this value.")
    ))
 
 (defun speedbar-make-specialized-keymap ()
-  "Create a keymap for use w/ a speedbar major or minor display mode.
+  "Create a keymap for use with a speedbar major or minor display mode.
 This basically creates a sparse keymap, and makes it's parent be
 `speedbar-key-map'."
   (let ((k (make-sparse-keymap)))
@@ -836,6 +878,7 @@ This basically creates a sparse keymap, and makes it's parent be
   (define-key speedbar-file-key-map "e" 'speedbar-edit-line)
   (define-key speedbar-file-key-map "\C-m" 'speedbar-edit-line)
   (define-key speedbar-file-key-map "+" 'speedbar-expand-line)
+  (define-key speedbar-file-key-map "=" 'speedbar-expand-line)
   (define-key speedbar-file-key-map "-" 'speedbar-contract-line)
 
   ;; file based commands
@@ -850,11 +893,20 @@ This basically creates a sparse keymap, and makes it's parent be
   )
 
 (defvar speedbar-easymenu-definition-base
-  '("Speedbar"
-    ["Update" speedbar-refresh t]
-    ["Auto Update" speedbar-toggle-updates
-     :style toggle :selected speedbar-update-flag]
-    )
+  (append
+   '("Speedbar"
+     ["Update" speedbar-refresh t]
+     ["Auto Update" speedbar-toggle-updates
+      :style toggle :selected speedbar-update-flag])
+   (if (and (or (fboundp 'defimage)
+               (fboundp 'make-image-specifier))
+           (if (fboundp 'display-graphic-p)
+               (display-graphic-p)
+             window-system))
+       (list
+       ["Use Images" speedbar-toggle-images
+        :style toggle :selected speedbar-use-images]))
+   )
   "Base part of the speedbar menu.")
 
 (defvar speedbar-easymenu-definition-special
@@ -864,6 +916,9 @@ This basically creates a sparse keymap, and makes it's parent be
     ["Expand File Tags" speedbar-expand-line
      (save-excursion (beginning-of-line)
                     (looking-at "[0-9]+: *.\\+. "))]
+    ["Flush Cache & Expand" speedbar-flush-expand-line
+     (save-excursion (beginning-of-line)
+                    (looking-at "[0-9]+: *.\\+. "))]
     ["Contract File Tags" speedbar-contract-line
      (save-excursion (beginning-of-line)
                     (looking-at "[0-9]+: *.-. "))]
@@ -890,17 +945,18 @@ This basically creates a sparse keymap, and makes it's parent be
                     (looking-at "[0-9]+: *\\[[+-]\\] [^ \n]+ \\*?[!#]$"))]
     )
   "Additional menu items while in file-mode.")
+
 (defvar speedbar-easymenu-definition-trailer
-  (list
+  (append
    (if (and (featurep 'custom) (fboundp 'custom-declare-variable))
-       ["Customize..." speedbar-customize t])
-   ["Close" speedbar-close-frame t]
-   ["Quit" delete-frame t] )
+       (list ["Customize..." speedbar-customize t]))
+   (list
+    ["Close" speedbar-close-frame t]
+    ["Quit" delete-frame t] ))
   "Menu items appearing at the end of the speedbar menu.")
 
 (defvar speedbar-desired-buffer nil
-  "Non-nil when speedbar is showing buttons specific a special mode.
+  "Non-nil when speedbar is showing buttons specific to a special mode.
 In this case it is the originating buffer.")
 (defvar speedbar-buffer nil
   "The buffer displaying the speedbar.")
@@ -933,6 +989,31 @@ directories.")
   "Never set this by hand.  Value is t when S-mouse activity occurs.")
 
 \f
+;;; Compatibility
+;;
+(if (fboundp 'frame-parameter)
+
+    (defalias 'speedbar-frame-parameter 'frame-parameter)
+
+  (defun speedbar-frame-parameter (frame parameter)
+    "Return FRAME's PARAMETER value."
+    (cdr (assoc parameter (frame-parameters frame)))))
+
+(if (fboundp 'make-overlay)
+    (progn
+      (defalias 'speedbar-make-overlay 'make-overlay)
+      (defalias 'speedbar-overlay-put 'overlay-put)
+      (defalias 'speedbar-delete-overlay 'delete-overlay)
+      (defalias 'speedbar-overlay-start 'overlay-start)
+      (defalias 'speedbar-overlay-end 'overlay-end)
+      (defalias 'speedbar-mode-line-update 'force-mode-line-update))
+  (defalias 'speedbar-make-overlay 'make-extent)
+  (defalias 'speedbar-overlay-put 'set-extent-property)
+  (defalias 'speedbar-delete-overlay 'delete-extent)
+  (defalias 'speedbar-overlay-start 'extent-start)
+  (defalias 'speedbar-overlay-end 'extent-end)
+  (defalias 'speedbar-mode-line-update 'redraw-modeline))
+\f
 ;;; Mode definitions/ user commands
 ;;
 
@@ -988,17 +1069,24 @@ supported at a time.
          (raise-frame speedbar-frame)
        (setq speedbar-frame
              (if speedbar-xemacsp
-                 (make-frame (nconc (list 'height
-                                          (speedbar-needed-height))
-                                    speedbar-frame-plist))
-               (let* ((mh (frame-parameter nil 'menu-bar-lines))
-                      (cfx (frame-parameter nil 'left))
-                      (cfy (frame-parameter nil 'top))
+                 ;; Only guess height if it is not specified.
+                 (if (member 'height speedbar-frame-plist)
+                     (make-frame speedbar-frame-plist)
+                   (make-frame (nconc (list 'height
+                                            (speedbar-needed-height))
+                                      speedbar-frame-plist)))
+               (let* ((mh (speedbar-frame-parameter nil 'menu-bar-lines))
+                      (cfx (speedbar-frame-parameter nil 'left))
+                      (cfy (speedbar-frame-parameter nil 'top))
                       (cfw (frame-pixel-width))
                       (params
-                       (append
-                        speedbar-frame-parameters
-                        (list (cons 'height (+ mh (frame-height))))))
+                       ;; Only add a guessed height if one is not specified
+                       ;; in the input parameters.
+                       (if (assoc 'height speedbar-frame-parameters)
+                           speedbar-frame-parameters
+                         (append
+                          speedbar-frame-parameters
+                          (list (cons 'height (+ mh (frame-height)))))))
                       (frame
                        (if (or (< emacs-major-version 20)
                                (not (eq window-system 'x)))
@@ -1007,19 +1095,50 @@ supported at a time.
                                (x-sensitive-text-pointer-shape
                                 x-pointer-hand2))
                            (make-frame params)))))
-                 (if (and window-system (not (eq window-system 'pc)))
-                     (set-frame-position frame
-                                         ;; Decide which side to put it
-                                         ;; on.  200 is just a buffer
-                                         ;; for the left edge of the
-                                         ;; screen.  The extra 10 is just
-                                         ;; dressings for window decorations.
-                                         (if (< cfx 200)
-                                             (+ cfx cfw 10)
-                                           (- cfx (frame-pixel-width frame)
-                                              10))
-                                         cfy))
-                 frame)))
+                 ;; Position speedbar frame.
+                 (if (or (not window-system) (eq window-system 'pc)
+                         (assoc 'left speedbar-frame-parameters)
+                         (assoc 'top speedbar-frame-parameters))
+                     ;; Do no positioning if not on a windowing system,
+                     ;; or if left/top were specified in the parameters.
+                     frame
+                   (let ((cfx
+                          (if (not (consp cfx))
+                              cfx
+                            ;; If cfx is a list, that means we grow
+                            ;; from a specific edge of the display.
+                            ;; Convert that to the distance from the
+                            ;; left side of the display.
+                            (if (eq (car cfx) '-)
+                                ;; A - means distance from the right edge
+                                ;; of the display, or DW - cfx - framewidth
+                                (- (x-display-pixel-width) (car (cdr cfx))
+                                   (frame-pixel-width))
+                              (car (cdr cfx))))))
+                     (modify-frame-parameters
+                      frame
+                      (list
+                       (cons
+                        'left
+                        ;; Decide which side to put it
+                        ;; on.  200 is just a buffer
+                        ;; for the left edge of the
+                        ;; screen.  The extra 10 is just
+                        ;; dressings for window decorations.
+                        (let ((sfw (frame-pixel-width frame)))
+                          (let ((left-guess (- cfx 10 sfw))
+                                (right-guess (+ cfx cfw 5)))
+                            (let ((left-margin left-guess)
+                                  (right-margin
+                                   (- (x-display-pixel-width)
+                                      right-guess 5 sfw)))
+                              (cond ((>= left-margin 0) left-guess)
+                                    ((>= right-margin 0) right-guess)
+                                    ;; otherwise choose side we overlap less
+                                    ((> left-margin right-margin) 0)
+                                    (t (- (x-display-pixel-width) sfw 5)))))))
+                       (cons 'top cfy)))
+                     frame)))))
        ;; reset the selection variable
        (setq speedbar-last-selected-file nil)
        ;; Put the buffer into the frame
@@ -1029,7 +1148,8 @@ supported at a time.
          (select-frame speedbar-frame)
          (switch-to-buffer speedbar-buffer)
          (set-window-dedicated-p (selected-window) t))
-       (if (or (null window-system) (eq window-system 'pc))
+       (if (and (or (null window-system) (eq window-system 'pc))
+                (fboundp 'set-frame-name))
            (progn
              (select-frame speedbar-frame)
              (set-frame-name "Speedbar")))
@@ -1108,13 +1228,13 @@ Files are completely ignored if they match `speedbar-file-unshown-regexp'
 which is generated from `completion-ignored-extensions'.
 
 Files with a `*' character after their name are files checked out of a
-version control system.  (currently only RCS is supported.)  New
+version control system.  (Currently only RCS is supported.)  New
 version control systems can be added by examining the documentation
-for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'
+for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'.
 
 Files with a `#' or `!' character after them are source files that
 have an object file associated with them.  The `!' indicates that the
-files is out of date.   You can control what source/object associations
+files is out of date.  You can control what source/object associations
 exist through the variable `speedbar-obj-alist'.
 
 Click on the [+] to display a list of tags from that file.  Click on
@@ -1165,12 +1285,11 @@ in the selected file.
                               (speedbar-quick-mouse event))
                              ((or (eq count 2)
                                   (eq count 3))
-                              (mouse-set-point event)
+                              (speedbar-mouse-set-point event)
                               (speedbar-do-function-pointer)
                               (speedbar-quick-mouse event)))
                        ;; Don't do normal operations.
                        t)))))
-    (make-local-hook 'kill-buffer-hook)
     (add-hook 'kill-buffer-hook (lambda () (let ((skilling (boundp 'skilling)))
                                             (if skilling
                                                 nil
@@ -1181,18 +1300,41 @@ in the selected file.
     (toggle-read-only 1)
     (speedbar-set-mode-line-format)
     (if speedbar-xemacsp
-       (progn
-         (make-local-variable 'mouse-motion-handler)
-         (setq mouse-motion-handler 'speedbar-track-mouse-xemacs))
+       (with-no-warnings
+        (set (make-local-variable 'mouse-motion-handler)
+             'speedbar-track-mouse-xemacs))
       (if speedbar-track-mouse-flag
-         (progn
-           (make-local-variable 'track-mouse)
-           (setq track-mouse t)))      ;this could be messy.
+         (set (make-local-variable 'track-mouse) t))   ;this could be messy.
       (setq auto-show-mode nil))       ;no auto-show for Emacs
-    (run-hooks 'speedbar-mode-hook))
+    (run-mode-hooks 'speedbar-mode-hook))
   (speedbar-update-contents)
   speedbar-buffer)
 
+(defmacro speedbar-with-attached-buffer (&rest forms)
+  "Execute FORMS in the attached frame's special buffer.
+Optionally select that frame if necessary."
+  `(save-selected-window
+     (speedbar-set-timer speedbar-update-speed)
+     (select-frame speedbar-attached-frame)
+     ,@forms
+     (speedbar-maybee-jump-to-attached-frame)))
+
+(defun speedbar-message (fmt &rest args)
+  "Like message, but for use in the speedbar frame.
+Argument FMT is the format string, and ARGS are the arguments for message."
+  (save-selected-window
+    (select-frame speedbar-attached-frame)
+    (apply 'message fmt args)))
+
+(defun speedbar-y-or-n-p (prompt)
+  "Like `y-or-n-p', but for use in the speedbar frame.
+Argument PROMPT is the prompt to use."
+  (save-selected-window
+    (if (and default-minibuffer-frame (not (eq default-minibuffer-frame
+                                              speedbar-attached-frame)))
+       (select-frame speedbar-attached-frame))
+    (y-or-n-p prompt)))
+
 (defun speedbar-show-info-under-mouse (&optional event)
   "Call the info function for the line under the mouse.
 Optional EVENT is currently not used."
@@ -1200,7 +1342,7 @@ Optional EVENT is currently not used."
     (if (equal (car pos) speedbar-frame)
        (save-excursion
          (save-window-excursion
-           (apply 'set-mouse-position pos)
+           (apply 'set-mouse-position (list (car pos) (cadr pos) (cddr pos)))
            (speedbar-item-info))))))
 
 (defun speedbar-set-mode-line-format ()
@@ -1209,7 +1351,8 @@ This gives visual indications of what is up.  It EXPECTS the speedbar
 frame and window to be the currently active frame and window."
   (if (and (frame-live-p speedbar-frame)
           (or (not speedbar-xemacsp)
-              (specifier-instance has-modeline-p)))
+              (with-no-warnings
+               (specifier-instance has-modeline-p))))
       (save-excursion
        (set-buffer speedbar-buffer)
        (let* ((w (or (speedbar-frame-width) 20))
@@ -1232,7 +1375,7 @@ frame and window to be the currently active frame and window."
          (if (not (equal mode-line-format tf))
              (progn
                (setq mode-line-format tf)
-               (force-mode-line-update)))))))
+               (speedbar-mode-line-update)))))))
 
 (defun speedbar-temp-buffer-show-function (buffer)
   "Placed in the variable `temp-buffer-show-function' in `speedbar-mode'.
@@ -1313,7 +1456,8 @@ and the existence of packages."
          (easy-menu-define speedbar-menu-map (current-local-map)
                            "Speedbar menu" md)
        (easy-menu-add md (current-local-map))
-       (set-buffer-menubar (list md))))))
+       (set-buffer-menubar (list md))))
+    (run-hooks 'speedbar-reconfigure-keymaps-hook)))
 
 \f
 ;;; User Input stuff
@@ -1325,7 +1469,7 @@ and the existence of packages."
 (defun speedbar-mouse-hscroll (e)
   "Read a mouse event E from the mode line, and horizontally scroll.
 If the mouse is being clicked on the far left, or far right of the
-mode-line.  This is only useful for non-XEmacs"
+mode-line.  This is only useful for non-XEmacs."
   (interactive "e")
   (let* ((xp (car (nth 2 (car (cdr e)))))
         (cpw (/ (frame-pixel-width)
@@ -1336,8 +1480,9 @@ mode-line.  This is only useful for non-XEmacs"
           (scroll-left 2))
          ((> oc (- (window-width) 3))
           (scroll-right 2))
-         (t (message "Click on the edge of the modeline to scroll left/right")))
-    ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
+         (t (speedbar-message
+             "Click on the edge of the modeline to scroll left/right")))
+    ;;(speedbar-message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
     ))
 
 (defun speedbar-customize ()
@@ -1357,9 +1502,9 @@ mode-line.  This is only useful for non-XEmacs"
     (save-excursion
       (let ((char (nth 1 (car (cdr event)))))
        (if (not (numberp char))
-           (message nil)
+           (speedbar-message nil)
          (goto-char char)
-         ;; (message "%S" event)
+         ;; (speedbar-message "%S" event)
          (speedbar-item-info)
          )))))
 
@@ -1408,9 +1553,7 @@ Must be bound to event E."
     ;; This gets the cursor where the user can see it.
     (if (not (bolp)) (forward-char -1))
     (sit-for 0)
-    (if (< emacs-major-version 20)
-       (mouse-major-mode-menu e)
-      (mouse-major-mode-menu e nil))))
+    (mouse-major-mode-menu e nil)))
 
 (defun speedbar-hack-buffer-menu (e)
   "Control mouse 1 is buffer menu.
@@ -1427,10 +1570,11 @@ Argument E is the event causing this activity."
          (set-window-dedicated-p (selected-window) nil)
          (call-interactively fn)
          (setq newbuff (current-buffer)))
-      (switch-to-buffer " SPEEDBAR")
+      (switch-to-buffer speedbar-buffer)
       (set-window-dedicated-p (selected-window) t))
-    (speedbar-with-attached-buffer
-     (switch-to-buffer newbuff))))
+    (if (not (eq newbuff speedbar-buffer))
+       (speedbar-with-attached-buffer
+        (switch-to-buffer newbuff)))))
 
 (defun speedbar-next (arg)
   "Move to the next ARGth line in a speedbar buffer."
@@ -1534,7 +1678,7 @@ files, or the directory button."
 
 (defun speedbar-up-directory ()
   "Keyboard accelerator for moving the default directory up one.
-Assumes that the current buffer is the speedbar buffer"
+Assumes that the current buffer is the speedbar buffer."
   (interactive)
   (setq default-directory (expand-file-name (concat default-directory "../")))
   (speedbar-update-contents))
@@ -1545,19 +1689,18 @@ Assumes that the current buffer is the speedbar buffer"
   "Refresh the current speedbar display, disposing of any cached data."
   (interactive)
   (let ((dl speedbar-shown-directories)
-       (dm (and (boundp 'deactivate-mark) deactivate-mark)))
+       deactivate-mark)
     (while dl
       (adelete 'speedbar-directory-contents-alist (car dl))
       (setq dl (cdr dl)))
     (if (<= 1 speedbar-verbosity-level)
-       (message "Refreshing speedbar..."))
+       (speedbar-message "Refreshing speedbar..."))
     (speedbar-update-contents)
     (speedbar-stealthy-updates)
     ;; Reset the timer in case it got really hosed for some reason...
     (speedbar-set-timer speedbar-update-speed)
     (if (<= 1 speedbar-verbosity-level)
-       (message "Refreshing speedbar...done"))
-    (if (boundp 'deactivate-mark) (setq deactivate-mark dm))))
+       (speedbar-message "Refreshing speedbar...done"))))
 
 (defun speedbar-item-load ()
   "Load the item under the cursor or mouse if it is a Lisp file."
@@ -1565,7 +1708,7 @@ Assumes that the current buffer is the speedbar buffer"
   (let ((f (speedbar-line-file)))
     (if (and (file-exists-p f) (string-match "\\.el\\'" f))
        (if (and (file-exists-p (concat f "c"))
-                (y-or-n-p (format "Load %sc? " f)))
+                (speedbar-y-or-n-p (format "Load %sc? " f)))
            ;; If the compiled version exists, load that instead...
            (load-file (concat f "c"))
          (load-file f))
@@ -1592,7 +1735,7 @@ This should be bound to a mouse EVENT."
   (speedbar-item-info))
 
 (defun speedbar-generic-item-info ()
-  "Attempt to derive, and then display information about thils line item.
+  "Attempt to derive, and then display information about this line item.
 File style information is displayed with `speedbar-item-info'."
   (save-excursion
     (beginning-of-line)
@@ -1601,36 +1744,80 @@ File style information is displayed with `speedbar-item-info'."
     ;; Skip items in "folder" type text characters.
     (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0)))
     ;; Get the text
-    (message "Text: %s" (buffer-substring-no-properties
-                        (point) (progn (end-of-line) (point))))))
+    (speedbar-message "Text: %s" (buffer-substring-no-properties
+                                 (point) (progn (end-of-line) (point))))))
 
 (defun speedbar-item-info ()
-  "Display info in the mini-buffer about the button the mouse is over."
+  "Display info in the mini-buffer about the button the mouse is over.
+This function can be replaced in `speedbar-mode-functions-list' as
+`speedbar-item-info'."
   (interactive)
+  (let (message-log-max)
+    (funcall (or (speedbar-fetch-replacement-function 'speedbar-item-info)
+                'speedbar-generic-item-info))))
+
+(defun speedbar-item-info-file-helper (&optional filename)
+  "Display info about a file that is on the current line.
+nil if not applicable.  If FILENAME, then use that instead of reading
+it from the speedbar buffer."
+  (let* ((item (or filename (speedbar-line-file)))
+        (attr (if item (file-attributes item) nil)))
+    (if (and item attr) (speedbar-message "%s %-6d %s" (nth 8 attr)
+                                         (nth 7 attr) item)
+      nil)))
+
+(defun speedbar-item-info-tag-helper ()
+  "Display info about a tag that is on the current line.
+nil if not applicable."
+  (save-excursion
+    (beginning-of-line)
+    (if (re-search-forward " [-+=]?> \\([^\n]+\\)"
+                          (save-excursion(end-of-line)(point)) t)
+       (let ((tag (match-string 1))
+             (attr (speedbar-line-token))
+             (item nil))
+         (if (and (featurep 'semantic) (semantic-token-p attr))
+             (speedbar-message (semantic-summerize-nonterminal attr))
+           (looking-at "\\([0-9]+\\):")
+           (setq item (file-name-nondirectory (speedbar-line-path)))
+           (speedbar-message "Tag: %s  in %s" tag item)))
+      (if (re-search-forward "{[+-]} \\([^\n]+\\)$"
+                            (save-excursion(end-of-line)(point)) t)
+         (speedbar-message "Group of tags \"%s\"" (match-string 1))
+       (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t)
+           (let* ((detailtext (match-string 1))
+                  (detail (or (speedbar-line-token) detailtext))
+                 (parent (save-excursion
+                           (beginning-of-line)
+                           (let ((dep (if (looking-at "[0-9]+:")
+                                          (1- (string-to-int (match-string 0)))
+                                        0)))
+                             (re-search-backward (concat "^"
+                                                          (int-to-string dep)
+                                                          ":")
+                                                 nil t))
+                           (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$")
+                               (speedbar-line-token)
+                             nil))))
+             (if (and (featurep 'semantic) (semantic-token-p detail))
+                 (speedbar-message
+                  (semantic-summerize-nonterminal detail parent))
+               (if parent
+                   (speedbar-message "Detail: %s of tag %s" detail
+                                     (if (and (featurep 'semantic)
+                                              (semantic-token-p parent))
+                                         (semantic-token-name parent)
+                                       parent))
+                 (speedbar-message "Detail: %s" detail))))
+         nil)))))
+
+(defun speedbar-files-item-info ()
+  "Display info in the mini-buffer about the button the mouse is over."
   (if (not speedbar-shown-directories)
       (speedbar-generic-item-info)
-    (let* ((item (speedbar-line-file))
-          (attr (if item (file-attributes item) nil)))
-      (if (and item attr) (message "%s %-6d %s" (nth 8 attr) (nth 7 attr) item)
-       (save-excursion
-         (beginning-of-line)
-         (if (not (looking-at "\\([0-9]+\\):"))
-             (speedbar-generic-item-info)
-           (setq item (speedbar-line-path (string-to-int (match-string 1))))
-           (if (re-search-forward "> \\([^ ]+\\)$"
-                                  (save-excursion(end-of-line)(point)) t)
-               (progn
-                 (setq attr (get-text-property (match-beginning 1)
-                                               'speedbar-token))
-                 (message "Tag: %s  in %s @ %s"
-                          (match-string 1) item
-                          (if attr
-                              (if (markerp attr) (marker-position attr) attr)
-                            0)))
-             (if (re-search-forward "{[+-]} \\([^\n]+\\)$"
-                                    (save-excursion(end-of-line)(point)) t)
-                 (message "Group of tags \"%s\"" (match-string 1))
-               (speedbar-generic-item-info)))))))))
+    (or (speedbar-item-info-file-helper)
+       (speedbar-item-info-tag-helper)
+       (speedbar-generic-item-info))))
 
 (defun speedbar-item-copy ()
   "Copy the item under the cursor.
@@ -1649,10 +1836,10 @@ Files can be copied to new names or places."
        (if (file-directory-p rt)
            (setq rt
                  (concat (expand-file-name rt)
-                         (if (string-match "/$" rt) "" "/")
+                         (if (string-match "[/\\]$" rt) "" "/")
                          (file-name-nondirectory f))))
        (if (or (not (file-exists-p rt))
-               (y-or-n-p (format "Overwrite %s with %s? " rt f)))
+               (speedbar-y-or-n-p (format "Overwrite %s with %s? " rt f)))
            (progn
              (copy-file f rt t t)
              ;; refresh display if the new place is currently displayed.
@@ -1678,10 +1865,10 @@ Files can be renamed to new names or moved to new directories."
          (if (file-directory-p rt)
              (setq rt
                    (concat (expand-file-name rt)
-                           (if (string-match "/\\'" rt) "" "/")
+                           (if (string-match "[/\\]\\'" rt) "" "/")
                            (file-name-nondirectory f))))
          (if (or (not (file-exists-p rt))
-                 (y-or-n-p (format "Overwrite %s with %s? " rt f)))
+                 (speedbar-y-or-n-p (format "Overwrite %s with %s? " rt f)))
              (progn
                (rename-file f rt t)
                ;; refresh display if the new place is currently displayed.
@@ -1697,12 +1884,12 @@ Files can be renamed to new names or moved to new directories."
   (interactive)
   (let ((f (speedbar-line-file)))
     (if (not f) (error "Not a file"))
-    (if (y-or-n-p (format "Delete %s? " f))
+    (if (speedbar-y-or-n-p (format "Delete %s? " f))
        (progn
          (if (file-directory-p f)
              (delete-directory f)
            (delete-file f))
-         (message "Okie dokie..")
+         (speedbar-message "Okie dokie..")
          (let ((p (point)))
            (speedbar-refresh)
            (goto-char p))
@@ -1722,7 +1909,7 @@ variable `speedbar-obj-alist'."
       (setq oa (cdr oa)))
     (setq obj (concat (file-name-sans-extension f) (cdr (car oa))))
     (if (and oa (file-exists-p obj)
-            (y-or-n-p (format "Delete %s? " obj)))
+            (speedbar-y-or-n-p (format "Delete %s? " obj)))
        (progn
          (delete-file obj)
          (speedbar-reset-scanners)))))
@@ -1748,8 +1935,14 @@ variable `speedbar-obj-alist'."
       (speedbar-disable-update)
     (speedbar-enable-update)))
 
+(defun speedbar-toggle-images ()
+  "Toggle images for the speedbar frame."
+  (interactive)
+  (setq speedbar-use-images (not speedbar-use-images))
+  (speedbar-refresh))
+
 (defun speedbar-toggle-sorting ()
-  "Toggle automatic update for the speedbar frame."
+  "Toggle sorting for the speedbar frame."
   (interactive)
   (setq speedbar-sort-tags (not speedbar-sort-tags)))
 
@@ -1762,7 +1955,7 @@ variable `speedbar-obj-alist'."
 ;;; Utility functions
 ;;
 (defun speedbar-set-timer (timeout)
-  "Apply a timer with TIMEOUT, or remove a timer if TIMOUT is nil.
+  "Apply a timer with TIMEOUT, or remove a timer if TIMEOUT is nil.
 TIMEOUT is the number of seconds until the speedbar timer is called
 again.  When TIMEOUT is nil, turn off all timeouts.
 This function will also enable or disable the `vc-checkin-hook' used
@@ -1828,24 +2021,6 @@ If it is not shown, force it to appear in the default window."
        (select-window win)
       (set-window-buffer (selected-window) buffer))))
 
-(defmacro speedbar-with-attached-buffer (&rest forms)
-  "Execute FORMS in the attached frame's special buffer.
-Optionally select that frame if necessary."
-  ;; Reset the timer with a new timeout when cliking a file
-  ;; in case the user was navigating directories, we can cancel
-  ;; that other timer.
-  (list
-   'progn
-   '(speedbar-set-timer speedbar-update-speed)
-   (list
-    'let '((cf (selected-frame)))
-    '(select-frame speedbar-attached-frame)
-    '(speedbar-select-window speedbar-desired-buffer)
-    (cons 'progn forms)
-    '(select-frame cf)
-    '(speedbar-maybee-jump-to-attached-frame)
-    )))
-
 (defun speedbar-insert-button (text face mouse function
                                    &optional token prevline)
   "Insert TEXT as the next logical speedbar button.
@@ -1854,28 +2029,36 @@ When the user clicks on TEXT, FUNCTION is called with the TOKEN parameter.
 This function assumes that the current buffer is the speedbar buffer.
 If PREVLINE, then put this button on the previous line.
 
-This is a convenience function for special mode that create their own
+This is a convenience function for special modes that create their own
 specialized speedbar displays."
   (goto-char (point-max))
-  (if (/= (current-column) 0) (insert "\n"))
-  (if prevline (progn (delete-char -1) (insert " "))) ;back up if desired...
+  (let ((start (point)))
+    (if (/= (current-column) 0) (insert "\n"))
+    (put-text-property start (point) 'invisible nil))
+  (if prevline (progn (delete-char -1)
+                     (insert " ") ;back up if desired...
+                     (put-text-property (1- (point)) (point) 'invisible nil)))
   (let ((start (point)))
     (insert text)
     (speedbar-make-button start (point) face mouse function token))
   (let ((start (point)))
     (insert "\n")
     (put-text-property start (point) 'face nil)
+    (put-text-property start (point) 'invisible nil)
     (put-text-property start (point) 'mouse-face nil)))
 
 (defun speedbar-make-button (start end face mouse function &optional token)
   "Create a button from START to END, with FACE as the display face.
 MOUSE is the mouse face.  When this button is clicked on FUNCTION
-will be run with the TOKEN parameter (any Lisp object)"
+will be run with the TOKEN parameter (any Lisp object)."
   (put-text-property start end 'face face)
   (put-text-property start end 'mouse-face mouse)
   (put-text-property start end 'invisible nil)
   (if function (put-text-property start end 'speedbar-function function))
   (if token (put-text-property start end 'speedbar-token token))
+  ;; So far the only text we have is less that 3 chars.
+  (if (<= (- end start) 3)
+      (speedbar-insert-image-button-maybe start (- end start)))
   )
 \f
 ;;; Initial Expansion list management
@@ -1930,6 +2113,19 @@ This is based on `speedbar-initial-expansion-list-name' referencing
   (speedbar-refresh)
   (speedbar-reconfigure-keymaps))
 
+(defun speedbar-fetch-replacement-function (function)
+  "Return a current mode specific replacement for function, or nil.
+Scans `speedbar-mode-functions-list' first for the current mode, then
+for FUNCTION."
+  (cdr (assoc function
+             (cdr (assoc speedbar-initial-expansion-list-name
+                         speedbar-mode-functions-list)))))
+
+(defun speedbar-add-mode-functions-list (new-list)
+  "Add NEW-LIST to the list of mode functions.
+See `speedbar-mode-functions-list' for details."
+  (add-to-list 'speedbar-mode-functions-list new-list))
+
 \f
 ;;; Special speedbar display management
 ;;
@@ -1993,7 +2189,7 @@ of the special mode functions."
 The car is the list of directories, the cdr is list of files not
 matching ignored headers.  Cache any directory files found in
 `speedbar-directory-contents-alist' and use that cache before scanning
-the file-system"
+the file-system."
   (setq directory (expand-file-name directory))
   ;; If in powerclick mode, then the directory we are getting
   ;; should be rescanned.
@@ -2002,44 +2198,41 @@ the file-system"
   ;; find the directory, either in the cache, or build it.
   (or (cdr-safe (assoc directory speedbar-directory-contents-alist))
       (let ((default-directory directory)
-           (dir (directory-files directory nil))
-           (dirs nil)
-           (files nil))
-       (while dir
-         (if (not
-              (or (string-match speedbar-file-unshown-regexp (car dir))
-                  (string-match speedbar-directory-unshown-regexp (car dir))))
-             (if (file-directory-p (car dir))
-                 (setq dirs (cons (car dir) dirs))
-               (setq files (cons (car dir) files))))
-         (setq dir (cdr dir)))
-       (let ((nl (cons (nreverse dirs) (list (nreverse files)))))
+           (case-fold-search read-file-name-completion-ignore-case)
+           dirs files)
+       (dolist (file (directory-files directory nil))
+         (or (string-match speedbar-file-unshown-regexp file)
+             (string-match speedbar-directory-unshown-regexp file)
+             (if (file-directory-p file)
+                 (setq dirs (cons file dirs))
+               (setq files (cons file files)))))
+       (let ((nl `(,(nreverse dirs) ,(nreverse files))))
          (aput 'speedbar-directory-contents-alist directory nl)
-         nl))
-      ))
+         nl))))
 
 (defun speedbar-directory-buttons (directory index)
   "Insert a single button group at point for DIRECTORY.
 Each directory path part is a different button.  If part of the path
 matches the user directory ~, then it is replaced with a ~.
 INDEX is not used, but is required by the caller."
-  (let* ((tilde (expand-file-name "~"))
+  (let* ((tilde (expand-file-name "~/"))
         (dd (expand-file-name directory))
         (junk (string-match (regexp-quote tilde) dd))
         (displayme (if junk
-                       (concat "~" (substring dd (match-end 0)))
+                       (concat "~/" (substring dd (match-end 0)))
                      dd))
         (p (point)))
-    (if (string-match "^~/?\\'" displayme) (setq displayme (concat tilde "/")))
+    (if (string-match "^~[/\\]?\\'" displayme) (setq displayme tilde))
     (insert displayme)
     (save-excursion
       (goto-char p)
-      (while (re-search-forward "\\([^/]+\\)/" nil t)
+      (while (re-search-forward "\\([^/\\]+\\)[/\\]" nil t)
        (speedbar-make-button (match-beginning 1) (match-end 1)
                              'speedbar-directory-face
                              'speedbar-highlight-face
                              'speedbar-directory-buttons-follow
-                             (if (= (match-beginning 1) p)
+                             (if (and (= (match-beginning 1) p)
+                                      (not (char-equal (char-after (+ p 1)) ?:)))
                                  (expand-file-name "~/")  ;the tilde
                                (buffer-substring-no-properties
                                 p (match-end 0)))))
@@ -2049,14 +2242,14 @@ INDEX is not used, but is required by the caller."
             (let ((ww (or (speedbar-frame-width) 20)))
               (move-to-column ww nil)
               (while (>= (current-column) ww)
-                (re-search-backward "/" nil t)
+                (re-search-backward "[/\\]" nil t)
                 (if (<= (current-column) 2)
                     (progn
-                      (re-search-forward "/" nil t)
+                      (re-search-forward "[/\\]" nil t)
                       (if (< (current-column) 4)
-                          (re-search-forward "/" nil t))
+                          (re-search-forward "[/\\]" nil t))
                       (forward-char -1)))
-                (if (looking-at "/?$")
+                (if (looking-at "[/\\]?$")
                     (beginning-of-line)
                   (insert "/...\n ")
                   (move-to-column ww nil)))))
@@ -2067,13 +2260,13 @@ INDEX is not used, but is required by the caller."
               (if (< ww tl)
                   (progn
                     (move-to-column (- tl ww))
-                    (if (re-search-backward "/" nil t)
+                    (if (re-search-backward "[/\\]" nil t)
                         (progn
                           (delete-region (point-min) (point))
                           (insert "$")
                           )))))))
       )
-    (if (string-match "\\`/[^/]+/\\'" displayme)
+    (if (string-match "\\`[/\\][^/\\]+[/\\]\\'" displayme)
        (progn
          (insert "  ")
          (let ((p (point)))
@@ -2106,41 +2299,41 @@ TAG-BUTTON-FACE is a face used for this type of tag.
 Lastly, DEPTH shows the depth of expansion.
 
 This function assumes that the cursor is in the speedbar window at the
-position to insert a new item, and that the new item will end with a CR"
+position to insert a new item, and that the new item will end with a CR."
   (let ((start (point))
        (end (progn
               (insert (int-to-string depth) ":")
-              (point))))
+              (point)))
+       (depthspacesize (* depth speedbar-indentation-width)))
     (put-text-property start end 'invisible t)
-    )
-  (insert-char ?  depth nil)
-  (put-text-property (- (point) depth) (point) 'invisible nil)
-  (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]")
-                          ((eq exp-button-type 'angle) "<%c>")
-                          ((eq exp-button-type 'curly) "{%c}")
-                          (t ">")))
-        (buttxt (format exp-button exp-button-char))
-        (start (point))
-        (end (progn (insert buttxt) (point)))
-        (bf (if exp-button-type 'speedbar-button-face nil))
-        (mf (if exp-button-function 'speedbar-highlight-face nil))
-        )
-    (speedbar-make-button start end bf mf exp-button-function exp-button-data)
-    (if speedbar-hide-button-brackets-flag
-       (progn
-         (put-text-property start (1+ start) 'invisible t)
-         (put-text-property end (1- end) 'invisible t)))
-    )
-  (insert-char ?  1 nil)
-  (put-text-property (1- (point)) (point) 'invisible nil)
-  (let ((start (point))
-       (end (progn (insert tag-button) (point))))
-    (insert-char ?\n 1 nil)
+    (insert-char ?  depthspacesize nil)
+    (put-text-property (- (point) depthspacesize) (point) 'invisible nil)
+    (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]")
+                            ((eq exp-button-type 'angle) "<%c>")
+                            ((eq exp-button-type 'curly) "{%c}")
+                            (t ">")))
+          (buttxt (format exp-button exp-button-char))
+          (start (point))
+          (end (progn (insert buttxt) (point)))
+          (bf (if exp-button-type 'speedbar-button-face nil))
+          (mf (if exp-button-function 'speedbar-highlight-face nil))
+          )
+      (speedbar-make-button start end bf mf exp-button-function exp-button-data)
+      (if speedbar-hide-button-brackets-flag
+         (progn
+           (put-text-property start (1+ start) 'invisible t)
+           (put-text-property end (1- end) 'invisible t)))
+      )
+    (insert-char ?  1 nil)
     (put-text-property (1- (point)) (point) 'invisible nil)
-    (speedbar-make-button start end tag-button-face
-                         (if tag-button-function 'speedbar-highlight-face nil)
-                         tag-button-function tag-button-data))
-)
+    (let ((start (point))
+         (end (progn (insert tag-button) (point))))
+      (insert-char ?\n 1 nil)
+      (put-text-property (1- (point)) (point) 'invisible nil)
+      (speedbar-make-button start end tag-button-face
+                           (if tag-button-function 'speedbar-highlight-face nil)
+                           tag-button-function tag-button-data))
+    ))
 
 (defun speedbar-change-expand-button-char (char)
   "Change the expansion button character to CHAR for the current line."
@@ -2152,39 +2345,47 @@ position to insert a new item, and that the new item will end with a CR"
          (goto-char (match-beginning 1))
          (delete-char 1)
          (insert-char char 1 t)
-         (put-text-property (point) (1- (point)) 'invisible nil)))))
+         (put-text-property (point) (1- (point)) 'invisible nil)
+         ;; make sure we fix the image on the text here.
+         (speedbar-insert-image-button-maybe (- (point) 2) 3)))))
 
 \f
 ;;; Build button lists
 ;;
-(defun speedbar-insert-files-at-point (files level)
+(defun speedbar-insert-files-at-point (files level directory)
   "Insert list of FILES starting at point, and indenting all files to LEVEL.
 Tag expandable items with a +, otherwise a ?.  Don't highlight ? as we
 don't know how to manage them.  The input parameter FILES is a cons
-cell of the form ( 'DIRLIST .  'FILELIST )"
+cell of the form ( 'DIRLIST .  'FILELIST )."
   ;; Start inserting all the directories
-  (let ((dirs (car files)))
-    (while dirs
-      (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs)
-                             (car dirs) 'speedbar-dir-follow nil
-                             'speedbar-directory-face level)
-      (setq dirs (cdr dirs))))
-  (let ((lst (car (cdr files)))
-       (case-fold-search t))
-    (while lst
-      (let* ((known (string-match speedbar-file-regexp (car lst)))
+  (dolist (dir (car files))
+    (if (if speedbar-scan-subdirs
+           (condition-case nil
+               (let ((l (speedbar-file-lists (concat directory dir))))
+                 (or (car l) (cadr l)))
+             (file-error))
+         (file-readable-p (concat directory dir)))
+       (speedbar-make-tag-line 'angle ?+ 'speedbar-dired dir
+                               dir 'speedbar-dir-follow nil
+                               'speedbar-directory-face level)
+      (speedbar-make-tag-line 'angle ?  nil dir
+                             dir 'speedbar-dir-follow nil
+                             'speedbar-directory-face level)))
+  (let ((case-fold-search read-file-name-completion-ignore-case))
+    (dolist (file (cadr files))
+      (let* ((known (and (file-readable-p (concat directory file))
+                        (string-match speedbar-file-regexp file)))
             (expchar (if known ?+ ??))
             (fn (if known 'speedbar-tag-file nil)))
        (if (or speedbar-show-unknown-files (/= expchar ??))
-           (speedbar-make-tag-line 'bracket expchar fn (car lst)
-                                   (car lst) 'speedbar-find-file nil
-                                   'speedbar-file-face level)))
-      (setq lst (cdr lst)))))
+           (speedbar-make-tag-line 'bracket expchar fn file
+                                   file 'speedbar-find-file nil
+                                   'speedbar-file-face level))))))
 
 (defun speedbar-default-directory-list (directory index)
   "Insert files for DIRECTORY with level INDEX at point."
   (speedbar-insert-files-at-point
-   (speedbar-file-lists directory) index)
+   (speedbar-file-lists directory) index directory)
   (speedbar-reset-scanners)
   (if (= index 0)
       ;; If the shown files variable has extra directories, then
@@ -2202,186 +2403,219 @@ cell of the form ( 'DIRLIST .  'FILELIST )"
                (if (looking-at "[0-9]+:[ ]*<")
                    (progn
                      (goto-char (match-end 0))
-                 (speedbar-do-function-pointer)))
-               (setq sf (cdr sf)))))
+                     (speedbar-do-function-pointer)))))
+         (setq sf (cdr sf)))
        )))
 
-(defun speedbar-apply-one-tag-hierarchy-method (lst method)
-  "Adjust the tag hierarchy LST by METHOD."
-  (cond
-   ((eq method 'sort)
-    (sort (copy-alist lst)
-         (lambda (a b) (string< (car a) (car b)))))
-   ((eq method 'prefix-group)
-    (let ((newlst nil)
-         (sublst nil)
-         (work-list nil)
-         (junk-list nil)
-         (short-group-list nil)
-         (short-start-name nil)
-         (short-end-name nil)
-         (num-shorts-grouped 0)
-         (bins (make-vector 256 nil))
-         (diff-idx 0))
-      ;; Break out sub-lists
-      (while lst
-       (if (listp (cdr-safe (car-safe lst)))
-           (setq newlst (cons (car lst) newlst))
-         (setq sublst (cons (car lst) sublst)))
-       (setq lst (cdr lst)))
-      ;; Now, first find out how long our list is.  Never let a
-      ;; list get-shorter than our minimum.
-      (if (<= (length sublst) speedbar-tag-split-minimum-length)
-         (setq work-list (nreverse sublst))
-       (setq diff-idx (length (try-completion "" sublst)))
-       ;; Sort the whole list into bins.
-       (while sublst
-         (let ((e (car sublst))
-               (s (car (car sublst))))
-           (cond ((<= (length s) diff-idx)
-                  ;; 0 storage bin for shorty.
-                  (aset bins 0 (cons e (aref bins 0))))
-                 (t
-                  ;; stuff into a bin based on ascii value at diff
-                  (aset bins (aref s diff-idx)
-                        (cons e (aref bins (aref s diff-idx)))))))
-         (setq sublst (cdr sublst)))
-       ;; Go through all our bins  Stick singles into our
-       ;; junk-list, everything else as sublsts in work-list.
-       ;; If two neighboring lists are both small, make a grouped
-       ;; group combinding those two sub-lists.
-       (setq diff-idx 0)
-       (while (> 256 diff-idx)
-         (let ((l (aref bins diff-idx)))
-           (if l
-               (let ((tmp (cons (try-completion "" l) l)))
-                 (if (or (> (length l) speedbar-tag-regroup-maximum-length)
-                         (> (+ (length l) (length short-group-list))
-                            speedbar-tag-split-minimum-length))
-                     (progn
-                       ;; We have reached a longer list, so we
-                       ;; must finish off a grouped group.
-                       (cond
-                        ((and short-group-list
-                              (= (length short-group-list)
-                                 num-shorts-grouped))
-                         ;; All singles?  Junk list
-                         (setq junk-list (append short-group-list
-                                                 junk-list)))
-                        ((= num-shorts-grouped 1)
-                         ;; Only one short group?  Just stick it in
-                         ;; there by itself.
-                         (setq work-list
-                               (cons (cons (try-completion
-                                            "" short-group-list)
-                                           (nreverse short-group-list))
-                                     work-list)))
-                        (short-group-list
-                         ;; Multiple groups to be named in a special
-                         ;; way by displaying the range over which we
-                         ;; have grouped them.
+(defun speedbar-sort-tag-hierarchy (lst)
+  "Sort all elements of tag hierarchy LST."
+  (sort (copy-alist lst)
+       (lambda (a b) (string< (car a) (car b)))))
+
+(defun speedbar-prefix-group-tag-hierarchy (lst)
+  "Prefix group names for tag hierarchy LST."
+  (let ((newlst nil)
+       (sublst nil)
+       (work-list nil)
+       (junk-list nil)
+       (short-group-list nil)
+       (short-start-name nil)
+       (short-end-name nil)
+       (num-shorts-grouped 0)
+       (bins (make-vector 256 nil))
+       (diff-idx 0))
+    ;; Break out sub-lists
+    (while lst
+      (if (and (listp (cdr-safe (car-safe lst)))
+              ;; This one is for bovine tokens
+              (not (symbolp (car-safe (cdr-safe (car-safe lst))))))
+         (setq newlst (cons (car lst) newlst))
+       (setq sublst (cons (car lst) sublst)))
+      (setq lst (cdr lst)))
+    ;; Reverse newlst because it was made backwards.
+    ;; Sublist doesn't need reversing because the act
+    ;; of binning things will reverse it for us.
+    (setq newlst (nreverse newlst))
+    ;; Now, first find out how long our list is.  Never let a
+    ;; list get-shorter than our minimum.
+    (if (<= (length sublst) speedbar-tag-split-minimum-length)
+       (setq work-list (nreverse sublst))
+      (setq diff-idx (length (try-completion "" sublst)))
+      ;; Sort the whole list into bins.
+      (while sublst
+       (let ((e (car sublst))
+             (s (car (car sublst))))
+         (cond ((<= (length s) diff-idx)
+                ;; 0 storage bin for shorty.
+                (aset bins 0 (cons e (aref bins 0))))
+               (t
+                ;; stuff into a bin based on ascii value at diff
+                (aset bins (aref s diff-idx)
+                      (cons e (aref bins (aref s diff-idx)))))))
+       (setq sublst (cdr sublst)))
+      ;; Go through all our bins  Stick singles into our
+      ;; junk-list, everything else as sublsts in work-list.
+      ;; If two neighboring lists are both small, make a grouped
+      ;; group combinding those two sub-lists.
+      (setq diff-idx 0)
+      (while (> 256 diff-idx)
+       (let ((l (nreverse;; Reverse the list since they are stuck in
+                 ;; backwards.
+                 (aref bins diff-idx))))
+         (if l
+             (let ((tmp (cons (try-completion "" l) l)))
+               (if (or (> (length l) speedbar-tag-regroup-maximum-length)
+                       (> (+ (length l) (length short-group-list))
+                          speedbar-tag-split-minimum-length))
+                   (progn
+                     ;; We have reached a longer list, so we
+                     ;; must finish off a grouped group.
+                     (cond
+                      ((and short-group-list
+                            (= (length short-group-list)
+                               num-shorts-grouped))
+                       ;; All singles?  Junk list
+                       (setq junk-list (append short-group-list
+                                               junk-list)))
+                      ((= num-shorts-grouped 1)
+                       ;; Only one short group?  Just stick it in
+                       ;; there by itself.  Make a group, and find
+                       ;; a subexpression
+                       (let ((subexpression (try-completion
+                                             "" short-group-list)))
+                         (if (< (length subexpression)
+                                speedbar-tag-group-name-minimum-length)
+                             (setq subexpression
+                                   (concat short-start-name
+                                           " ("
+                                           (substring
+                                            (car (car short-group-list))
+                                            (length short-start-name))
+                                           ")")))
                          (setq work-list
-                               (cons (cons (concat short-start-name
-                                                   " to "
-                                                   short-end-name)
-                                           (nreverse short-group-list))
+                               (cons (cons subexpression
+                                           short-group-list)
                                      work-list))))
-                       ;; Reset short group list information every time.
-                       (setq short-group-list nil
-                             short-start-name nil
-                             short-end-name nil
-                               num-shorts-grouped 0)))
-                 ;; Ok, now that we cleaned up the short-group-list,
-                 ;; we can deal with this new list, to decide if it
-                 ;; should go on one of these sub-lists or not.
-                 (if (< (length l) speedbar-tag-regroup-maximum-length)
-                     (setq short-group-list (append short-group-list l)
-                           num-shorts-grouped (1+ num-shorts-grouped)
-                           short-end-name (car tmp)
-                           short-start-name (if short-start-name
-                                                short-start-name
-                                              (car tmp)))
-                   (setq work-list (cons tmp work-list))))))
-         (setq diff-idx (1+ diff-idx))))
-      ;; Did we run out of things?  Drop our new list onto the end.
-      (cond
-       ((and short-group-list (= (length short-group-list) num-shorts-grouped))
-       ;; All singles?  Junk list
-       (setq junk-list (append short-group-list junk-list)))
-       ((= num-shorts-grouped 1)
-       ;; Only one short group?  Just stick it in
-       ;; there by itself.
-       (setq work-list
-             (cons (cons (try-completion "" short-group-list)
-                         (nreverse short-group-list))
-                   work-list)))
-       (short-group-list
-       ;; Multiple groups to be named in a special
-       ;; way by displaying the range over which we
-       ;; have grouped them.
-       (setq work-list
-             (cons (cons (concat short-start-name " to " short-end-name)
-                         (nreverse short-group-list))
-                   work-list))))
-      ;; Now, stick our new list onto the end of
-      (if work-list
-         (if junk-list
-             (append (nreverse newlst)
-                     (nreverse work-list)
-                     junk-list)
-           (append (nreverse newlst)
-                   (nreverse work-list)))
-       (append (nreverse newlst) junk-list))))
-   ((eq method 'trim-words)
-    (let ((newlst nil)
-         (sublst nil)
-         (trim-prefix nil)
-         (trim-chars 0)
-         (trimlst nil))
-      (while lst
-       (if (listp (cdr-safe (car-safe lst)))
-           (setq newlst (cons (car lst) newlst))
-         (setq sublst (cons (car lst) sublst)))
-       (setq lst (cdr lst)))
-      ;; Get the prefix to trim by.  Make sure that we don't trim
-      ;; off silly pieces, only complete understandable words.
-      (setq trim-prefix (try-completion "" sublst))
-      (if (or (= (length sublst) 1)
-             (not trim-prefix)
-             (not (string-match "\\(\\w+\\W+\\)+" trim-prefix)))
-         (append (nreverse newlst) (nreverse sublst))
-       (setq trim-prefix (substring trim-prefix (match-beginning 0)
-                                    (match-end 0)))
-       (setq trim-chars (length trim-prefix))
-       (while sublst
-         (setq trimlst (cons
-                        (cons (substring (car (car sublst)) trim-chars)
-                              (cdr (car sublst)))
-                        trimlst)
-               sublst (cdr sublst)))
-       ;; Put the lists together
-       (append (nreverse newlst) trimlst))))
-   ((eq method 'simple-group)
-    (let ((newlst nil)
-         (sublst nil))
-      (while lst
-       (if (listp (cdr-safe (car-safe lst)))
-           (setq newlst (cons (car lst) newlst))
-         (setq sublst (cons (car lst) sublst)))
-       (setq lst (cdr lst)))
-      (if (not newlst)
-         (nreverse sublst)
-       (setq newlst (cons (cons "Tags" (nreverse sublst)) newlst))
-       (nreverse newlst))))
-   (t lst)))
+                      (short-group-list
+                       ;; Multiple groups to be named in a special
+                       ;; way by displaying the range over which we
+                       ;; have grouped them.
+                       (setq work-list
+                             (cons (cons (concat short-start-name
+                                                 " to "
+                                                 short-end-name)
+                                         (nreverse short-group-list))
+                                   work-list))))
+                     ;; Reset short group list information every time.
+                     (setq short-group-list nil
+                           short-start-name nil
+                           short-end-name nil
+                           num-shorts-grouped 0)))
+               ;; Ok, now that we cleaned up the short-group-list,
+               ;; we can deal with this new list, to decide if it
+               ;; should go on one of these sub-lists or not.
+               (if (< (length l) speedbar-tag-regroup-maximum-length)
+                   (setq short-group-list (append short-group-list l)
+                         num-shorts-grouped (1+ num-shorts-grouped)
+                         short-end-name (car tmp)
+                         short-start-name (if short-start-name
+                                              short-start-name
+                                            (car tmp)))
+                 (setq work-list (cons tmp work-list))))))
+       (setq diff-idx (1+ diff-idx))))
+    ;; Did we run out of things?  Drop our new list onto the end.
+    (cond
+     ((and short-group-list (= (length short-group-list) num-shorts-grouped))
+      ;; All singles?  Junk list
+      (setq junk-list (append short-group-list junk-list)))
+     ((= num-shorts-grouped 1)
+      ;; Only one short group?  Just stick it in
+      ;; there by itself.
+      (setq work-list
+           (cons (cons (try-completion "" short-group-list)
+                       short-group-list)
+                 work-list)))
+     (short-group-list
+      ;; Multiple groups to be named in a special
+      ;; way by displaying the range over which we
+      ;; have grouped them.
+      (setq work-list
+           (cons (cons (concat short-start-name " to " short-end-name)
+                       short-group-list)
+                 work-list))))
+    ;; Reverse the work list nreversed when consing.
+    (setq work-list (nreverse work-list))
+    ;; Now, stick our new list onto the end of
+    (if work-list
+       (if junk-list
+           (append newlst work-list junk-list)
+         (append newlst work-list))
+      (append  newlst junk-list))))
+
+(defun speedbar-trim-words-tag-hierarchy (lst)
+  "Trim all words in a tag hierarchy.
+Base trimming information on word separators, and group names.
+Argument LST is the list of tags to trim."
+  (let ((newlst nil)
+       (sublst nil)
+       (trim-prefix nil)
+       (trim-chars 0)
+       (trimlst nil))
+    (while lst
+      (if (listp (cdr-safe (car-safe lst)))
+         (setq newlst (cons (car lst) newlst))
+       (setq sublst (cons (car lst) sublst)))
+      (setq lst (cdr lst)))
+    ;; Get the prefix to trim by.  Make sure that we don't trim
+    ;; off silly pieces, only complete understandable words.
+    (setq trim-prefix (try-completion "" sublst))
+    (if (or (= (length sublst) 1)
+           (not trim-prefix)
+           (not (string-match "\\(\\w+\\W+\\)+" trim-prefix)))
+       (append (nreverse newlst) (nreverse sublst))
+      (setq trim-prefix (substring trim-prefix (match-beginning 0)
+                                  (match-end 0)))
+      (setq trim-chars (length trim-prefix))
+      (while sublst
+       (setq trimlst (cons
+                      (cons (substring (car (car sublst)) trim-chars)
+                            (cdr (car sublst)))
+                      trimlst)
+             sublst (cdr sublst)))
+      ;; Put the lists together
+      (append (nreverse newlst) trimlst))))
+
+(defun speedbar-simple-group-tag-hierarchy (lst)
+  "Create a simple 'Tags' group with orphaned tags.
+Argument LST is the list of tags to sort into groups."
+  (let ((newlst nil)
+       (sublst nil))
+    (while lst
+      (if (listp (cdr-safe (car-safe lst)))
+         (setq newlst (cons (car lst) newlst))
+       (setq sublst (cons (car lst) sublst)))
+      (setq lst (cdr lst)))
+    (if (not newlst)
+       (nreverse sublst)
+      (setq newlst (cons (cons "Tags" (nreverse sublst)) newlst))
+      (nreverse newlst))))
 
 (defun speedbar-create-tag-hierarchy (lst)
   "Adjust the tag hierarchy in LST, and return it.
 This uses `speedbar-tag-hierarchy-method' to determine how to adjust
-the list.  See it's value for details."
-  (let ((methods speedbar-tag-hierarchy-method))
+the list."
+  (let* ((f (save-excursion
+             (forward-line -1)
+             (speedbar-line-path)))
+        (methods (if (get-file-buffer f)
+                     (save-excursion (set-buffer (get-file-buffer f))
+                                     speedbar-tag-hierarchy-method)
+                   speedbar-tag-hierarchy-method))
+        (lst (if (fboundp 'copy-tree)
+                 (copy-tree lst)
+               lst)))
     (while methods
-      (setq lst (speedbar-apply-one-tag-hierarchy-method lst (car methods))
+      (setq lst (funcall (car methods) lst)
            methods (cdr methods)))
     lst))
 
@@ -2412,8 +2646,20 @@ name will have the function FIND-FUN and not token."
                                   (car (car lst)) ;button name
                                   nil nil 'speedbar-tag-face
                                   (1+ level)))
-         (t (message "Ooops!")))
+         (t (speedbar-message "Ooops!")))
     (setq lst (cdr lst))))
+
+(defun speedbar-insert-imenu-list (indent lst)
+  "At level INDENT, insert the imenu generated LST."
+  (speedbar-insert-generic-list indent lst
+                               'speedbar-tag-expand
+                               'speedbar-tag-find))
+
+(defun speedbar-insert-etags-list (indent lst)
+  "At level INDENT, insert the etags generated LST."
+  (speedbar-insert-generic-list indent lst
+                               'speedbar-tag-expand
+                               'speedbar-tag-find))
 \f
 ;;; Timed functions
 ;;
@@ -2465,7 +2711,7 @@ name will have the function FIND-FUN and not token."
        (if (and speedbar-smart-directory-expand-flag
                 (save-match-data
                   (setq cbd-parent cbd)
-                  (if (string-match "/$" cbd-parent)
+                  (if (string-match "[/\\]$" cbd-parent)
                       (setq cbd-parent (substring cbd-parent 0
                                                   (match-beginning 0))))
                   (setq cbd-parent (file-name-directory cbd-parent)))
@@ -2513,7 +2759,7 @@ name will have the function FIND-FUN and not token."
   (speedbar-reconfigure-keymaps))
 
 (defun speedbar-update-special-contents ()
-  "Used the mode-specific variable to fill in the speedbar buffer.
+  "Use the mode-specific variable to fill in the speedbar buffer.
 This should only be used by modes classified as special."
   (let ((funclst speedbar-special-mode-expansion-list)
        (specialbuff (current-buffer)))
@@ -2570,14 +2816,16 @@ This should only be used by modes classified as special."
                    ;;(eq (get major-mode 'mode-class 'special)))
                    (progn
                      (if (<= 2 speedbar-verbosity-level)
-                         (message "Updating speedbar to special mode: %s..."
-                                  major-mode))
+                         (speedbar-message
+                          "Updating speedbar to special mode: %s..."
+                          major-mode))
                      (speedbar-update-special-contents)
                      (if (<= 2 speedbar-verbosity-level)
                          (progn
-                           (message "Updating speedbar to special mode: %s...done"
-                                    major-mode)
-                           (message nil))))
+                           (speedbar-message
+                            "Updating speedbar to special mode: %s...done"
+                            major-mode)
+                           (speedbar-message nil))))
                  ;; Update all the contents if directories change!
                  (if (or (member (expand-file-name default-directory)
                                  speedbar-shown-directories)
@@ -2590,14 +2838,14 @@ This should only be used by modes classified as special."
                          (not (buffer-file-name)))
                      nil
                    (if (<= 1 speedbar-verbosity-level)
-                       (message "Updating speedbar to: %s..."
+                       (speedbar-message "Updating speedbar to: %s..."
                                 default-directory))
                    (speedbar-update-directory-contents)
                    (if (<= 1 speedbar-verbosity-level)
                        (progn
-                         (message "Updating speedbar to: %s...done"
+                         (speedbar-message "Updating speedbar to: %s...done"
                                   default-directory)
-                         (message nil)))))
+                         (speedbar-message nil)))))
                (select-frame af)))
            ;; Now run stealthy updates of time-consuming items
            (speedbar-stealthy-updates)))
@@ -2620,10 +2868,10 @@ interrupted by the user."
            (speedbar-stealthy-update-recurse t))
        (unwind-protect
            (speedbar-with-writable
-            (while (and l (funcall (car l)))
-              ;;(sit-for 0)
-              (setq l (cdr l))))
-         ;;(message "Exit with %S" (car l))
+             (while (and l (funcall (car l)))
+               ;;(sit-for 0)
+               (setq l (cdr l))))
+         ;;(speedbar-message "Exit with %S" (car l))
          ))))
 
 (defun speedbar-reset-scanners ()
@@ -2635,11 +2883,11 @@ If new functions are added, their state needs to be updated here."
   )
 
 (defun speedbar-find-selected-file (file)
-  "Goto the line where FILE is."
+  "Go to the line where FILE is."
   (goto-char (point-min))
   (let ((m nil))
     (while (and (setq m (re-search-forward
-                        (concat " \\(" (file-name-nondirectory file)
+                        (concat " \\(" (regexp-quote (file-name-nondirectory file))
                                 "\\)\\(" speedbar-indicator-regex "\\)?\n")
                         nil t))
                (not (string= file
@@ -2685,7 +2933,7 @@ updated."
         (newcf (if newcfd newcfd))
         (lastb (current-buffer))
         (sucf-recursive (boundp 'sucf-recursive))
-        (case-fold-search t))
+        (case-fold-search read-file-name-completion-ignore-case))
     (if (and newcf
             ;; check here, that way we won't refresh to newcf until
             ;; its been written, thus saving ourselves some time
@@ -2737,7 +2985,7 @@ updated."
 (defun speedbar-add-indicator (indicator-string &optional replace-this)
   "Add INDICATOR-STRING to the end of this speedbar line.
 If INDICATOR-STRING is space, and REPLACE-THIS is a character, then
-an the existing indicator is removed.  If there is already an
+the existing indicator is removed.  If there is already an
 indicator, then do not add a space."
   (beginning-of-line)
   ;; The nature of the beast: Assume we are in "the right place"
@@ -2823,7 +3071,7 @@ the file being checked."
                        (point))))
         (fulln (concat f fn)))
     (if (<= 2 speedbar-verbosity-level)
-       (message "Speedbar vc check...%s" fulln))
+       (speedbar-message "Speedbar vc check...%s" fulln))
     (and (file-writable-p fulln)
         (speedbar-this-file-in-vc f fn))))
 
@@ -2854,11 +3102,11 @@ that will occur on your system."
    (file-exists-p (concat path "RCS/" name ",v"))
    (file-exists-p (concat path "RCS/" name))
    ;; Local SCCS file name
-   (file-exists-p (concat path "SCCS/p." name))
+   (file-exists-p (concat path "SCCS/s." name))
    ;; Remote SCCS file name
    (let ((proj-dir (getenv "PROJECTDIR")))
      (if proj-dir
-         (file-exists-p (concat proj-dir "/SCCS/p." name))
+         (file-exists-p (concat proj-dir "/SCCS/s." name))
        nil))
    ;; User extension
    (run-hook-with-args 'speedbar-vc-in-control-hook path name)
@@ -2912,7 +3160,7 @@ the file being checked."
                        (point))))
         (fulln (concat f fn)))
     (if (<= 2 speedbar-verbosity-level)
-       (message "Speedbar obj check...%s" fulln))
+       (speedbar-message "Speedbar obj check...%s" fulln))
     (let ((oa speedbar-obj-alist))
       (while (and oa (not (string-match (car (car oa)) fulln)))
        (setq oa (cdr oa)))
@@ -2932,11 +3180,25 @@ the file being checked."
 \f
 ;;; Clicking Activity
 ;;
+(defun speedbar-mouse-set-point (e)
+  "Set POINT based on event E.
+Handle clicking on images in XEmacs."
+  (if (and (fboundp 'event-over-glyph-p) (event-over-glyph-p e))
+      ;; We are in XEmacs, and clicked on a picture
+      (let ((ext (event-glyph-extent e)))
+       ;; This position is back inside the extent where the
+       ;; junk we pushed into the property list lives.
+       (if (extent-end-position ext)
+           (goto-char (1- (extent-end-position ext)))
+         (mouse-set-point e)))
+    ;; We are not in XEmacs, OR we didn't click on a picture.
+    (mouse-set-point e)))
+
 (defun speedbar-quick-mouse (e)
   "Since mouse events are strange, this will keep the mouse nicely positioned.
 This should be bound to mouse event E."
   (interactive "e")
-  (mouse-set-point e)
+  (speedbar-mouse-set-point e)
   (speedbar-position-cursor-on-line)
   )
 
@@ -2950,6 +3212,8 @@ This should be bound to mouse event E."
 
 (defun speedbar-power-click (e)
   "Activate any speedbar button as a power click.
+A power click will dispose of cached data (if available) or bring a buffer
+up into a different window.
 This should be bound to mouse event E."
   (interactive "e")
   (let ((speedbar-power-click t))
@@ -2961,7 +3225,7 @@ This must be bound to a mouse event.  A button is any location of text
 with a mouse face that has a text property called `speedbar-function'.
 This should be bound to mouse event E."
   (interactive "e")
-  (mouse-set-point e)
+  (speedbar-mouse-set-point e)
   (speedbar-do-function-pointer)
   (speedbar-quick-mouse e))
 
@@ -2973,19 +3237,19 @@ This should be bound to mouse event E."
   (interactive "e")
   ;; Emacs only.  XEmacs handles this via `mouse-track-click-hook'.
   (cond ((eq (car e) 'down-mouse-1)
-        (mouse-set-point e))
+        (speedbar-mouse-set-point e))
        ((eq (car e) 'mouse-1)
         (speedbar-quick-mouse e))
        ((or (eq (car e) 'double-down-mouse-1)
             (eq (car e) 'triple-down-mouse-1))
-        (mouse-set-point e)
+        (speedbar-mouse-set-point e)
         (speedbar-do-function-pointer)
         (speedbar-quick-mouse e))))
 
 (defun speedbar-do-function-pointer ()
   "Look under the cursor and examine the text properties.
 From this extract the file/tag name, token, indentation level and call
-a function if appropriate"
+a function if appropriate."
   (let* ((fn (get-text-property (point) 'speedbar-function))
         (tok (get-text-property (point) 'speedbar-token))
         ;; The 1-,+ is safe because scaning starts AFTER the point
@@ -3003,30 +3267,54 @@ a function if appropriate"
                                    (buffer-substring-no-properties
                                    (match-beginning 0) (match-end 0))
                                  "0")))))
-    ;;(message "%S:%S:%S:%s" fn tok txt dent)
+    ;;(speedbar-message "%S:%S:%S:%s" fn tok txt dent)
     (and fn (funcall fn txt tok dent)))
   (speedbar-position-cursor-on-line))
 \f
 ;;; Reading info from the speedbar buffer
 ;;
+(defun speedbar-line-text (&optional p)
+  "Retrieve the text after prefix junk for the current line.
+Optional argument P is where to start the search from."
+  (save-excursion
+    (if p (goto-char p))
+    (beginning-of-line)
+    (if (looking-at (concat
+                    "\\([0-9]+\\): *[[<{][-+?][]>}] \\([^ \n]+\\)\\("
+                    speedbar-indicator-regex "\\)?"))
+       (match-string 2)
+      nil)))
+
+(defun speedbar-line-token (&optional p)
+  "Retrieve the token information after the prefix junk for the current line.
+Optional argument P is where to start the search from."
+  (save-excursion
+    (if p (goto-char p))
+    (beginning-of-line)
+    (if (looking-at (concat
+                    "\\([0-9]+\\): *[[<{]?[-+?=][]>}@()|] \\([^ \n]+\\)\\("
+                    speedbar-indicator-regex "\\)?"))
+       (progn
+         (goto-char (match-beginning 2))
+         (get-text-property (point) 'speedbar-token))
+      nil)))
+
 (defun speedbar-line-file (&optional p)
-  "Retrieve the file or whatever from the line at P point.
+  "Retrieve the file or whatever from the line at point P.
 The return value is a string representing the file.  If it is a
 directory, then it is the directory name."
-  (save-excursion
-    (save-match-data
-      (beginning-of-line)
-      (if (looking-at (concat
-                      "\\([0-9]+\\): *[[<][-+?][]>] \\([^ \n]+\\)\\("
-                      speedbar-indicator-regex "\\)?"))
+  (save-match-data
+    (let ((f (speedbar-line-text p)))
+      (if f
          (let* ((depth (string-to-int (match-string 1)))
-                (path (speedbar-line-path depth))
-                (f (match-string 2)))
-           (concat path f))
+                (path (speedbar-line-path depth)))
+           (if (file-exists-p (concat path f))
+               (concat path f)
+             nil))
        nil))))
 
 (defun speedbar-goto-this-file (file)
-  "If FILE is displayed, goto this line and return t.
+  "If FILE is displayed, go to this line and return t.
 Otherwise do not move and return nil."
   (let ((path (substring (file-name-directory (expand-file-name file))
                         (length (expand-file-name default-directory))))
@@ -3035,7 +3323,7 @@ Otherwise do not move and return nil."
       (goto-char (point-min))
       ;; scan all the directories
       (while (and path (not (eq path t)))
-       (if (string-match "^/?\\([^/]+\\)" path)
+       (if (string-match "^[/\\]?\\([^/\\]+\\)" path)
            (let ((pp (match-string 1 path)))
              (if (save-match-data
                    (re-search-forward (concat "> " (regexp-quote pp) "$")
@@ -3063,43 +3351,50 @@ Otherwise do not move and return nil."
            (goto-char dest)
            nil))))))
 
-(defun speedbar-line-path (depth)
+(defun speedbar-line-path (&optional depth)
+  "Retrieve the pathname associated with the current line.
+This may require traversing backwards from DEPTH and combining the default
+directory with these items.  This function is replaceable in
+`speedbar-mode-functions-list' as `speedbar-line-path'."
+  (let ((rf (speedbar-fetch-replacement-function 'speedbar-line-path)))
+    (if rf (funcall rf depth) default-directory)))
+
+(defun speedbar-files-line-path (&optional depth)
   "Retrieve the pathname associated with the current line.
 This may require traversing backwards from DEPTH and combining the default
 directory with these items."
-  (cond
-   ((string= speedbar-initial-expansion-list-name "files")
-    (save-excursion
-      (save-match-data
-       (let ((path nil))
-         (setq depth (1- depth))
-         (while (/= depth -1)
-           (if (not (re-search-backward (format "^%d:" depth) nil t))
-               (error "Error building path of tag")
-             (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$")
-                    (setq path (concat (buffer-substring-no-properties
-                                        (match-beginning 1) (match-end 1))
-                                       "/"
-                                       path)))
-                   ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$")
-                    ;; This is the start of our path.
-                    (setq path (buffer-substring-no-properties
-                                (match-beginning 1) (match-end 1))))))
-           (setq depth (1- depth)))
-         (if (and path
-                  (string-match (concat speedbar-indicator-regex "$")
-                                path))
-             (setq path (substring path 0 (match-beginning 0))))
-         (concat default-directory path)))))
-   (t
-    ;; If we aren't in file mode, then return an empty string to make
-    ;; sure that we can still get some stuff done.
-    "")))
+  (save-excursion
+    (save-match-data
+      (if (not depth)
+         (progn
+           (beginning-of-line)
+           (looking-at "^\\([0-9]+\\):")
+           (setq depth (string-to-int (match-string 1)))))
+      (let ((path nil))
+       (setq depth (1- depth))
+       (while (/= depth -1)
+         (if (not (re-search-backward (format "^%d:" depth) nil t))
+             (error "Error building path of tag")
+           (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$")
+                  (setq path (concat (buffer-substring-no-properties
+                                      (match-beginning 1) (match-end 1))
+                                     "/"
+                                     path)))
+                 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$")
+                  ;; This is the start of our path.
+                  (setq path (buffer-substring-no-properties
+                              (match-beginning 1) (match-end 1))))))
+         (setq depth (1- depth)))
+       (if (and path
+                (string-match (concat speedbar-indicator-regex "$")
+                              path))
+           (setq path (substring path 0 (match-beginning 0))))
+       (concat default-directory path)))))
 
 (defun speedbar-path-line (path)
   "Position the cursor on the line specified by PATH."
   (save-match-data
-    (if (string-match "/$" path)
+    (if (string-match "[/\\]$" path)
        (setq path (substring path 0 (match-beginning 0))))
     (let ((nomatch t) (depth 0)
          (fname (file-name-nondirectory path))
@@ -3130,30 +3425,47 @@ directory with these items."
        (if (re-search-forward "[]>?}] [^ ]"
                               (save-excursion (end-of-line) (point))
                               t)
-           (speedbar-do-function-pointer)
+           (progn
+             (forward-char -1)
+             (speedbar-do-function-pointer))
          nil))
       (speedbar-do-function-pointer)))
 
-(defun speedbar-expand-line ()
-  "Expand the line under the cursor."
-  (interactive)
+(defun speedbar-expand-line (&optional arg)
+  "Expand the line under the cursor.
+With universal argument ARG, flush cached data."
+  (interactive "P")
   (beginning-of-line)
-  (re-search-forward ":\\s-*.\\+. " (save-excursion (end-of-line) (point)))
-  (forward-char -2)
-  (speedbar-do-function-pointer))
+  (let ((speedbar-power-click arg))
+    (condition-case nil
+       (progn
+         (re-search-forward ":\\s-*.\\+. "
+                            (save-excursion (end-of-line) (point)))
+         (forward-char -2)
+         (speedbar-do-function-pointer))
+      (error (speedbar-position-cursor-on-line)))))
+
+(defun speedbar-flush-expand-line ()
+  "Expand the line under the cursor and flush any cached information."
+  (interactive)
+  (speedbar-expand-line 1))
 
 (defun speedbar-contract-line ()
   "Contract the line under the cursor."
   (interactive)
   (beginning-of-line)
-  (re-search-forward ":\\s-*.-. " (save-excursion (end-of-line) (point)))
-  (forward-char -2)
-  (speedbar-do-function-pointer))
+  (condition-case nil
+      (progn
+       (re-search-forward ":\\s-*.-. "
+                          (save-excursion (end-of-line) (point)))
+       (forward-char -2)
+       (speedbar-do-function-pointer))
+    (error (speedbar-position-cursor-on-line))))
 
 (if speedbar-xemacsp
     (defalias 'speedbar-mouse-event-p 'button-press-event-p)
   (defun speedbar-mouse-event-p (event)
-    "Return t if the event is a mouse related event"
+    "Return t if the event is a mouse related event."
     ;; And Emacs does it this way
     (if (and (listp event)
             (member (event-basic-type event)
@@ -3186,7 +3498,7 @@ current indentation level."
 
 (defun speedbar-dir-follow (text token indent)
   "Speedbar click handler for directory names.
-Clicking a directory will cause the speedbar to list files in the
+Clicking a directory will cause the speedbar to list files in
 the subdirectory TEXT.  TOKEN is an unused requirement.  The
 subdirectory chosen will be at INDENT level."
   (setq default-directory
@@ -3206,15 +3518,15 @@ subdirectory chosen will be at INDENT level."
   "Delete text from point to indentation level INDENT or greater.
 Handles end-of-sublist smartly."
   (speedbar-with-writable
-   (save-excursion
-     (end-of-line) (forward-char 1)
-     (let ((start (point)))
-       (while (and (looking-at "^\\([0-9]+\\):")
-                  (> (string-to-int (match-string 1)) indent)
-                  (not (eobp)))
-        (forward-line 1)
-        (beginning-of-line))
-       (delete-region start (point))))))
+    (save-excursion
+      (end-of-line) (forward-char 1)
+      (let ((start (point)))
+       (while (and (looking-at "^\\([0-9]+\\):")
+                   (> (string-to-int (match-string 1)) indent)
+                   (not (eobp)))
+         (forward-line 1)
+         (beginning-of-line))
+       (delete-region start (point))))))
 
 (defun speedbar-dired (text token indent)
   "Speedbar click handler for directory expand button.
@@ -3244,7 +3556,7 @@ expanded.  INDENT is the current indentation level."
             (if (not (string-match (concat "^" (regexp-quote td)) (car oldl)))
                 (setq newl (cons (car oldl) newl)))
             (setq oldl (cdr oldl)))
-          (setq speedbar-shown-directories newl))
+          (setq speedbar-shown-directories (nreverse newl)))
         (speedbar-change-expand-button-char ?+)
         (speedbar-delete-subblock indent)
         )
@@ -3258,7 +3570,7 @@ expanded.  INDENT is the current indentation level."
 TEXT is the button clicked on.  TOKEN is the directory to follow.
 INDENT is the current indentation level and is unused."
   (if (string-match "^[A-z]:$" token)
-      (setq default-directory (concat token (char-to-string directory-sep-char)))
+      (setq default-directory (concat token "/"))
     (setq default-directory token))
   ;; Because we leave speedbar as the current buffer,
   ;; update contents will change directory without
@@ -3274,12 +3586,8 @@ indentation level."
   (cond ((string-match "+" text)       ;we have to expand this file
         (let* ((fn (expand-file-name (concat (speedbar-line-path indent)
                                              token)))
-               (lst (if speedbar-use-imenu-flag
-                       (let ((tim (speedbar-fetch-dynamic-imenu fn)))
-                         (if (eq tim t)
-                             (speedbar-fetch-dynamic-etags fn)
-                           tim))
-                     (speedbar-fetch-dynamic-etags fn))))
+               (mode nil)
+               (lst (speedbar-fetch-dynamic-tags fn)))
           ;; if no list, then remove expando button
           (if (not lst)
               (speedbar-change-expand-button-char ??)
@@ -3287,9 +3595,7 @@ indentation level."
             (speedbar-with-writable
               (save-excursion
                 (end-of-line) (forward-char 1)
-                (speedbar-insert-generic-list indent
-                                              lst 'speedbar-tag-expand
-                                              'speedbar-tag-find))))))
+                (funcall (car lst) indent (cdr lst)))))))
        ((string-match "-" text)        ;we have to contract this node
         (speedbar-change-expand-button-char ?+)
         (speedbar-delete-subblock indent))
@@ -3297,7 +3603,7 @@ indentation level."
   (speedbar-center-buffer-smartly))
 
 (defun speedbar-tag-find (text token indent)
-  "For the tag TEXT in a file TOKEN, goto that position.
+  "For the tag TEXT in a file TOKEN, go to that position.
 INDENT is the current indentation level."
   (let ((file (speedbar-line-path indent)))
     (speedbar-find-file-in-frame file)
@@ -3410,29 +3716,54 @@ interested in."
        (goto-char cp)))))
 
 \f
+;;; Tag Management -- List of expanders:
+;;
+(defun speedbar-fetch-dynamic-tags (file)
+  "Return a list of tags generated dynamically from FILE.
+This uses the entries in `speedbar-dynamic-tags-function-list'
+to find the proper tags.  It is up to each of those individual
+functions to do caching and flushing if appropriate."
+  (save-excursion
+    (set-buffer (find-file-noselect file))
+    ;; If there is a buffer-local value of
+    ;; speedbar-dynamic-tags-function-list, it will now be available.
+    (let ((dtf speedbar-dynamic-tags-function-list)
+         (ret t))
+      (while (and (eq ret t) dtf)
+       (setq ret
+             (if (fboundp (car (car dtf)))
+                 (funcall (car (car dtf)) (buffer-file-name))
+               t))
+       (if (eq ret t)
+           (setq dtf (cdr dtf))))
+      (if (eq ret t)
+         ;; No valid tag list, return nil
+         nil
+       ;; We have some tags.  Return the list with the insert fn
+       ;; prepended
+       (cons (cdr (car dtf)) ret)))))
+
 ;;; Tag Management -- Imenu
 ;;
 (if (not speedbar-use-imenu-flag)
 
     nil
 
-(eval-when-compile (if (locate-library "imenu") (require 'imenu)))
+(eval-when-compile (condition-case nil (require 'imenu) (error nil)))
 
 (defun speedbar-fetch-dynamic-imenu (file)
   "Load FILE into a buffer, and generate tags using Imenu.
 Returns the tag list, or t for an error."
   ;; Load this AND compile it in
   (require 'imenu)
-  (save-excursion
-    (set-buffer (find-file-noselect file))
-    (if speedbar-power-click (setq imenu--index-alist nil))
-    (condition-case nil
-       (let ((index-alist (imenu--make-index-alist t)))
-         (if speedbar-sort-tags
-             (sort (copy-alist index-alist)
-                   (lambda (a b) (string< (car a) (car b))))
-           index-alist))
-      (error t))))
+  (if speedbar-power-click (setq imenu--index-alist nil))
+  (condition-case nil
+      (let ((index-alist (imenu--make-index-alist t)))
+       (if speedbar-sort-tags
+           (sort (copy-alist index-alist)
+                 (lambda (a b) (string< (car a) (car b))))
+         index-alist))
+    (error t)))
 )
 \f
 ;;; Tag Management -- etags  (old XEmacs compatibility part)
@@ -3461,14 +3792,14 @@ This variable is ignored if `speedbar-use-imenu-flag' is non-nil.")
 (defvar speedbar-fetch-etags-command "etags"
   "*Command used to create an etags file.
 
-This variable is ignored if `speedbar-use-imenu-flag' is t")
+This variable is ignored if `speedbar-use-imenu-flag' is t.")
 
 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-")
   "*List of arguments to use with `speedbar-fetch-etags-command'.
 This creates an etags output buffer.  Use `speedbar-toggle-etags' to
 modify this list conveniently.
 
-This variable is ignored if `speedbar-use-imenu-flag' is t")
+This variable is ignored if `speedbar-use-imenu-flag' is t.")
 
 (defun speedbar-toggle-etags (flag)
   "Toggle FLAG in `speedbar-fetch-etags-arguments'.
@@ -3478,7 +3809,7 @@ value is \"show\" then toggle the value of
 `speedbar-show-unknown-files'.
 
   This function is a convenience function for XEmacs menu created by
-Farzin Guilak <farzin@protocol.com>"
+Farzin Guilak <farzin@protocol.com>."
   (interactive)
   (cond
    ((equal flag "sort")
@@ -3502,13 +3833,15 @@ Each symbol will be associated with its line position in FILE."
        (save-excursion
          (if (get-buffer "*etags tmp*")
              (kill-buffer "*etags tmp*"))      ;kill to clean it up
-         (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
+         (if (<= 1 speedbar-verbosity-level)
+             (speedbar-message "Fetching etags..."))
          (set-buffer (get-buffer-create "*etags tmp*"))
          (apply 'call-process speedbar-fetch-etags-command nil
                 (current-buffer) nil
                 (append speedbar-fetch-etags-arguments (list file)))
          (goto-char (point-min))
-         (if (<= 1 speedbar-verbosity-level) (message "Fetching etags..."))
+         (if (<= 1 speedbar-verbosity-level)
+             (speedbar-message "Fetching etags..."))
          (let ((expr
                 (let ((exprlst speedbar-fetch-etags-parse-list)
                       (ans nil))
@@ -3519,12 +3852,14 @@ Each symbol will be associated with its line position in FILE."
                   (cdr ans))))
            (if expr
                (let (tnl)
+                 (set-buffer (get-buffer-create "*etags tmp*"))
                  (while (not (save-excursion (end-of-line) (eobp)))
                    (save-excursion
                      (setq tnl (speedbar-extract-one-symbol expr)))
                    (if tnl (setq newlist (cons tnl newlist)))
                    (forward-line 1)))
-             (message "Sorry, no support for a file of that extension"))))
+             (speedbar-message
+              "Sorry, no support for a file of that extension"))))
       )
     (if speedbar-sort-tags
        (sort newlist (lambda (a b) (string< (car a) (car b))))
@@ -3550,7 +3885,7 @@ Each symbol will be associated with its line position in FILE."
 (defun speedbar-extract-one-symbol (expr)
   "At point, return nil, or one alist in the form: (SYMBOL .  POSITION)
 The line should contain output from etags.  Parse the output using the
-regular expression EXPR"
+regular expression EXPR."
   (let* ((sym (if (stringp expr)
                  (if (save-excursion
                        (re-search-forward expr (save-excursion
@@ -3574,7 +3909,7 @@ regular expression EXPR"
       nil)))
 
 (defun speedbar-parse-c-or-c++tag ()
-  "Parse a c or c++ tag, which tends to be a little complex."
+  "Parse a C or C++ tag, which tends to be a little complex."
   (save-excursion
     (let ((bound (save-excursion (end-of-line) (point))))
       (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t)
@@ -3612,6 +3947,7 @@ regular expression EXPR"
   (define-key speedbar-buffers-key-map "e" 'speedbar-edit-line)
   (define-key speedbar-buffers-key-map "\C-m" 'speedbar-edit-line)
   (define-key speedbar-buffers-key-map "+" 'speedbar-expand-line)
+  (define-key speedbar-buffers-key-map "=" 'speedbar-expand-line)
   (define-key speedbar-buffers-key-map "-" 'speedbar-contract-line)
 
   ;; Buffer specific keybindings
@@ -3625,9 +3961,18 @@ regular expression EXPR"
     ["Expand File Tags" speedbar-expand-line
      (save-excursion (beginning-of-line)
                     (looking-at "[0-9]+: *.\\+. "))]
+    ["Flush Cache & Expand" speedbar-flush-expand-line
+     (save-excursion (beginning-of-line)
+                    (looking-at "[0-9]+: *.\\+. "))]
     ["Contract File Tags" speedbar-contract-line
      (save-excursion (beginning-of-line)
                     (looking-at "[0-9]+: *.-. "))]
+    ["Kill Buffer" speedbar-buffer-kill-buffer
+     (save-excursion (beginning-of-line)
+                    (looking-at "[0-9]+: *.-. "))]
+    ["Revert Buffer" speedbar-buffer-revert-buffer
+     (save-excursion (beginning-of-line)
+                    (looking-at "[0-9]+: *.-. "))]
     )
   "Menu item elements shown when displaying a buffer list.")
 
@@ -3655,7 +4000,8 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
               (fn (if known 'speedbar-tag-file nil))
               (fname (save-excursion (set-buffer (car bl))
                                      (buffer-file-name))))
-         (speedbar-make-tag-line 'bracket expchar fn fname
+         (speedbar-make-tag-line 'bracket expchar fn
+                                 (if fname (file-name-nondirectory fname))
                                  (buffer-name (car bl))
                                  'speedbar-buffer-click temp
                                  'speedbar-file-face 0)))
@@ -3685,6 +4031,38 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
                                  'speedbar-file-face 0)))
       (setq bl (cdr bl)))))
 
+(defun speedbar-buffers-item-info ()
+  "Display information about the current buffer on the current line."
+  (or (speedbar-item-info-tag-helper)
+      (let* ((item (speedbar-line-text))
+            (buffer (if item (get-buffer item) nil)))
+       (and buffer
+            (speedbar-message "%s%s %S %d %s"
+                              (if (buffer-modified-p buffer) "* " "")
+                              item
+                              (save-excursion (set-buffer buffer) major-mode)
+                              (save-excursion (set-buffer buffer)
+                                              (buffer-size))
+                              (or (buffer-file-name buffer) "<No file>"))))))
+
+(defun speedbar-buffers-line-path (&optional depth)
+  "Fetch the full path to the file (buffer) specified on the current line.
+Optional argument DEPTH specifies the current depth of the back search."
+  (save-excursion
+    (end-of-line)
+    (let ((start (point)))
+      ;; Buffers are always at level 0
+      (if (not (re-search-backward "^0:" nil t))
+         nil
+       (let* ((bn (speedbar-line-text))
+              (buffer (if bn (get-buffer bn))))
+         (if buffer
+             (if (save-excursion
+                   (end-of-line)
+                   (eq start (point)))
+                 (file-name-directory (buffer-file-name buffer))
+               (buffer-file-name buffer))))))))
+
 (defun speedbar-buffer-click (text token indent)
   "When the users clicks on a buffer-button in speedbar.
 TEXT is the buffer's name, TOKEN and INDENT are unused."
@@ -3711,7 +4089,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
                                                      (end-of-line)
                                                      (point))))))
              (if (and (get-buffer text)
-                      (y-or-n-p (format "Kill buffer %s? " text)))
+                      (speedbar-y-or-n-p (format "Kill buffer %s? " text)))
                  (kill-buffer text))
              (speedbar-refresh))))))
 
@@ -3735,9 +4113,43 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
                (set-buffer text)
                (revert-buffer t)))))))
 
+\f
+;;; Useful hook values and such.
+;;
+(defvar speedbar-highlight-one-tag-line nil
+  "Overlay used for highlighting the most recently jumped to tag line.")
+
+(defun speedbar-highlight-one-tag-line ()
+  "Highlight the current line, unhighlighting a previously jumped to line."
+  (speedbar-unhighlight-one-tag-line)
+  (setq speedbar-highlight-one-tag-line
+       (speedbar-make-overlay (save-excursion (beginning-of-line) (point))
+                              (save-excursion (end-of-line)
+                                              (forward-char 1)
+                                              (point))))
+  (speedbar-overlay-put speedbar-highlight-one-tag-line 'face
+                       'speedbar-highlight-face)
+  (add-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line)
+  )
+
+(defun speedbar-unhighlight-one-tag-line ()
+  "Unhighlight the currently highlighted line."
+  (if speedbar-highlight-one-tag-line
+      (progn
+       (speedbar-delete-overlay speedbar-highlight-one-tag-line)
+       (setq speedbar-highlight-one-tag-line nil)))
+  (remove-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line))
+
+(defun speedbar-recenter-to-top ()
+  "Recenter the current buffer so POINT is on the top of the window."
+  (recenter 1))
+
+(defun speedbar-recenter ()
+  "Recenter the current buffer so POINT is in the center of the window."
+  (recenter (/ (window-height (selected-window)) 2)))
 
 \f
-;;; Color loading section  This is messy *Blech!*
+;;; Color loading section.
 ;;
 (defface speedbar-button-face '((((class color) (background light))
                                 (:foreground "green4"))
@@ -3750,7 +4162,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
                               (:foreground "cyan4"))
                              (((class color) (background dark))
                               (:foreground "cyan"))
-                             (t (:bold t)))
+                             (t (:weight bold)))
   "Face used for file names."
   :group 'speedbar-faces)
 
@@ -3758,7 +4170,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
                                    (:foreground "blue4"))
                                   (((class color) (background dark))
                                    (:foreground "light blue")))
-  "Faced used for directory names."
+  "Face used for directory names."
   :group 'speedbar-faces)
 (defface speedbar-tag-face '((((class color) (background light))
                              (:foreground "brown"))
@@ -3779,22 +4191,173 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
                                    (:background "green"))
                                   (((class color) (background dark))
                                    (:background "sea green"))
-                                  (((class grayscale monochrome)
+                                  (((class grayscale mono)
                                     (background light))
                                    (:background "black"))
-                                  (((class grayscale monochrome)
+                                  (((class grayscale mono)
                                     (background dark))
                                    (:background "white")))
   "Face used for highlighting buttons with the mouse."
   :group 'speedbar-faces)
 
+\f
+;;; Image loading and inlining
+;;
+
+;;; Some images if defimage is available:
+(eval-when-compile
+
+(if (fboundp 'defimage)
+    (defalias 'defimage-speedbar 'defimage)
+
+  (if (not (fboundp 'make-glyph))
+
+(defmacro defimage-speedbar (variable imagespec docstring)
+  "Don't bother loading up an image...
+Argument VARIABLE is the variable to define.
+Argument IMAGESPEC is the list defining the image to create.
+Argument DOCSTRING is the documentation for VARIABLE."
+  `(defvar ,variable nil ,docstring))
+
+;; ELSE
+(defun speedbar-find-image-on-load-path (image)
+  "Find the image file IMAGE on the load path."
+  (let ((l load-path)
+       (r nil))
+    (while (and l (not r))
+      (if (file-exists-p (concat (car l) "/" image))
+         (setq r (concat (car l) "/" image)))
+      (setq l (cdr l)))
+    r))
+
+(defun speedbar-convert-emacs21-imagespec-to-xemacs (spec)
+  "Convert the Emacs21 image SPEC into an XEmacs image spec."
+  (let* ((sl (car spec))
+        (itype (nth 1 sl))
+        (ifile (nth 3 sl)))
+    (vector itype ':file (speedbar-find-image-on-load-path ifile))))
+
+(defmacro defimage-speedbar (variable imagespec docstring)
+  "Define VARIABLE as an image if `defimage' is not available.
+IMAGESPEC is the image data, and DOCSTRING is documentation for the image."
+  `(defvar ,variable
+     ;; The Emacs21 version of defimage looks just like the XEmacs image
+     ;; specifier, except that it needs a :type keyword.  If we line
+     ;; stuff up right, we can use this cheat to support XEmacs specifiers.
+     (condition-case nil
+        (make-glyph
+         (make-image-specifier
+          (speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec)))
+         'buffer)
+       (error nil))
+     ,docstring)))))
+
+(defimage-speedbar speedbar-directory-plus
+  ((:type xpm :file "sb-dir-plus.xpm" :ascent center))
+  "Image used for closed directories with stuff in them.")
+
+(defimage-speedbar speedbar-directory-minus
+  ((:type xpm :file "sb-dir-minus.xpm" :ascent center))
+  "Image used for open directories with stuff in them.")
+
+(defimage-speedbar speedbar-directory
+  ((:type xpm :file "sb-dir.xpm" :ascent center))
+  "Image used for empty or unreadable directories.")
+
+(defimage-speedbar speedbar-page-plus
+  ((:type xpm :file "sb-pg-plus.xpm" :ascent center))
+  "Image used for closed files with stuff in them.")
+
+(defimage-speedbar speedbar-page-minus
+  ((:type xpm :file "sb-pg-minus.xpm" :ascent center))
+  "Image used for open files with stuff in them.")
+
+(defimage-speedbar speedbar-page
+  ((:type xpm :file "sb-pg.xpm" :ascent center))
+  "Image used for files that can't be opened.")
+
+(defimage-speedbar speedbar-tag
+  ((:type xpm :file "sb-tag.xpm" :ascent center))
+  "Image used for tags.")
+
+(defimage-speedbar speedbar-tag-plus
+  ((:type xpm :file "sb-tag-plus.xpm" :ascent center))
+  "Image used for closed tag groups.")
+
+(defimage-speedbar speedbar-tag-minus
+  ((:type xpm :file "sb-tag-minus.xpm" :ascent center))
+  "Image used for open tag groups.")
+
+(defimage-speedbar speedbar-tag-gt
+  ((:type xpm :file "sb-tag-gt.xpm" :ascent center))
+  "Image used for open tag groups.")
+
+(defimage-speedbar speedbar-tag-v
+  ((:type xpm :file "sb-tag-v.xpm" :ascent center))
+  "Image used for open tag groups.")
+
+(defimage-speedbar speedbar-tag-type
+  ((:type xpm :file "sb-tag-type.xpm" :ascent center))
+  "Image used for open tag groups.")
+
+(defimage-speedbar speedbar-mail
+  ((:type xpm :file "sb-mail.xpm" :ascent center))
+  "Image used for open tag groups.")
+
+(defvar speedbar-expand-image-button-alist
+  '(("<+>" . speedbar-directory-plus)
+    ("<->" . speedbar-directory-minus)
+    ("< >" . speedbar-directory)
+    ("[+]" . speedbar-page-plus)
+    ("[-]" . speedbar-page-minus)
+    ("[?]" . speedbar-page)
+    ("{+}" . speedbar-tag-plus)
+    ("{-}" . speedbar-tag-minus)
+    ("<M>" . speedbar-mail)
+    (" =>" . speedbar-tag)
+    (" +>" . speedbar-tag-gt)
+    (" ->" . speedbar-tag-v)
+    (">" . speedbar-tag)
+    ("@" . speedbar-tag-type)
+    ("  @" . speedbar-tag-type)
+    )
+  "List of text and image associations.")
+
+(defun speedbar-insert-image-button-maybe (start length)
+  "Insert an image button based on text starting at START for LENGTH chars.
+If buttontext is unknown, just insert that text.
+If we have an image associated with it, use that image."
+  (if speedbar-use-images
+      (let* ((bt (buffer-substring start (+ length start)))
+            (a (assoc bt speedbar-expand-image-button-alist)))
+       ;; Regular images (created with `insert-image' are intangible
+       ;; which (I suppose) make them more compatible with XEmacs 21.
+       ;; Unfortunatly, there is a giant pile o code dependent on the
+       ;; underlying text.  This means if we leave it tangible, then I
+       ;; don't have to change said giant piles o code.
+       (if (and a (symbol-value (cdr a)))
+           (if (featurep 'xemacs)
+               (add-text-properties (+ start (length bt)) start
+                                    (list 'end-glyph (symbol-value (cdr a))
+                                          'rear-nonsticky (list 'display)
+                                          'invisible t
+                                          'detachable t))
+             (add-text-properties start (+ start (length bt))
+                                  (list 'display (symbol-value (cdr a))
+                                        'rear-nonsticky (list 'display))))
+         ;(message "Bad text [%s]" (buffer-substring start (+ start length)))
+         ))))
+
+
 ;; some edebug hooks
 (add-hook 'edebug-setup-hook
          (lambda ()
            (def-edebug-spec speedbar-with-writable def-body)))
 
 (provide 'speedbar)
-;;; speedbar ends here
 
 ;; run load-time hooks
 (run-hooks 'speedbar-load-hook)
+
+;; arch-tag: 4477e6d1-f78c-48b9-a503-387d3c9767d5
+;;; speedbar.el ends here