Source

ecb / ecb-speedbar.el

Diff from to

File ecb-speedbar.el

 ;; imenu
 (silentcomp-defvar imenu--rescan-item)
 (silentcomp-defvar imenu--index-alist)
+;; XEmacs
+(silentcomp-defun event-button)
+(silentcomp-defvar mouse-motion-handler)
 
+(defgroup ecb-speedbar nil
+  "Settings for the speedbar-integration of ECB."
+  :group 'ecb-general
+  :prefix "ecb-")
+
+(defcustom ecb-speedbar-before-activate-hook nil
+  "*Hook running directly before ECB activates the integrated speedbar.
+
+For example this hook can be used to change the expansion-mode of the
+integrated speedbar via `speedbar-change-initial-expansion-list'.
+Example: \(speedbar-change-initial-expansion-list \"buffers\")."
+  :group 'ecb-speedbar
+  :type 'hook)
 
 (defconst ecb-speedbar-adviced-functions '((speedbar-click . around)
                                            (speedbar-frame-mode . around)
 adviced with more than one class \(e.g. with a before and an after-advice)
 then for every class a cons must be added to this list.")
 
+(defconst ecb-speedbar-buffer-name " SPEEDBAR"
+  "Name of the ECB speedbar buffer.")
+
+(defun ecb-speedbar-buffer-selected ()
+  (equal (current-buffer) (get-buffer ecb-speedbar-buffer-name)))
+
 (defadvice speedbar-click (around ecb)
   "Makes the function compatible with ECB. If ECB is active and the window of
 `ecb-speedbar-buffer-name' is visible \(means a layouts uses the
 is not speedbar-window, then the speedbar-window is selected. If the
 speedbar-window is active, then select the edit-window."
   (if ecb-minor-mode
-      (if (equal (current-buffer) (get-buffer ecb-speedbar-buffer-name))
+      (if (ecb-speedbar-buffer-selected)
           (ecb-select-edit-window)
         (ecb-speedbar-select-speedbar-window))
     ad-do-it))
     (mouse-set-point e)))
   
 
-(defconst ecb-speedbar-buffer-name " SPEEDBAR"
-  "Name of the ECB speedbar buffer.")
-
 (defun ecb-speedbar-select-speedbar-window ()
   (ignore-errors
     (and (window-live-p (get-buffer-window ecb-speedbar-buffer-name))
   ;; enable the advices for speedbar
   (ecb-enable-advices ecb-speedbar-adviced-functions)
   
+  (run-hooks 'ecb-speedbar-before-activate-hook)
+
   ;;disable automatic speedbar updates... let the ECB handle this with
   ;;ecb-current-buffer-sync
   (speedbar-disable-update)
     (save-excursion
       (setq speedbar-buffer (get-buffer-create ecb-speedbar-buffer-name))
       (set-buffer speedbar-buffer)
-      (speedbar-mode)))
+      (speedbar-mode)
+
+      (if ecb-running-xemacs
+          ;; Hack the XEmacs mouse-motion handler
+          (progn
+            ;; Hack the XEmacs mouse-motion handler
+            (set (make-local-variable 'mouse-motion-handler)
+                 'dframe-track-mouse-xemacs)
+            ;; Hack the double click handler
+            (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)
+                                 (dframe-quick-mouse event))
+                                ((or (eq count 2)
+                                     (eq count 3))
+                                 (dframe-click event)))
+                          ;; Don't do normal operations.
+                          t))))
+        ;; Enable mouse tracking in emacs
+        (if dframe-track-mouse-function
+            (set (make-local-variable 'track-mouse) t)) ;this could be messy.
+        ;; disable auto-show-mode for Emacs
+        (setq auto-show-mode nil))))
 
   ;;Start up the timer
   (speedbar-reconfigure-keymaps)
              (set-buffer visible-buffer)
              (ecb-fix-filename default-directory)))
           (ecb-default-directory (ecb-fix-filename default-directory)))
-      (when (and (not (string-equal speedbar-default-directory
-                                    ecb-default-directory))
+      (when (and (or (not (string-equal speedbar-default-directory
+                                        ecb-default-directory))
+                     (string= speedbar-initial-expansion-list-name "buffers"))
                  speedbar-buffer
                  (buffer-live-p speedbar-buffer))
         (ecb-speedbar-update-contents)))))
                                               (intern (car tag))))
              (ecb--semantic--tag-set-overlay new-tag (make-vector 2 (cdr tag)))
              (ecb--semantic--tag-put-property new-tag 'ecb-speedbar-tag t)
-             (tree-node-new (progn
-                              (set-text-properties
-                               0 (length (car tag))
-                               `(face ,ecb-method-non-semantic-face) (car tag))
-                              (car tag))
-                            0
-                            new-tag
-                            t
-                            node))
+             (ecb-apply-user-filter-to-tags (list new-tag))
+             (when (not (ecb-tag-forbidden-display-p new-tag))
+               (tree-node-new (progn
+                                (set-text-properties
+                                 0 (length (car tag))
+                                 `(face ,ecb-method-non-semantic-face) (car tag))
+                                (car tag))
+                              0
+                              new-tag
+                              t
+                              node)))
             ((speedbar-generic-list-positioned-group-p tag)
              ;; the semantic tag for this tag
              (setq new-tag (ecb--semantic-tag (car tag)
                                               (intern (car tag))))
              (ecb--semantic--tag-set-overlay new-tag
-                                            (make-vector 2 (car (cdr tag))))
+                                             (make-vector 2 (car (cdr tag))))
              (ecb--semantic--tag-put-property new-tag 'ecb-speedbar-tag t)
-             (ecb-create-non-semantic-tree
-              (setq new-node
-                    (tree-node-new (progn
-                                     (set-text-properties
-                                      0 (length (car tag))
-                                      `(face ,ecb-method-non-semantic-face) (car tag))
-                                     (car tag))
-                                   0
-                                   new-tag
-                                   nil node))
-              (cdr (cdr tag)))
-             (tree-node-set-expanded new-node
-                                     (member major-mode
-                                             ecb-non-semantic-methods-initial-expand)))
+             (ecb-apply-user-filter-to-tags (list new-tag))
+             (when (not (ecb-tag-forbidden-display-p new-tag))             
+               (ecb-create-non-semantic-tree
+                (setq new-node
+                      (tree-node-new (progn
+                                       (set-text-properties
+                                        0 (length (car tag))
+                                        `(face ,ecb-method-non-semantic-face) (car tag))
+                                       (car tag))
+                                     0
+                                     new-tag
+                                     nil node))
+                (cdr (cdr tag)))
+               (tree-node-set-expanded new-node
+                                       (member major-mode
+                                               ecb-non-semantic-methods-initial-expand))))
             ((speedbar-generic-list-group-p tag)
              (ecb-create-non-semantic-tree
               (setq new-node
 
 (silentcomp-provide 'ecb-speedbar)
 
-;;; ecb-speedbar.el ends here
+;;; ecb-speedbar.el ends here