annotate lisp/utils/speedbar.el @ 151:59463afc5666 r20-3b2

Import from CVS: tag r20-3b2
author cvs
date Mon, 13 Aug 2007 09:37:19 +0200
parents 4be1180a9e89
children 85ec50267440
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1 ;;; speedbar - quick access to files and tags
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1996 Eric M. Ludlam
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
4 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
5 ;;; Author: Eric M. Ludlam <zappo@gnu.ai.mit.edu>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
6 ;;; RCS: $Id: speedbar.el,v 1.1 1997/02/17 06:40:14 steve Exp $
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
7 ;;; Version: 0.3.1
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
8 ;;; Keywords: file, tags, tools
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
9 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
10 ;;; This program is free software; you can redistribute it and/or modify
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
11 ;;; it under the terms of the GNU General Public License as published by
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
12 ;;; the Free Software Foundation; either version 2, or (at your option)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
13 ;;; any later version.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
14 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
15 ;;; This program is distributed in the hope that it will be useful,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
18 ;;; GNU General Public License for more details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
19 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
20 ;;; You should have received a copy of the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
21 ;;; along with this program; if not, you can either send email to this
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
22 ;;; program's author (see below) or write to:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
23 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
24 ;;; The Free Software Foundation, Inc.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
25 ;;; 675 Mass Ave.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
26 ;;; Cambridge, MA 02139, USA.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
27 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
28 ;;; Please send bug reports, etc. to zappo@gnu.ai.mit.edu.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
29 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
30
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
31 ;;; Commentary:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
32 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
33 ;;; The speedbar provides a frame in which files, and locations in
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
34 ;;; files are displayed. These items can be clicked on with mouse-2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
35 ;;; in order to make the last active frame display that file location.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
36 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
37 ;;; If you want to choose it from a menu or something, do this:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
38 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
39 ;;; (autoload 'speedbar-frame-mode "speedbar" "Popup a speedbar frame" t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
40 ;;; (define-key-after (lookup-key global-map [menu-bar tools])
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
41 ;;; [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar])
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
42 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
43 ;;; To activate speedbar without the menu, type: M-x speedbar-frame-mode RET
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
44 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
45 ;;; Once a speedbar frame is active, it takes advantage of idle time
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
46 ;;; to keep it's contents updated. The contents is usually a list of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
47 ;;; files in the directory of the currently active buffer. When
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
48 ;;; applicable, tags in the active file can be expanded.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
49 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
50 ;;; Speedbar uses multiple methods for creating tags to jump to.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
51 ;;; When the variable `speedbar-use-imenu-package' is set, then
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
52 ;;; speedbar will first try to use imenu to get tags. If the mode of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
53 ;;; the buffer doesn't support imenu, then etags is used. Using Imenu
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
54 ;;; has the advantage that tags are cached, so opening and closing
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
55 ;;; tags lists is faster. Speedbar-imenu will also load the file into
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
56 ;;; a non-selected buffer so clicking the file later will be faster.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
57 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
58 ;;; To add new files types into the speedbar, modify
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
59 ;;; `speedbar-file-regexp' to include the extension of the file type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
60 ;;; you wish to include. If speedbar complains that the file type is
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
61 ;;; not supported, that means there is no built in support from imenu,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
62 ;;; and the etags part wasn't set up right.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
63 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
64 ;;; To add new file types to imenu, see the documentation in the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
65 ;;; file imenu.el that comes with emacs. To add new file types which
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
66 ;;; etags supports, you need to modify the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
67 ;;; `speedbar-fetch-etags-parse-list'. This variable is an
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
68 ;;; association list with each element of the form: (extension-regex
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
69 ;;; . parse-one-line) The extension-regex would be something like
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
70 ;;; "\\.c$" for a .c file, and the parse-one-line would be either a
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
71 ;;; regular expression where match tag 1 is the element you wish
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
72 ;;; displayed as a tag. If you need to do something more complex,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
73 ;;; then you can also write a function which parses one line, and put
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
74 ;;; its symbol there instead.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
75 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
76 ;;; If the updates are going to slow for you, modify the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
77 ;;; `speedbar-update-speed' to a longer idle time before updates.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
78 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
79 ;;; If you navigate directories, you will probably notice that you
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
80 ;;; will navigate to a directory which is eventually replaced after
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
81 ;;; you go back to editing a file (unless you pull up a new file.)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
82 ;;; The delay time before this happens is in
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
83 ;;; `speedbar-navigating-speed', and defaults to 20 seconds.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
84 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
85 ;;; XEmacs users may want to change the default timeouts for
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
86 ;;; `speedbar-update-speed' to something longer as XEmacs doesn't have
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
87 ;;; idle timers, the speedbar timer keeps going off arbitrarilly while
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
88 ;;; you're typing. It's quite pesky.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
89 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
90 ;;; To get speedbar-configure-faces to work, you will need to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
91 ;;; download my eieio package from my ftp site.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
92 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
93 ;;; EIEIO is NOT required when using speedbar. It is ONLY needed
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
94 ;;; if you want to use a fancy dialog face editor for speedbar.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
95
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
96 ;;; Speedbar updates can be found at:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
97 ;;; ftp://ftp.ultranet.com/pub/zappo/speedbar.*.el
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
98 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
99
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
100 ;;; HISTORY:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
101 ;;; 0.1 Initial Revision
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
102 ;;; 0.2 Fixed problem with x-pointer-shape causing future frames not
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
103 ;;; to be created.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
104 ;;; Fixed annoying habit of `speedbar-update-contents' to make
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
105 ;;; it possible to accidentally kill the speedbar buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
106 ;;; Clicking directory names now only changes the contents of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
107 ;;; the speedbar, and does not cause a dired mode to appear.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
108 ;;; Clicking the <+> next to the directory does cause dired to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
109 ;;; be run.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
110 ;;; Added XEmacs support, which means timer support moved to a
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111 ;;; platform independant call.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
112 ;;; Added imenu support. Now modes are supported by imenu
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
113 ;;; first, and etags only if the imenu call doesn't work.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
114 ;;; Imenu is a little faster than etags, and is more emacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
115 ;;; friendly.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
116 ;;; Added more user control variables described in the commentary.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
117 ;;; Added smart recentering when nodes are opened and closed.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
118 ;;; 0.3 x-pointer-shape fixed for emacs 19.35, so I put that check in.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
119 ;;; Added invisible codes to the beginning of each line.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
120 ;;; Added list aproach to node expansion for easier addition of new
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
121 ;;; types of things to expand by
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
122 ;;; Added multi-level path name support
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
123 ;;; Added multi-level tag name support.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
124 ;;; Only mouse-2 is now used for node expansion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
125 ;;; Added keys e + - to edit expand, and contract node lines
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
126 ;;; Added longer legal file regexp for all those modes which support
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
127 ;;; imenu. (pascal, fortran90, ada, pearl)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
128 ;;; Fixed centering algorithm
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
129 ;;; Tried to choose background independent colors. Made more robust.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
130 ;;; Rearranged code into a more logical order
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
131 ;;; 0.3.1 Fixed doc & broken keybindings
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
132 ;;; Added mode hooks.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
133 ;;; Improved color selection to be background mode smart
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
134 ;;; `nil' passed to `speedbar-frame-mode' now toggles the frame as
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
135 ;;; advertised in the doc string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
136 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
137 ;;; TODO:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
138 ;;; 1) Rember contents of directories when leaving them so it's faster
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
139 ;;; when returning.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
140 ;;; 2) List of directories to never visit. (User might be browsing
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
141 ;;; there temporarilly such as info files, documentation and the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
142 ;;; like)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
143 ;;; 3) Implement SHIFT-mouse2 to rescan buffers with imenu.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
144 ;;; 4) Better XEmacs support of menus and button-bar
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
145 ;;; 5) More functions to create buttons and options
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
146 ;;; 6) filtering algoritms to reduce the number of tags/files
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
147 ;;; displayed.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
148 ;;; 7) Build `speedbar-file-regexp' on the fly.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
149 ;;; 8) More intelligent current file highlighting.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
150
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
151 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
152
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
153 (defvar speedbar-initial-expansion-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
154 '(speedbar-directory-buttons speedbar-default-directory-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
155 "*List of functions to call to fill in the speedbar buffer whenever
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
156 a top level update is issued. These functions will allways get the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
157 default directory to use passed in as the first parameter, and a 0 as
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
158 the second parameter. They must assume that the cursor is at the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
159 postion where they start inserting buttons.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
160
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
161 (defvar speedbar-show-unknown-files nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
162 "*Non-nil shows files with a ? in the expansion tag for files we can't
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
163 expand. `nil' means don't show the file in the list.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
164
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
165 ;; Xemacs timers aren't based on idleness. Therefore tune it down a little
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
166 ;; or suffer mightilly!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
167 (defvar speedbar-update-speed (if speedbar-xemacsp 5 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
168 "*Time in seconds of idle time needed before speedbar will update
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
169 it's buffer to match what you've been doing in your other frame.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
170 (defvar speedbar-navigating-speed 10
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
171 "*Idle time to wait before re-running the timer proc to pick up any new
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
172 activity if the user has started navigating directories in the speedbar.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
173
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
174 (defvar speedbar-width 20
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
175 "*Initial size of the speedbar window")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
176
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
177 (defvar speedbar-scrollbar-width 10
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
178 "*Initial sizeo of the speedbar scrollbar. The thinner, the more
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
179 display room you will have.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
180
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
181 (defvar speedbar-raise-lower t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
182 "*Non-nil means speedbar will auto raise and lower itself. When this
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
183 is set, you can have only a tiny strip visible under your main emacs,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
184 and it will raise and lower itself when you put the pointer in it.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
185
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
186 (defvar speedbar-use-imenu-package (not speedbar-xemacsp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
187 "*Optionally use the imenu package instead of etags for parsing. This
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
188 is experimental for performace testing.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
189
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
190 (defvar speedbar-before-delete-hook nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
191 "*Hooks called before deletiing the speedbar frame.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
192
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
193 (defvar speedbar-mode-hook nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
194 "*Hooks called after creating a speedbar buffer")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
195
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
196 (defvar speedbar-timer-hook nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
197 "*Hooks called after running the speedbar timer function")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
198
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
199 (defvar speedbar-file-unshown-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
200 (let ((nstr "") (noext completion-ignored-extensions))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
201 (while noext
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
202 (setq nstr (concat nstr (regexp-quote (car noext)) "$"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
203 (if (cdr noext) "\\|" ""))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
204 noext (cdr noext)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
205 (concat nstr "\\|#[^#]+#$\\|\\.\\.?$"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
206 "*Regular expression matching files we don't want to display in a
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
207 speedbar buffer")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
208
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
209 (defvar speedbar-file-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
210 (if speedbar-use-imenu-package
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
211 "\\(\\.\\([CchH]\\|c\\(++\\|pp\\)\\|f90\\|ada\\|pl?\\|el\\|t\\(ex\\(i\\(nfo\\)?\\)?\\|cl\\)\\|emacs\\)$\\)\\|[Mm]akefile\\(\\.in\\)?"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
212 "\\.\\([CchH]\\|c\\(++\\|pp\\)\\|p\\|el\\|tex\\(i\\(nfo\\)?\\)?\\|emacs\\)$")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
213 "*Regular expresson matching files we know how to expand.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
214
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
215 (defvar speedbar-syntax-table nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
216 "Syntax-table used on the speedbar")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
217
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
218 (if speedbar-syntax-table
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
219 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
220 (setq speedbar-syntax-table (make-syntax-table))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
221 ;; turn off paren matching around here.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
222 (modify-syntax-entry ?\' " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
223 (modify-syntax-entry ?\" " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
224 (modify-syntax-entry ?( " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
225 (modify-syntax-entry ?) " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
226 (modify-syntax-entry ?[ " " speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
227 (modify-syntax-entry ?] " " speedbar-syntax-table))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
228
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
229
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
230 (defvar speedbar-key-map nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
231 "Keymap used in speedbar buffer.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
232 (defvar speedbar-menu-map nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
233 "Keymap used in speedbar menu buffer.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
234
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
235 (if speedbar-key-map
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
236 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
237 (setq speedbar-key-map (make-keymap))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
238 (suppress-keymap speedbar-key-map t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
239
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
240 (define-key speedbar-key-map "e" 'speedbar-edit-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
241 (define-key speedbar-key-map "+" 'speedbar-expand-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
242 (define-key speedbar-key-map "-" 'speedbar-contract-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
243
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
244 (if (string-match "XEmacs" emacs-version)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
245 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
246 ;; bind mouse bindings so we can manipulate the items on each line
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
247 (define-key speedbar-key-map 'button2 'speedbar-click)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
248
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
249 ;; Xemacs users. You probably want your own toolbar for
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
250 ;; the speedbar frame or mode or whatever. Make some buttons
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
251 ;; and mail me how to do it!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
252 ;; Also, how do you disable all those menu items? Email me that too
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
253 ;; as it would be most helpful.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
254 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
255 ;; bind mouse bindings so we can manipulate the items on each line
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
256 (define-key speedbar-key-map [mouse-2] 'speedbar-click)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
257 (define-key speedbar-key-map [down-mouse-2] 'speedbar-quick-mouse)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
258
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
259 ;; this was meant to do a rescan or something
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
260 ;;(define-key speedbar-key-map [shift-mouse-2] 'speedbar-hard-click)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
261
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
262 ;; disable all menus - we don't have a lot of space to play with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
263 ;; in such a skinny frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
264 (define-key speedbar-key-map [menu-bar buffer] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
265 (define-key speedbar-key-map [menu-bar files] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
266 (define-key speedbar-key-map [menu-bar tools] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
267 (define-key speedbar-key-map [menu-bar edit] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
268 (define-key speedbar-key-map [menu-bar search] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
269 (define-key speedbar-key-map [menu-bar help-menu] 'undefined)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
270
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
271 ;; This lets the user scroll as if we had a scrollbar... well maybe not
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
272 (define-key speedbar-key-map [mode-line mouse-2] 'speedbar-mouse-hscroll)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
273
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
274 ;; Create a menu for speedbar
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
275 (setq speedbar-menu-map (make-sparse-keymap))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
276 (define-key speedbar-key-map [menu-bar speedbar]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
277 (cons "Speedbar" speedbar-menu-map))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
278 (define-key speedbar-menu-map [close]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
279 (cons "Close" 'speedbar-close-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
280 (define-key speedbar-menu-map [clonfigure]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
281 (cons "Configure Faces" 'speedbar-configure-faces))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
282 (define-key speedbar-menu-map [configopt]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
283 (cons "Configure Options" 'speedbar-configure-options))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
284 (define-key speedbar-menu-map [Update]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
285 (cons "Update" 'speedbar-update-contents))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
286 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
287
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
288 (put 'speedbar-configure-faces 'menu-enable '(featurep 'dialog))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
289 (put 'speedbar-configure-options 'menu-enable '(featurep 'dialog))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
290
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
291 (defvar speedbar-buffer nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
292 "The buffer displaying the speedbar.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
293 (defvar speedbar-frame nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
294 "The frame displaying speedbar.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
295 (defvar speedbar-timer nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
296 "The speedbar timer used for updating the buffer.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
297 (defvar speedbar-attached-frame nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
298 "The frame which started speedbar mode. This is the frame from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
299 which all data displayed in the speedbar is gathered, and in which files
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
300 and such are displayed.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
301
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
302 (defvar speedbar-last-selected-file nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
303 "The last file which was selected in speedbar buffer")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
304
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
305 (defvar speedbar-shown-directories nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
306 "Used to maintain list of directories simultaneously open in the current
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
307 speedbar.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
308
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
309
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
310 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
311 ;;; Mode definitions/ user commands
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
312 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
313 ;;;###autoload
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
314 (defun speedbar-frame-mode (&optional arg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
315 "Enable or disable use of a speedbar. Positive number means turn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
316 on, negative turns speedbar off, and nil means toggle. Once the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
317 speedbar frame is activated, a buffer in `speedbar-mode' will be
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
318 displayed. Currently, only one speedbar is supported at a time."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
319 (interactive "P")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
320 (if (not window-system)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
321 (error "Speedbar is not useful outside of a windowing environement"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
322 ;; toggle frame on and off.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
323 (if (not arg) (if speedbar-frame (setq arg -1) (setq arg 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
324 ;; turn the frame off on neg number
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
325 (if (and (numberp arg) (< arg 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
326 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
327 (run-hooks 'speedbar-before-delete-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
328 (if (and speedbar-frame (frame-live-p speedbar-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
329 (delete-frame speedbar-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
330 (speedbar-set-timer nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
331 (setq speedbar-frame nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
332 (if (bufferp speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
333 (kill-buffer speedbar-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
334 ;; Set this as our currently attached frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
335 (setq speedbar-attached-frame (selected-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
336 ;; Get the buffer to play with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
337 (speedbar-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
338 ;; Get the frame to work in
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
339 (if (and speedbar-frame (frame-live-p speedbar-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
340 (raise-frame speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
341 (let ((params (list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
342 ;; Xemacs fails to delete speedbar
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
343 ;; if minibuffer is off.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
344 ;; JTL <<<< Seems to be OK for 19.15.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
345 ;; removed tool- & menubar.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
346 ;; <<<< JTL
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
347 (cons 'minibuffer nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
348 (cons 'width speedbar-width)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
349 (cons 'height (frame-height))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
350 (cons 'scroll-bar-width speedbar-scrollbar-width)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
351 (cons 'auto-raise speedbar-raise-lower)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
352 (cons 'auto-lower speedbar-raise-lower)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
353 '(modeline . nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
354 '(border-width . 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
355 '(unsplittable . t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
356 '(default-toolbar-visible-p . nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
357 '(menubar-visible-p . nil))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
358 (setq speedbar-frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
359 (if (< emacs-minor-version 35)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
360 (make-frame params)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
361 (let ((x-pointer-shape x-pointer-top-left-arrow)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
362 (x-sensitive-text-pointer-shape x-pointer-hand2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
363 (make-frame params)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
364 ;; reset the selection variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
365 (setq speedbar-last-selected-file nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
366 ;; Put the buffer into the frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
367 (save-window-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
368 (select-frame speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
369 (switch-to-buffer speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
370 (setq default-minibuffer-frame speedbar-attached-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
371 (speedbar-set-timer speedbar-update-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
372 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
373
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
374 (defun speedbar-close-frame ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
375 "Turn off speedbar mode"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
376 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
377 (speedbar-frame-mode -1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
378
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
379 (defun speedbar-mode ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
380 "Create and return a SPEEDBAR buffer. The speedbar buffer allows
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
381 the user to manage a list of directories and paths at different
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
382 depths. The first line represents the default path of the speedbar
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
383 frame. Each directory segment is a button which jumps speedbar's
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
384 default directory to that path. Buttons are activated by clicking
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
385 mouse-2.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
386
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
387 Each line starting with <+> represents a directory. Click on the <+>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
388 to insert the directory listing into the current tree. Click on the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
389 <-> to retract that list. Click on the directory name to go to that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
390 directory as the default.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
391
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
392 Each line starting with [+] is a file. If the variable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
393 `speedbar-show-unknown-files' is t, the lines starting with [?] are
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
394 files which don't have imenu support, but are not expressly ignored.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
395 Files are completely ignored if they match `speedbar-file-unshown-regexp'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
396 which is generated from `completion-ignored-extensions'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
397
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
398 Click on the [+] to display a list of tags from that file. Click on
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
399 the [-] to retract the list. Click on the file name to edit the file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
400 in the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
401
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
402 If you open tags, you might find a node starting with {+}, which is a
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
403 category of tags. Click the {+} to expand the category. Jumpable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
404 tags start with >. Click the name of the tag to go to that position
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
405 in the selected file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
406
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
407 Keybindings: \\<speedbar-key-map>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
408 \\[speedbar-click] Activate the button under the mouse.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
409 \\[speedbar-edit-line] Edit the file/directory on this line. Same as clicking
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
410 on the name on the selected line.)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
411 \\[speedbar-expand-line] Expand the current line. Same as clicking on the + on a line.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
412 \\[speedbar-contract-line] Contract the current line. Same as clicking on the - on a line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
413 (setq speedbar-buffer (set-buffer (get-buffer-create "SPEEDBAR")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
414 (kill-all-local-variables)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
415 (setq major-mode 'speedbar-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
416 (setq mode-name "SB")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
417 (use-local-map speedbar-key-map)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
418 (set-syntax-table speedbar-syntax-table)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
419 (setq mode-line-format
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
420 '("<< SPEEDBAR " (line-number-mode " %3l ") " >>"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
421 (setq font-lock-keywords nil) ;; no font-locking please
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
422 (setq truncate-lines t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
423 (if (not speedbar-xemacsp) (setq auto-show-mode nil)) ;no auto-show for FSF
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
424 (run-hooks 'speedbar-mode-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
425 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
426 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
427
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
428 (defun speedbar-mouse-hscroll (e)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
429 "Read a mouse event from the mode line, and horizontally scroll if the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
430 mouse is being clicked on the far left, or far right of the modeline."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
431 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
432 (let* ((xp (car (nth 2 (car (cdr e)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
433 (cpw (/ (frame-pixel-width)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
434 (frame-width)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
435 (oc (1+ (/ xp cpw)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
436 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
437 (cond ((< oc 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
438 (scroll-left 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
439 ((> oc (- (window-width) 3))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
440 (scroll-right 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
441 (t (message "Click on the edge of the modeline to scroll left/right")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
442 ;;(message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
443 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
444
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
445
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
446 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
447 ;;; Utility functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
448 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
449 (defun speedbar-set-timer (timeout)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
450 "Unset an old timer (if there is one) and activate a new timer with the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
451 given timeout value."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
452 (cond
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
453 ;; Xemacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
454 (speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
455 (if speedbar-timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
456 (progn (delete-itimer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
457 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
458 (if timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
459 (setq speedbar-timer (start-itimer "speedbar"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
460 'speedbar-timer-fn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
461 timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
462 nil))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
463 ;; GNU emacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
464 (t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
465 (if speedbar-timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
466 (progn (cancel-timer speedbar-timer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
467 (setq speedbar-timer nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
468 (if timeout
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
469 (setq speedbar-timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
470 (run-with-idle-timer timeout nil 'speedbar-timer-fn))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
471 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
472
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
473 (defmacro speedbar-with-writable (&rest forms)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
474 "Allow the buffer to be writable and evaluate forms. Turn read-only back
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
475 on when done."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
476 (list 'let '((speedbar-with-writable-buff (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
477 '(toggle-read-only -1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
478 (cons 'progn forms)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
479 '(save-excursion (set-buffer speedbar-with-writable-buff)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
480 (toggle-read-only 1))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
481 (put 'speedbar-with-writable 'lisp-indent-function 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
482
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
483 (defun speedbar-make-button (start end face mouse function &optional token)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
484 "Create a button from START to END, with FACE as the display face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
485 and MOUSE and the mouse face. When this button is clicked on FUNCTION
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
486 will be run with the token parameter of TOKEN (any lisp object)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
487 (put-text-property start end 'face face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
488 (put-text-property start end 'mouse-face mouse)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
489 (put-text-property start end 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
490 (if function (put-text-property start end 'speedbar-function function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
491 (if token (put-text-property start end 'speedbar-token token))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
492 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
493
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
494 (defun speedbar-file-lists (directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
495 "Create file lists for DIRECTORY. The car is the list of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
496 directories, the cdr is list of files not matching ignored headers."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
497 (let ((default-directory directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
498 (dir (directory-files directory nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
499 (dirs nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
500 (files nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
501 (while dir
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
502 (if (not (string-match speedbar-file-unshown-regexp (car dir)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
503 (if (file-directory-p (car dir))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
504 (setq dirs (cons (car dir) dirs))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
505 (setq files (cons (car dir) files))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
506 (setq dir (cdr dir)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
507 (cons (nreverse dirs) (list (nreverse files))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
508 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
509
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
510 (defun speedbar-directory-buttons (directory index)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
511 "Inserts a single button group at point for DIRECTORY. Each directory
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
512 path part is a different button. If part of the path matches the user
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
513 directory ~, then it is replaced with a ~"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
514 (let* ((tilde (expand-file-name "~"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
515 (dd (expand-file-name directory))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
516 (junk (string-match (regexp-quote tilde) dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
517 (displayme (if junk
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
518 (concat "~" (substring dd (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
519 dd))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
520 (p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
521 (if (string-match "^~/?$" displayme) (setq displayme (concat tilde "/")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
522 (insert displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
523 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
524 (goto-char p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
525 (while (re-search-forward "\\([^/]+\\)/" nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
526 (speedbar-make-button (match-beginning 1) (match-end 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
527 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
528 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
529 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
530 (if (= (match-beginning 1) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
531 (expand-file-name "~/") ;the tilde
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
532 (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
533 p (match-end 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
534 (if (string-match "^/[^/]+/$" displayme)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
535 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
536 (insert " ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
537 (let ((p (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
538 (insert "<root>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
539 (speedbar-make-button p (point)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
540 'speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
541 'speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
542 'speedbar-directory-buttons-follow
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
543 "/"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
544 (insert-char ?\n 1 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
545
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
546 (defun speedbar-make-tag-line (exp-button-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
547 exp-button-char exp-button-function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
548 exp-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
549 tag-button tag-button-function tag-button-data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
550 tag-button-face depth)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
551 "Creates a tag line with BUTTON-TYPE for the small button that
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
552 expands or contracts a node (if applicable), and BUTTON-CHAR the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
553 character in it (+, -, ?, etc). BUTTON-FUNCTION is the function to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
554 call if it's clicked on. Button types are 'bracket, 'angle, 'curly, or nil.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
555
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
556 Next, TAG-BUTTON is the text of the tag. TAG-FUNCTION is the function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
557 to call if clicked on, and TAG-DATA is the data to attach to the text
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
558 field (such a tag positioning, etc). TAG-FACE is a face used for this
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
559 type of tag.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
560
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
561 Lastly, DEPTH shows the depth of expansion.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
562
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
563 This function assumes that the cursor is in the speecbar window at the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
564 position to insert a new item, and that the new item will end with a CR"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
565 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
566 (end (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
567 (insert (int-to-string depth) ":")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
568 (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
569 (put-text-property start end 'invisible t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
570 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
571 (insert-char ? depth nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
572 (put-text-property (- (point) depth) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
573 (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
574 ((eq exp-button-type 'angle) "<%c>")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
575 ((eq exp-button-type 'curly) "{%c}")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
576 (t ">")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
577 (buttxt (format exp-button exp-button-char))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
578 (start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
579 (end (progn (insert buttxt) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
580 (bf (if exp-button-type 'speedbar-button-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
581 (mf (if exp-button-function 'speedbar-highlight-face nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
582 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
583 (speedbar-make-button start end bf mf exp-button-function exp-button-data)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
584 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
585 (insert-char ? 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
586 (put-text-property (1- (point)) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
587 (let ((start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
588 (end (progn (insert tag-button) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
589 (insert-char ?\n 1 nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
590 (put-text-property (1- (point)) (point) 'invisible nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
591 (speedbar-make-button start end tag-button-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
592 (if tag-button-function 'speedbar-highlight-face nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
593 tag-button-function tag-button-data))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
594 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
595
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
596 (defun speedbar-change-expand-button-char (char)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
597 "Change the expanson button character to CHAR for the current line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
598 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
599 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
600 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
601 (point)) t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
602 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
603 (goto-char (match-beginning 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
604 (delete-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
605 (insert-char char 1 t)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
606
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
607
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
608 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
609 ;;; Build button lists
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
610 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
611 (defun speedbar-insert-files-at-point (files level)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
612 "Insert list of FILES starting at point, and indenting all files to LEVEL
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
613 depth. Tag exapndable items with a +, otherwise a ?. Don't highlight ? as
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
614 we don't know how to manage them. The input parameter FILES is a cons
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
615 cell of the form ( 'dir-list . 'file-list )"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
616 ;; Start inserting all the directories
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
617 (let ((dirs (car files)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
618 (while dirs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
619 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
620 (car dirs) 'speedbar-dir-follow nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
621 'speedbar-directory-face level)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
622 (setq dirs (cdr dirs))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
623 (let ((lst (car (cdr files))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
624 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
625 (let* ((known (string-match speedbar-file-regexp (car lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
626 (expchar (if known ?+ ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
627 (fn (if known 'speedbar-tag-file nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
628 (if (or speedbar-show-unknown-files (/= expchar ??))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
629 (speedbar-make-tag-line 'bracket expchar fn (car lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
630 (car lst) 'speedbar-find-file nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
631 'speedbar-file-face level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
632 (setq lst (cdr lst)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
633
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
634 (defun speedbar-default-directory-list (directory index)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
635 "Inserts files for DIRECTORY with level INDEX at point"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
636 (speedbar-insert-files-at-point
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
637 (speedbar-file-lists directory) index)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
638 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
639
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
640 (defun speedbar-insert-generic-list (level lst expand-fun find-fun)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
641 "At LEVEL, inserts a generic multi-level alist LIST. Associations with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
642 lists get {+} tags (to expand into more nodes) and those with positions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
643 just get a > as the indicator. {+} buttons will have the function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
644 EXPAND-FUN and the token is the CDR list. The token name will have the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
645 function FIND-FUN and not token."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
646 ;; Remove imenu rescan button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
647 (if (string= (car (car lst)) "*Rescan*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
648 (setq lst (cdr lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
649 ;; insert the parts
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
650 (while lst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
651 (cond ((null (car-safe lst)) nil) ;this would be a separator
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
652 ((numberp (cdr-safe (car-safe lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
653 (speedbar-make-tag-line nil nil nil nil ;no expand button data
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
654 (car (car lst)) ;button name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
655 find-fun ;function
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
656 (cdr (car lst)) ;token is position
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
657 'speedbar-tag-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
658 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
659 ((listp (cdr-safe (car-safe lst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
660 (speedbar-make-tag-line 'curly ?+ expand-fun (cdr (car lst))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
661 (car (car lst)) ;button name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
662 nil nil 'speedbar-tag-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
663 (1+ level)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
664 (t (message "Ooops!")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
665 (setq lst (cdr lst))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
666
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
667 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
668 ;;; Timed functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
669 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
670 (defun speedbar-update-contents ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
671 "Update the contents of the speedbar buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
672 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
673 (setq speedbar-last-selected-file nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
674 (setq speedbar-shown-directories (list (expand-file-name default-directory)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
675 (let ((cbd default-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
676 (funclst speedbar-initial-expansion-list))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
677 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
678 (set-buffer speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
679 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
680 (setq default-directory cbd)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
681 (delete-region (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
682 (while funclst
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
683 (funcall (car funclst) cbd 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
684 (setq funclst (cdr funclst)))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
685
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
686 (defun speedbar-timer-fn ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
687 "Run whenever emacs is idle to update the speedbar item"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
688 (if (not (and speedbar-frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
689 (frame-live-p speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
690 speedbar-attached-frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
691 (frame-live-p speedbar-attached-frame)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
692 (speedbar-set-timer nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
693 (unwind-protect
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
694 (if (frame-visible-p speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
695 (let ((af (selected-frame)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
696 (save-window-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
697 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
698 ;; make sure we at least choose a window to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
699 ;; get a good directory from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
700 (if (string-match "\\*Minibuf-[0-9]+\\*" (buffer-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
701 (other-window 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
702 ;; Update all the contents if directories change!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
703 (if (or (member (expand-file-name default-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
704 speedbar-shown-directories)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
705 (eq af speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
706 (not (buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
707 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
708 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
709 (message "Updating speedbar to: %s..." default-directory)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
710 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
711 (message "Updating speedbar to: %s...done" default-directory)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
712 ;; Reset the timer
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
713 (speedbar-set-timer speedbar-update-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
714 ;; Ok, un-underline old file, underline current file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
715 (speedbar-update-current-file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
716 (run-hooks 'speedbar-timer-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
717 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
718
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
719 (defun speedbar-update-current-file ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
720 "Find out what the current file is, and update our visuals to indicate
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
721 what it is. This is specific to file names."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
722 (let* ((lastf (selected-frame))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
723 (newcf (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
724 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
725 (let ((rf (if (buffer-file-name)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
726 (file-name-nondirectory (buffer-file-name))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
727 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
728 (select-frame lastf)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
729 rf)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
730 (lastb (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
731 (if (and newcf (not (string= newcf speedbar-last-selected-file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
732 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
733 (select-frame speedbar-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
734 (set-buffer speedbar-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
735 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
736 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
737 (if (and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
738 speedbar-last-selected-file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
739 (re-search-forward
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
740 (concat " \\(" (regexp-quote speedbar-last-selected-file) "\\)\n")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
741 nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
742 (put-text-property (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
743 (match-end 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
744 'face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
745 'speedbar-file-face))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
746 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
747 (if (re-search-forward
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
748 (concat " \\(" (regexp-quote newcf) "\\)\n") nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
749 (put-text-property (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
750 (match-end 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
751 'face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
752 'speedbar-selected-face))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
753 (setq speedbar-last-selected-file newcf))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
754 (forward-line -1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
755 (speedbar-position-cursor-on-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
756 (set-buffer lastb)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
757 (select-frame lastf)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
758
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
759 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
760 ;;; Clicking Activity
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
761 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
762 (defun speedbar-quick-mouse (e)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
763 "Since mouse events are strange, this will keep the mouse nicely
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
764 positioned."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
765 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
766 (mouse-set-point e)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
767 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
768 (forward-char 3)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
769 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
770
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
771 (defun speedbar-position-cursor-on-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
772 "Position the cursor on a line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
773 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
774 (re-search-forward "[]>}]" (save-excursion (end-of-line) (point)) t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
775
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
776 (defun speedbar-line-path (depth)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
777 "Retrieve the pathname associated with the current line. This may
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
778 require traversing backwards and combinding the default directory with
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
779 these items."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
780 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
781 (let ((path nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
782 (setq depth (1- depth))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
783 (while (/= depth -1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
784 (if (not (re-search-backward (format "^%d:" depth) nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
785 (error "Error building path of tag")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
786 (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
787 (setq path (concat (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
788 (match-beginning 1) (match-end 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
789 "/"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
790 path)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
791 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
792 ;; This is the start of our path.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
793 (setq path (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
794 (match-beginning 1) (match-end 1))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
795 (setq depth (1- depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
796 (concat default-directory path))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
797
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
798 (defun speedbar-edit-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
799 "Edit whatever tag or file is on the current speedbar line."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
800 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
801 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
802 (re-search-forward "[]>}] [a-zA-Z0-9]" (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
803 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
804
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
805 (defun speedbar-expand-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
806 "Expand the line under the cursor."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
807 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
808 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
809 (re-search-forward ":\\s-*.\\+. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
810 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
811 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
812
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
813 (defun speedbar-contract-line ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
814 "Expand the line under the cursor."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
815 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
816 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
817 (re-search-forward ":\\s-*.-. " (save-excursion (end-of-line) (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
818 (forward-char -2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
819 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
820
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
821 (defun speedbar-click (e)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
822 "When the user clicks mouse 1 on our speedbar, we must decide what
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
823 we want to do! The entire speedbar has functions attached to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
824 buttons. All we have to do is extract from the buffer the information
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
825 we need. See `speedbar-mode' for the type of behaviour we want to achieve"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
826 (interactive "e")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
827 (mouse-set-point e)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
828 (speedbar-do-function-pointer))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
829
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
830 (defun speedbar-do-function-pointer ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
831 "Look under the cursor and examine the text properties. From this extract
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
832 the file/tag name, token, indentation level and call a function if apropriate"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
833 (let* ((fn (get-text-property (point) 'speedbar-function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
834 (tok (get-text-property (point) 'speedbar-token))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
835 ;; The 1-,+ is safe because scaning starts AFTER the point
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
836 ;; specified. This lets the search include the character the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
837 ;; cursor is on.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
838 (tp (previous-single-property-change
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
839 (if (get-text-property (1+ (point)) 'speedbar-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
840 (1+ (point)) (point)) 'speedbar-function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
841 (np (next-single-property-change
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
842 (if (and (> (point) 1) (get-text-property (1- (point)) 'speedbar-function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
843 (1- (point)) (point)) 'speedbar-function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
844 (txt (buffer-substring-no-properties (or tp (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
845 (or np (point-max))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
846 (dent (save-excursion (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
847 (string-to-number
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
848 (if (looking-at "[0-9]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
849 (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
850 (match-beginning 0) (match-end 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
851 "0")))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
852 ;;(message "%S:%S:%S:%s" fn tok txt dent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
853 (and fn (funcall fn txt tok dent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
854 (speedbar-position-cursor-on-line))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
855
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
856 (defun speedbar-find-file (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
857 "Speedbar click handler for filenames. Clicking the filename loads
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
858 that file into the attached buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
859 (let ((cdd (speedbar-line-path indent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
860 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
861 (find-file (concat cdd text))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
862 (speedbar-update-current-file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
863 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
864 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
865 ;; that other timer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
866 (speedbar-set-timer speedbar-update-speed)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
867
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
868 (defun speedbar-dir-follow (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
869 "Speedbar click handler for directory names. Clicking a directory will
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
870 cause the speedbar to list files in the selected subdirectory."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
871 (setq default-directory
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
872 (concat (expand-file-name (concat (speedbar-line-path indent) text))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
873 "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
874 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
875 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
876 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
877 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
878 (speedbar-set-timer speedbar-navigating-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
879 (setq speedbar-last-selected-file nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
880 (speedbar-update-current-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
881
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
882
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
883 (defun speedbar-dired (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
884 "Speedbar click handler for filenames. Clicking the filename loads
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
885 that file into the attached buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
886 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
887 (setq speedbar-shown-directories
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
888 (cons (expand-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
889 (concat (speedbar-line-path indent) token "/"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
890 speedbar-shown-directories))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
891 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
892 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
893 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
894 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
895 (speedbar-default-directory-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
896 (concat (speedbar-line-path indent) token "/")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
897 (1+ indent)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
898 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
899 (let ((oldl speedbar-shown-directories)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
900 (newl nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
901 (td (expand-file-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
902 (concat (speedbar-line-path indent) token))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
903 (while oldl
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
904 (if (not (string-match (concat "^" (regexp-quote td)) (car oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
905 (setq newl (cons (car oldl) newl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
906 (setq oldl (cdr oldl)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
907 (setq speedbar-shown-directories newl))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
908 (speedbar-change-expand-button-char ?+)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
909 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
910 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
911 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
912 (if (save-excursion (re-search-forward (format "^%d:" indent) nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
913 (delete-region (point) (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
914 (delete-region (point) (point-max)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
915 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
916 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
917 (speedbar-center-buffer-smartly)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
918 (setq speedbar-last-selected-file nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
919 (save-excursion (speedbar-update-current-file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
920
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
921 (defun speedbar-directory-buttons-follow (text token ident)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
922 "Speedbar click handler for default directory buttons."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
923 (setq default-directory token)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
924 ;; Because we leave speedbar as the current buffer,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
925 ;; update contents will change directory without
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
926 ;; having to touch the attached frame.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
927 (speedbar-update-contents)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
928 (speedbar-set-timer speedbar-navigating-speed))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
929
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
930 (defun speedbar-tag-file (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
931 "The cursor is on a selected line. Expand the tags in the specified
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
932 file. The parameter TXT and TOK are required, where TXT is the button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
933 clicked, and TOK is the file to expand."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
934 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
935 (let* ((fn (expand-file-name (concat (speedbar-line-path indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
936 token)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
937 (lst (if speedbar-use-imenu-package
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
938 (let ((tim (speedbar-fetch-dynamic-imenu fn)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
939 (if (eq tim t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
940 (speedbar-fetch-dynamic-etags fn)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
941 tim))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
942 (speedbar-fetch-dynamic-etags fn))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
943 ;; if no list, then remove expando button
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
944 (if (not lst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
945 (speedbar-change-expand-button-char ??)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
946 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
947 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
948 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
949 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
950 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
951 lst 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
952 'speedbar-tag-find))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
953 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
954 (speedbar-change-expand-button-char ?+)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
955 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
956 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
957 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
958 (if (save-excursion (re-search-forward (format "^%d:" indent) nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
959 (delete-region (point) (match-beginning 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
960 (delete-region (point) (point-max))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
961 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
962 (speedbar-center-buffer-smartly))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
963
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
964 (defun speedbar-tag-find (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
965 "For the tag in a file, goto that position"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
966 (let ((file (speedbar-line-path indent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
967 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
968 (find-file file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
969 (save-excursion (speedbar-update-current-file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
970 ;; Reset the timer with a new timeout when cliking a file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
971 ;; in case the user was navigating directories, we can cancel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
972 ;; that other timer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
973 (speedbar-set-timer speedbar-update-speed)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
974 (goto-char token)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
975
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
976 (defun speedbar-tag-expand (text token indent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
977 "For the tag in a file which is really a list of tags of a certain type,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
978 expand or contract that list."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
979 (cond ((string-match "+" text) ;we have to expand this file
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
980 (speedbar-change-expand-button-char ?-)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
981 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
982 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
983 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
984 (speedbar-insert-generic-list indent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
985 token 'speedbar-tag-expand
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
986 'speedbar-tag-find))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
987 ((string-match "-" text) ;we have to contract this node
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
988 (speedbar-change-expand-button-char ?+)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
989 (speedbar-with-writable
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
990 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
991 (end-of-line) (forward-char 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
992 (if (save-excursion (re-search-forward (format "^%d:" indent) nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
993 (delete-region (point) (match-beginning 0))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
994 (t (error "Ooops... not sure what to do.")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
995 (speedbar-center-buffer-smartly))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
996
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
997 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
998 ;;; Centering Utility
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
999 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1000 (defun speedbar-center-buffer-smartly ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1001 "Look at the buffer, and center it so that which the user is most
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1002 interested in (as far as we can tell) is all visible. This assumes
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1003 that the cursor is on a file, or tag of a file which the user is
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1004 interested in."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1005 (if (<= (count-lines (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1006 (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1007 ;; whole buffer fits
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1008 (let ((cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1009 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1010 (recenter 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1011 (goto-char cp))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1012 ;; too big
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1013 (let (depth start end exp p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1014 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1015 (beginning-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1016 (setq depth (if (looking-at "[0-9]+")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1017 (string-to-int (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1018 (match-beginning 0) (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1019 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1020 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1021 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1022 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1023 (if (re-search-backward exp nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1024 (setq start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1025 (error "Center error"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1026 (save-excursion ;Not sure about this part.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1027 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1028 (setq p (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1029 (while (and (not (re-search-forward exp nil t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1030 (>= depth 0))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1031 (setq depth (1- depth))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1032 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1033 (if (/= (point) p)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1034 (setq end (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1035 (setq end (point-max)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1036 ;; Now work out the details of centering
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1037 (let ((nl (count-lines start end))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1038 (cp (point)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1039 (if (> nl (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1040 ;; We can't fit it all, so just center on cursor
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1041 (progn (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1042 (recenter 1))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1043 ;; we can fit everything on the screen, but...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1044 (if (and (pos-visible-in-window-p start (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1045 (pos-visible-in-window-p end (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1046 ;; we are all set!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1047 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1048 ;; we need to do something...
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1049 (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1050 (let ((newcent (/ (- (window-height (selected-window)) nl) 2))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1051 (lte (count-lines start (point-max))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1052 (if (and (< (+ newcent lte) (window-height (selected-window)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1053 (> (- (window-height (selected-window)) lte 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1054 newcent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1055 (setq newcent (- (window-height (selected-window))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1056 lte 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1057 (recenter newcent))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1058 (goto-char cp)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1059
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1060
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1061 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1062 ;;; Tag Management -- Imenu
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1063 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1064 (defun speedbar-fetch-dynamic-imenu (file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1065 "Use the imenu package to load in file, and extract all the items
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1066 tags we wish to display in the speedbar package."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1067 ;; (eval-when-compile (require 'imenu))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1068 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1069 (set-buffer (find-file-noselect file))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1070 (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1071 (imenu--make-index-alist t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1072 (error t))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1073
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1074
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1075 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1076 ;;; Tag Management -- etags (Not useful for FSF emacs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1077 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1078 (defvar speedbar-fetch-etags-parse-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1079 '(("\\.\\([cChH]\\|c++\\|cpp\\|cc\\)$" . speedbar-parse-c-or-c++tag)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1080 ("\\.el\\|\\.emacs" .
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1081 "defun\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1082 ("\\.tex$" . speedbar-parse-tex-string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1083 ("\\.p" .
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1084 "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1085
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1086 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1087 "*Alist matching extension vs an expression which will extract the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1088 symbol name we wish to display as match 1. To add a new file type, you
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1089 would want to add a new association to the list, where the car
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1090 is the file match, and the cdr is the way to extract an element from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1091 the tags output. If the output is complex, use a function symbol
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1092 instead of regexp. The function should expect to be at the beginning
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1093 of a line in the etags buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1094
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1095 This variable is ignored if `speedbar-use-imenu-package' is `t'")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1096
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1097 (defvar speedbar-fetch-etags-command "etags"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1098 "*Command used to create an etags file.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1099
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1100 This variable is ignored if `speedbar-use-imenu-package' is `t'")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1101
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1102 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1103 "*List of arguments to use with `speedbar-fetch-etags-command' to create
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1104 an etags output buffer.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1105
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1106 This variable is ignored if `speedbar-use-imenu-package' is `t'")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1107
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1108 (defun speedbar-fetch-dynamic-etags (file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1109 "For the complete file definition FILE, run etags as a subprocess,
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1110 fetch it's output, and create a list of symbols extracted, and their
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1111 position in FILE."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1112 (let ((newlist nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1113 (unwind-protect
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1114 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1115 (if (get-buffer "*etags tmp*")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1116 (kill-buffer "*etags tmp*")) ;kill to clean it up
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1117 (set-buffer (get-buffer-create "*etags tmp*"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1118 (apply 'call-process speedbar-fetch-etags-command nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1119 (current-buffer) nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1120 (append speedbar-fetch-etags-arguments (list file)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1121 (goto-char (point-min))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1122 (let ((expr
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1123 (let ((exprlst speedbar-fetch-etags-parse-list)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1124 (ans nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1125 (while (and (not ans) exprlst)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1126 (if (string-match (car (car exprlst)) file)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1127 (setq ans (car exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1128 (setq exprlst (cdr exprlst)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1129 (cdr ans))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1130 (if expr
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1131 (let (tnl)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1132 (while (not (save-excursion (end-of-line) (eobp)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1133 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1134 (setq tnl (speedbar-extract-one-symbol expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1135 (if tnl (setq newlist (cons tnl newlist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1136 (forward-line 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1137 (message "Sorry, no support for a file of that extension"))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1138 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1139 (reverse newlist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1140
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1141 (defun speedbar-extract-one-symbol (expr)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1142 "At point in current buffer, return nil, or one alist of the form
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1143 of a dotted pair: ( symbol . position ) from etags output. Parse the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1144 output using the regular expression EXPR"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1145 (let* ((sym (if (stringp expr)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1146 (if (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1147 (re-search-forward expr (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1148 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1149 (point)) t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1150 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1151 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1152 (funcall expr)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1153 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1154 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1155 (end-of-line)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1156 (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1157 t)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1158 (if (and j sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1159 (1+ (string-to-int (buffer-substring-no-properties
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1160 (match-beginning 2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1161 (match-end 2))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1162 0))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1163 (if (/= pos 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1164 (cons sym pos)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1165 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1166
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1167 (defun speedbar-parse-c-or-c++tag ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1168 "Parse a c or c++ tag, which tends to be a little complex."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1169 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1170 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1171 (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1172 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1173 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1174 ((re-search-forward "\\<\\([^ \t]+\\)\\s-+new(" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1175 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1176 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1177 ((re-search-forward "\\<\\([^ \t(]+\\)\\s-*(\C-?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1178 (buffer-substring-no-properties (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1179 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1180 (t nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1181 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1182
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1183 (defun speedbar-parse-tex-string ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1184 "Parse a tex string. Only find data which is relevant"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1185 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1186 (let ((bound (save-excursion (end-of-line) (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1187 (cond ((re-search-forward "\\(section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1188 (buffer-substring-no-properties (match-beginning 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1189 (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1190 (t nil)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1191
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1192
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1193 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1194 ;;; configuration scripts (optional)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1195 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1196 (defun speedbar-configure-options ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1197 "Configure variable options for the speedbar program using dlg-config"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1198 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1199 (require 'dlg-config)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1200 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1201 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1202 (dlg-init)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1203 (let ((oframe (create-widget "Speedbar Options" widget-frame
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1204 widget-toplevel-shell
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1205 :x 2 :y -3
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1206 :frame-label "Speedbar Options"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1207 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1208 (create-widget "show-unknown" widget-toggle-button oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1209 :x 1 :y 1 :label-value "Show files that are not supported by imenu"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1210 :state (data-object-symbol "speedbar-show-unknown-files"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1211 :value speedbar-show-unknown-files
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1212 :symbol 'speedbar-show-unknown-files))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1213
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1214 (create-widget "raiselower" widget-toggle-button oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1215 :x 1 :y -1 :label-value "Use frame auto raise/lower property"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1216 :state (data-object-symbol "speedbar-raise-lower"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1217 :value speedbar-raise-lower
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1218 :symbol 'speedbar-raise-lower))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1219
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1220 (create-widget "update-speed" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1221 :x 1 :y -2 :label-value "Update Delay :")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1222 (create-widget "update-speed-txt" widget-text-field oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1223 :width 5 :height 1 :x -2 :y t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1224 :value (data-object-symbol-string-to-int
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1225 "update-speed"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1226 :symbol 'speedbar-update-speed
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1227 :value (int-to-string speedbar-update-speed)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1228 (create-widget "update-speed-unit" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1229 :x -3 :y t :label-value "Seconds")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1230
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1231 (create-widget "navigating-speed" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1232 :x 1 :y -1 :label-value "Navigating Delay:")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1233 (create-widget "navigating-speed-txt" widget-text-field oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1234 :width 5 :height 1 :x -2 :y t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1235 :value (data-object-symbol-string-to-int
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1236 "navigating-speed"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1237 :symbol 'speedbar-navigating-speed
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1238 :value (int-to-string speedbar-navigating-speed)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1239 (create-widget "navigating-speed-unit" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1240 :x -3 :y t :label-value "Seconds")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1241
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1242 (create-widget "width" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1243 :x 1 :y -2 :label-value "Display Width :")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1244 (create-widget "width-txt" widget-text-field oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1245 :width 5 :height 1 :x -2 :y t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1246 :value (data-object-symbol-string-to-int
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1247 "width"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1248 :symbol 'speedbar-width
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1249 :value (int-to-string speedbar-width)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1250 (create-widget "width-unit" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1251 :x -3 :y t :label-value "Characters")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1252
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1253 (create-widget "scrollbar-width" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1254 :x 1 :y -1 :label-value "Scrollbar Width :")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1255 (create-widget "scrollbar-width-txt" widget-text-field oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1256 :width 5 :height 1 :x -2 :y t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1257 :value (data-object-symbol-string-to-int
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1258 "width"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1259 :symbol 'speedbar-width
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1260 :value (int-to-string speedbar-scrollbar-width)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1261 (create-widget "scrollbar-width-unit" widget-label oframe
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1262 :x -3 :y t :label-value "Pixels")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1263
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1264
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1265 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1266 (dlg-end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1267 (dialog-refresh)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1268 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1269
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1270 (defun speedbar-configure-faces ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1271 "Configure faces for the speedbar program using dlg-config."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1272 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1273 (require 'dlg-config)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1274 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1275 (select-frame speedbar-attached-frame)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1276 (dlg-faces '(speedbar-button-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1277 speedbar-file-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1278 speedbar-directory-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1279 speedbar-tag-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1280 speedbar-highlight-face
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1281 speedbar-selected-face))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1282
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1283 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1284 ;;; Color loading section This is message *Blech!*
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1285 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1286 (defun speedbar-load-color (sym l-fg l-bg d-fg d-bg &optional bold italic underline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1287 "Create a color for SYM with a L-FG and L-BG color, or D-FG and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1288 D-BG. Optionally make BOLD, ITALIC, or UNDERLINED if applicable. If
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1289 the background attribute of the current frame is determined to be
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1290 light (white, for example) then L-FG and L-BG is used. If not, then
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1291 D-FG and D-BG is used. This will allocate the colors in the best
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1292 possible mannor. This will allow me to store multiple defaults and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1293 dynamically determine which colors to use."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1294 (let* ((params (frame-parameters))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1295 (disp-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1296 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1297 (x-get-resource ".displayType" "DisplayType" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1298 (x-get-resource ".displayType" "DisplayType"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1299 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1300 (display-type
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1301 (cond (disp-res (intern (downcase disp-res)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1302 ((and (fboundp 'x-display-color-p) (x-display-color-p)) 'color)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1303 (t 'mono)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1304 (bg-res (if (fboundp 'x-get-resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1305 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1306 (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1307 (x-get-resource ".backgroundMode" "BackgroundMode"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1308 nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1309 (bgmode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1310 (cond (bg-res (intern (downcase bg-res)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1311 ((and params
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1312 (fboundp 'x-color-values)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1313 (< (apply '+ (x-color-values
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1314 (cdr (assq 'background-color params))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1315 (/ (apply '+ (x-color-values "white")) 3)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1316 'dark)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1317 (t 'light))) ;our default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1318 (set-p (function (lambda (face-name resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1319 (if speedbar-xemacsp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1320 (x-get-resource
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1321 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1322 (concat "Face.Attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1323 'string)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1324 (x-get-resource
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1325 (concat face-name ".attribute" resource)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1326 (concat "Face.Attribute" resource)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1327 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1328 (nbg (cond ((eq bgmode 'dark) d-bg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1329 (t l-bg)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1330 (nfg (cond ((eq bgmode 'dark) d-fg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1331 (t l-fg))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1332
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1333 (if (not (eq display-type 'color))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1334 ;; we need a face of some sort, so just make due with default
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1335 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1336 (copy-face 'default sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1337 (if bold (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1338 (make-face-bold sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1339 (error (message "Cannot make face %s bold!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1340 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1341 (if italic (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1342 (make-face-italic sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1343 (error (message "Cannot make face %s italic!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1344 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1345 (set-face-underline-p sym underline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1346 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1347 ;; make a colorized version of a face. Be sure to check Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1348 ;; for possible overrides first!
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1349 (let ((newface (make-face sym)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1350 ;; For each attribute, check if it might already be set by Xdefaults
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1351 (if (and nfg (not (funcall set-p (symbol-name sym) "Foreground")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1352 (set-face-foreground sym nfg))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1353 (if (and nbg (not (funcall set-p (symbol-name sym) "Background")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1354 (set-face-background sym nbg))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1355
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1356 (if bold (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1357 (make-face-bold sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1358 (error (message "Cannot make face %s bold!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1359 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1360 (if italic (condition-case nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1361 (make-face-italic sym)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1362 (error (message "Cannot make face %s italic!"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1363 (symbol-name sym)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1364 (set-face-underline-p sym underline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1365 ))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1366
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1367 ;; JTL <<<<
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1368 (if nil ;;(x-display-color-p) ;; just a quick hack so it will run.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1369 ;; we can use customize for this.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1370 ;; <<<< JTL
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1371 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1372 (speedbar-load-color 'speedbar-button-face "green4" "default" "green3" "default")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1373 (speedbar-load-color 'speedbar-file-face "cyan4" nil "cyan" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1374 (speedbar-load-color 'speedbar-directory-face "blue4" nil "light blue" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1375 (speedbar-load-color 'speedbar-tag-face "brown" nil "yellow" nil nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1376 (speedbar-load-color 'speedbar-selected-face "red" nil "red" nil nil nil t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1377 (speedbar-load-color 'speedbar-highlight-face nil "green" nil "sea green" nil nil nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1378 ) ; color
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1379 (make-face 'speedbar-button-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1380 ;;(make-face 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1381 (copy-face 'bold 'speedbar-file-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1382 (make-face 'speedbar-directory-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1383 (make-face 'speedbar-tag-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1384 ;;(make-face 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1385 (copy-face 'underline 'speedbar-selected-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1386 ;;(make-face 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1387 (copy-face 'highlight 'speedbar-highlight-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1388
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1389 ) ;; monochrome
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1390
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1391 ;;; end of lisp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1392 (provide 'speedbar)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1393
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1394 ;;; speedbar.el ends here