-;;; 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, 99, 00 Free Software Foundation
+;;; Copyright (C) 1996, 97, 98, 99, 2000, 01 Free Software Foundation
;; Author: Eric M. Ludlam <zappo@gnu.org>
-;; Version: 0.11
+;; Version: 0.11a
;; Keywords: file, tags, tools
;; This file is part of GNU Emacs.
;; 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.
+;; Other filters can be easily added.
;;
-;; AUC-TEX users: The imenu tags for AUC-TEX mode don't work very
+;; AUC-TEX users: The imenu tags for AUC-TEX 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)
;; 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 tweekable variable is `speedbar-stealthy-function-list'
+;; 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 are
-;; over ridable, but more will be added as the need is discovered.
+;; 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
"Hooks run when speedbar visits a tag in the selected frame."
:group 'speedbar
:type 'hook
+ :version "21.1"
:options '(speedbar-highlight-one-tag-line
speedbar-recenter-to-top
speedbar-recenter
(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
(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.
Any parameter supported by a frame may be added. The parameter `height'
(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))
- window-system)
+ (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
(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" ".p[lm]" ".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"
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
(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:
)
(defvar speedbar-easymenu-definition-base
- `("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))
- window-system)
- ["Use Images" speedbar-toggle-images
- :style toggle :selected speedbar-use-images])
- )
+ (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
(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
This is a convenience function for special mode 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)
(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
(if f
(let* ((depth (string-to-int (match-string 1)))
(path (speedbar-line-path depth)))
- (concat path f))
+ (if (file-exists-p (concat path f))
+ (concat path f)
+ nil))
nil))))
(defun speedbar-goto-this-file (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."
- (end-of-line)
- ;; 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 (file-name-directory (buffer-file-name buffer))))))
+ (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.
)))
-(defimage-speedbar speedbar-directory-+
- ((:type xpm :file "sb-dir+.xpm" :ascent center))
+(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--
- ((:type xpm :file "sb-dir-.xpm" :ascent center))
+(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-file-+
- ((:type xpm :file "sb-file+.xpm" :ascent center))
+(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-file--
- ((:type xpm :file "sb-file-.xpm" :ascent center))
+(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-file-
- ((:type xpm :file "sb-file.xpm" :ascent center))
+(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-
+(defimage-speedbar speedbar-tag
((:type xpm :file "sb-tag.xpm" :ascent center))
"Image used for tags.")
-(defimage-speedbar speedbar-tag-+
- ((:type xpm :file "sb-tag+.xpm" :ascent center))
+(defimage-speedbar speedbar-tag-plus
+ ((:type xpm :file "sb-tag-plus.xpm" :ascent center))
"Image used for closed tag groups.")
-(defimage-speedbar speedbar-tag--
- ((:type xpm :file "sb-tag-.xpm" :ascent center))
+(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
"Image used for open tag groups.")
(defvar speedbar-expand-image-button-alist
- '(("<+>" . speedbar-directory-+)
- ("<->" . speedbar-directory--)
- ("[+]" . speedbar-file-+)
- ("[-]" . speedbar-file--)
- ("[?]" . speedbar-file-)
- ("{+}" . speedbar-tag-+)
- ("{-}" . speedbar-tag--)
+ '(("<+>" . speedbar-directory-plus)
+ ("<->" . speedbar-directory-minus)
+ ("[+]" . speedbar-page-plus)
+ ("[-]" . speedbar-page-minus)
+ ("[?]" . speedbar-page)
+ ("{+}" . speedbar-tag-plus)
+ ("{-}" . speedbar-tag-minus)
("<M>" . speedbar-mail)
- (" =>" . speedbar-tag-)
+ (" =>" . speedbar-tag)
(" +>" . speedbar-tag-gt)
(" ->" . speedbar-tag-v)
- (">" . speedbar-tag-)
+ (">" . speedbar-tag)
("@" . speedbar-tag-type)
(" @" . speedbar-tag-type)
)
;; 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 (fboundp 'set-extent-property)
+ (if (featurep 'xemacs)
(add-text-properties (+ start (length bt)) start
(list 'end-glyph (symbol-value (cdr a))
'rear-nonsticky (list 'display)
(def-edebug-spec speedbar-with-writable def-body)))
(provide 'speedbar)
-;;; speedbar ends here
;; run load-time hooks
(run-hooks 'speedbar-load-hook)
+
+;;; speedbar.el ends here