;;; speedbar --- quick access to files and tags in a frame
;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-;; 2005, 2006, 2007 Free Software Foundation, Inc.
+;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: file, tags, tools
"The current version of speedbar.")
(defvar speedbar-incompatible-version "0.14beta4"
"This version of speedbar is incompatible with this version.
-Due to massive API changes (removing the use of the word PATH)
+Due to massive API changes (removing the use of the word PATH)
this version is not backward compatible to 0.14 or earlier.")
;; This file is part of GNU Emacs.
;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
(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."
+A nil value means don't show the file in the list."
:group 'speedbar
:type 'boolean)
(looking-at "[0-9]+: *\\[[+-]\\] [^ \n]+ \\*?[!#]$"))]
)
"Additional menu items while in file-mode.")
-
+
(defvar speedbar-easymenu-definition-trailer
(append
(if (and (featurep 'custom) (fboundp 'custom-declare-variable))
(defalias 'speedbar-make-overlay
(if (featurep 'xemacs) 'make-extent 'make-overlay))
-(defalias 'speedbar-overlay-put
+(defalias 'speedbar-overlay-put
(if (featurep 'xemacs) 'set-extent-property 'overlay-put))
-(defalias 'speedbar-delete-overlay
+(defalias 'speedbar-delete-overlay
(if (featurep 'xemacs) 'delete-extent 'delete-overlay))
-(defalias 'speedbar-mode-line-update
+(defalias 'speedbar-mode-line-update
(if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update))
\f
;;; Mode definitions/ user commands
;;;###autoload
(defun speedbar-frame-mode (&optional arg)
"Enable or disable speedbar. Positive ARG means turn on, negative turn off.
-nil means toggle. Once the speedbar frame is activated, a buffer in
+A nil ARG means toggle. Once the speedbar frame is activated, a buffer in
`speedbar-mode' will be displayed. Currently, only one speedbar is
supported at a time.
`speedbar-before-popup-hook' is called before popping up the speedbar frame.
'speedbar-buffer
"Speedbar"
#'speedbar-frame-mode
- (if dframe-xemacsp
+ (if (featurep 'xemacs)
(append speedbar-frame-plist
;; This is a hack to get speedbar to iconfiy
;; with the selected frame.
(defun speedbar-frame-reposition-smartly ()
"Reposition the speedbar frame to be next to the attached frame."
- (cond ((and dframe-xemacsp
+ (cond ((and (featurep 'xemacs)
(or (member 'left speedbar-frame-plist)
(member 'top speedbar-frame-plist)))
(dframe-reposition-frame
(cons (car (cdr (member 'left speedbar-frame-plist)))
(car (cdr (member 'top speedbar-frame-plist)))))
)
- ((and (not dframe-xemacsp)
+ ((and (not (featurep 'xemacs))
(or (assoc 'left speedbar-frame-parameters)
(assoc 'top speedbar-frame-parameters)))
;; if left/top were specified in the parameters, pass them
"Handle a delete frame event E.
If the deleted frame is the frame SPEEDBAR is attached to,
we need to delete speedbar also."
- (let ((frame-to-be-deleted (car (car (cdr e)))))
- (if (eq frame-to-be-deleted dframe-attached-frame)
- (delete-frame speedbar-frame)))
- )
+ (when (and speedbar-frame
+ (eq (car (car (cdr e))) ;; frame to be deleted
+ dframe-attached-frame))
+ (delete-frame speedbar-frame)))
;;;###autoload
(defun speedbar-get-focus ()
(defsubst speedbar-frame-width ()
"Return the width of the speedbar frame in characters.
-nil if it doesn't exist."
+Return nil if it doesn't exist."
(frame-width speedbar-frame))
(defun speedbar-mode ()
;; Backwards compatibility
(defalias 'speedbar-with-attached-buffer 'dframe-with-attached-buffer)
(defalias 'speedbar-maybee-jump-to-attached-frame 'dframe-maybee-jump-to-attached-frame)
-
+
(defun speedbar-set-mode-line-format ()
"Set the format of the mode line based on the current speedbar environment.
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-current-frame))
- (or (not dframe-xemacsp)
+ (or (not (featurep 'xemacs))
(with-no-warnings
(specifier-instance has-modeline-p)))
speedbar-buffer)
(if speedbar-previous-menu (easy-menu-remove speedbar-previous-menu))
(setq speedbar-previous-menu md)
;; Now add the new menu
- (if (not dframe-xemacsp)
+ (if (not (featurep 'xemacs))
(easy-menu-define speedbar-menu-map (current-local-map)
"Speedbar menu" md)
(easy-menu-add md (current-local-map))
(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."
+Return 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)
(defun speedbar-item-info-tag-helper ()
"Display info about a tag that is on the current line.
-nil if not applicable."
+Return nil if not applicable."
(save-excursion
(beginning-of-line)
(if (re-search-forward " [-+=]?> \\([^\n]+\\)"
(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."
(save-excursion
(defun speedbar-default-directory-list (directory index)
"Insert files for DIRECTORY with level INDEX at point."
- (speedbar-insert-files-at-point
+ (speedbar-insert-files-at-point
(speedbar-file-lists directory) index)
(speedbar-reset-scanners)
(if (= index 0)
(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
"Go to the line where FILE is."
(set-buffer speedbar-buffer)
-
+
(goto-char (point-min))
(let ((m nil))
(while (and (setq m (re-search-forward
(not (or (and (featurep 'ange-ftp)
(string-match
(car (symbol-value
- (if dframe-xemacsp
+ (if (featurep 'xemacs)
'ange-ftp-directory-format
'ange-ftp-name-format)))
(expand-file-name default-directory)))
(widen)
(let ((rf (speedbar-fetch-replacement-function 'speedbar-line-directory)))
(if rf (funcall rf depth) default-directory))))
-
+
(defun speedbar-files-line-directory (&optional depth)
"Retrieve the directoryname associated with the current line.
This may require traversing backwards from DEPTH and combining the default
(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)
interested in."
(save-selected-window
-
+
(select-window (get-buffer-window speedbar-buffer t))
-
+
(set-buffer speedbar-buffer)
-
+
(if (<= (count-lines (point-min) (point-max))
(1- (window-height (selected-window))))
;; whole buffer fits