Commits

Anonymous committed b68be96

synch with speedbar-0.6.2

Comments (0)

Files changed (6)

 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.03
-AUTHOR_VERSION =  0.5.4x
+VERSION = 1.04
+AUTHOR_VERSION =  0.6.2
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = speedbar
 PKG_TYPE = regular
 ;;; sb-gud --- Speedbar support for the Grand Unified Debugger
 
-;; Copyright (C) 1997 Free Software Foundation
+;; Copyright (C) 1997, 1998 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Version: 0.1
 ;; Keywords: tools, gud
 ;; X-RCS: $Id$
 ;;
+;; This file is part of GNU Emacs.
+;;
 ;; This program 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)
 ;;; sb-info --- Speedbar support for Info
 
-;; Copyright (C) 1997 Free Software Foundation
+;; Copyright (C) 1997, 1998 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Version: 0.1
 ;; Keywords: file, tags, tools
 ;; X-RCS: $Id$
 ;;
+;; This file is part of GNU Emacs.
+;;
 ;; This program 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)
 ;;; sb-rmail --- Speedbar support for rmail
 
-;; Copyright (C) 1997 Free Software Foundation
+;; Copyright (C) 1997, 1998 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Version: 0.1
 ;; Keywords: file, tags, tools
 ;; X-RCS: $Id$
 ;;
+;; This file is part of GNU Emacs.
+;;
 ;; This program 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)
-;;; speedbar --- quick access to files and tags -*-byte-compile-warnings:nil;-*-
+;;; speedbar --- quick access to files and tags
 
-;;; Copyright (C) 1996, 97 Free Software Foundation
+;;; Copyright (C) 1996, 97, 98 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
-;; Version: 0.5.4-x
+;; Version: 0.6.2
 ;; Keywords: file, tags, tools
 ;; X-RCS: $Id$
 ;;
+;; This file is part of GNU Emacs.
+;;
 ;; This program 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)
 ;;              675 Mass Ave.
 ;;              Cambridge, MA 02139, USA.
 ;;
-;; Please send bug reports, etc. to zappo@gnu.ai.mit.edu.
+;; Please send bug reports, etc. to zappo@gnu.org
 ;;
 
 ;;; Commentary:
 ;;
