1 \input texinfo @c -*-texinfo-*-
2 @setfilename ../../info/speedbar
3 @settitle Speedbar: File/Tag summarizing utility
7 Copyright @copyright{} 1999--2013 Free Software Foundation, Inc.
10 Permission is granted to copy, distribute and/or modify this document
11 under the terms of the GNU Free Documentation License, Version 1.3 or
12 any later version published by the Free Software Foundation; with no
13 Invariant Sections, with the Front-Cover texts being ``A GNU Manual'',
14 and with the Back-Cover Texts as in (a) below. A copy of the license
15 is included in the section entitled ``GNU Free Documentation License''.
17 (a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
18 modify this GNU manual.''
22 @dircategory Emacs misc features
24 * Speedbar: (speedbar). File/Tag summarizing utility.
29 @center @titlefont{Speedbar}
32 @vskip 0pt plus 1 fill
34 @vskip 0pt plus 1filll
43 Speedbar is a program for Emacs which can be used to summarize
44 information related to the current buffer. Its original inspiration
45 is the `explorer' often used in modern development environments, office
46 packages, and web browsers.
48 Speedbar displays a narrow frame in which a tree view is shown. This
49 tree view defaults to containing a list of files and directories. Files
50 can be `expanded' to list tags inside. Directories can be expanded to
51 list the files within itself. Each file or tag can be jumped to
54 Speedbar expands upon `explorer' windows by maintaining context with the
55 user. For example, when using the file view, the current buffer's file
56 is highlighted. Speedbar also mimics the explorer windows by providing
57 multiple display modes. These modes come in two flavors. Major display
58 modes remain consistent across buffers, and minor display modes appear
59 only when a buffer of the applicable type is shown. This allows
60 authors of other packages to provide speedbar summaries customized to
61 the needs of that mode.
63 Throughout this manual, activities are defined as `clicking on', or
64 `expanding' items. Clicking means using @kbd{Mouse-2} on a
65 button. Expanding refers to clicking on an expansion button to display
66 an expanded summary of the entry the expansion button is
67 on. @xref{Basic Navigation}.
74 * Introduction:: Basics of speedbar.
75 * Basic Navigation:: Basics of speedbar common between all modes.
76 * File Mode:: Summarizing files.
77 * Buffer Mode:: Summarizing buffers.
78 * Minor Modes:: Additional minor modes such as Info and RMAIL.
79 * Customizing:: Changing speedbar behavior.
80 * Extending:: Extend speedbar for your own project.
81 * GNU Free Documentation License:: The license for this documentation.
89 To start using speedbar use the command @kbd{M-x speedbar RET} or
90 select it from the @samp{Options->Show/Hide} sub-menu. This command
91 will open a new frame to summarize the local files. On X Window
92 systems or on MS-Windows, speedbar's frame is twenty characters wide,
93 and will mimic the height of the frame from which it was started. It
94 positions itself to the left or right of the frame you started it
97 To use speedbar effectively, it is important to understand its
98 relationship with the frame you started it from. This frame is the
99 @dfn{attached frame} which speedbar will use as a reference point. Once
100 started, speedbar watches the contents of this frame, and attempts to
101 make its contents relevant to the buffer loaded into the attached
102 frame. In addition, all requests made in speedbar that require the
103 display of another buffer will display in the attached frame.
105 When used in terminal mode, the new frame appears the same size as the
106 terminal. Since it is not visible while working in the attached frame,
107 speedbar will save time by using the @dfn{slowbar mode}, where no tracking is
108 done until speedbar is requested to show itself (i.e., the speedbar's
109 frame becomes the selected frame).
111 @cindex @code{speedbar-get-focus}
112 The function to use when switching between frames using the keyboard is
113 @code{speedbar-get-focus}. This function will toggle between frames, and
114 it's useful to bind it to a key in terminal mode. @xref{Customizing}.
116 @node Basic Navigation
117 @chapter Basic Navigation
119 Speedbar can display different types of data, and has several display
120 and behavior modes. These modes all have a common behavior, menu
121 system, and look. If one mode is learned, then the other modes are easy
125 * Basic Key Bindings::
131 @node Basic Key Bindings
132 @section Basic Key Bindings
135 These key bindings are common across all modes:
139 @cindex quitting speedbar
140 Quit speedbar, and kill the frame.
142 Quit speedbar, and hide the frame. This makes it faster to restore the
143 speedbar frame, than if you press @kbd{Q}.
145 @cindex refresh speedbar display
146 Refresh whatever contents are in speedbar.
149 Toggle speedbar to and from slowbar mode. In slowbar mode, frame
150 tracking is not done.
154 Move, respectively, to the next or previous item. A summary of that
155 item will be displayed in the attached frame's minibuffer.
158 Move to the next or previous item in a restricted fashion. If a list is
159 open, the cursor will skip over it. If the cursor is in an open list,
160 it will not leave it.
163 Move forwards and backwards across extended groups. This lets you
164 quickly skip over all files, directories, or other common sub-items at
165 the same current depth.
167 Switch buffers in the attached frame.
170 Speedbar can handle multiple modes. Two are provided by default.
171 These modes are File mode, and Buffers mode. There are accelerators to
172 switch into these different modes.
174 @cindex mode switching hotkeys
177 Switch into Quick Buffers mode (@pxref{Buffer Mode}). After one use, the
178 previous display mode is restored.
180 Switch into File mode.
182 Switch back to the previous mode.
185 Some modes provide groups, lists and tags. @xref{Basic Visuals}. When
186 these are available, some additional common bindings are available.
192 Edit/Open the current group or tag. This behavior is dependent on the
193 mode. In general, files or buffers are opened in the attached frame,
194 and directories or group nodes are expanded locally.
197 Expand the current group, displaying sub items.
198 When used with a prefix argument, any data that may have been cached is
199 flushed. This is similar to a power click. @xref{Mouse Bindings}.
201 Contract the current group, hiding sub items.
205 @section Basic Visuals
208 Speedbar has visual cues for indicating different types of data. These
209 cues are used consistently across the different speedbar modes to make
210 them easier to interpret.
212 At a high level, in File mode, there are directory buttons, sub
213 directory buttons, file buttons, tag buttons, and expansion buttons.
214 This makes it easy to use the mouse to navigate a directory tree, and
215 quickly view files, or a summary of those files.
217 The most basic visual effect used to distinguish between these button
218 types is color and mouse highlighting. Anything the mouse highlights
219 can be clicked on and is called a button (@pxref{Mouse Bindings}).
220 Anything not highlighted by the mouse will not be clickable.
222 Text in speedbar consists of four different types of data. Knowing how
223 to read these textual elements will make it easier to navigate by
224 identifying the types of data available.
229 Groups summarize information in a single line, and provide a high level
230 view of more complex systems, like a directory tree, or manual chapters.
232 Groups appear at different indentation levels, and are prefixed with a
233 @samp{+} in some sort of `box'. The group name will summarize the
234 information within it, and the expansion box will display that
235 information inline. In File mode, directories and files are `groups'
236 where the @samp{+} is surrounded by brackets like this:
244 In this example, we see both open and closed directories, in addition to
245 a file. The directories have a box consisting of angle brackets, and a
246 file uses square brackets.
248 In all modes, a group can be `edited' by pressing @kbd{RET}, meaning a
249 file will be opened, or a directory explicitly opened in speedbar. A
250 group can be expanded or contracted using @kbd{+} or
251 @kbd{-}. @xref{Basic Key Bindings}.
253 Sometimes groups may have a @samp{?} in its indicator box. This means
254 that it is a group type, but there are no contents, or no known way of
255 extracting contents of that group.
257 When a group has been expanded, the indicator button changes from
258 @samp{+} to @samp{-}. This indicates that the contents are being shown.
259 Click the @samp{-} button to contract the group, or hide the contents
265 Tags are the leaf nodes of the tree system. Tags are generally prefixed
266 with a simple character, such as @samp{>}. Tags can only be jumped to using
267 @kbd{RET} or @kbd{e}.
269 @subsubsection Boolean Flags
271 Sometimes a group or tag is given a boolean flag. These flags appear as
272 extra text characters at the end of the line. File mode uses boolean
273 flags, such as a @samp{*} to indicate that a file has been checked out
274 of a versioning system.
276 For additional flags, see
277 @c Note to self, update these to sub-nodes which are more relevant.
278 @ref{File Mode}, and @ref{Version Control}.
280 @subsubsection Unadorned Text
282 Unadorned text generally starts in column 0, without any special symbols
283 prefixing them. In Buffers mode different buffer groups are prefixed
284 with a description of what the following buffers are (Files, scratch
285 buffers, and invisible buffers.)
287 Unadorned text will generally be colorless, and not clickable.
289 @subsubsection Color Cues
291 Each type of Group, item indicator, and label is given a different
292 color. The colors chosen are dependent on whether the background color
294 Of important note is that the `current item', which may be a buffer or
295 file name, is highlighted red, and underlined.
297 Colors can be customized from the group @code{speedbar-faces}. Some
298 modes, such as for Info, will use the Info colors instead of default
299 speedbar colors as an indication of what is currently being displayed.
301 The face naming convention mirrors the File display mode. Modes which
302 do not use files will attempt to use the same colors on analogous
306 @section Mouse Bindings
307 @cindex mouse bindings
309 The mouse has become a common information navigation tool. Speedbar
310 will use the mouse to navigate file systems, buffer lists, and other
311 data. The different textual cues provide buttons which can be clicked
312 on (@pxref{Basic Visuals}). Anything that highlights can be clicked on
313 with the mouse, or affected by the menu.
315 The mouse bindings are:
319 Move cursor to that location.
321 @itemx Double-Mouse-1
322 Activate the current button. @kbd{Double-Mouse-1} is called a @dfn{double
323 click} on other platforms, and is useful for windows users with two
325 @c Isn't it true that with two-button mice, the right button is Mouse-2?
326 @c On GNU/Linux, the right button is Mouse-3.
328 @itemx S-Double-Mouse-1
330 This has the same effect as @kbd{Mouse-2}, except it is called a power
331 click. This means that if a group with an expansion button @samp{+} is
332 clicked, any caches are flushed, and subitems re-read. If it is a name,
333 it will be opened in a new frame.
335 Activate the speedbar menu. The item selected affects the line clicked,
336 not the line where the cursor was.
337 @item Mouse-1 @r{(mode line)}
338 Activate the menu. This affects the item the cursor is on before the
339 click, since the mouse was not clicked on anything.
341 Buffers sub-menu. The buffer in the attached frame is switched.
344 When the mouse moves over buttons in speedbar, details of that item
345 should be displayed in the minibuffer of the attached frame. Sometimes
346 this can contain extra information such as file permissions, or tag
349 @node Displays Submenu
350 @section Displays Submenu
351 @cindex displays submenu
353 You can display different data by using different display modes. These
354 specialized modes make it easier to navigate the relevant pieces of
355 information, such as files and directories, or buffers.
357 In the main menu, found by clicking @kbd{Mouse-3}, there is a submenu
358 labeled @samp{Displays}. This submenu lets you easily choose between
359 different display modes.
361 The contents are modes currently loaded into emacs. By default, this
362 would include Files, Quick Buffers, and Buffers. Other major display
363 modes such as Info are loaded separately.
369 File mode displays a summary of your current directory. You can display
370 files in the attached frame, or summarize the tags found in files. You
371 can even see if a file is checked out of a version control system, or
372 has some associated object file.
374 Advanced behavior, like copying and renaming files, is also provided.
377 * Directory Display:: What the display means.
378 * Hidden Files:: How to display hidden files.
379 * File Key Bindings:: Performing file operations.
382 @node Directory Display
383 @section Directory Display
384 @cindex directory display
386 There are three major sections in the display. The first line or two is
387 the root directory speedbar is currently viewing. You can jump to one
388 of the parent directories by clicking on the name of the directory you
391 Next, directories are listed. A directory starts with the group
392 indicator button @samp{<+>}. Clicking the directory name makes speedbar
393 load that directory as the root directory for its display. Clicking the
394 @samp{<+>} button will list all directories and files beneath.
396 Next, files are listed. Files start with the group indicator @samp{[+]}
397 or @samp{[?]}. You can jump to a file in the attached frame by clicking
398 on the file name. You can expand a file and look at its tags by
399 clicking on the @samp{[+]} symbol near the file name.
401 A typical session might look like this:
425 In this example, you can see several directories. The directory
426 @file{speedbar} has been opened inline. Inside the directory
427 @file{speedbar}, the file @file{speedbar.el} has its tags exposed.
428 These tags are extensive, and they are summarized into tag groups.
430 Files get additional boolean flags associated with them. Valid flags are:
435 This file has been checked out of a version control
436 system. @xref{Version Control}.
437 @cindex @code{speedbar-obj-alist}
439 This file has an up to date object file associated with it. The
440 variable @code{speedbar-obj-alist} defines how speedbar determines this
443 This file has an out of date object file associated with it.
446 A Tag group is prefixed with the symbol @samp{@{+@}}. Clicking this
447 symbol will show all symbols that have been organized into that group.
448 Different types of files have unique tagging methods as defined by their
449 major mode. Tags are generated with either the @code{imenu} package, or
450 through the @code{etags} interface.
452 Tag groups are defined in multiple ways which make it easier to find the
453 tag you are looking for. Imenu keywords explicitly create groups, and
454 speedbar will automatically create groups if tag lists are too long.
456 In our example, Imenu created the groups @samp{Types} and
457 @samp{Variables}. All remaining top-level symbols are then regrouped
458 based on the variable @code{speedbar-tag-hierarchy-method}. The
459 subgroups @samp{def} and @samp{speedbar-} are groupings where the first
460 few characters of the given symbols are specified in the group name.
461 Some group names may say something like @samp{speedbar-t to speedbar-v},
462 indicating that all symbols which alphabetically fall between those
463 categories are included in that sub-group. @xref{Tag Hierarchy Methods}.
466 @section Hidden Files
469 On GNU and Unix systems, a hidden file is a file whose name starts
470 with a period. They are hidden from a regular directory listing
471 because the user is not generally interested in them.
473 In speedbar, a hidden file is a file which isn't very interesting and
474 might prove distracting to the user. Any uninteresting files are
475 removed from the File display. There are two levels of uninterest in
476 speedbar. The first level of uninterest are files which have no
477 expansion method, or way of extracting tags. The second level is any
478 file that matches the same pattern used for completion in
479 @code{find-file}. This is derived from the variable
480 @code{completion-ignored-extensions}.
482 You can toggle the display of uninteresting files from the toggle menu
483 item @samp{Show All Files}. This will display all level one hidden files.
484 These files will be shown with a @samp{?} indicator. Level 2 hidden
485 files will still not be shown.
487 Object files fall into the category of level 2 hidden files. You can
488 determine their presence by the @samp{#} and @samp{!} file indicators.
489 @xref{Directory Display}.
491 @node File Key Bindings
492 @section File Key Bindings
493 @cindex file key bindings
495 File mode has key bindings permitting different file system operations
496 such as copy or rename. These commands all operate on the @dfn{current
497 file}. In this case, the current file is the file at point, or clicked
498 on when pulling up the menu.
502 Move the entire speedbar display up one directory.
504 Display information in the minibuffer about this line. This is the same
505 information shown when navigating with @kbd{n} and @kbd{p}, or moving
506 the mouse over an item.
508 Byte compile the Emacs Lisp file on this line.
510 Load the Emacs Lisp file on this line. If a @file{.elc} file exists,
511 optionally load that.
513 Copy the current file to some other location.
515 Rename the current file, possibly moving it to some other location.
517 Delete the current file.
519 Delete the current file's object file. Use the symbols @samp{#} and
520 @samp{!} to determine if there is an object file available.
523 One menu item toggles the display of all available files. By default,
524 only files which Emacs understands, and knows how to convert into a tag
525 list, are shown. By showing all files, additional files such as text files are
526 also displayed, but they are prefixed with the @samp{[?]} symbol. This
527 means that it is a file, but Emacs doesn't know how to expand it.
533 Buffer mode is very similar to File mode, except that instead of
534 tracking the current directory and all files available there, the
535 current list of Emacs buffers is shown.
537 These buffers can have their tags expanded in the same way as files,
538 and uses the same unknown file indicator (@pxref{File Mode}).
540 Buffer mode does not have file operation bindings, but the following
541 buffer specific key bindings are available:
545 Kill this buffer. Do not touch its file.
547 Revert this buffer, reloading from disk.
550 In addition to Buffer mode, there is also Quick Buffer mode. In fact,
551 Quick Buffers is bound to the @kbd{b} key. The only difference between
552 Buffers and Quick Buffers is that after one operation is performed
553 which affects the attached frame, the display is immediately reverted to
554 the last displayed mode.
556 Thus, if you are in File mode, and you need quick access to a buffer,
557 press @kbd{b}, click on the buffer you want, and speedbar will revert
561 @chapter Minor Display Modes
562 @cindex minor display modes
564 For some buffers, a list of files and tags makes no sense. This could
565 be because files are not currently in reference (such as web pages), or
566 that the files you might be interested have special properties (such as
569 In these cases, a minor display mode is needed. A minor display mode
570 will override any major display mode currently being displayed for the
571 duration of the specialized buffer's use. Minor display modes
572 will follow the general rules of their major counterparts in terms of
573 key bindings and visuals, but will have specialized behaviors.
576 * RMAIL:: Managing folders.
577 * Info:: Browsing topics.
578 * GDB:: Watching expressions or managing the current
586 When using RMAIL, speedbar will display two sections. The first is a
587 layer one reply button. Clicking here will initialize a reply buffer
588 showing only this email address in the @samp{To:} field.
590 The second section lists all RMAIL folders in the same directory as your
591 main RMAIL folder. The general rule is that RMAIL folders always appear
592 in all caps, or numbers. It is possible to save mail in folders with
593 lower case letters, but there is no clean way of detecting such RMAIL folders
594 without opening them all.
596 Each folder can be visited by clicking the name. You can move mail from
597 the current RMAIL folder into a different folder by clicking the
598 @samp{<M>} button. The @samp{M} stands for Move.
600 In this way you can manage your existing RMAIL folders fairly easily
607 When browsing Info files, all local relevant information is displayed in
608 the info buffer and a topical high-level view is provided in speedbar.
609 All top-level info nodes are shown in the speedbar frame, and can be
610 jumped to by clicking the name.
612 You can open these nodes with the @samp{[+]} button to see what sub-topics
613 are available. Since these sub-topics are not examined until you click
614 the @samp{[+]} button, sometimes a @samp{[?]} will appear when you click on
615 a @samp{[+]}, indicating that there are no sub-topics.
622 You can debug an application with GDB in Emacs using graphical mode or
623 text command mode (@pxref{GDB Graphical Interface,,, emacs, The
624 extensible self-documenting text editor}).
626 If you are using graphical mode you can see how selected variables
627 change each time your program stops (@pxref{Watch Expressions,,,
628 emacs, The extensible self-documenting text editor}).
630 If you are using text command mode, speedbar can show
631 you the current stack when the current buffer is the @file{*gdb*}
632 buffer. Usually, it will just report that there is no stack, but when
633 the application is stopped, the current stack will be shown.
635 You can click on any stack element and gdb will move to that stack
636 level. You can then check variables local to that level at the GDB
643 Speedbar is highly customizable, with a plethora of control elements.
644 Since speedbar is so visual and reduces so much information, this is an
645 important aspect of its behavior.
647 In general, there are three custom groups you can use to quickly modify
652 Basic speedbar behaviors.
654 Customizations regarding version control handling.
656 Customize speedbar's many colors and fonts.
660 * Frames and Faces:: Visible behaviors.
661 * Tag Hierarchy Methods:: Customizing how tags are displayed.
662 * Version Control:: Adding new VC detection modes.
663 * Hooks:: The many hooks you can use.
666 @node Frames and Faces
667 @section Frames and Faces
669 @cindex frame parameters
671 There are several faces speedbar generates to provide a consistent
672 color scheme across display types. You can customize these faces using
673 your favorite method. They are:
676 @cindex @code{speedbar-button-face}
677 @item speedbar-button-face
678 Face used on expand/contract buttons.
679 @cindex @code{speedbar-file-face}
680 @item speedbar-file-face
681 Face used on Files. Should also be used on non-directory like nodes.
682 @cindex @code{speedbar-directory-face}
683 @item speedbar-directory-face
684 Face used for directories, or nodes which consist of groups of other nodes.
685 @cindex @code{speedbar-tag-face}
686 @item speedbar-tag-face
687 Face used for tags in a file, or for leaf items.
688 @cindex @code{speedbar-selected-face}
689 @item speedbar-selected-face
690 Face used to highlight the selected item. This would be the current
692 @cindex @code{speedbar-highlight-face}
693 @item speedbar-highlight-face
694 Face used when the mouse passes over a button.
697 You can also customize speedbar's initial frame parameters. How this is
698 accomplished is dependent on your platform being Emacs or XEmacs.
700 @cindex @code{speedbar-frame-parameters}, Emacs
701 In Emacs, change the alist @code{speedbar-frame-parameters}. This
702 variable is used to set up initial details. Height is also
703 automatically added when speedbar is created, though you can override
706 @cindex @code{speedbar-frame-plist}, XEmacs
707 In XEmacs, change the plist @code{speedbar-frame-plist}. This is the
708 XEmacs way of doing the same thing.
710 @node Tag Hierarchy Methods
711 @section Tag Hierarchy Methods
712 @cindex tag hierarchy
716 When listing tags within a file, it is possible to get an annoyingly
717 long list of entries. Imenu (which generates the tag list in Emacs)
718 will group some classes of items automatically. Even here, however,
719 some tag groups can be quite large.
721 @cindex @code{speedbar-tag-hierarchy-method}
722 To solve this problem, tags can be grouped into logical units through a
723 hierarchy processor. The specific variable to use is
724 @code{speedbar-tag-hierarchy-method}. There are several methods that
725 can be applied in any order. They are:
728 @cindex @code{speedbar-trim-words-tag-hierarchy}
729 @item speedbar-trim-words-tag-hierarchy
730 Find a common prefix for all elements of a group, and trim it off.
731 @cindex @code{speedbar-prefix-group-tag-hierarchy}
732 @item speedbar-prefix-group-tag-hierarchy
733 If a group is too large, place sets of tags into bins based on common
735 @cindex @code{speedbar-simple-group-tag-hierarchy}
736 @item speedbar-simple-group-tag-hierarchy
737 Take all items in the top level list not in a group, and stick them into
739 @cindex @code{speedbar-sort-tag-hierarchy}
740 @item speedbar-sort-tag-hierarchy
741 Sort all items, leaving groups on top.
744 You can also add your own functions to reorganize tags as you see fit.
746 Some other control variables are:
749 @cindex @code{speedbar-tag-group-name-minimum-length}
750 @item speedbar-tag-group-name-minimum-length
753 The minimum length of a prefix group name before expanding. Thus, if
754 the @code{speedbar-tag-hierarchy-method} includes
755 @code{speedbar-prefix-group-tag-hierarchy} and one such group's common
756 characters is less than this number of characters, then the group name
757 will be changed to the form of:
769 This way we won't get silly looking listings.
771 @cindex @code{speedbar-tag-split-minimum-length}
772 @item speedbar-tag-split-minimum-length
775 Minimum length before we stop trying to create sub-lists in tags.
776 This is used by all tag-hierarchy methods that break large lists into
779 @cindex @code{speedbar-tag-regroup-maximum-length}
780 @item speedbar-tag-regroup-maximum-length
783 Maximum length of submenus that are regrouped.
784 If the regrouping option is used, then if two or more short subgroups
785 are next to each other, then they are combined until this number of
789 @node Version Control
790 @section Version Control
791 @cindex version control
792 @cindex vc extensions
794 When using the file mode in speedbar, information regarding a version
795 control system adds small details to the display. If a file is in a
796 version control system, and is ``checked out'' or ``locked'' locally, an
797 asterisk @samp{*} appears at the end of the file name. In addition,
798 the directory name for Version Control systems are left out of the
801 @cindex @code{speedbar-directory-unshown-regexp}
802 You can easily add new version control systems into speedbar's detection
803 scheme. To make a directory ``disappear'' from the list, use the variable
804 @code{speedbar-directory-unshown-regexp}.
806 @cindex @code{speedbar-vc-path-enable-hook}
807 Next, you need to write entries for two hooks. The first is
808 @code{speedbar-vc-path-enable-hook} which will enable a VC check in the
809 current directory for the group of files being checked. Your hook
810 function should take one parameter (the directory to check) and return
811 @code{t} if your VC method is in control here.
813 @cindex @code{speedbar-vc-in-control-hook}
814 The second function is @code{speedbar-vc-in-control-hook}. This hook
815 takes two parameters, the @var{path} of the file to check, and the
816 @var{file} name. Return @code{t} if you want to have the asterisk
817 placed near this file.
819 @cindex @code{speedbar-vc-indicator}
820 Lastly, you can change the VC indicator using the variable
821 @code{speedbar-vc-indicator}, and specify a single character string.
827 There are several hooks in speedbar allowing custom behaviors to be
828 added. Available hooks are:
831 @cindex @code{speedbar-visiting-file-hook}
832 @item speedbar-visiting-file-hook
833 Hooks run when speedbar visits a file in the selected frame.
834 @cindex @code{speedbar-visiting-tag-hook}
835 @item speedbar-visiting-tag-hook
836 Hooks run when speedbar visits a tag in the selected frame.
837 @cindex @code{speedbar-load-hook}
838 @item speedbar-load-hook
839 Hooks run when speedbar is loaded.
840 @cindex @code{speedbar-reconfigure-keymaps-hook}
841 @item speedbar-reconfigure-keymaps-hook
842 Hooks run when the keymaps are regenerated. Keymaps are reconfigured
843 whenever modes change. This will let you add custom key bindings.
844 @cindex @code{speedbar-before-popup-hook}
845 @item speedbar-before-popup-hook
846 Hooks called before popping up the speedbar frame.
847 New frames are often popped up when ``power clicking'' on an item to view
849 @cindex @code{speedbar-before-delete-hook}
850 @item speedbar-before-delete-hook
851 Hooks called before deleting or hiding the speedbar frame.
852 @cindex @code{speedbar-mode-hook}
853 @item speedbar-mode-hook
854 Hooks called after creating a speedbar buffer.
855 @cindex @code{speedbar-timer-hook}
856 @item speedbar-timer-hook
857 Hooks called after running the speedbar timer function.
858 @cindex @code{speedbar-scanner-reset-hook}
859 @item speedbar-scanner-reset-hook
860 Hook called whenever generic scanners are reset.
861 Set this to implement your own scanning or rescan safe functions with
869 Speedbar can run different types of Major display modes such as Files
870 (@pxref{File Mode}), and Buffers (@pxref{Buffer Mode}). It can also manage
871 different minor display modes for use with buffers handling specialized
874 These major and minor display modes are handled through an extension
875 system which permits specialized keymaps and menu extensions, in
876 addition to a unique rendering function. You can also specify a wide
877 range of tagging functions. The default uses @code{imenu}, but new
878 tagging methods can be easily added. In this chapter, you will
879 learn how to write your own major or minor display modes, and how to
880 create specialized tagging functions.
883 * Minor Display Modes:: How to create a minor display mode.
884 * Major Display Modes:: How to create a major display mode.
885 * Tagging Extensions:: How to create your own tagging methods.
886 * Creating a display:: How to insert buttons and hierarchies.
889 @node Minor Display Modes
890 @section Minor Display Modes
891 @cindex create minor display mode
893 A @dfn{minor display mode} is a mode useful when using a specific type of
894 buffer. This mode might not be useful for any other kind of data or
895 mode, or may just be more useful that a files or buffers based mode when
896 working with a specialized mode.
898 Examples that already exist for speedbar include RMAIL, Info, and gdb.
899 These modes display information specific to the major mode shown in the
902 To enable a minor display mode in your favorite Major mode, follow these
903 steps. The string @samp{@var{name}} is the name of the major mode being
904 augmented with speedbar.
908 Create the keymap variable @code{@var{name}-speedbar-key-map}.
911 Create a function, named whatever you like, which assigns values into your
912 keymap. Use this command to create the keymap before assigning
916 (setq @var{name}-speedbar-key-map (speedbar-make-specialized-keymap))
919 This function creates a special keymap for use in speedbar.
922 Call your install function, or assign it to a hook like this:
925 (if (featurep 'speedbar)
926 (@var{name}-install-speedbar-variables)
927 (add-hook 'speedbar-load-hook '@var{name}-install-speedbar-variables))
931 Create an easymenu compatible vector named
932 @code{@var{name}-speedbar-menu-items}. This will be spliced into
933 speedbar's control menu.
936 Create a function called @code{@var{name}-speedbar-buttons}. This function
937 should take one variable, which is the buffer for which it will create
938 buttons. At this time @code{(current-buffer)} will point to the
939 uncleared speedbar buffer.
942 When writing @code{@var{name}-speedbar-buttons}, the first thing you will
943 want to do is execute a check to see if you need to re-create your
944 display. If it needs to be cleared, you need to erase the speedbar
945 buffer yourself, and start drawing buttons. @xref{Creating a display}.
947 @node Major Display Modes
948 @section Major Display Modes
949 @cindex create major display mode
951 Creating a @dfn{Major Display Mode} for speedbar requires authoring a keymap,
952 an easy-menu segment, and writing several functions. These items can be
953 given any name, and are made the same way as in a minor display mode
954 (@pxref{Minor Display Modes}). Once this is done, these items need to be
957 Because this setup activity may or may not have speedbar available when
958 it is being loaded, it is necessary to create an install function. This
959 function should create and initialize the keymap, and add your
960 expansions into the customization tables.
962 @cindex @code{speedbar-make-specialized-keymap}
963 When creating the keymap, use the function
964 @code{speedbar-make-specialized-keymap} instead of other keymap making
965 functions. This will provide you with the initial bindings needed.
966 Some common speedbar functions you might want to bind are:
969 @cindex @code{speedbar-edit-line}
970 @item speedbar-edit-line
971 Edit the item on the current line.
972 @cindex @code{speedbar-expand-line}
973 @item speedbar-expand-line
974 Expand the item under the cursor.
975 With a numeric argument (@kbd{C-u}), flush cached data before expanding.
976 @cindex @code{speedbar-contract-line}
977 @item speedbar-contract-line
978 Contract the item under the cursor.
981 @cindex @code{speedbar-line-path}
982 These function require that function @code{speedbar-line-path} be
983 correctly overloaded to work.
985 Next, register your extension like this;
988 (speedbar-add-expansion-list '("MyExtension"
989 MyExtension-speedbar-menu-items
990 MyExtension-speedbar-key-map
991 MyExtension-speedbar-buttons))
994 There are no limitations to the names you use.
996 The first parameter is the string representing your display mode.
997 The second parameter is a variable name containing an easymenu compatible
998 menu definition. This will be stuck in the middle of speedbar's menu.
999 The third parameter is the variable name containing the keymap we
1001 The last parameter is a function which draws buttons for your mode.
1002 This function must take two parameters. The directory currently being
1003 displayed, and the depth at which you should start rendering buttons.
1004 The function will then draw (starting at the current cursor position)
1005 any buttons deemed necessary based on the input parameters.
1006 @xref{Creating a display}.
1008 Next, you need to register function overrides. This may look something
1012 (speedbar-add-mode-functions-list
1014 (speedbar-item-info . MyExtension-speedbar-item-info)
1015 (speedbar-line-path . MyExtension-speedbar-line-path)))
1018 The first element in the list is the name of you extension. The second
1019 is an alist of functions to overload. The function to overload is
1020 first, followed by what you want called instead.
1022 For @code{speedbar-line-path} your function should take an optional DEPTH
1023 parameter. This is the starting depth for heavily indented lines. If
1024 it is not provided, you can derive it like this:
1031 (looking-at "^\\([0-9]+\\):")
1032 (setq depth (string-to-int (match-string 1)))))
1036 where the depth is stored as invisible text at the beginning of each
1039 The path returned should be the full path name of the file associated
1040 with that line. If the cursor is on a tag, then the file containing
1041 that tag should be returned. This is critical for built in file based
1042 functions to work (meaning less code for you to write). If your display
1043 does not deal in files, you do not need to overload this function.
1045 @cindex @code{speedbar-item-info}
1046 The function @code{speedbar-item-info}, however, is very likely to need
1047 overloading. This function takes no parameters and must derive a text
1048 summary to display in the minibuffer.
1050 There are several helper functions you can use if you are going to use
1051 built in tagging. These functions can be @code{or}ed since each one
1052 returns non-@code{nil} if it displays a message. They are:
1055 @cindex @code{speedbar-item-info-file-helper}
1056 @item speedbar-item-info-file-helper
1057 This takes an optional @var{filename} parameter. You can derive your own
1058 filename, or it will derive it using a (possibly overloaded) function
1059 @code{speedbar-line-file}. It shows details about a file.
1060 @cindex @code{speedbar-item-info-tag-helper}
1061 @item speedbar-item-info-tag-helper
1062 If the current line is a tag, then display information about that tag,
1063 such as its parent file, and location.
1066 Your custom function might look like this:
1069 (defun MyExtension-item-info ()
1070 "Display information about the current line."
1071 (or (speedbar-item-info-tag-helper)
1072 (message "Interesting detail.")))
1075 Once you have done all this, speedbar will show an entry in the
1076 @samp{Displays} menu declaring that your extension is available.
1078 @node Tagging Extensions
1079 @section Tagging Extensions
1081 It is possible to create new methods for tagging files in speedbar.
1082 To do this, you need two basic functions, one function to fetch the
1083 tags from a buffer, the other to insert them below the filename.
1085 @defun my-fetch-dynamic-tags file
1086 Parse @var{file} for a list of tags. Return the list, or @code{t} if there was
1090 The non-error return value can be anything, as long as it can be
1091 inserted by its paired function:
1093 @defun my-insert-tag-list level lst
1094 Insert a list of tags @var{lst} started at indentation level
1095 @var{level}. Creates buttons for each tag, and provides any other
1096 display information required.
1099 @cindex @code{speedbar-create-tag-hierarchy}
1100 It is often useful to use @code{speedbar-create-tag-hierarchy} on your
1101 token list. See that function's documentation for details on what it
1104 @cindex @code{speedbar-dynamic-tags-function-list}
1105 Once these two functions are written, modify the variable
1106 @code{speedbar-dynamic-tags-function-list} to include your parser at the
1107 beginning, like this:
1110 (add-to-list 'speedbar-dynamic-tags-function-list
1111 '(my-fetch-dynamic-tags . my-insert-tag-list))
1114 If your parser is only good for a few types of files, make sure that it
1115 is either a buffer local modification, or that the tag generator returns
1116 @code{t} for non valid buffers.
1118 @node Creating a display
1119 @section Creating a display
1120 @cindex creating a display
1122 Rendering a display in speedbar is completely flexible. When your
1123 button function is called, see @ref{Minor Display Modes}, and @ref{Major
1124 Display Modes}, you have control to @code{insert} anything you want.
1126 The conventions allow almost anything to be inserted, but several helper
1127 functions are provided to make it easy to create the standardized
1130 To understand the built in functions, each `button' in speedbar consists
1131 of four important pieces of data. The text to be displayed, token
1132 data to be associated with the text, a function to call, and some face to
1135 When a function is provided, then that text becomes mouse activated,
1136 meaning the mouse will highlight the text.
1138 Additionally, for data which can form deep trees, each line is given a
1139 depth which indicates how far down the tree it is. This information is
1140 stored in invisible text at the beginning of each line, and is used by
1141 the navigation commands.
1143 @defun speedbar-insert-button text face mouse function &optional token prevline
1144 This function inserts one button into the current location.
1145 @var{text} is the text to insert. @var{face} is the face in which it
1146 will be displayed. @var{mouse} is the face to display over the text
1147 when the mouse passes over it. @var{function} is called whenever the
1148 user clicks on the text.
1150 The optional argument @var{token} is extra data to associated with the
1151 text. Lastly @var{prevline} should be non-@code{nil} if you want this line to
1152 appear directly after the last button which was created instead of on
1156 @defun speedbar-make-tag-line exp-button-type exp-button-char exp-button-function exp-button-data tag-button tag-button-function tag-button-data tag-button-face depth
1158 Create a tag line with @var{exp-button-type} for the small expansion
1159 button. This is the button that expands or contracts a node (if
1160 applicable), and @var{exp-button-char} the character in it (@samp{+},
1161 @samp{-}, @samp{?}, etc.). @var{exp-button-function} is the function
1162 to call if it's clicked on. Button types are @code{bracket},
1163 @code{angle}, @code{curly}, @code{expandtag}, @code{statictag}, and
1164 @code{nil}. @var{exp-button-data} is extra data attached to the text
1165 forming the expansion button.
1167 Next, @var{tag-button} is the text of the tag.
1168 @var{tag-button-function} is the function to call if clicked on, and
1169 @var{tag-button-data} is the data to attach to the text field (such a
1170 tag positioning, etc.). @var{tag-button-face} is a face used for this
1173 Lastly, @var{depth} shows the depth of expansion.
1175 This function assumes that the cursor is in the speedbar window at the
1176 position to insert a new item, and that the new item will end with a CR.
1179 @defun speedbar-insert-generic-list level list expand-fun find-fun
1181 At @var{level}, (the current indentation level desired) insert a generic
1182 multi-level alist @var{list}. Associations with lists get @samp{@{+@}}
1183 tags (to expand into more nodes) and those with positions or other data
1184 just get a @samp{>} as the indicator. @samp{@{+@}} buttons will have the
1185 function @var{expand-fun} and the token is the @code{cdr} list. The
1186 token name will have the function @var{find-fun} and not token.
1188 Each element of the list can have one of these forms:
1191 @item (@var{name} . marker-or-number)
1192 One tag at this level.
1193 @item (@var{name} (@var{name} . marker-or-number) (@var{name} . marker-or-number) ... )
1195 @item (@var{name} marker-or-number (@var{name} . marker-or-number) ... )
1196 One Group of tags where the group has a starting position.
1199 When you use @code{speedbar-insert-generic-list}, there are some
1200 variables you can set buffer-locally to change the behavior. The most
1201 obvious is @code{speedbar-tag-hierarchy-method}.
1202 @xref{Tag Hierarchy Methods}.
1204 @defvar speedbar-generic-list-group-expand-button-type
1205 This is the button type used for groups of tags, whether expanded
1206 or added in via a hierarchy method. Two good values are
1207 @code{curly} and @code{expandtag}. Curly is the default button, and
1208 @code{expandtag} is useful if the groups also has a position.
1211 @defvar speedbar-generic-list-tag-button-type
1212 This is the button type used for a single tag.
1213 Two good values are @code{nil} and @code{statictag}.
1214 @code{nil} is the default, and @code{statictag} has the same width as
1220 @node GNU Free Documentation License
1221 @appendix GNU Free Documentation License
1222 @include doclicense.texi
1226 @unnumbered Concept Index
1230 @c LocalWords: speedbar's xref slowbar kbd subsubsection
1231 @c LocalWords: keybindings