(url-setup-privacy-info): Add docstring.
[bpt/emacs.git] / lisp / speedbar.el
index a25b7aa..a48f480 100644 (file)
@@ -4,9 +4,8 @@
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: file, tags, tools
-;; X-RCS: $Id: speedbar.el,v 1.247 2005/06/30 02:37:40 zappo Exp $
 
-(defvar speedbar-version "1.0pre3"
+(defvar speedbar-version "1.0"
   "The current version of speedbar.")
 (defvar speedbar-incompatible-version "0.14beta4"
   "This version of speedbar is incompatible with this version.
@@ -27,8 +26,8 @@ this version is not backward compatible to 0.14 or earlier.")
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 ;;
@@ -278,7 +277,9 @@ 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
@@ -297,7 +298,7 @@ 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."
@@ -330,6 +331,16 @@ display is used instead."
   :group 'speedbar
   :type 'boolean)
 
+(defcustom speedbar-default-position 'left-right
+  "*Default position of the speedbar frame.
+Possible values are 'left, 'right or 'left-right.
+If value is 'left-right, the most suitable location is
+determined automatically."
+  :group 'speedbar
+  :type '(radio (const :tag "Automatic" left-right)
+               (const :tag "Left" left)
+               (const :tag "Right" right)))
+
 (defcustom speedbar-sort-tags nil
   "*If non-nil, sort tags in the speedbar display.  *Obsolete*.
 Use `semantic-tag-hierarchy-method' instead."
@@ -761,7 +772,7 @@ This basically creates a sparse keymap, and makes it's parent be
   (define-key speedbar-file-key-map "-" 'speedbar-contract-line)
 
   (define-key speedbar-file-key-map "[" 'speedbar-expand-line-descendants)
-  (define-key speedbar-file-key-map "]" 'speedbar-close-line-descendants)
+  (define-key speedbar-file-key-map "]" 'speedbar-contract-line-descendants)
 
   (define-key speedbar-file-key-map " " 'speedbar-toggle-line-expansion)
 
@@ -966,7 +977,7 @@ supported at a time.
        (t
         (dframe-reposition-frame speedbar-frame
                                  (dframe-attached-frame speedbar-frame)
-                                 'left-right))))
+                                 speedbar-default-position))))
 
 (defun speedbar-detach ()
   "Detach the current Speedbar from auto-updating.
@@ -1105,7 +1116,8 @@ frame and window to be the currently active frame and window."
           (or (not dframe-xemacsp)
               (with-no-warnings
                 (specifier-instance has-modeline-p)))
-          speedbar-buffer)      (save-excursion
+          speedbar-buffer)
+      (save-excursion
        (set-buffer speedbar-buffer)
        (let* ((w (or (speedbar-frame-width) 20))
               (p1 "<<")
@@ -1676,9 +1688,8 @@ specialized speedbar displays."
     (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)))
+    (add-text-properties
+     start (point) '(face nil invisible nil mouse-face nil))))
 
 (defun speedbar-insert-separator (text)
   "Insert a separation label of TEXT.
@@ -1697,13 +1708,11 @@ Separators are not active, have no labels, depth, or actions."
   "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)"
-  (put-text-property start end 'face face)
-  (put-text-property start end 'mouse-face mouse)
+  (add-text-properties
+   start end `(face ,face mouse-face ,mouse invisible nil
+               speedbar-text ,(buffer-substring-no-properties start end)))
   (if speedbar-use-tool-tips-flag
       (put-text-property start end 'help-echo #'dframe-help-echo))
-  (put-text-property start end 'invisible nil)
-  (put-text-property start end 'speedbar-text
-                    (buffer-substring-no-properties start end))
   (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.
@@ -2454,10 +2463,9 @@ name will have the function FIND-FUN and not token."
        (set-buffer speedbar-buffer)
        (speedbar-with-writable
          (erase-buffer)
-         (while funclst
+         (dolist (func funclst)
            (setq default-directory cbd)
-           (funcall (car funclst) cbd 0)
-           (setq funclst (cdr funclst)))
+           (funcall func cbd 0))
        (speedbar-reconfigure-keymaps)
        (goto-char (point-min)))
        ))))
