]> code.delx.au - gnu-emacs/blobdiff - lisp/speedbar.el
(comint-postoutput-scroll-to-bottom): Cope with unset
[gnu-emacs] / lisp / speedbar.el
index d1307ec4c0c6268f78cc4e410fb11d5c11bb2809..65c891aa2d744dbc68450924b79e06b888b7e970 100644 (file)
@@ -3,9 +3,9 @@
 ;;; Copyright (C) 1996, 97, 98 Free Software Foundation
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
-;; Version: 0.7.1
+;; Version: 0.7.2
 ;; Keywords: file, tags, tools
-;; X-RCS: $Id: speedbar.el,v 1.4 1998/07/10 16:48:06 kwzh Exp zappo $
+;; X-RCS: $Id: speedbar.el,v 1.7 1998/08/08 21:20:51 zappo Exp zappo $
 
 ;; This file is part of GNU Emacs.
 
@@ -360,7 +360,6 @@ between different directories."
 
 (defcustom speedbar-frame-parameters '((minibuffer . nil)
                                       (width . 20)
-                                      (scroll-bar-width . 10)
                                       (border-width . 0)
                                       (menu-bar-lines . 0)
                                       (unsplittable . t))
@@ -1526,17 +1525,14 @@ Assumes that the current buffer is the speedbar buffer"
     (while dl
       (adelete 'speedbar-directory-contents-alist (car dl))
       (setq dl (cdr dl)))
-    (if (<= 1 speedbar-verbosity-level) (message "Refreshing speedbar..."))
+    (if (<= 1 speedbar-verbosity-level)
+       (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)
-       (progn
-         (message "Refreshing speedbar...done")
-         (sit-for 0)
-         (message nil)))
-    ;; Protect the highlighted region.
+       (message "Refreshing speedbar...done"))
     (if (boundp 'deactivate-mark) (setq deactivate-mark dm))))
 
 (defun speedbar-item-load ()
@@ -2551,8 +2547,10 @@ This should only be used by modes classified as special."
                                 major-mode))
                    (speedbar-update-special-contents)
                    (if (<= 2 speedbar-verbosity-level)
-                       (message "Updating speedbar to special mode: %s...done"
-                                major-mode)))
+                       (progn
+                         (message "Updating speedbar to special mode: %s...done"
+                                  major-mode)
+                         (message nil))))
                ;; Update all the contents if directories change!
                (if (or (member (expand-file-name default-directory)
                                speedbar-shown-directories)
@@ -2569,8 +2567,10 @@ This should only be used by modes classified as special."
                               default-directory))
                  (speedbar-update-directory-contents)
                  (if (<= 1 speedbar-verbosity-level)
-                     (message "Updating speedbar to: %s...done"
-                              default-directory))))
+                     (progn
+                       (message "Updating speedbar to: %s...done"
+                                default-directory)
+                       (message nil)))))
              (select-frame af))
            ;; Now run stealthy updates of time-consuming items
            (speedbar-stealthy-updates)))
@@ -2606,19 +2606,36 @@ If new functions are added, their state needs to be updated here."
   (run-hooks 'speedbar-scanner-reset-hook)
   )
 
