In doc, use standard American English style for e.g., etc., i.e.
[emacs.git] / doc / misc / speedbar.texi
blob1c427c0b47c2738c529d51c38a1902f7f74d7152
1 \input texinfo   @c -*-texinfo-*-
2 @setfilename ../../info/speedbar
3 @settitle Speedbar: File/Tag summarizing utility
4 @syncodeindex fn cp
6 @copying
7 Copyright @copyright{} 1999--2013 Free Software Foundation, Inc.
9 @quotation
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.''
19 @end quotation
20 @end copying
22 @dircategory Emacs misc features
23 @direntry
24 * Speedbar: (speedbar).         File/Tag summarizing utility.
25 @end direntry
27 @titlepage
28 @sp 10
29 @center @titlefont{Speedbar}
30 @sp 2
31 @center Eric Ludlam
32 @vskip 0pt plus 1 fill
33 @page
34 @vskip 0pt plus 1filll
35 @insertcopying
36 @end titlepage
38 @contents
40 @node Top, , , (dir)Top
41 @comment  node-name,  next,  previous,  up
42 @top Speedbar
44 Speedbar is a program for Emacs which can be used to summarize
45 information related to the current buffer.  Its original inspiration
46 is the `explorer' often used in modern development environments, office
47 packages, and web browsers.
49 Speedbar displays a narrow frame in which a tree view is shown.  This
50 tree view defaults to containing a list of files and directories.  Files
51 can be `expanded' to list tags inside. Directories can be expanded to
52 list the files within itself.  Each file or tag can be jumped to
53 immediately.
55 Speedbar expands upon `explorer' windows by maintaining context with the
56 user.  For example, when using the file view, the current buffer's file
57 is highlighted.  Speedbar also mimics the explorer windows by providing
58 multiple display modes.  These modes come in two flavors.  Major display
59 modes remain consistent across buffers, and minor display modes appear
60 only when a buffer of the applicable type is shown.  This allows
61 authors of other packages to provide speedbar summaries customized to
62 the needs of that mode.
64 Throughout this manual, activities are defined as `clicking on', or
65 `expanding' items.  Clicking means using @kbd{Mouse-2} on a
66 button.  Expanding refers to clicking on an expansion button to display
67 an expanded summary of the entry the expansion button is
68 on.  @xref{Basic Navigation}.
70 @ifnottex
71 @insertcopying
72 @end ifnottex
74 @menu
75 * Introduction::     Basics of speedbar.
76 * Basic Navigation:: Basics of speedbar common between all modes.
77 * File Mode::        Summarizing files.
78 * Buffer Mode::      Summarizing buffers.
79 * Minor Modes::      Additional minor modes such as Info and RMAIL.
80 * Customizing::      Changing speedbar behavior.
81 * Extending::        Extend speedbar for your own project.
82 * GNU Free Documentation License:: The license for this documentation.
83 * Index::
84 @end menu
86 @node Introduction, Basic Navigation, , Top
87 @comment  node-name,  next,  previous,  up
88 @chapter Introduction
89 @cindex introduction
91 To start using speedbar use the command @kbd{M-x speedbar RET} or
92 select it from the @samp{Options->Show/Hide} sub-menu.  This command
93 will open a new frame to summarize the local files.  On X Window
94 systems or on MS-Windows, speedbar's frame is twenty characters wide,
95 and will mimic the height of the frame from which it was started.  It
96 positions itself to the left or right of the frame you started it
97 from.
99 To use speedbar effectively, it is important to understand its
100 relationship with the frame you started it from.  This frame is the
101 @dfn{attached frame} which speedbar will use as a reference point.  Once
102 started, speedbar watches the contents of this frame, and attempts to
103 make its contents relevant to the buffer loaded into the attached
104 frame.  In addition, all requests made in speedbar that require the
105 display of another buffer will display in the attached frame.
107 When used in terminal mode, the new frame appears the same size as the
108 terminal.  Since it is not visible while working in the attached frame,
109 speedbar will save time by using the @dfn{slowbar mode}, where no tracking is
110 done until speedbar is requested to show itself (i.e., the speedbar's
111 frame becomes the selected frame).
113 @cindex @code{speedbar-get-focus}
114 The function to use when switching between frames using the keyboard is
115 @code{speedbar-get-focus}.  This function will toggle between frames, and
116 it's useful to bind it to a key in terminal mode.  @xref{Customizing}.
118 @node Basic Navigation, File Mode, Introduction, Top
119 @comment  node-name,  next,  previous,  up
120 @chapter Basic Navigation
122 Speedbar can display different types of data, and has several display
123 and behavior modes.  These modes all have a common behavior, menu
124 system, and look.  If one mode is learned, then the other modes are easy
125 to use.
127 @menu
128 * Basic Key Bindings::
129 * Basic Visuals::
130 * Mouse Bindings::
131 * Displays Submenu::
132 @end menu
134 @node Basic Key Bindings, Basic Visuals, Basic Navigation, Basic Navigation
135 @comment  node-name,  next,  previous,  up
136 @section Basic Key Bindings
137 @cindex key bindings
139 These key bindings are common across all modes:
141 @table @kbd
142 @item Q
143 @cindex quitting speedbar
144 Quit speedbar, and kill the frame.
145 @item q
146 Quit speedbar, and hide the frame.  This makes it faster to restore the
147 speedbar frame, than if you press @kbd{Q}.
148 @item g
149 @cindex refresh speedbar display
150 Refresh whatever contents are in speedbar.
151 @item t
152 @cindex slowbar mode
153 Toggle speedbar to and from slowbar mode.  In slowbar mode, frame
154 tracking is not done.
155 @item n
156 @itemx p
157 @cindex navigation
158 Move, respectively, to the next or previous item.  A summary of that
159 item will be displayed in the attached frame's minibuffer.
160 @item M-n
161 @itemx M-p
162 Move to the next or previous item in a restricted fashion.  If a list is
163 open, the cursor will skip over it.  If the cursor is in an open list,
164 it will not leave it.
165 @item C-M-n
166 @itemx C-M-p
167 Move forwards and backwards across extended groups.  This lets you
168 quickly skip over all files, directories, or other common sub-items at
169 the same current depth.
170 @item C-x b
171 Switch buffers in the attached frame.
172 @end table
174 Speedbar can handle multiple modes.  Two are provided by default.
175 These modes are File mode, and Buffers mode.  There are accelerators to
176 switch into these different modes.
178 @cindex mode switching hotkeys
179 @table @kbd
180 @item b
181 Switch into Quick Buffers mode (@pxref{Buffer Mode}).  After one use, the
182 previous display mode is restored.
183 @item f
184 Switch into File mode.
185 @item r
186 Switch back to the previous mode.
187 @end table
189 Some modes provide groups, lists and tags.  @xref{Basic Visuals}.  When
190 these are available, some additional common bindings are available.
192 @cindex common keys
193 @table @kbd
194 @item RET
195 @itemx e
196 Edit/Open the current group or tag.  This behavior is dependent on the
197 mode.  In general, files or buffers are opened in the attached frame,
198 and directories or group nodes are expanded locally.
199 @item +
200 @itemx =
201 Expand the current group, displaying sub items.
202 When used with a prefix argument, any data that may have been cached is
203 flushed.  This is similar to a power click.  @xref{Mouse Bindings}.
204 @item -
205 Contract the current group, hiding sub items.
206 @end table
208 @node Basic Visuals, Mouse Bindings, Basic Key Bindings, Basic Navigation
209 @comment  node-name,  next,  previous,  up
210 @section Basic Visuals
211 @cindex visuals
213 Speedbar has visual cues for indicating different types of data.  These
214 cues are used consistently across the different speedbar modes to make
215 them easier to interpret.
217 At a high level, in File mode, there are directory buttons, sub
218 directory buttons, file buttons, tag buttons, and expansion buttons.
219 This makes it easy to use the mouse to navigate a directory tree, and
220 quickly view files, or a summary of those files.
222 The most basic visual effect used to distinguish between these button
223 types is color and mouse highlighting.  Anything the mouse highlights
224 can be clicked on and is called a button (@pxref{Mouse Bindings}).
225 Anything not highlighted by the mouse will not be clickable.
227 Text in speedbar consists of four different types of data.  Knowing how
228 to read these textual elements will make it easier to navigate by
229 identifying the types of data available.
231 @subsubsection Groups
232 @cindex groups
234 Groups summarize information in a single line, and provide a high level
235 view of more complex systems, like a directory tree, or manual chapters.
237 Groups appear at different indentation levels, and are prefixed with a
238 @samp{+} in some sort of `box'.  The group name will summarize the
239 information within it, and the expansion box will display that
240 information inline.  In File mode, directories and files are `groups'
241 where the @samp{+} is surrounded by brackets like this:
243 @example
244 <+> include
245 <-> src
246  [+] foo.c
247 @end example
249 In this example, we see both open and closed directories, in addition to
250 a file.  The directories have a box consisting of angle brackets, and a
251 file uses square brackets.
253 In all modes, a group can be `edited' by pressing @kbd{RET}, meaning a
254 file will be opened, or a directory explicitly opened in speedbar.  A
255 group can be expanded or contracted using @kbd{+} or
256 @kbd{-}.  @xref{Basic Key Bindings}.
258 Sometimes groups may have a @samp{?} in its indicator box.  This means
259 that it is a group type, but there are no contents, or no known way of
260 extracting contents of that group.
262 When a group has been expanded, the indicator button changes from
263 @samp{+} to @samp{-}.  This indicates that the contents are being shown.
264 Click the @samp{-} button to contract the group, or hide the contents
265 currently displayed.
267 @subsubsection Tags
268 @cindex tags
270 Tags are the leaf nodes of the tree system.  Tags are generally prefixed
271 with a simple character, such as @samp{>}.  Tags can only be jumped to using
272 @kbd{RET} or @kbd{e}.
274 @subsubsection Boolean Flags
276 Sometimes a group or tag is given a boolean flag.  These flags appear as
277 extra text characters at the end of the line.  File mode uses boolean
278 flags, such as a @samp{*} to indicate that a file has been checked out
279 of a versioning system.
281 For additional flags, see
282 @c Note to self, update these to sub-nodes which are more relevant.
283 @ref{File Mode}, and @ref{Version Control}.
285 @subsubsection Unadorned Text
287 Unadorned text generally starts in column 0, without any special symbols
288 prefixing them.  In Buffers mode different buffer groups are prefixed
289 with a description of what the following buffers are (Files, scratch
290 buffers, and invisible buffers.)
292 Unadorned text will generally be colorless, and not clickable.
294 @subsubsection Color Cues
296 Each type of Group, item indicator, and label is given a different
297 color.  The colors chosen are dependent on whether the background color
298 is light or dark.
299 Of important note is that the `current item', which may be a buffer or
300 file name, is highlighted red, and underlined.
302 Colors can be customized from the group @code{speedbar-faces}.  Some
303 modes, such as for Info, will use the Info colors instead of default
304 speedbar colors as an indication of what is currently being displayed.
306 The face naming convention mirrors the File display mode.  Modes which
307 do not use files will attempt to use the same colors on analogous
308 entries.
310 @node Mouse Bindings, Displays Submenu, Basic Visuals, Basic Navigation
311 @comment  node-name,  next,  previous,  up
312 @section Mouse Bindings
313 @cindex mouse bindings
315 The mouse has become a common information navigation tool.  Speedbar
316 will use the mouse to navigate file systems, buffer lists, and other
317 data.  The different textual cues provide buttons which can be clicked
318 on (@pxref{Basic Visuals}).  Anything that highlights can be clicked on
319 with the mouse, or affected by the menu.
321 The mouse bindings are:
323 @table @kbd
324 @item Mouse-1
325 Move cursor to that location.
326 @item Mouse-2
327 @itemx Double-Mouse-1
328 Activate the current button.  @kbd{Double-Mouse-1} is called a @dfn{double
329 click} on other platforms, and is useful for windows users with two
330 button mice.
331 @c Isn't it true that with two-button mice, the right button is Mouse-2?
332 @c On GNU/Linux, the right button is Mouse-3.
333 @item S-Mouse-2
334 @itemx S-Double-Mouse-1
335 @cindex power click
336 This has the same effect as @kbd{Mouse-2}, except it is called a power
337 click.  This means that if a group with an expansion button @samp{+} is
338 clicked, any caches are flushed, and subitems re-read.  If it is a name,
339 it will be opened in a new frame.
340 @item Mouse-3
341 Activate the speedbar menu.  The item selected affects the line clicked,
342 not the line where the cursor was.
343 @item Mouse-1 @r{(mode line)}
344 Activate the menu.  This affects the item the cursor is on before the
345 click, since the mouse was not clicked on anything.
346 @item C-Mouse-1
347 Buffers sub-menu.  The buffer in the attached frame is switched.
348 @end table
350 When the mouse moves over buttons in speedbar, details of that item
351 should be displayed in the minibuffer of the attached frame.  Sometimes
352 this can contain extra information such as file permissions, or tag
353 location.
355 @node Displays Submenu, , Mouse Bindings, Basic Navigation
356 @comment  node-name,  next,  previous,  up
357 @section Displays Submenu
358 @cindex displays submenu
360 You can display different data by using different display modes.  These
361 specialized modes make it easier to navigate the relevant pieces of
362 information, such as files and directories, or buffers.
364 In the main menu, found by clicking @kbd{Mouse-3}, there is a submenu
365 labeled @samp{Displays}.  This submenu lets you easily choose between
366 different display modes.
368 The contents are modes currently loaded into emacs.  By default, this
369 would include Files, Quick Buffers, and Buffers.  Other major display
370 modes such as Info are loaded separately.
372 @node File Mode, Buffer Mode, Basic Navigation, Top
373 @comment  node-name,  next,  previous,  up
374 @chapter File Mode
375 @cindex file mode
377 File mode displays a summary of your current directory.  You can display
378 files in the attached frame, or summarize the tags found in files.  You
379 can even see if a file is checked out of a version control system, or
380 has some associated object file.
382 Advanced behavior, like copying and renaming files, is also provided.
384 @menu
385 * Directory Display::   What the display means.
386 * Hidden Files::        How to display hidden files.
387 * File Key Bindings::   Performing file operations.
388 @end menu
390 @node Directory Display, Hidden Files, File Mode, File Mode
391 @comment  node-name,  next,  previous,  up
392 @section Directory Display
393 @cindex directory display
395 There are three major sections in the display.  The first line or two is
396 the root directory speedbar is currently viewing.  You can jump to one
397 of the parent directories by clicking on the name of the directory you
398 wish to jump to.
400 Next, directories are listed.  A directory starts with the group
401 indicator button @samp{<+>}.  Clicking the directory name makes speedbar
402 load that directory as the root directory for its display.  Clicking the
403 @samp{<+>} button will list all directories and files beneath.
405 Next, files are listed.  Files start with the group indicator @samp{[+]}
406 or @samp{[?]}.  You can jump to a file in the attached frame by clicking
407 on the file name.  You can expand a file and look at its tags by
408 clicking on the @samp{[+]} symbol near the file name.
410 A typical session might look like this:
412 @example
413 ~/lisp/
414 <+> checkdoc
415 <+> eieio
416 <-> speedbar
417  [+] Makefile
418  [+] rpm.el #
419  [+] sb-gud.el #
420  [+] sb-info.el #
421  [+] sb-rmail.el #
422  [+] sb-w3.el
423  [-] speedbar.el *!
424   @{+@} Types
425   @{+@} Variables
426   @{+@} def (group)
427   @{+@} speedbar-
428  [+] speedbar.texi *
429 <+> testme
430 [+] align.el
431 [+] autoconf.el
432 @end example
434 In this example, you can see several directories.  The directory
435 @file{speedbar} has been opened inline.  Inside the directory
436 @file{speedbar}, the file @file{speedbar.el} has its tags exposed.
437 These tags are extensive, and they are summarized into tag groups.
439 Files get additional boolean flags associated with them.  Valid flags are:
441 @cindex file flags
442 @table @code
443 @item *
444 This file has been checked out of a version control
445 system.  @xref{Version Control}.
446 @cindex @code{speedbar-obj-alist}
447 @item #
448 This file has an up to date object file associated with it.  The
449 variable @code{speedbar-obj-alist} defines how speedbar determines this
450 value.
451 @item !
452 This file has an out of date object file associated with it.
453 @end table
455 A Tag group is prefixed with the symbol @samp{@{+@}}.  Clicking this
456 symbol will show all symbols that have been organized into that group.
457 Different types of files have unique tagging methods as defined by their
458 major mode.  Tags are generated with either the @code{imenu} package, or
459 through the @code{etags} interface.
461 Tag groups are defined in multiple ways which make it easier to find the
462 tag you are looking for.  Imenu keywords explicitly create groups, and
463 speedbar will automatically create groups if tag lists are too long.
465 In our example, Imenu created the groups @samp{Types} and
466 @samp{Variables}.  All remaining top-level symbols are then regrouped
467 based on the variable @code{speedbar-tag-hierarchy-method}.  The
468 subgroups @samp{def} and @samp{speedbar-} are groupings where the first
469 few characters of the given symbols are specified in the group name.
470 Some group names may say something like @samp{speedbar-t to speedbar-v},
471 indicating that all symbols which alphabetically fall between those
472 categories are included in that sub-group.  @xref{Tag Hierarchy Methods}.
474 @node Hidden Files, File Key Bindings, Directory Display, File Mode
475 @comment  node-name,  next,  previous,  up
476 @section Hidden Files
477 @cindex hidden files
479 On GNU and Unix systems, a hidden file is a file whose name starts
480 with a period.  They are hidden from a regular directory listing
481 because the user is not generally interested in them.
483 In speedbar, a hidden file is a file which isn't very interesting and
484 might prove distracting to the user.  Any uninteresting files are
485 removed from the File display.  There are two levels of uninterest in
486 speedbar.  The first level of uninterest are files which have no
487 expansion method, or way of extracting tags.  The second level is any
488 file that matches the same pattern used for completion in
489 @code{find-file}.  This is derived from the variable
490 @code{completion-ignored-extensions}.
492 You can toggle the display of uninteresting files from the toggle menu
493 item @samp{Show All Files}.  This will display all level one hidden files.
494 These files will be shown with a @samp{?} indicator.  Level 2 hidden
495 files will still not be shown.
497 Object files fall into the category of level 2 hidden files.  You can
498 determine their presence by the @samp{#} and @samp{!} file indicators.
499 @xref{Directory Display}.
501 @node File Key Bindings, , Hidden Files, File Mode
502 @comment  node-name,  next,  previous,  up
503 @section File Key Bindings
504 @cindex file key bindings
506 File mode has key bindings permitting different file system operations
507 such as copy or rename.  These commands all operate on the @dfn{current
508 file}.  In this case, the current file is the file at point, or clicked
509 on when pulling up the menu.
511 @table @kbd
512 @item U
513 Move the entire speedbar display up one directory.
514 @item I
515 Display information in the minibuffer about this line.  This is the same
516 information shown when navigating with @kbd{n} and @kbd{p}, or moving
517 the mouse over an item.
518 @item B
519 Byte compile the Emacs Lisp file on this line.
520 @item L
521 Load the Emacs Lisp file on this line.  If a @file{.elc} file exists,
522 optionally load that.
523 @item C
524 Copy the current file to some other location.
525 @item R
526 Rename the current file, possibly moving it to some other location.
527 @item D
528 Delete the current file.
529 @item O
530 Delete the current file's object file.  Use the symbols @samp{#} and
531 @samp{!} to determine if there is an object file available.
532 @end table
534 One menu item toggles the display of all available files.  By default,
535 only files which Emacs understands, and knows how to convert into a tag
536 list, are shown.  By showing all files, additional files such as text files are
537 also displayed, but they are prefixed with the @samp{[?]} symbol.  This
538 means that it is a file, but Emacs doesn't know how to expand it.
540 @node Buffer Mode, Minor Modes, File Mode, Top
541 @comment  node-name,  next,  previous,  up
542 @chapter Buffer Mode
543 @cindex buffer mode
545 Buffer mode is very similar to File mode, except that instead of
546 tracking the current directory and all files available there, the
547 current list of Emacs buffers is shown.
549 These buffers can have their tags expanded in the same way as files,
550 and uses the same unknown file indicator (@pxref{File Mode}).
552 Buffer mode does not have file operation bindings, but the following
553 buffer specific key bindings are available:
555 @table @kbd
556 @item k
557 Kill this buffer.  Do not touch its file.
558 @item r
559 Revert this buffer, reloading from disk.
560 @end table
562 In addition to Buffer mode, there is also Quick Buffer mode.  In fact,
563 Quick Buffers is bound to the @kbd{b} key.  The only difference between
564 Buffers and Quick Buffers is that after one operation  is performed
565 which affects the attached frame, the display is immediately reverted to
566 the last displayed mode.
568 Thus, if you are in File mode, and you need quick access to a buffer,
569 press @kbd{b}, click on the buffer you want, and speedbar will revert
570 back to File mode.
572 @node Minor Modes, Customizing, Buffer Mode, Top
573 @comment  node-name,  next,  previous,  up
574 @chapter Minor Display Modes
575 @cindex minor display modes
577 For some buffers, a list of files and tags makes no sense.  This could
578 be because files are not currently in reference (such as web pages), or
579 that the files you might be interested have special properties (such as
580 email folders.)
582 In these cases, a minor display mode is needed.  A minor display mode
583 will override any major display mode currently being displayed for the
584 duration of the specialized buffer's use.  Minor display modes
585 will follow the general rules of their major counterparts in terms of
586 key bindings and visuals, but will have specialized behaviors.
588 @menu
589 * RMAIL::  Managing folders.
590 * Info::   Browsing topics.
591 * GDB::    Watching expressions or managing the current
592             stack trace.
593 @end menu
595 @node RMAIL, Info, Minor Modes, Minor Modes
596 @comment  node-name,  next,  previous,  up
597 @section RMAIL
598 @cindex RMAIL
600 When using RMAIL, speedbar will display two sections.  The first is a
601 layer one reply button.  Clicking here will initialize a reply buffer
602 showing only this email address in the @samp{To:} field.
604 The second section lists all RMAIL folders in the same directory as your
605 main RMAIL folder.  The general rule is that RMAIL folders always appear
606 in all caps, or numbers.  It is possible to save mail in folders with
607 lower case letters, but there is no clean way of detecting such RMAIL folders
608 without opening them all.
610 Each folder can be visited by clicking the name.  You can move mail from
611 the current RMAIL folder into a different folder by clicking the
612 @samp{<M>} button.  The @samp{M} stands for Move.
614 In this way you can manage your existing RMAIL folders fairly easily
615 using the mouse.
617 @node Info, GDB, RMAIL, Minor Modes
618 @comment  node-name,  next,  previous,  up
619 @section Info
620 @cindex Info
622 When browsing Info files, all local relevant information is displayed in
623 the info buffer and a topical high-level view is provided in speedbar.
624 All top-level info nodes are shown in the speedbar frame, and can be
625 jumped to by clicking the name.
627 You can open these nodes with the @samp{[+]} button to see what sub-topics
628 are available.  Since these sub-topics are not examined until you click
629 the @samp{[+]} button, sometimes a @samp{[?]} will appear when you click on
630 a @samp{[+]}, indicating that there are no sub-topics.
632 @node GDB, , Info, Minor Modes
633 @comment  node-name,  next,  previous,  up
634 @section GDB
635 @cindex gdb
636 @cindex gud
638 You can debug an application with GDB in Emacs using graphical mode or
639 text command mode (@pxref{GDB Graphical Interface,,, emacs, The
640 extensible self-documenting text editor}).
642 If you are using graphical mode you can see how selected variables
643 change each time your program stops (@pxref{Watch Expressions,,,
644 emacs, The extensible self-documenting text editor}).
646 If you are using text command mode, speedbar can show
647 you the current stack when the current buffer is the @file{*gdb*}
648 buffer.  Usually, it will just report that there is no stack, but when
649 the application is stopped, the current stack will be shown.
651 You can click on any stack element and gdb will move to that stack
652 level.  You can then check variables local to that level at the GDB
653 prompt.
655 @node Customizing, Extending, Minor Modes, Top
656 @comment  node-name,  next,  previous,  up
657 @chapter Customizing
658 @cindex customizing
660 Speedbar is highly customizable, with a plethora of control elements.
661 Since speedbar is so visual and reduces so much information, this is an
662 important aspect of its behavior.
664 In general, there are three custom groups you can use to quickly modify
665 speedbar's behavior.
667 @table @code
668 @item speedbar
669 Basic speedbar behaviors.
670 @item speedbar-vc
671 Customizations regarding version control handling.
672 @item speedbar-faces
673 Customize speedbar's many colors and fonts.
674 @end table
676 @menu
677 * Frames and Faces::        Visible behaviors.
678 * Tag Hierarchy Methods::   Customizing how tags are displayed.
679 * Version Control::         Adding new VC detection modes.
680 * Hooks::                   The many hooks you can use.
681 @end menu
683 @node Frames and Faces, Tag Hierarchy Methods, Customizing, Customizing
684 @comment  node-name,  next,  previous,  up
685 @section Frames and Faces
686 @cindex faces
687 @cindex frame parameters
689 There are several faces speedbar generates to provide a consistent
690 color scheme across display types.  You can customize these faces using
691 your favorite method.  They are:
693 @table @asis
694 @cindex @code{speedbar-button-face}
695 @item speedbar-button-face
696 Face used on expand/contract buttons.
697 @cindex @code{speedbar-file-face}
698 @item speedbar-file-face
699 Face used on Files.  Should also be used on non-directory like nodes.
700 @cindex @code{speedbar-directory-face}
701 @item speedbar-directory-face
702 Face used for directories, or nodes which consist of groups of other nodes.
703 @cindex @code{speedbar-tag-face}
704 @item speedbar-tag-face
705 Face used for tags in a file, or for leaf items.
706 @cindex @code{speedbar-selected-face}
707 @item speedbar-selected-face
708 Face used to highlight the selected item.  This would be the current
709 file being edited.
710 @cindex @code{speedbar-highlight-face}
711 @item speedbar-highlight-face
712 Face used when the mouse passes over a button.
713 @end table
715 You can also customize speedbar's initial frame parameters.  How this is
716 accomplished is dependent on your platform being Emacs or XEmacs.
718 @cindex @code{speedbar-frame-parameters}, Emacs
719 In Emacs, change the alist @code{speedbar-frame-parameters}.  This
720 variable is used to set up initial details.  Height is also
721 automatically added when speedbar is created, though you can override
724 @cindex @code{speedbar-frame-plist}, XEmacs
725 In XEmacs, change the plist @code{speedbar-frame-plist}.  This is the
726 XEmacs way of doing the same thing.
728 @node Tag Hierarchy Methods, Version Control, Frames and Faces, Customizing
729 @comment  node-name,  next,  previous,  up
730 @section Tag Hierarchy Methods
731 @cindex tag hierarchy
732 @cindex tag groups
733 @cindex tag sorting
735 When listing tags within a file, it is possible to get an annoyingly
736 long list of entries.  Imenu (which generates the tag list in Emacs)
737 will group some classes of items automatically.   Even here, however,
738 some tag groups can be quite large.
740 @cindex @code{speedbar-tag-hierarchy-method}
741 To solve this problem, tags can be grouped into logical units through a
742 hierarchy processor.  The specific variable to use is
743 @code{speedbar-tag-hierarchy-method}.  There are several methods that
744 can be applied in any order.  They are:
746 @table @code
747 @cindex @code{speedbar-trim-words-tag-hierarchy}
748 @item speedbar-trim-words-tag-hierarchy
749 Find a common prefix for all elements of a group, and trim it off.
750 @cindex @code{speedbar-prefix-group-tag-hierarchy}
751 @item speedbar-prefix-group-tag-hierarchy
752 If a group is too large, place sets of tags into bins based on common
753 prefixes.
754 @cindex @code{speedbar-simple-group-tag-hierarchy}
755 @item speedbar-simple-group-tag-hierarchy
756 Take all items in the top level list not in a group, and stick them into
757 a @samp{Tags} group.
758 @cindex @code{speedbar-sort-tag-hierarchy}
759 @item speedbar-sort-tag-hierarchy
760 Sort all items, leaving groups on top.
761 @end table
763 You can also add your own functions to reorganize tags as you see fit.
765 Some other control variables are:
767 @table @code
768 @cindex @code{speedbar-tag-group-name-minimum-length}
769 @item speedbar-tag-group-name-minimum-length
770 Default value: 4.
772 The minimum length of a prefix group name before expanding.  Thus, if
773 the @code{speedbar-tag-hierarchy-method} includes
774 @code{speedbar-prefix-group-tag-hierarchy} and one such group's common
775 characters is less than this number of characters, then the group name
776 will be changed to the form of:
778 @example
779 worda to wordb
780 @end example
782 instead of just
784 @example
785 word
786 @end example
788 This way we won't get silly looking listings.
790 @cindex @code{speedbar-tag-split-minimum-length}
791 @item speedbar-tag-split-minimum-length
792 Default value: 20.
794 Minimum length before we stop trying to create sub-lists in tags.
795 This is used by all tag-hierarchy methods that break large lists into
796 sub-lists.
798 @cindex @code{speedbar-tag-regroup-maximum-length}
799 @item speedbar-tag-regroup-maximum-length
800 Default value: 10.
802 Maximum length of submenus that are regrouped.
803 If the regrouping option is used, then if two or more short subgroups
804 are next to each other, then they are combined until this number of
805 items is reached.
806 @end table
808 @node Version Control, Hooks, Tag Hierarchy Methods, Customizing
809 @comment  node-name,  next,  previous,  up
810 @section Version Control
811 @cindex version control
812 @cindex vc extensions
814 When using the file mode in speedbar, information regarding a version
815 control system adds small details to the display.  If a file is in a
816 version control system, and is ``checked out'' or ``locked'' locally, an
817 asterisk @samp{*} appears at the end of the file name.  In addition,
818 the directory name for Version Control systems are left out of the
819 speedbar display.
821 @cindex @code{speedbar-directory-unshown-regexp}
822 You can easily add new version control systems into speedbar's detection
823 scheme.  To make a directory ``disappear'' from the list, use the variable
824 @code{speedbar-directory-unshown-regexp}.
826 @cindex @code{speedbar-vc-path-enable-hook}
827 Next, you need to write entries for two hooks.  The first is
828 @code{speedbar-vc-path-enable-hook} which will enable a VC check in the
829 current directory for the group of files being checked.  Your hook
830 function should take one parameter (the directory to check) and return
831 @code{t} if your VC method is in control here.
833 @cindex @code{speedbar-vc-in-control-hook}
834 The second function is @code{speedbar-vc-in-control-hook}.  This hook
835 takes two parameters, the @var{path} of the file to check, and the
836 @var{file} name.  Return @code{t} if you want to have the asterisk
837 placed near this file.
839 @cindex @code{speedbar-vc-indicator}
840 Lastly, you can change the VC indicator using the variable
841 @code{speedbar-vc-indicator}, and specify a single character string.
843 @node Hooks, , Version Control, Customizing
844 @comment  node-name,  next,  previous,  up
845 @section Hooks
846 @cindex hooks
848 There are several hooks in speedbar allowing custom behaviors to be
849 added.  Available hooks are:
851 @table @code
852 @cindex @code{speedbar-visiting-file-hook}
853 @item speedbar-visiting-file-hook
854 Hooks run when speedbar visits a file in the selected frame.
855 @cindex @code{speedbar-visiting-tag-hook}
856 @item speedbar-visiting-tag-hook
857 Hooks run when speedbar visits a tag in the selected frame.
858 @cindex @code{speedbar-load-hook}
859 @item speedbar-load-hook
860 Hooks run when speedbar is loaded.
861 @cindex @code{speedbar-reconfigure-keymaps-hook}
862 @item speedbar-reconfigure-keymaps-hook
863 Hooks run when the keymaps are regenerated.  Keymaps are reconfigured
864 whenever modes change.  This will let you add custom key bindings.
865 @cindex @code{speedbar-before-popup-hook}
866 @item speedbar-before-popup-hook
867 Hooks called before popping up the speedbar frame.
868 New frames are often popped up when ``power clicking'' on an item to view
870 @cindex @code{speedbar-before-delete-hook}
871 @item speedbar-before-delete-hook
872 Hooks called before deleting or hiding the speedbar frame.
873 @cindex @code{speedbar-mode-hook}
874 @item speedbar-mode-hook
875 Hooks called after creating a speedbar buffer.
876 @cindex @code{speedbar-timer-hook}
877 @item speedbar-timer-hook
878 Hooks called after running the speedbar timer function.
879 @cindex @code{speedbar-scanner-reset-hook}
880 @item speedbar-scanner-reset-hook
881 Hook called whenever generic scanners are reset.
882 Set this to implement your own scanning or rescan safe functions with
883 state data.
884 @end table
886 @node Extending, GNU Free Documentation License, Customizing, Top
887 @comment  node-name,  next,  previous,  up
888 @chapter Extending
889 @cindex extending
891 Speedbar can run different types of Major display modes such as Files
892 (@pxref{File Mode}), and Buffers (@pxref{Buffer Mode}).  It can also manage
893 different minor display modes for use with buffers handling specialized
894 data.
896 These major and minor display modes are handled through an extension
897 system which permits specialized keymaps and menu extensions, in
898 addition to a unique rendering function.  You can also specify a wide
899 range of tagging functions.  The default uses @code{imenu}, but new
900 tagging methods can be easily added.  In this chapter, you will
901 learn how to write your own major or minor display modes, and how to
902 create specialized tagging functions.
904 @menu
905 * Minor Display Modes::    How to create a minor display mode.
906 * Major Display Modes::    How to create a major display mode.
907 * Tagging Extensions::     How to create your own tagging methods.
908 * Creating a display::     How to insert buttons and hierarchies.
909 @end menu
911 @node Minor Display Modes, Major Display Modes, Extending, Extending
912 @section Minor Display Modes
913 @cindex create minor display mode
915 A @dfn{minor display mode} is a mode useful when using a specific type of
916 buffer.  This mode might not be useful for any other kind of data or
917 mode, or may just be more useful that a files or buffers based mode when
918 working with a specialized mode.
920 Examples that already exist for speedbar include RMAIL, Info, and gdb.
921 These modes display information specific to the major mode shown in the
922 attached frame.
924 To enable a minor display mode in your favorite Major mode, follow these
925 steps.  The string @samp{@var{name}} is the name of the major mode being
926 augmented with speedbar.
928 @enumerate
929 @item
930 Create the keymap variable @code{@var{name}-speedbar-key-map}.
932 @item
933 Create a function, named whatever you like, which assigns values into your
934 keymap.  Use this command to create the keymap before assigning
935 bindings:
937 @smallexample
938     (setq @var{name}-speedbar-key-map (speedbar-make-specialized-keymap))
939 @end smallexample
941 This function creates a special keymap for use in speedbar.
943 @item
944 Call your install function, or assign it to a hook like this:
946 @smallexample
947 (if (featurep 'speedbar)
948     (@var{name}-install-speedbar-variables)
949   (add-hook 'speedbar-load-hook '@var{name}-install-speedbar-variables))
950 @end smallexample
952 @item
953 Create an easymenu compatible vector named
954 @code{@var{name}-speedbar-menu-items}.  This will be spliced into
955 speedbar's control menu.
957 @item
958 Create a function called @code{@var{name}-speedbar-buttons}.  This function
959 should take one variable, which is the buffer for which it will create
960 buttons.   At this time @code{(current-buffer)} will point to the
961 uncleared speedbar buffer.
962 @end enumerate
964 When writing @code{@var{name}-speedbar-buttons}, the first thing you will
965 want to do is execute a check to see if you need to re-create your
966 display.  If it needs to be cleared, you need to erase the speedbar
967 buffer yourself, and start drawing buttons.  @xref{Creating a display}.
969 @node Major Display Modes, Tagging Extensions, Minor Display Modes, Extending
970 @section Major Display Modes
971 @cindex create major display mode
973 Creating a @dfn{Major Display Mode} for speedbar requires authoring a keymap,
974 an easy-menu segment, and writing several functions.  These items can be
975 given any name, and are made the same way as in a minor display mode
976 (@pxref{Minor Display Modes}).  Once this is done, these items need to be
977 registered.
979 Because this setup activity may or may not have speedbar available when
980 it is being loaded, it is necessary to create an install function.  This
981 function should create and initialize the keymap, and add your
982 expansions into the customization tables.
984 @cindex @code{speedbar-make-specialized-keymap}
985 When creating the keymap, use the function
986 @code{speedbar-make-specialized-keymap} instead of other keymap making
987 functions.  This will provide you with the initial bindings needed.
988 Some common speedbar functions you might want to bind are:
990 @table @code
991 @cindex @code{speedbar-edit-line}
992 @item speedbar-edit-line
993 Edit the item on the current line.
994 @cindex @code{speedbar-expand-line}
995 @item speedbar-expand-line
996 Expand the item under the cursor.
997 With a numeric argument (@kbd{C-u}), flush cached data before expanding.
998 @cindex @code{speedbar-contract-line}
999 @item speedbar-contract-line
1000 Contract the item under the cursor.
1001 @end table
1003 @cindex @code{speedbar-line-path}
1004 These function require that function @code{speedbar-line-path} be
1005 correctly overloaded to work.
1007 Next, register your extension like this;
1009 @example
1010   (speedbar-add-expansion-list '("MyExtension"
1011                                  MyExtension-speedbar-menu-items
1012                                  MyExtension-speedbar-key-map
1013                                  MyExtension-speedbar-buttons))
1014 @end example
1016 There are no limitations to the names you use.
1018 The first parameter is the string representing your display mode.
1019 The second parameter is a variable name containing an easymenu compatible
1020 menu definition.  This will be stuck in the middle of speedbar's menu.
1021 The third parameter is the variable name containing the keymap we
1022 discussed earlier.
1023 The last parameter is a function which draws buttons for your mode.
1024 This function must take two parameters.  The directory currently being
1025 displayed, and the depth at which you should start rendering buttons.
1026 The function will then draw (starting at the current cursor position)
1027 any buttons deemed necessary based on the input parameters.
1028 @xref{Creating a display}.
1030 Next, you need to register function overrides.  This may look something
1031 like this:
1033 @example
1034 (speedbar-add-mode-functions-list
1035  '("MYEXTENSION"
1036    (speedbar-item-info . MyExtension-speedbar-item-info)
1037    (speedbar-line-path . MyExtension-speedbar-line-path)))
1038 @end example
1040 The first element in the list is the name of you extension.  The second
1041 is an alist of functions to overload.  The function to overload is
1042 first, followed by what you want called instead.
1044 For @code{speedbar-line-path} your function should take an optional DEPTH
1045 parameter.  This is the starting depth for heavily indented lines.  If
1046 it is not provided, you can derive it like this:
1048 @example
1049 (save-match-data
1050   (if (not depth)
1051       (progn
1052         (beginning-of-line)
1053         (looking-at "^\\([0-9]+\\):")
1054         (setq depth (string-to-int (match-string 1)))))
1055 @end example
1057 @noindent
1058 where the depth is stored as invisible text at the beginning of each
1059 line.
1061 The path returned should be the full path name of the file associated
1062 with that line.  If the cursor is on a tag, then the file containing
1063 that tag should be returned.  This is critical for built in file based
1064 functions to work (meaning less code for you to write).  If your display
1065 does not deal in files, you do not need to overload this function.
1067 @cindex @code{speedbar-item-info}
1068 The function @code{speedbar-item-info}, however, is very likely to need
1069 overloading.  This function takes no parameters and must derive a text
1070 summary to display in the minibuffer.
1072 There are several helper functions you can use if you are going to use
1073 built in tagging.  These functions can be @code{or}ed since each one
1074 returns non-@code{nil} if it displays a message.  They are:
1076 @table @code
1077 @cindex @code{speedbar-item-info-file-helper}
1078 @item speedbar-item-info-file-helper
1079 This takes an optional @var{filename} parameter.  You can derive your own
1080 filename, or it will derive it using a (possibly overloaded) function
1081 @code{speedbar-line-file}.  It shows details about a file.
1082 @cindex @code{speedbar-item-info-tag-helper}
1083 @item speedbar-item-info-tag-helper
1084 If the current line is a tag, then display information about that tag,
1085 such as its parent file, and location.
1086 @end table
1088 Your custom function might look like this:
1090 @example
1091 (defun MyExtension-item-info ()
1092   "Display information about the current line."
1093   (or (speedbar-item-info-tag-helper)
1094       (message "Interesting detail.")))
1095 @end example
1097 Once you have done all this, speedbar will show an entry in the
1098 @samp{Displays} menu declaring that your extension is available.
1100 @node Tagging Extensions, Creating a display, Major Display Modes, Extending
1101 @section Tagging Extensions
1103 It is possible to create new methods for tagging files in speedbar.
1104 To do this, you need two basic functions, one function to fetch the
1105 tags from a buffer, the other to insert them below the filename.
1107 @defun my-fetch-dynamic-tags file
1108 Parse @var{file} for a list of tags.  Return the list, or @code{t} if there was
1109 an error.
1110 @end defun
1112 The non-error return value can be anything, as long as it can be
1113 inserted by its paired function:
1115 @defun my-insert-tag-list level lst
1116 Insert a list of tags @var{lst} started at indentation level
1117 @var{level}.  Creates buttons for each tag, and provides any other
1118 display information required.
1119 @end  defun
1121 @cindex @code{speedbar-create-tag-hierarchy}
1122 It is often useful to use @code{speedbar-create-tag-hierarchy} on your
1123 token list.  See that function's documentation for details on what it
1124 requires.
1126 @cindex @code{speedbar-dynamic-tags-function-list}
1127 Once these two functions are written, modify the variable
1128 @code{speedbar-dynamic-tags-function-list} to include your parser at the
1129 beginning, like this:
1131 @example
1132 (add-to-list 'speedbar-dynamic-tags-function-list
1133              '(my-fetch-dynamic-tags . my-insert-tag-list))
1134 @end example
1136 If your parser is only good for a few types of files, make sure that it
1137 is either a buffer local modification, or that the tag generator returns
1138 @code{t} for non valid buffers.
1140 @node Creating a display, , Tagging Extensions, Extending
1141 @section Creating a display
1142 @cindex creating a display
1144 Rendering a display in speedbar is completely flexible.  When your
1145 button function is called, see @ref{Minor Display Modes}, and @ref{Major
1146 Display Modes}, you have control to @code{insert} anything you want.
1148 The conventions allow almost anything to be inserted, but several helper
1149 functions are provided to make it easy to create the standardized
1150 buttons.
1152 To understand the built in functions, each `button' in speedbar consists
1153 of four important pieces of data.  The text to be displayed, token
1154 data to be associated with the text, a function to call, and some face to
1155 display it in.
1157 When a function is provided, then that text becomes mouse activated,
1158 meaning the mouse will highlight the text.
1160 Additionally, for data which can form deep trees, each line is given a
1161 depth which indicates how far down the tree it is.  This information is
1162 stored in invisible text at the beginning of each line, and is used by
1163 the navigation commands.
1165 @defun speedbar-insert-button text face mouse function &optional token prevline
1166 This function inserts one button into the current location.
1167 @var{text} is the text to insert.  @var{face} is the face in which it
1168 will be displayed.   @var{mouse} is the face to display over the text
1169 when the mouse passes over it.  @var{function} is called whenever the
1170 user clicks on the text.
1172 The optional argument @var{token} is extra data to associated with the
1173 text.  Lastly @var{prevline} should be non-@code{nil} if you want this line to
1174 appear directly after the last button which was created instead of on
1175 the next line.
1176 @end defun
1178 @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
1180 Create a tag line with @var{exp-button-type} for the small expansion
1181 button.  This is the button that expands or contracts a node (if
1182 applicable), and @var{exp-button-char} the character in it (@samp{+},
1183 @samp{-}, @samp{?}, etc.).  @var{exp-button-function} is the function
1184 to call if it's clicked on.  Button types are @code{bracket},
1185 @code{angle}, @code{curly}, @code{expandtag}, @code{statictag}, and
1186 @code{nil}.  @var{exp-button-data} is extra data attached to the text
1187 forming the expansion button.
1189 Next, @var{tag-button} is the text of the tag.
1190 @var{tag-button-function} is the function to call if clicked on, and
1191 @var{tag-button-data} is the data to attach to the text field (such a
1192 tag positioning, etc.).  @var{tag-button-face} is a face used for this
1193 type of tag.
1195 Lastly, @var{depth} shows the depth of expansion.
1197 This function assumes that the cursor is in the speedbar window at the
1198 position to insert a new item, and that the new item will end with a CR.
1199 @end defun
1201 @defun speedbar-insert-generic-list level list expand-fun find-fun
1203 At @var{level}, (the current indentation level desired) insert a generic
1204 multi-level alist @var{list}.  Associations with lists get @samp{@{+@}}
1205 tags (to expand into more nodes) and those with positions or other data
1206 just get a @samp{>} as the indicator.  @samp{@{+@}} buttons will have the
1207 function @var{expand-fun} and the token is the @code{cdr} list.  The
1208 token name will have the function @var{find-fun} and not token.
1210 Each element of the list can have one of these forms:
1212 @table @code
1213 @item (@var{name} . marker-or-number)
1214 One tag at this level.
1215 @item (@var{name} (@var{name} . marker-or-number) (@var{name} . marker-or-number) ... )
1216 One group of tags.
1217 @item (@var{name} marker-or-number (@var{name} . marker-or-number) ... )
1218 One Group of tags where the group has a starting position.
1219 @end table
1221 When you use @code{speedbar-insert-generic-list}, there are some
1222 variables you can set buffer-locally to change the behavior.  The most
1223 obvious is @code{speedbar-tag-hierarchy-method}.
1224 @xref{Tag Hierarchy Methods}.
1226 @defvar speedbar-generic-list-group-expand-button-type
1227 This is the button type used for groups of tags, whether expanded
1228 or added in via a hierarchy method.  Two good values are
1229 @code{curly} and @code{expandtag}.  Curly is the default button, and
1230 @code{expandtag} is useful if the groups also has a position.
1231 @end defvar
1233 @defvar speedbar-generic-list-tag-button-type
1234 This is the button type used for a single tag.
1235 Two good values are @code{nil} and @code{statictag}.
1236 @code{nil} is the default, and @code{statictag} has the same width as
1237 @code{expandtag}.
1238 @end defvar
1240 @end defun
1242 @node GNU Free Documentation License, Index, Extending, Top
1243 @appendix GNU Free Documentation License
1244 @include doclicense.texi
1247 @node Index, , GNU Free Documentation License, Top
1248 @comment  node-name,  next,  previous,  up
1249 @unnumbered Concept Index
1250 @printindex cp
1252 @bye
1253 @c  LocalWords:  speedbar's xref slowbar kbd subsubsection
1254 @c  LocalWords:  keybindings