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