]> code.delx.au - gnu-emacs/blobdiff - lisp/speedbar.el
(save-abbrevs, save-some-buffers): Don't ask the user
[gnu-emacs] / lisp / speedbar.el
index f60f7030ebc1afebcd6eeeb1f020c585625e6766..d60d38a8275f144e9dd0f11e498a7535e55b2edf 100644 (file)
@@ -1,9 +1,9 @@
-;;; 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.
@@ -90,9 +90,9 @@
 ;; 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
@@ -347,6 +347,7 @@ 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.
 Any parameter supported by a frame may be added.  The parameter `height'
@@ -670,7 +671,7 @@ It is generated from the variable `completion-ignored-extensions'")
   (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"
@@ -1276,7 +1277,6 @@ in the selected file.
                               (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
@@ -2873,7 +2873,7 @@ If new functions are added, their state needs to be updated here."
   (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
@@ -3294,7 +3294,9 @@ directory, then it is the directory name."
       (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)
@@ -4030,13 +4032,20 @@ If TEMP is non-nil, then clicking on a buffer restores the previous display."
 (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.
@@ -4308,7 +4317,7 @@ If we have an image associated with it, use that image."
        ;; 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)
@@ -4327,7 +4336,8 @@ If we have an image associated with it, use that image."
            (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