287 |
(defvar speedbar-special-mode-key-map nil |
(defvar speedbar-special-mode-key-map nil |
288 |
"Default keymap used when identifying a specialized display mode. |
"Default keymap used when identifying a specialized display mode. |
289 |
This keymap is local to each buffer that wants to define special keybindings |
This keymap is local to each buffer that wants to define special keybindings |
290 |
effective when it's display is shown.") |
effective when its display is shown.") |
291 |
|
|
292 |
(defcustom speedbar-visiting-file-hook nil |
(defcustom speedbar-visiting-file-hook nil |
293 |
"Hooks run when speedbar visits a file in the selected frame." |
"Hooks run when speedbar visits a file in the selected frame." |
382 |
(defvar speedbar-dynamic-tags-function-list |
(defvar speedbar-dynamic-tags-function-list |
383 |
'((speedbar-fetch-dynamic-imenu . speedbar-insert-imenu-list) |
'((speedbar-fetch-dynamic-imenu . speedbar-insert-imenu-list) |
384 |
(speedbar-fetch-dynamic-etags . speedbar-insert-etags-list)) |
(speedbar-fetch-dynamic-etags . speedbar-insert-etags-list)) |
385 |
"Set to a functions which will return and insert a list of tags. |
"Set to a list of functions which will return and insert a list of tags. |
386 |
Each element is of the form ( FETCH . INSERT ) where FETCH |
Each element is of the form ( FETCH . INSERT ) where FETCH |
387 |
is a funciotn which takes one parameter (the file to tag) and returns a |
is a function which takes one parameter (the file to tag) and returns a |
388 |
list of tags. The tag list can be of any form as long as the |
list of tags. The tag list can be of any form as long as the |
389 |
corresponding insert method can handle it. If it returns t, then an |
corresponding insert method can handle it. If it returns t, then an |
390 |
error occured, and the next fetch routine is tried. |
error occurred, and the next fetch routine is tried. |
391 |
INSERT is a function which takes an INDENTation level, and a LIST of |
INSERT is a function which takes an INDENTation level, and a LIST of |
392 |
tags to insert. It will then create the speedbar buttons.") |
tags to insert. It will then create the speedbar buttons.") |
393 |
|
|
497 |
(if (fboundp 'display-graphic-p) |
(if (fboundp 'display-graphic-p) |
498 |
(display-graphic-p) |
(display-graphic-p) |
499 |
window-system)) |
window-system)) |
500 |
"*Non nil if speedbar should display icons." |
"*Non-nil if speedbar should display icons." |
501 |
:group 'speedbar |
:group 'speedbar |
502 |
:version "21.1" |
:version "21.1" |
503 |
:type 'boolean) |
:type 'boolean) |
847 |
)) |
)) |
848 |
|
|
849 |
(defun speedbar-make-specialized-keymap () |
(defun speedbar-make-specialized-keymap () |
850 |
"Create a keymap for use w/ a speedbar major or minor display mode. |
"Create a keymap for use with a speedbar major or minor display mode. |
851 |
This basically creates a sparse keymap, and makes it's parent be |
This basically creates a sparse keymap, and makes it's parent be |
852 |
`speedbar-key-map'." |
`speedbar-key-map'." |
853 |
(let ((k (make-sparse-keymap))) |
(let ((k (make-sparse-keymap))) |
943 |
"Menu items appearing at the end of the speedbar menu.") |
"Menu items appearing at the end of the speedbar menu.") |
944 |
|
|
945 |
(defvar speedbar-desired-buffer nil |
(defvar speedbar-desired-buffer nil |
946 |
"Non-nil when speedbar is showing buttons specific a special mode. |
"Non-nil when speedbar is showing buttons specific to a special mode. |
947 |
In this case it is the originating buffer.") |
In this case it is the originating buffer.") |
948 |
(defvar speedbar-buffer nil |
(defvar speedbar-buffer nil |
949 |
"The buffer displaying the speedbar.") |
"The buffer displaying the speedbar.") |
1665 |
|
|
1666 |
(defun speedbar-up-directory () |
(defun speedbar-up-directory () |
1667 |
"Keyboard accelerator for moving the default directory up one. |
"Keyboard accelerator for moving the default directory up one. |
1668 |
Assumes that the current buffer is the speedbar buffer" |
Assumes that the current buffer is the speedbar buffer." |
1669 |
(interactive) |
(interactive) |
1670 |
(setq default-directory (expand-file-name (concat default-directory "../"))) |
(setq default-directory (expand-file-name (concat default-directory "../"))) |
1671 |
(speedbar-update-contents)) |
(speedbar-update-contents)) |
1738 |
(defun speedbar-item-info () |
(defun speedbar-item-info () |
1739 |
"Display info in the mini-buffer about the button the mouse is over. |
"Display info in the mini-buffer about the button the mouse is over. |
1740 |
This function can be replaced in `speedbar-mode-functions-list' as |
This function can be replaced in `speedbar-mode-functions-list' as |
1741 |
`speedbar-item-info'" |
`speedbar-item-info'." |
1742 |
(interactive) |
(interactive) |
1743 |
(let (message-log-max) |
(let (message-log-max) |
1744 |
(funcall (or (speedbar-fetch-replacement-function 'speedbar-item-info) |
(funcall (or (speedbar-fetch-replacement-function 'speedbar-item-info) |
1943 |
;;; Utility functions |
;;; Utility functions |
1944 |
;; |
;; |
1945 |
(defun speedbar-set-timer (timeout) |
(defun speedbar-set-timer (timeout) |
1946 |
"Apply a timer with TIMEOUT, or remove a timer if TIMOUT is nil. |
"Apply a timer with TIMEOUT, or remove a timer if TIMEOUT is nil. |
1947 |
TIMEOUT is the number of seconds until the speedbar timer is called |
TIMEOUT is the number of seconds until the speedbar timer is called |
1948 |
again. When TIMEOUT is nil, turn off all timeouts. |
again. When TIMEOUT is nil, turn off all timeouts. |
1949 |
This function will also enable or disable the `vc-checkin-hook' used |
This function will also enable or disable the `vc-checkin-hook' used |
2017 |
This function assumes that the current buffer is the speedbar buffer. |
This function assumes that the current buffer is the speedbar buffer. |
2018 |
If PREVLINE, then put this button on the previous line. |
If PREVLINE, then put this button on the previous line. |
2019 |
|
|
2020 |
This is a convenience function for special mode that create their own |
This is a convenience function for special modes that create their own |
2021 |
specialized speedbar displays." |
specialized speedbar displays." |
2022 |
(goto-char (point-max)) |
(goto-char (point-max)) |
2023 |
(let ((start (point))) |
(let ((start (point))) |
2038 |
(defun speedbar-make-button (start end face mouse function &optional token) |
(defun speedbar-make-button (start end face mouse function &optional token) |
2039 |
"Create a button from START to END, with FACE as the display face. |
"Create a button from START to END, with FACE as the display face. |
2040 |
MOUSE is the mouse face. When this button is clicked on FUNCTION |
MOUSE is the mouse face. When this button is clicked on FUNCTION |
2041 |
will be run with the TOKEN parameter (any Lisp object)" |
will be run with the TOKEN parameter (any Lisp object)." |
2042 |
(put-text-property start end 'face face) |
(put-text-property start end 'face face) |
2043 |
(put-text-property start end 'mouse-face mouse) |
(put-text-property start end 'mouse-face mouse) |
2044 |
(put-text-property start end 'invisible nil) |
(put-text-property start end 'invisible nil) |
2291 |
Lastly, DEPTH shows the depth of expansion. |
Lastly, DEPTH shows the depth of expansion. |
2292 |
|
|
2293 |
This function assumes that the cursor is in the speedbar window at the |
This function assumes that the cursor is in the speedbar window at the |
2294 |
position to insert a new item, and that the new item will end with a CR" |
position to insert a new item, and that the new item will end with a CR." |
2295 |
(let ((start (point)) |
(let ((start (point)) |
2296 |
(end (progn |
(end (progn |
2297 |
(insert (int-to-string depth) ":") |
(insert (int-to-string depth) ":") |
2348 |
"Insert list of FILES starting at point, and indenting all files to LEVEL. |
"Insert list of FILES starting at point, and indenting all files to LEVEL. |
2349 |
Tag expandable items with a +, otherwise a ?. Don't highlight ? as we |
Tag expandable items with a +, otherwise a ?. Don't highlight ? as we |
2350 |
don't know how to manage them. The input parameter FILES is a cons |
don't know how to manage them. The input parameter FILES is a cons |
2351 |
cell of the form ( 'DIRLIST . 'FILELIST )" |
cell of the form ( 'DIRLIST . 'FILELIST )." |
2352 |
;; Start inserting all the directories |
;; Start inserting all the directories |
2353 |
(let ((dirs (car files))) |
(let ((dirs (car files))) |
2354 |
(while dirs |
(while dirs |
2745 |
(speedbar-reconfigure-keymaps)) |
(speedbar-reconfigure-keymaps)) |
2746 |
|
|
2747 |
(defun speedbar-update-special-contents () |
(defun speedbar-update-special-contents () |
2748 |
"Used the mode-specific variable to fill in the speedbar buffer. |
"Use the mode-specific variable to fill in the speedbar buffer. |
2749 |
This should only be used by modes classified as special." |
This should only be used by modes classified as special." |
2750 |
(let ((funclst speedbar-special-mode-expansion-list) |
(let ((funclst speedbar-special-mode-expansion-list) |
2751 |
(specialbuff (current-buffer))) |
(specialbuff (current-buffer))) |
2869 |
) |
) |
2870 |
|
|
2871 |
(defun speedbar-find-selected-file (file) |
(defun speedbar-find-selected-file (file) |
2872 |
"Goto the line where FILE is." |
"Go to the line where FILE is." |
2873 |
(goto-char (point-min)) |
(goto-char (point-min)) |
2874 |
(let ((m nil)) |
(let ((m nil)) |
2875 |
(while (and (setq m (re-search-forward |
(while (and (setq m (re-search-forward |
2971 |
(defun speedbar-add-indicator (indicator-string &optional replace-this) |
(defun speedbar-add-indicator (indicator-string &optional replace-this) |
2972 |
"Add INDICATOR-STRING to the end of this speedbar line. |
"Add INDICATOR-STRING to the end of this speedbar line. |
2973 |
If INDICATOR-STRING is space, and REPLACE-THIS is a character, then |
If INDICATOR-STRING is space, and REPLACE-THIS is a character, then |
2974 |
an the existing indicator is removed. If there is already an |
the existing indicator is removed. If there is already an |
2975 |
indicator, then do not add a space." |
indicator, then do not add a space." |
2976 |
(beginning-of-line) |
(beginning-of-line) |
2977 |
;; The nature of the beast: Assume we are in "the right place" |
;; The nature of the beast: Assume we are in "the right place" |
3235 |
(defun speedbar-do-function-pointer () |
(defun speedbar-do-function-pointer () |
3236 |
"Look under the cursor and examine the text properties. |
"Look under the cursor and examine the text properties. |
3237 |
From this extract the file/tag name, token, indentation level and call |
From this extract the file/tag name, token, indentation level and call |
3238 |
a function if appropriate" |
a function if appropriate." |
3239 |
(let* ((fn (get-text-property (point) 'speedbar-function)) |
(let* ((fn (get-text-property (point) 'speedbar-function)) |
3240 |
(tok (get-text-property (point) 'speedbar-token)) |
(tok (get-text-property (point) 'speedbar-token)) |
3241 |
;; The 1-,+ is safe because scaning starts AFTER the point |
;; The 1-,+ is safe because scaning starts AFTER the point |
3286 |
nil))) |
nil))) |
3287 |
|
|
3288 |
(defun speedbar-line-file (&optional p) |
(defun speedbar-line-file (&optional p) |
3289 |
"Retrieve the file or whatever from the line at P point. |
"Retrieve the file or whatever from the line at point P. |
3290 |
The return value is a string representing the file. If it is a |
The return value is a string representing the file. If it is a |
3291 |
directory, then it is the directory name." |
directory, then it is the directory name." |
3292 |
(save-match-data |
(save-match-data |
3300 |
nil)))) |
nil)))) |
3301 |
|
|
3302 |
(defun speedbar-goto-this-file (file) |
(defun speedbar-goto-this-file (file) |
3303 |
"If FILE is displayed, goto this line and return t. |
"If FILE is displayed, go to this line and return t. |
3304 |
Otherwise do not move and return nil." |
Otherwise do not move and return nil." |
3305 |
(let ((path (substring (file-name-directory (expand-file-name file)) |
(let ((path (substring (file-name-directory (expand-file-name file)) |
3306 |
(length (expand-file-name default-directory)))) |
(length (expand-file-name default-directory)))) |
3341 |
"Retrieve the pathname associated with the current line. |
"Retrieve the pathname associated with the current line. |
3342 |
This may require traversing backwards from DEPTH and combining the default |
This may require traversing backwards from DEPTH and combining the default |
3343 |
directory with these items. This function is replaceable in |
directory with these items. This function is replaceable in |
3344 |
`speedbar-mode-functions-list' as `speedbar-line-path'" |
`speedbar-mode-functions-list' as `speedbar-line-path'." |
3345 |
(let ((rf (speedbar-fetch-replacement-function 'speedbar-line-path))) |
(let ((rf (speedbar-fetch-replacement-function 'speedbar-line-path))) |
3346 |
(if rf (funcall rf depth) default-directory))) |
(if rf (funcall rf depth) default-directory))) |
3347 |
|
|
3449 |
(if speedbar-xemacsp |
(if speedbar-xemacsp |
3450 |
(defalias 'speedbar-mouse-event-p 'button-press-event-p) |
(defalias 'speedbar-mouse-event-p 'button-press-event-p) |
3451 |
(defun speedbar-mouse-event-p (event) |
(defun speedbar-mouse-event-p (event) |
3452 |
"Return t if the event is a mouse related event" |
"Return t if the event is a mouse related event." |
3453 |
;; And Emacs does it this way |
;; And Emacs does it this way |
3454 |
(if (and (listp event) |
(if (and (listp event) |
3455 |
(member (event-basic-type event) |
(member (event-basic-type event) |
3482 |
|
|
3483 |
(defun speedbar-dir-follow (text token indent) |
(defun speedbar-dir-follow (text token indent) |
3484 |
"Speedbar click handler for directory names. |
"Speedbar click handler for directory names. |
3485 |
Clicking a directory will cause the speedbar to list files in the |
Clicking a directory will cause the speedbar to list files in |
3486 |
the subdirectory TEXT. TOKEN is an unused requirement. The |
the subdirectory TEXT. TOKEN is an unused requirement. The |
3487 |
subdirectory chosen will be at INDENT level." |
subdirectory chosen will be at INDENT level." |
3488 |
(setq default-directory |
(setq default-directory |
3587 |
(speedbar-center-buffer-smartly)) |
(speedbar-center-buffer-smartly)) |
3588 |
|
|
3589 |
(defun speedbar-tag-find (text token indent) |
(defun speedbar-tag-find (text token indent) |
3590 |
"For the tag TEXT in a file TOKEN, goto that position. |
"For the tag TEXT in a file TOKEN, go to that position. |
3591 |
INDENT is the current indentation level." |
INDENT is the current indentation level." |
3592 |
(let ((file (speedbar-line-path indent))) |
(let ((file (speedbar-line-path indent))) |
3593 |
(speedbar-find-file-in-frame file) |
(speedbar-find-file-in-frame file) |
3776 |
(defvar speedbar-fetch-etags-command "etags" |
(defvar speedbar-fetch-etags-command "etags" |
3777 |
"*Command used to create an etags file. |
"*Command used to create an etags file. |
3778 |
|
|
3779 |
This variable is ignored if `speedbar-use-imenu-flag' is t") |
This variable is ignored if `speedbar-use-imenu-flag' is t.") |
3780 |
|
|
3781 |
(defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-") |
(defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-") |
3782 |
"*List of arguments to use with `speedbar-fetch-etags-command'. |
"*List of arguments to use with `speedbar-fetch-etags-command'. |
3783 |
This creates an etags output buffer. Use `speedbar-toggle-etags' to |
This creates an etags output buffer. Use `speedbar-toggle-etags' to |
3784 |
modify this list conveniently. |
modify this list conveniently. |
3785 |
|
|
3786 |
This variable is ignored if `speedbar-use-imenu-flag' is t") |
This variable is ignored if `speedbar-use-imenu-flag' is t.") |
3787 |
|
|
3788 |
(defun speedbar-toggle-etags (flag) |
(defun speedbar-toggle-etags (flag) |
3789 |
"Toggle FLAG in `speedbar-fetch-etags-arguments'. |
"Toggle FLAG in `speedbar-fetch-etags-arguments'. |
3793 |
`speedbar-show-unknown-files'. |
`speedbar-show-unknown-files'. |
3794 |
|
|
3795 |
This function is a convenience function for XEmacs menu created by |
This function is a convenience function for XEmacs menu created by |
3796 |
Farzin Guilak <farzin@protocol.com>" |
Farzin Guilak <farzin@protocol.com>." |
3797 |
(interactive) |
(interactive) |
3798 |
(cond |
(cond |
3799 |
((equal flag "sort") |
((equal flag "sort") |
3869 |
(defun speedbar-extract-one-symbol (expr) |
(defun speedbar-extract-one-symbol (expr) |
3870 |
"At point, return nil, or one alist in the form: (SYMBOL . POSITION) |
"At point, return nil, or one alist in the form: (SYMBOL . POSITION) |
3871 |
The line should contain output from etags. Parse the output using the |
The line should contain output from etags. Parse the output using the |
3872 |
regular expression EXPR" |
regular expression EXPR." |
3873 |
(let* ((sym (if (stringp expr) |
(let* ((sym (if (stringp expr) |
3874 |
(if (save-excursion |
(if (save-excursion |
3875 |
(re-search-forward expr (save-excursion |
(re-search-forward expr (save-excursion |
3893 |
nil))) |
nil))) |
3894 |
|
|
3895 |
(defun speedbar-parse-c-or-c++tag () |
(defun speedbar-parse-c-or-c++tag () |
3896 |
"Parse a c or c++ tag, which tends to be a little complex." |
"Parse a C or C++ tag, which tends to be a little complex." |
3897 |
(save-excursion |
(save-excursion |
3898 |
(let ((bound (save-excursion (end-of-line) (point)))) |
(let ((bound (save-excursion (end-of-line) (point)))) |
3899 |
(cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t) |
(cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t) |
4117 |
) |
) |
4118 |
|
|
4119 |
(defun speedbar-unhighlight-one-tag-line () |
(defun speedbar-unhighlight-one-tag-line () |
4120 |
"Unhighlight the currently highlight line." |
"Unhighlight the currently highlighted line." |
4121 |
(if speedbar-highlight-one-tag-line |
(if speedbar-highlight-one-tag-line |
4122 |
(progn |
(progn |
4123 |
(speedbar-delete-overlay speedbar-highlight-one-tag-line) |
(speedbar-delete-overlay speedbar-highlight-one-tag-line) |
4154 |
(:foreground "blue4")) |
(:foreground "blue4")) |
4155 |
(((class color) (background dark)) |
(((class color) (background dark)) |
4156 |
(:foreground "light blue"))) |
(:foreground "light blue"))) |
4157 |
"Faced used for directory names." |
"Face used for directory names." |
4158 |
:group 'speedbar-faces) |
:group 'speedbar-faces) |
4159 |
(defface speedbar-tag-face '((((class color) (background light)) |
(defface speedbar-tag-face '((((class color) (background light)) |
4160 |
(:foreground "brown")) |
(:foreground "brown")) |
4198 |
|
|
4199 |
(defmacro defimage-speedbar (variable imagespec docstring) |
(defmacro defimage-speedbar (variable imagespec docstring) |
4200 |
"Don't bother loading up an image... |
"Don't bother loading up an image... |
4201 |
Argument VARIABLE is the varible to define. |
Argument VARIABLE is the variable to define. |
4202 |
Argument IMAGESPEC is the list defining the image to create. |
Argument IMAGESPEC is the list defining the image to create. |
4203 |
Argument DOCSTRING is the documentation for VARIABLE." |
Argument DOCSTRING is the documentation for VARIABLE." |
4204 |
`(defvar ,variable nil ,docstring)) |
`(defvar ,variable nil ,docstring)) |
4215 |
r)) |
r)) |
4216 |
|
|
4217 |
(defun speedbar-convert-emacs21-imagespec-to-xemacs (spec) |
(defun speedbar-convert-emacs21-imagespec-to-xemacs (spec) |
4218 |
"Convert the Emacs21 Image SPEC into an XEmacs image spec." |
"Convert the Emacs21 image SPEC into an XEmacs image spec." |
4219 |
(let* ((sl (car spec)) |
(let* ((sl (car spec)) |
4220 |
(itype (nth 1 sl)) |
(itype (nth 1 sl)) |
4221 |
(ifile (nth 3 sl))) |
(ifile (nth 3 sl))) |
4222 |
(vector itype ':file (speedbar-find-image-on-load-path ifile)))) |
(vector itype ':file (speedbar-find-image-on-load-path ifile)))) |
4223 |
|
|
4224 |
(defmacro defimage-speedbar (variable imagespec docstring) |
(defmacro defimage-speedbar (variable imagespec docstring) |
4225 |
"Devine VARIABLE as an image if `defimage' is not available.. |
"Define VARIABLE as an image if `defimage' is not available. |
4226 |
IMAGESPEC is the image data, and DOCSTRING is documentation for the image." |
IMAGESPEC is the image data, and DOCSTRING is documentation for the image." |
4227 |
`(defvar ,variable |
`(defvar ,variable |
4228 |
;; The Emacs21 version of defimage looks just like the XEmacs image |
;; The Emacs21 version of defimage looks just like the XEmacs image |