-;;   To use speedbar, simply type `M-x speedbar', and it will be
-;;   autoloaded for you.  A "Speedbar" submenu will be added under
-;;   "Tools".
-;;
 ;;   The speedbar provides a frame in which files, and locations in
 ;; files are displayed.  These items can be clicked on with mouse-2
 ;; in order to make the last active frame display that file location.
 ;;
-;;   If you want to choose Speedbar from a menu, you can do something
-;; like this:
+;; Starting Speedbar:
 ;;
-;;   (add-menu-button '("Buffers")
+;;   If speedbar came to you as a part of Emacs, simply type
+;; `M-x speedbar', and it will be autoloaded for you. A "Speedbar"
+;; submenu will be added under "Tools".
+;;
+;;   If speedbar is not a part of your distribution, then add
+;; this to your .emacs file:
+;;
+;;   (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
+;;   (autoload 'speedbar-get-focus "speedbar" "Jump to speedbar frame" t)
+;;
+;;   If you want to choose it from a menu, you can do this:
+;;
+;;   Emacs:
+;;   (define-key-after (lookup-key global-map [menu-bar tools])
+;;      [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar])
+;;
+;;   XEmacs:
+;;   (add-menu-button '("Tools")
 ;;		      ["Speedbar" speedbar-frame-mode
 ;;		       :style toggle
 ;;		       :selected (and (boundp 'speedbar-frame)
 ;;				      (frame-visible-p speedbar-frame))]
 ;;		      "--")
 ;;
-;;
 ;;   If you want to access speedbar using only the keyboard, do this:
 ;;
-;;   (global-set-key [f4] 'speedbar-get-focus)
+;;   (global-set-key [(f4)] 'speedbar-get-focus)
 ;;
 ;;   This will let you hit f4 (or whatever key you choose) to jump
-;; focus to the speedbar frame.  Pressing RET or e to jump to a file
+;; focus to the speedbar frame.  Pressing it again will bring you back
+;; to the attached frame.  Pressing RET or e to jump to a file
 ;; or tag will move you back to the attached frame.  The command
 ;; `speedbar-get-focus' will also create a speedbar frame if it does
 ;; not exist.
 ;;
+;; Customizing Speedbar:
+;;
 ;;   Once a speedbar frame is active, it takes advantage of idle time
 ;; to keep its contents updated.  The contents is usually a list of
 ;; files in the directory of the currently active buffer.  When
 ;; The delay time before this happens is in
 ;; `speedbar-navigating-speed', and defaults to 10 seconds.
 ;;
-;;    Users of emacs previous to to v 19.31 (when idle timers
-;; where introduced) will not have speedbar updating automatically.
-;; Use "r" to refresh the display after changing directories.
-;; Remember, do not interrupt the stealthy updates or you display may
-;; not be completely refreshed.
+;;    Users XEmacs previous to 20 may want to change the default
+;; timeouts for `speedbar-update-speed' to something longer as XEmacs
+;; doesn't have idle timers, the speedbar timer keeps going off
+;; arbitrarily while you're typing.  It's quite pesky.
+;;
+;;    Users of really old emacsen without the needed timers will not
+;; have speedbar updating automatically.  Use "r" to refresh the
+;; display after changing directories.  Remember, do not interrupt the
+;; stealthy updates or your display may not be completely refreshed.
 ;;
 ;;    See optional file `speedbspec.el' for additional configurations
 ;; which allow speedbar to create specialized lists for special modes
 ;; that are not file-related.
 ;;
-;;    See optional file `speedbcfg.el' for interactive buffers
-;; allowing simple configuration of colors and features of speedbar.
-;;
 ;;    AUC-TEX users: The imenu tags for AUC-TEX mode don't work very
 ;; well.  Use the imenu keywords from tex-mode.el for better results.
 ;;
 ;; This file requires the library package assoc (association lists)
+;; and the package custom (for easy configuration of speedbar)
+;;     http://www.dina.kvl.dk/~abraham/custom/
+;;
+;; If you do not have custom installed, you can still get face colors
+;; by modifying the faces directly in your .emacs file, or setting
+;; them in your .Xdefaults file.
+;; Here is an example .Xdefaults for a dark background:
+;;
+;; emacs*speedbar-button-face.attributeForeground:	Aquamarine
+;; emacs*speedbar-selected-face.attributeForeground:	red
+;; emacs*speedbar-selected-face.attributeUnderline:	true
+;; emacs*speedbar-directory-face.attributeForeground:	magenta
+;; emacs*speedbar-file-face.attributeForeground:	green3
+;; emacs*speedbar-highlight-face.attributeBackground:	sea green
+;; emacs*speedbar-tag-face.attributeForeground:		yellow
 
 ;;; Speedbar updates can be found at:
 ;; ftp://ftp.ultranet.com/pub/zappo/speedbar*.tar.gz
 ;; 0.5.4 Fixed more problems for Emacs 20 so speedbar loads correctly.
 ;;       Updated some documentation strings.
 ;;       Added customization menu item, and customized some more variables.
+;; 0.5.5 Fixed so that there can be no ignored paths
+;;       Added .l & .lsp as lisp, suggested by: sshteingold@cctrading.com
+;;       You can now adjust height in `speedbar-frame-parameters'
+;;       XEmacs fix for use of `local-variable-p'
+;; 0.5.6 Folded in XEmacs suggestions from Hrvoje Niksic <hniksic@srce.hr>
+;;         Several custom changes (group definitions, trim-method & others)
+;;         Keymap changes, and ways to add menu items.
+;;         Timer use changes for XEmacs 20.4
+;;         Regular expression enhancements.
+;; 0.6   Fixed up some frame definition stuff, use more convenience fns.
+;;       Rehashed frame creation code for better compatibility.
+;;       Fixed setting of kill-buffer hook.
+;;       Default speedbar has no menubar, mouse-3 is popup menu,
+;;       XEmacs double-click capability (Hrvoje Niksic <hniksic@srce.hr>)
+;;       General documentation fixup.
+;; 0.6.1 Fixed button-3 menu for Emacs 20.
+;; 0.6.2 Added autoload tag to `speedbar-get-focus'
 
 ;;; TODO:
 ;; - More functions to create buttons and options
 ;; customization stuff
 (defgroup speedbar nil
   "File and tag browser frame."
-  :group 'tools
-  :group 'tags)
+  :group 'tags
+  :group 'tools)
 
 (defgroup speedbar-faces nil
   "Faces used in speedbar."
 ;;; Code:
 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version)
   "Non-nil if we are running in the XEmacs environment.")
-
-;; compatibility
-;; #### I don't understand this.  If this aims to be compatible with
-;; XEmacs 20 (FSFmacs doesn't have char=), then I don't see the point,
-;; because `=' works with characters.  --hniksic
-;(if (fboundp 'char=)
-;    (defalias 'speedbar-char= 'char=)
-;  (defalias 'speedbar-char= '=))
+(defvar speedbar-xemacs20p (and speedbar-xemacsp (= emacs-major-version 20)))
 
 (defvar speedbar-initial-expansion-list
   '(speedbar-directory-buttons speedbar-default-directory-list)
 interruption.  See `speedbar-check-vc' as a good example.")
 
 (defcustom speedbar-mode-specific-contents-flag t
-  "*Non-nil means speedbar will show special-mode contents.
+  "*Non-nil means speedbar will show special mode contents.
 This permits some modes to create customized contents for the speedbar
 frame."
   :group 'speedbar
   :group 'speedbar
   :type 'boolean)
 
-;; XEmacs: setting this to 1 is two obtrusive in our implementation.
-(defcustom speedbar-update-speed 2
+(defcustom speedbar-update-speed
+  (if speedbar-xemacsp
+      (if speedbar-xemacs20p
+	  2				; 1 is too obrusive in XEmacs
+	5)				; when no idleness, need long delay
+    1)
   "*Idle time in seconds needed before speedbar will update itself.
 Updates occur to allow speedbar to display directory information
 relevant to the buffer you are currently editing."
   :group 'speedbar
   :type 'integer)
 
-;; I won't enable the code to support the old variable, because there
-;; have simply been too many changes.
-;(and (boundp 'speedbar-frame-parameters)
-;     (not (boundp 'speedbar-frame-plist))
-;     ;; #### Should use custom instead of setq.
-;     (setq speedbar-frame-plist
-;	   (alist-to-plist speedbar-frame-parameters)))
+(defcustom speedbar-frame-parameters '((minibuffer . nil)
+				       (width . 20)
+				       (scroll-bar-width . 10)
+				       (border-width . 0)
+				       (menu-bar-lines . 0)
+				       (unsplittable . t))
+  "*Parameters to use when creating the speedbar frame in Emacs.
+Parameters not listed here which will be added automatically are
+`height' which will be initialized to the height of the frame speedbar
+is attached to."
+  :group 'speedbar
+  :type '(repeat (sexp :tag "Parameter:")))
 
+;; These values by Hrvoje Niksic <hniksic@srce.hr>
 (defcustom speedbar-frame-plist
   '(minibuffer nil width 20 border-width 0
-    internal-border-width 0 unsplittable t
-    default-toolbar-visible-p nil has-modeline-p nil
-    ;; I don't see the particular value of these three, but...
-    text-pointer-glyph [cursor-font :data "top_left_arrow"]
-    nontext-pointer-glyph [cursor-font :data "top_left_arrow"]
-    selection-pointer-glyph [cursor-font :data "hand2"])
-  "*Parameters to use when creating the speedbar frame.
+	       internal-border-width 0 unsplittable t
+	       default-toolbar-visible-p nil has-modeline-p nil
+	       menubar-visible-p nil
+	       ;; I don't see the particular value of these three, but...
+	       text-pointer-glyph [cursor-font :data "top_left_arrow"]
+	       nontext-pointer-glyph [cursor-font :data "top_left_arrow"]
+	       selection-pointer-glyph [cursor-font :data "hand2"])
+  "*Parameters to use when creating the speedbar frame in XEmacs.
 Parameters not listed here which will be added automatically are
 `height' which will be initialized to the height of the frame speedbar
 is attached to."
 
 (defcustom speedbar-use-imenu-flag (stringp (locate-library "imenu"))
   "*Non-nil means use imenu for file parsing.  nil to use etags.
-Etags support is not as robust as imenu support."
-  :tag "Use Imenu"
+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."
+  :tag "User Imenu"
   :group 'speedbar
   :type 'boolean)
 
 directory for a file in the attached frame.  When smart expansion is
 enabled, new directories which are children of a displayed directory
 are expanded in the current framework.  If nil, then the current
-heirarchy would be replaced with the new directory."
+hierarchy would be replaced with the new directory."
   :group 'speedbar
   :type 'boolean)
 
 
 (defcustom speedbar-vc-path-enable-hook nil
   "*Return non-nil if the current path should be checked for Version Control.
-Functions in this hook must accept one paramter which is the path
+Functions in this hook must accept one parameter which is the path
 being checked."
   :group 'speedbar-vc
   :type 'hook)
 
 (defcustom speedbar-vc-in-control-hook nil
   "*Return non-nil if the specified file is under Version Control.
-Functions in this hook must accept two paramters.  The PATH of the
+Functions in this hook must accept two parameters.  The PATH of the
 current file, and the FILENAME of the file being checked."
   :group 'speedbar-vc
   :type 'hook)
 	    (if regex1 (concat "\\(\\.\\(" regex1 "\\)\\)") "")
 	    (if (and regex1 regex2) "\\|" "")
 	    (if regex2 (concat "\\(" regex2 "\\)") "")
-	    "\\)\\'")))
+	    "\\)$")))
+
+(defvar speedbar-ignored-path-regexp nil
+  "Regular expression matching paths speedbar will not switch to.
+Created from `speedbar-ignored-path-expressions' with the function
+`speedbar-extension-list-to-regex' (A misnamed function in this case.)
+Use the function `speedbar-add-ignored-path-regexp', or customize the
+variable `speedbar-ignored-path-expressions' to modify this variable.")
 
 (defcustom speedbar-ignored-path-expressions
   '("/logs?/\\'")
       (setq nstr (concat nstr (regexp-quote (car noext)) "\\'"
 			 (if (cdr noext) "\\|" ""))
 	    noext (cdr noext)))
-    (concat nstr "\\|#[^#]+#\\'\\|\\.\\.?\\'"))
+    (concat nstr "\\|#[^#]+#$\\|\\.\\.?\\'"))
   "*Regexp matching files we don't want displayed in a speedbar buffer.
 It is generated from the variable `completion-ignored-extensions'")
 
-(defvar speedbar-ignored-path-regexp nil
-  "Regular expression matching paths speedbar will not switch to.
-Created from `speedbar-ignored-path-expressions' with the function
-`speedbar-extension-list-to-regex' (A misnamed function in this case.)
-Use the function `speedbar-add-ignored-path-regexp' to modify this
-variable.")
-
-;; XEmacs: this is dangerous to customize, because we may well want to
-;; change the defaults in the future.
+;; this is dangerous to customize, because the defaults will probably
+;; change in the future.
 (defcustom speedbar-supported-extension-expressions
   (append '(".[CcHh]\\(\\+\\+\\|pp\\|c\\|h\\)?" ".tex\\(i\\(nfo\\)?\\)?"
-	    ".el" ".emacs" ".p" ".java")
+	    ".el" ".emacs" ".l" ".lsp" ".p" ".java")
 	  (if speedbar-use-imenu-flag
 	      '(".f90" ".ada" ".pl" ".tcl" ".m"
 		"Makefile\\(\\.in\\)?")))
 (defvar speedbar-key-map nil
   "Keymap used in speedbar buffer.")
 
-;(autoload 'speedbar-configure-options "speedbcfg" "Configure speedbar variables" t)
-;(autoload 'speedbar-configure-faces "speedbcfg" "Configure speedbar faces" t)
-
 (if speedbar-key-map
     nil
   (setq speedbar-key-map (make-keymap))
   (define-key speedbar-key-map "D" 'speedbar-item-delete)
   (define-key speedbar-key-map "R" 'speedbar-item-rename)
 
-  (if (string-match "XEmacs" emacs-version)
+  (if speedbar-xemacsp
       (progn
-	;; bind mouse bindings so we can manipulate the items on each line
+	;; mouse bindings so we can manipulate the items on each line
 	(define-key speedbar-key-map 'button2 'speedbar-click)
-	;; I hate myself for this unholy binding.
-	(define-key speedbar-key-map 'button1 'speedbar-click)
 	(define-key speedbar-key-map '(shift button2) 'speedbar-power-click)
-	(define-key speedbar-key-map '(meta button3) 'speedbar-mouse-item-info)
-	(define-key speedbar-key-map 'button3 'speedbar-popup-kludge))
-    ;; bind mouse bindings so we can manipulate the items on each line
+	(define-key speedbar-key-map 'button3 'speedbar-xemacs-popup-kludge)
+	(define-key speedbar-key-map '(meta button3) 'speedbar-mouse-item-info))
+    ;; mouse bindings so we can manipulate the items on each line
     (define-key speedbar-key-map [down-mouse-1] 'speedbar-double-click)
     (define-key speedbar-key-map [mouse-2] 'speedbar-click)
-    ;; This is the power click for poping up new frames
+    ;; This is the power click for new frames, or refreshing a cache
     (define-key speedbar-key-map [S-mouse-2] 'speedbar-power-click)
     ;; This adds a small unecessary visual effect
     ;;(define-key speedbar-key-map [down-mouse-2] 'speedbar-quick-mouse)
     (define-key speedbar-key-map [M-mouse-2] 'speedbar-mouse-item-info)
 
+    (define-key speedbar-key-map [down-mouse-3] 'speedbar-emacs-popup-kludge)
+
+    ;;***** Disable disabling: Remove menubar completely.
     ;; disable all menus - we don't have a lot of space to play with
     ;; in such a skinny frame.  This will cleverly find and nuke some
     ;; user-defined menus as well if they are there.  Too bad it
     ;; rely's on the structure of a keymap to work.
-    (let ((k (lookup-key global-map [menu-bar])))
-      (while k
-	(if (and (listp (car k)) (listp (cdr (car k))))
-	    (define-key speedbar-key-map (vector 'menu-bar (car (car k)))
-	      'undefined))
-	(setq k (cdr k))))
+;    (let ((k (lookup-key global-map [menu-bar])))
+;      (while k
+;        (if (and (listp (car k)) (listp (cdr (car k))))
+;	    (define-key speedbar-key-map (vector 'menu-bar (car (car k)))
+;	      'undefined))
+;	(setq k (cdr k))))
 
     ;; This lets the user scroll as if we had a scrollbar... well maybe not
     (define-key speedbar-key-map [mode-line mouse-2] 'speedbar-mouse-hscroll)
 
 ;;; Mode definitions/ user commands
 ;;
+
 ;;;###autoload
 (defalias 'speedbar 'speedbar-frame-mode)
 ;;;###autoload
 `speedbar-before-popup-hook' is called before popping up the speedbar frame.
 `speedbar-before-delete-hook' is called before the frame is deleted."
   (interactive "P")
-  (or (console-on-window-system-p)
+  (if (if (and speedbar-xemacsp (fboundp 'console-on-window-system-p))
+	  (not (console-on-window-system-p))
+	(not (symbol-value 'window-system)))
       (error "Speedbar is not useful outside of a windowing environment"))
-  ;; XEmacs: add entry to menubar.
-  (add-menu-button '("Buffers")
-		   ["Speedbar" speedbar-frame-mode
-		    :style toggle
-		    :selected (and (boundp 'speedbar-frame)
-				   (frame-live-p speedbar-frame)
-				   (frame-visible-p speedbar-frame))]
-		   "--")
+  (if speedbar-xemacsp
+      (add-menu-button '("Tools")
+		       ["Speedbar" speedbar-frame-mode
+			:style toggle
+			:selected (and (boundp 'speedbar-frame)
+				       (frame-live-p speedbar-frame)
+				       (frame-visible-p speedbar-frame))]
+		       "--")
+    (define-key-after (lookup-key global-map [menu-bar tools])
+      [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar]))
   ;; toggle frame on and off.
   (if (not arg) (if (and (frame-live-p speedbar-frame)
 			 (frame-visible-p speedbar-frame))
   (if (and (numberp arg) (< arg 0))
       (progn
 	(run-hooks 'speedbar-before-delete-hook)
-	;; XEmacs: I am not sure this frame caching is needed at all,
-	;; because frame creation is pretty fast in XEmacs.  -hniksic
-	(when (and speedbar-frame (frame-live-p speedbar-frame))
-	  (setq speedbar-cached-frame speedbar-frame)
-	  (make-frame-invisible speedbar-frame))
+	(if (and speedbar-frame (frame-live-p speedbar-frame))
+	    (progn
+	      (setq speedbar-cached-frame speedbar-frame)
+	      (make-frame-invisible speedbar-frame)))
 	(setq speedbar-frame nil)
 	(speedbar-set-timer nil)
 	;; Used to delete the buffer.  This has the annoying affect of
     (if (frame-live-p speedbar-cached-frame)
 	(progn
 	  (setq speedbar-frame speedbar-cached-frame)
-	  ;; Choose the width
-	  (set-frame-height speedbar-frame (speedbar-needed-height))
 	  (make-frame-visible speedbar-frame)
 	  ;; Get the buffer to play with
 	  (speedbar-mode)
 	  )
       (if (frame-live-p speedbar-frame)
 	  (raise-frame speedbar-frame)
-	;; XEmacs: use plist.  Which is where we handle the pointer
-	;; shapes, too.
 	(setq speedbar-frame
-	      (make-frame (nconc (list 'height
-				       (speedbar-needed-height))
-				 speedbar-frame-plist)))
+	      (if speedbar-xemacsp
+		  (make-frame (nconc (list 'height
+					   (speedbar-needed-height))
+				     speedbar-frame-plist))
+		(let* ((mh (cdr (assoc 'menu-bar-lines (frame-parameters))))
+		       (params (append speedbar-frame-parameters
+				       (list (cons
+					      'height
+					      (if speedbar-xemacsp
+						  (speedbar-needed-height)
+						(+ mh (frame-height))))))))
+		  (if (< emacs-major-version 20);;a bug is fixed in v20 & later
+		      (make-frame params)
+		    (let ((x-pointer-shape x-pointer-top-left-arrow)
+			  (x-sensitive-text-pointer-shape x-pointer-hand2))
+		      (make-frame params))))))
 	;; reset the selection variable
 	(setq speedbar-last-selected-file nil)
 	;; Put the buffer into the frame
 	  (set-window-dedicated-p (selected-window) t))
 	(speedbar-set-timer speedbar-update-speed)))))
 
+;;;###autoload
+(defun speedbar-get-focus ()
+  "Change frame focus to or from the speedbar frame.
+If the selected frame is not speedbar, then speedbar frame is
+selected.  If the speedbar frame is active, then select the attached frame."
+  (interactive)
+  (if (eq (selected-frame) speedbar-frame)
+      (if (frame-live-p speedbar-attached-frame)
+	  (select-frame speedbar-attached-frame))
+    ;; make sure we have a frame
+    (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1))
+    ;; go there
+    (select-frame speedbar-frame))
+  (other-frame 0))
+
 (defun speedbar-close-frame ()
   "Turn off a currently active speedbar."
   (interactive)
   (select-frame speedbar-attached-frame)
   (other-frame 0))
 
-(defun speedbar-frame-width ()
+(defmacro speedbar-frame-width ()
   "Return the width of the speedbar frame in characters.
 nil if it doesn't exist."
-  (and speedbar-frame (frame-property speedbar-frame 'width)))
+  '(frame-width speedbar-frame))
 
+;; XEmacs function only.
 (defun speedbar-needed-height (&optional frame)
-  "The needed height for the toolbar frame (in characters)."
+  "The needed height for the tool bar FRAME (in characters)."
   (or frame (setq frame (selected-frame)))
-  (/ (frame-pixel-height frame)
-     (face-height 'default frame)))
+  ;; The 1 is the missing modeline/minibuffer
+  (+ 1 (/ (frame-pixel-height frame)
+	  (face-height 'default frame))))
 
 (defun speedbar-mode ()
   "Major mode for managing a display of directories and tags.
 
 \\{speedbar-key-map}"
   ;; NOT interactive
-  (save-current-buffer
+  (save-excursion
     (setq speedbar-buffer (set-buffer (get-buffer-create " SPEEDBAR")))
     (kill-all-local-variables)
     (setq major-mode 'speedbar-mode)
 	  (setq default-minibuffer-frame speedbar-attached-frame)))
     (make-local-variable 'temp-buffer-show-function)
     (setq temp-buffer-show-function 'speedbar-temp-buffer-show-function)
+    (if speedbar-xemacsp
+	(progn
+	  ;; Argh!  mouse-track-click-hook doesn't understand the
+	  ;; make-local-hook conventions.
+	  (make-local-variable 'mouse-track-click-hook)
+	  (add-hook 'mouse-track-click-hook
+		    (lambda (event count)
+		      (if (/= (event-button event) 1)
+			  nil		; Do normal operations.
+			(cond ((eq count 1)
+			       (speedbar-quick-mouse event))
+			      ((or (eq count 2)
+				   (eq count 3))
+			       (mouse-set-point event)
+			       (speedbar-do-function-pointer)
+			       (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
-			     (if (eq (current-buffer)
-				     speedbar-buffer)
-				 (speedbar-frame-mode -1)))))
-	      nil t)
-    (when (specifier-instance has-modeline-p)
-      (speedbar-set-mode-line-format))
+    (add-hook 'kill-buffer-hook (lambda () (let ((skilling (boundp 'skilling)))
+					     (if skilling
+						 nil
+					       (if (eq (current-buffer)
+						       speedbar-buffer)
+						   (speedbar-frame-mode -1)))))
+	      t t)
+    (speedbar-set-mode-line-format)
     (if (not speedbar-xemacsp)
 	(setq auto-show-mode nil))	;no auto-show for Emacs
     (run-hooks 'speedbar-mode-hook))
   "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 (frame-live-p speedbar-frame)
+  (if (and (frame-live-p speedbar-frame)
+	   (or (not speedbar-xemacsp)
+	       (specifier-instance has-modeline-p)))
       (save-excursion
 	(set-buffer speedbar-buffer)
 	(let* ((w (or (speedbar-frame-width) 20))
   "Reconfigure the menu-bar in a speedbar frame.
 Different menu items are displayed depending on the current display mode
 and the existence of packages."
-  (let ((cf (selected-frame))
-	(md (append speedbar-easymenu-definition-base
+  (let ((md (append speedbar-easymenu-definition-base
 		    (if speedbar-shown-directories
 			;; file display mode version
 			speedbar-easymenu-definition-special
 	(save-excursion
 	  (set-buffer speedbar-buffer)
 	  ;; For the benefit of button3
-	  (unless (assoc "Speedbar" mode-popup-menu)
-	    (easy-menu-add md))
-	  (set-buffer-menubar (list md))))))
+	  (if (and (not (assoc "Speedbar" mode-popup-menu)))
+	      (easy-menu-add md))
+	  (set-buffer-menubar (list md)))
+      (easy-menu-add md))))
 
 
 ;;; User Input stuff
 ;; XEmacs: this can be implemented using modeline keymaps, but there
 ;; is no use, as we have horizontal scrollbar (as the docstring
 ;; hints.)
-;(defun speedbar-mouse-hscroll (e)
-;  "Read a mouse event E from the mode line, and horizontally scroll.
-;If the mouse is being clicked on the far left, or far right of the
-;mode-line.  This is only useful for non-XEmacs"
-;  (interactive "e")
-;  (let* ((xp (car (nth 2 (car (cdr e)))))
-;	 (cpw (/ (frame-pixel-width)
-;		 (frame-width)))
-;	 (oc (1+ (/ xp cpw)))
-;	 )
-;    (cond ((< oc 3)
-;	   (scroll-left 2))
-;	  ((> oc (- (window-width) 3))
-;	   (scroll-right 2))
-;	  (t (message "Click on the edge of the modeline to scroll left/right")))
-;    ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
-;    ))
+(defun speedbar-mouse-hscroll (e)
+  "Read a mouse event E from the mode line, and horizontally scroll.
+If the mouse is being clicked on the far left, or far right of the
+mode-line.  This is only useful for non-XEmacs"
+  (interactive "e")
+  (let* ((xp (car (nth 2 (car (cdr e)))))
+	 (cpw (/ (frame-pixel-width)
+		 (frame-width)))
+	 (oc (1+ (/ xp cpw)))
+	 )
+    (cond ((< oc 3)
+	   (scroll-left 2))
+	  ((> oc (- (window-width) 3))
+	   (scroll-right 2))
+	  (t (message "Click on the edge of the modeline to scroll left/right")))
+    ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
+    ))
 
 (defun speedbar-customize ()
   "Customize speedbar using the Custom package."
     (select-frame sf))
   (speedbar-maybee-jump-to-attached-frame))
 
-(defun speedbar-get-focus ()
-  "Change frame focus to or from the speedbar frame.
-If the selected frame is not speedbar, then speedbar frame is
-selected.  If the speedbar frame is active, then select the attached frame."
-  (interactive)
-  (if (eq (selected-frame) speedbar-frame)
-      (if (frame-live-p speedbar-attached-frame)
-	  (select-frame speedbar-attached-frame))
-    ;; make sure we have a frame
-    (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1))
-    ;; go there
-    (select-frame speedbar-frame))
-  (other-frame 0))
-
 ;; In XEmacs, we make popup menus work on the item over mouse (as
 ;; opposed to where the point happens to be.)  We attain this by
 ;; temporarily moving the point to that place.
-(defun speedbar-popup-kludge (event)
+;;    Hrvoje Niksic <hniksic@srce.hr>
+(defun speedbar-xemacs-popup-kludge (event)
+  "Pop up a menu related to the clicked on item.
+Must be bound to EVENT."
   (interactive "e")
   (save-excursion
     (goto-char (event-closest-point event))
     (beginning-of-line)
-    (forward-char (min 5 (- (point-at-eol)
-			    (point-at-bol))))
+    (forward-char (min 5 (- (save-excursion (end-of-line) (point))
+			    (save-excursion (beginning-of-line) (point)))))
     (popup-mode-menu)
     ;; Wait for menu to bail out.  `popup-mode-menu' (and other popup
     ;; menu functions) return immediately.
 	(dispatch-event new))
       (dispatch-event new))))
 
+(defun speedbar-emacs-popup-kludge (e)
+  "Pop up a menu related to the clicked on item.
+Must be bound to event E."
+  (interactive "e")
+  (save-excursion
+    (mouse-set-point e)
+    ;; This gets the cursor where the user can see it.
+    (if (not (bolp)) (forward-char -1))
+    (sit-for 0)
+    (if (< emacs-major-version 20)
+	(mouse-major-mode-menu e)
+      (mouse-major-mode-menu e nil))))
+
 (defun speedbar-next (arg)
   "Move to the next ARGth line in a speedbar buffer."
   (interactive "p")
 	(if (file-directory-p rt)
 	    (setq rt
 		  (concat (expand-file-name rt)
-			  (if (string-match "/\\'" rt) "" "/")
+			  (if (string-match "/$" rt) "" "/")
 			  (file-name-nondirectory f))))
 	(if (or (not (file-exists-p rt))
 		(y-or-n-p (format "Overwrite %s with %s? " rt f)))
 	(progn (delete-itimer speedbar-timer)
 	       (setq speedbar-timer nil)))
     (if timeout
-	(setq speedbar-timer (start-itimer "speedbar"
-					   'speedbar-timer-fn
-					   timeout
-					   timeout
-					   t))))
+	(if (and speedbar-xemacsp
+		 (or (>= emacs-major-version 20)
+		     (>= emacs-minor-version 15)))
+	    (setq speedbar-timer (start-itimer "speedbar"
+					       'speedbar-timer-fn
+					       timeout
+					       timeout
+					       t))
+	  (setq speedbar-timer (start-itimer "speedbar"
+					     'speedbar-timer-fn
+					     timeout
+					     nil)))))
    ;; Post 19.31 Emacs
    ((fboundp 'run-with-idle-timer)
     (if speedbar-timer
 	       (setq speedbar-timer nil)))
     (if timeout
 	(setq speedbar-timer
-	      (run-with-idle-timer timeout nil 'speedbar-timer-fn))))
+	      (run-with-idle-timer timeout t 'speedbar-timer-fn))))
    ;; Emacs 19.30 (Thanks twice: ptype@dra.hmg.gb)
    ((fboundp 'post-command-idle-hook)
     (if timeout
 	(add-hook 'post-command-idle-hook 'speedbar-timer-fn)
       (remove-hook 'post-command-idle-hook 'speedbar-timer-fn)))
-   ;; Older or other Emacsen with no timers.  Set up so that it's
+   ;; Older or other Emacsen with no timers.  Set up so that its
    ;; obvious this emacs can't handle the updates
    (t
     (setq speedbar-update-flag nil)))
   (speedbar-set-mode-line-format))
 
 (defmacro speedbar-with-writable (&rest forms)
-  "Allow the buffer to be writable and evaluate FORMS.
-Turn read only back on when done."
-  ;; XEmacs: the original implementation used `toggle-read-only'.  I
-  ;; may be missing something obvious here, but IMHO this should
-  ;; suffice:
-  `(let ((inhibit-read-only t))
-     ,@forms))
+  "Allow the buffer to be writable and evaluate FORMS."
+  (list 'let '((inhibit-read-only t))
+	'(toggle-read-only -1)
+	(cons 'progn forms)))
 (put 'speedbar-with-writable 'lisp-indent-function 0)
 
 (defun speedbar-select-window (buffer)
 			(concat "~" (substring dd (match-end 0)))
 		      dd))
 	 (p (point)))
-    (if (string-match "\\`~/?\\'" displayme) (setq displayme (concat tilde "/")))
+    (if (string-match "^~/?\\'" displayme) (setq displayme (concat tilde "/")))
     (insert displayme)
     (save-excursion
       (goto-char p)
 	   (local-variable-p
 	    'speedbar-special-mode-expansion-list
 	    (current-buffer)))
-	   ;(eq (get major-mode 'mode-class 'special)))
+      ;;(eq (get major-mode 'mode-class 'special)))
       (speedbar-update-special-contents)
     (speedbar-update-directory-contents)))
 
   (if (not (and (frame-live-p speedbar-frame)
 		(frame-live-p speedbar-attached-frame)))
       (speedbar-set-timer nil)
-    ;; Reset our timer
-    ;; XEmacs: this breaks itimers.  Use the RESTART argument to
-    ;; start-itimer instead.
-    (or (fboundp 'start-itimer)
-	(speedbar-set-timer speedbar-update-speed))
     ;; Save all the match data so that we don't mess up executing fns
     (save-match-data
       (if (and (frame-visible-p speedbar-frame) speedbar-update-flag)
 		;; Update all the contents if directories change!
 		(if (or (member (expand-file-name default-directory)
 				speedbar-shown-directories)
-			(string-match speedbar-ignored-path-regexp
-				      (expand-file-name default-directory))
+			(and speedbar-ignored-path-regexp
+			     (string-match
+			      speedbar-ignored-path-regexp
+			      (expand-file-name default-directory)))
 			(member major-mode speedbar-ignored-modes)
 			(eq af speedbar-frame)
 			(not (buffer-file-name)))
   )
 
 (defun speedbar-clear-current-file ()
-  "Locate the file thought to be current, and unhighlight it."
+  "Locate the file thought to be current, and remove its highlighting."
   (save-excursion
     (set-buffer speedbar-buffer)
     (if speedbar-last-selected-file
 	 (sucf-recursive (boundp 'sucf-recursive)))
     (if (and newcf
 	     ;; check here, that way we won't refresh to newcf until
-	     ;; it's been written, thus saving ourselves some time
+	     ;; its been written, thus saving ourselves some time
 	     (file-exists-p newcf)
 	     (not (string= newcf speedbar-last-selected-file)))
 	(progn
    ;; RCS file name
    (file-exists-p (concat path "RCS/" name ",v"))
    ;; Local SCCS file name
-   (file-exists-p (concat path "SCCS/p." fn))
+   (file-exists-p (concat path "SCCS/p." name))
    ;; Remote SCCS file name
    (let ((proj-dir (getenv "PROJECTDIR")))
      (if proj-dir
-         (file-exists-p (concat proj-dir "/SCCS/p." fn))
+         (file-exists-p (concat proj-dir "/SCCS/p." name))
        nil))
    ;; User extension
    (run-hook-with-args 'speedbar-vc-in-control-hook path name)
 with a mouse face that has a text property called `speedbar-function'.
 This should be bound to mouse event E."
   (interactive "e")
-  ;; Emacs only.  Modify this to handle XEmacs eccentricities
+  ;; Emacs only.  XEmacs handles this via `mouse-track-click-hook'.
   (cond ((eq (car e) 'down-mouse-1)
 	 (mouse-set-point e))
 	((eq (car e) 'mouse-1)
       (error t))))
 )
 
-;;; Tag Management -- etags  (XEmacs compatibility part)
+;;; Tag Management -- etags  (old XEmacs compatibility part)
 ;;
 (defvar speedbar-fetch-etags-parse-list
   '(;; Note that java has the same parse-group as c
-    ("\\.\\([cChH]\\|c\\+\\+\\|cpp\\|cc\\|hh\\|java\\)\\'" . speedbar-parse-c-or-c++tag)
-    ("\\.el\\|\\.emacs" . "defun\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?")
+    ("\\.\\([cChH]\\|c\\+\\+\\|cpp\\|cc\\|hh\\|java\\)\\'" .
+     speedbar-parse-c-or-c++tag)
+    ("^\\.emacs$\\|.\\(el\\|l\\|lsp\\)\\'" .
+     "def[^i]+\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?")
     ("\\.tex\\'" . speedbar-parse-tex-string)
-    ("\\.p" .
+    ("\\.p\\'" .
      "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?")
-
     )
   "Associations of file extensions and expressions for extracting tags.
 To add a new file type, you would want to add a new association to the
 use a function symbol instead of regexp.  The function should expect
 to be at the beginning of a line in the etags buffer.
 
-This variable is ignored if `speedbar-use-imenu-flag' is t")
+This variable is ignored if `speedbar-use-imenu-flag' is non-nil.")
 
 (defvar speedbar-fetch-etags-command "etags"
   "*Command used to create an etags file.
 ;;; speedbspec --- Buffer specialized configurations for speedbar
 
-;; Copyright (C) 1997 Free Software Foundation
+;; Copyright (C) 1997, 1998 Free Software Foundation
 ;;
 ;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
 ;; Version: 0.2
 ;; Keywords: file, tags, tools
 ;; X-RCS: $Id$
 ;;
+;; This file is part of GNU Emacs.
+;;
 ;; This program 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)
 ;;          Made the functions to turn on/off speedbar support interactive.
 ;;             It is *not* a minor-mode, it mearly enables special speedbar
 ;;             behaviors.
+;;  0.2.1 - Fix for emacs 20 when checking for autoload functions.
 
 ;;; Code:
 (require 'speedbar)
 	      nil ;; do nothing to broken mode
 	    (setq ms (substring ms 0 (match-beginning 0)))
 	    (setq v (intern-soft (concat ms "-speedbar-buttons")))
-	    ;; If it is autoloaded, we need to load it now so that
-	    ;; we have access to the varialbe -speedbar-menu-items.
-	    ;; Is this XEmacs safe?
 	    (if (not v)
 		nil ;; do nothing if not defined
+	      ;; If it is autoloaded, we need to load it now so that
+	      ;; we have access to the varialbe -speedbar-menu-items.
+	      ;; Is this XEmacs safe?
 	      (let ((sf (symbol-function v)))
-		(if (eq (car sf) 'autoload)
+		(if (and (listp sf) (eq (car sf) 'autoload))
 		    (load-library (car (cdr sf)))))
 	      (set (make-local-variable 'speedbar-special-mode-expansion-list)
 		   (list v))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.