@@ -2534,10 +2542,9 @@ name will have the function FIND-FUN and not token."
                            speedbar-shown-directories))
                 (insert (cdr cache)))
                (t
-                (while funclst
-                  (setq default-directory cbd)
-                  (funcall (car funclst) cbd 0)
-                  (setq funclst (cdr funclst))))))
+         (dolist (func funclst)
+           (setq default-directory cbd)
+           (funcall func cbd 0)))))
        (goto-char (point-min)))))
   (speedbar-reconfigure-keymaps))
 
@@ -2560,11 +2567,10 @@ This should only be used by modes classified as special."
              speedbar-shown-directories nil))
       ;; Now fill in the buffer with our newly found specialized list.
       (speedbar-with-writable
-       (while funclst
-         ;; We do not erase the buffer because these functions may
-         ;; decide NOT to update themselves.
-         (funcall (car funclst) specialbuff)
-         (setq funclst (cdr funclst))))
+         (dolist (func funclst)
+           ;; We do not erase the buffer because these functions may
+           ;; decide NOT to update themselves.
+           (funcall func specialbuff)))
 
       (goto-char (point-min))))
   (speedbar-reconfigure-keymaps))
@@ -2820,12 +2826,15 @@ indicator, then do not add a space."
                      (re-search-forward "^\\([0-9]+\\):\\s-*[[<][+-\?][]>] "
                                         nil t))
            (setq speedbar-ro-to-do-point (point))
-           (if (not (file-writable-p (speedbar-line-file)))
-               (speedbar-add-indicator
-                speedbar-object-read-only-indicator
-                (regexp-quote speedbar-object-read-only-indicator))
-             (speedbar-add-indicator
-              " " (regexp-quote speedbar-object-read-only-indicator))))
+           (let ((f (speedbar-line-file)))
+             (if f
+                 (if (not (file-writable-p f))
+                     (speedbar-add-indicator
+                      speedbar-object-read-only-indicator
+                      (regexp-quote speedbar-object-read-only-indicator))
+                   (speedbar-add-indicator
+                    " " (regexp-quote
+                         speedbar-object-read-only-indicator))))))
          (if (input-pending-p)
              ;; return that we are incomplete
              nil
@@ -3151,7 +3160,7 @@ Otherwise do not move and return nil."
            nil))))))
 
 (defun speedbar-line-directory (&optional depth)
-  "Retrieve the directoryname associated with the current line.
+  "Retrieve the directory name 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-directory'."
@@ -3598,7 +3607,7 @@ functions to do caching and flushing if appropriate."
 
     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.
@@ -3818,6 +3827,7 @@ regular expression EXPR."
     ["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]+: *.[-+?]. "))]
@@ -4091,8 +4101,34 @@ TEXT is the buffer's name, TOKEN and INDENT are unused."
       )
   )
 
+\f
+;;; Obsolete variables and functions
+
+(define-obsolete-variable-alias
+  'speedbar-ignored-path-regexp 'speedbar-ignored-directory-regexp)
+
+(define-obsolete-variable-alias 'speedbar-ignored-path-expressions
+  'speedbar-ignored-directory-expressions)
+
+(define-obsolete-function-alias 'speedbar-add-ignored-path-regexp
+  'speedbar-add-ignored-directory-regexp)
+
+(define-obsolete-function-alias 'speedbar-line-path
+  'speedbar-line-directory)
+
+(define-obsolete-function-alias 'speedbar-buffers-line-path
+  'speedbar-buffers-line-directory)
+
+(define-obsolete-function-alias 'speedbar-path-line
+  'speedbar-directory-line)
+
+(define-obsolete-function-alias 'speedbar-buffers-line-path
+  'speedbar-buffers-line-directory)
+
 (provide 'speedbar)
-;;; speedbar ends here
 
 ;; run load-time hooks
 (run-hooks 'speedbar-load-hook)
+
+;; arch-tag: 4477e6d1-f78c-48b9-a503-387d3c9767d5
+;;; speedbar ends here