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