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