+(defun speedbar-find-selected-file (file)
+  "Goto the line where FILE is."
+  (goto-char (point-min))
+  (let ((m nil))
+    (while (and (setq m (re-search-forward
+                        (concat " \\(" (file-name-nondirectory file)
+                                "\\)\\(" speedbar-indicator-regex "\\)?\n")
+                        nil t))
+               (not (string= file
+                             (concat
+                              (speedbar-line-path
+                               (save-excursion
+                                 (goto-char (match-beginning 0))
+                                 (beginning-of-line)
+                                 (save-match-data
+                                   (looking-at "[0-9]+:")
+                                   (string-to-number (match-string 0)))))
+                              (match-string 1))))))
+    (if m
+       (progn
+         (goto-char (match-beginning 1))
+         (match-string 1)))))
+
 (defun speedbar-clear-current-file ()
   "Locate the file thought to be current, and remove its highlighting."
   (save-excursion
     (set-buffer speedbar-buffer)
     (if speedbar-last-selected-file
        (speedbar-with-writable
-         (goto-char (point-min))
-         (if (and
-              speedbar-last-selected-file
-              (re-search-forward
-               (concat " \\(" (regexp-quote speedbar-last-selected-file)
-                       "\\)\\(" speedbar-indicator-regex "\\)?\n")
-               nil t))
+         (if (speedbar-find-selected-file speedbar-last-selected-file)
              (put-text-property (match-beginning 1)
                                 (match-end 1)
                                 'face
@@ -2637,7 +2654,7 @@ updated."
                               nil)))
                     (select-frame lastf)
                     rf)))
-        (newcf (if newcfd (file-name-nondirectory newcfd)))
+        (newcf (if newcfd newcfd))
         (lastb (current-buffer))
         (sucf-recursive (boundp 'sucf-recursive))
         (case-fold-search t))
@@ -2656,15 +2673,12 @@ updated."
          ;; now highlight the new one.
          (set-buffer speedbar-buffer)
          (speedbar-with-writable
-           (goto-char (point-min))
-           (if (re-search-forward
-                (concat " \\(" (regexp-quote newcf) "\\)\\("
-                        speedbar-indicator-regex "\\)?$") nil t)
-                 ;; put the property on it
-                 (put-text-property (match-beginning 1)
-                                    (match-end 1)
-                                    'face
-                                    'speedbar-selected-face)
+           (if (speedbar-find-selected-file newcf)
+               ;; put the property on it
+               (put-text-property (match-beginning 1)
+                                  (match-end 1)
+                                  'face
+                                  'speedbar-selected-face)
              ;; Oops, it's not in the list.  Should it be?
              (if (and (string-match speedbar-file-regexp newcf)
                       (string= (file-name-directory newcfd)
@@ -2672,8 +2686,7 @@ updated."
                  ;; yes, it is (we will ignore unknowns for now...)
                  (progn
                    (speedbar-refresh)
-                   (if (re-search-forward
-                        (concat " \\(" (regexp-quote newcf) "\\)\n") nil t)
+                   (if (speedbar-find-selected-file newcf)
                        ;; put the property on it
                        (put-text-property (match-beginning 1)
                                           (match-end 1)
@@ -3086,7 +3099,7 @@ directory with these items."
        (beginning-of-line)
        ;; If this fails, then it is a non-standard click, and as such,
        ;; perfectly allowed.
-       (if (re-search-forward "[]>}] [a-zA-Z0-9]"
+       (if (re-search-forward "[]>?}] [^ ]"
                               (save-excursion (end-of-line) (point))
                               t)
            (speedbar-do-function-pointer)
@@ -3165,16 +3178,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)
-      (while (and (not (save-excursion
-                        (re-search-forward (format "^%d:" indent)
-                                           nil t)))
-                 (>= indent 0))
-       (setq indent (1- indent)))
-      (delete-region (point) (if (>= indent 0)
-                                (match-beginning 0)
-                              (point-max))))))
+   (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.
@@ -3334,7 +3346,7 @@ interested in."
        (end-of-line)
        (if (re-search-backward exp nil t)
            (setq start (point))
-         (error "Center error"))
+         (setq start (point-min)))
        (save-excursion                 ;Not sure about this part.
          (end-of-line)
          (setq p (point))
@@ -3662,7 +3674,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
        (beginning-of-line)
        ;; If this fails, then it is a non-standard click, and as such,
        ;; perfectly allowed.
-       (if (re-search-forward "[]>}] [a-zA-Z0-9]"
+       (if (re-search-forward "[]>?}] [^ ]"
                               (save-excursion (end-of-line) (point))
                               t)
            (let ((text (progn
@@ -3682,7 +3694,7 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
     (beginning-of-line)
     ;; If this fails, then it is a non-standard click, and as such,
     ;; perfectly allowed
-    (if (re-search-forward "[]>}] [a-zA-Z0-9]"
+    (if (re-search-forward "[]>?}] [^ ]"
                           (save-excursion (end-of-line) (point))
                           t)
        (let ((text (progn