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