Mercurial > emacs
annotate lisp/speedbar.el @ 56714:ba670a86ca95
(child_setup_tty, init_sys_modes): Use CDISABLE.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Thu, 19 Aug 2004 10:08:15 +0000 |
parents | d21a8e697065 |
children | 5ea587a67aae |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38377
diff
changeset
|
1 ;;; speedbar.el --- quick access to files and tags in a frame |
21650 | 2 |
36047
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
3 ;;; Copyright (C) 1996, 97, 98, 99, 2000, 01 Free Software Foundation |
22735 | 4 |
5 ;; Author: Eric M. Ludlam <zappo@gnu.org> | |
36047
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
6 ;; Version: 0.11a |
22735 | 7 ;; Keywords: file, tags, tools |
8 | |
21650 | 9 ;; This file is part of GNU Emacs. |
22735 | 10 |
21650 | 11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
22735 | 15 |
21650 | 16 ;; GNU Emacs is distributed in the hope that it will be useful, |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
22735 | 20 |
21650 | 21 ;; You should have received a copy of the GNU General Public License |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 ;; | |
28 ;; The speedbar provides a frame in which files, and locations in | |
29 ;; files are displayed. These items can be clicked on with mouse-2 | |
30 ;; in order to make the last active frame display that file location. | |
31 ;; | |
32 ;; Starting Speedbar: | |
33 ;; | |
26491
7de24bd78e93
Clean up comment at the start of the file.
Gerd Moellmann <gerd@gnu.org>
parents:
25432
diff
changeset
|
34 ;; Simply type `M-x speedbar', and it will be autoloaded for you. |
7de24bd78e93
Clean up comment at the start of the file.
Gerd Moellmann <gerd@gnu.org>
parents:
25432
diff
changeset
|
35 |
22735 | 36 ;; If you want to choose it from a menu, such as "Tools", you can do this: |
21650 | 37 ;; |
38 ;; (define-key-after (lookup-key global-map [menu-bar tools]) | |
39 ;; [speedbar] '("Speedbar" . speedbar-frame-mode) [calendar]) | |
40 ;; | |
41 ;; If you want to access speedbar using only the keyboard, do this: | |
42 ;; | |
26491
7de24bd78e93
Clean up comment at the start of the file.
Gerd Moellmann <gerd@gnu.org>
parents:
25432
diff
changeset
|
43 ;; (global-set-key [f4] 'speedbar-get-focus) |
21650 | 44 ;; |
45 ;; This will let you hit f4 (or whatever key you choose) to jump | |
46 ;; focus to the speedbar frame. Pressing it again will bring you back | |
47 ;; to the attached frame. Pressing RET or e to jump to a file | |
48 ;; or tag will move you back to the attached frame. The command | |
49 ;; `speedbar-get-focus' will also create a speedbar frame if it does | |
50 ;; not exist. | |
51 ;; | |
52 ;; Customizing Speedbar: | |
53 ;; | |
54 ;; Once a speedbar frame is active, it takes advantage of idle time | |
55 ;; to keep its contents updated. The contents is usually a list of | |
56 ;; files in the directory of the currently active buffer. When | |
57 ;; applicable, tags in the active file can be expanded. | |
58 ;; | |
59 ;; To add new supported files types into speedbar, use the function | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
60 ;; `speedbar-add-supported-extension'. If speedbar complains that the |
21650 | 61 ;; file type is not supported, that means there is no built in |
62 ;; support from imenu, and the etags part wasn't set up correctly. You | |
63 ;; may add elements to `speedbar-supported-extension-expressions' as long | |
64 ;; as it is done before speedbar is loaded. | |
65 ;; | |
66 ;; To prevent speedbar from following you into certain directories | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
67 ;; use the function `speedbar-add-ignored-path-regexp' to add a new |
21650 | 68 ;; regular expression matching a type of path. You may add list |
69 ;; elements to `speedbar-ignored-path-expressions' as long as it is | |
70 ;; done before speedbar is loaded. | |
71 ;; | |
72 ;; To add new file types to imenu, see the documentation in the | |
22735 | 73 ;; file imenu.el that comes with Emacs. To add new file types which |
21650 | 74 ;; etags supports, you need to modify the variable |
75 ;; `speedbar-fetch-etags-parse-list'. | |
76 ;; | |
77 ;; If the updates are going too slow for you, modify the variable | |
78 ;; `speedbar-update-speed' to a longer idle time before updates. | |
79 ;; | |
80 ;; If you navigate directories, you will probably notice that you | |
81 ;; will navigate to a directory which is eventually replaced after | |
82 ;; you go back to editing a file (unless you pull up a new file.) | |
83 ;; The delay time before this happens is in | |
84 ;; `speedbar-navigating-speed', and defaults to 10 seconds. | |
85 ;; | |
22735 | 86 ;; To enable mouse tracking with information in the minibuffer of |
87 ;; the attached frame, use the variable `speedbar-track-mouse-flag'. | |
88 ;; | |
89 ;; Tag layout can be modified through `speedbar-tag-hierarchy-method', | |
90 ;; which controls how tags are layed out. It is actually a list of | |
91 ;; functions that filter the data. The default groups large tag lists | |
92 ;; into sub-lists. A long flat list can be used instead if needed. | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
93 ;; Other filters can be easily added. |
22735 | 94 ;; |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
95 ;; AUC-TEX users: The imenu tags for AUC-TEX mode doesn't work very |
21650 | 96 ;; well. Use the imenu keywords from tex-mode.el for better results. |
97 ;; | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
98 ;; This file requires the library package assoc (association lists) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
99 ;; |
22735 | 100 ;;; Developing for speedbar |
101 ;; | |
102 ;; Adding a speedbar specialized display mode: | |
103 ;; | |
104 ;; Speedbar can be configured to create a special display for certain | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
105 ;; modes that do not display traditional file/tag data. Rmail, Info, |
22735 | 106 ;; and the debugger are examples. These modes can, however, benefit |
107 ;; from a speedbar style display in their own way. | |
21650 | 108 ;; |
22735 | 109 ;; If your `major-mode' is `foo-mode', the only requirement is to |
110 ;; create a function called `foo-speedbar-buttons' which takes one | |
111 ;; argument, BUFFER. BUFFER will be the buffer speedbar wants filled. | |
112 ;; In `foo-speedbar-buttons' there are several functions that make | |
113 ;; building a speedbar display easy. See the documentation for | |
114 ;; `speedbar-with-writable' (needed because the buffer is usually | |
115 ;; read-only) `speedbar-make-tag-line', `speedbar-insert-button', and | |
116 ;; `speedbar-insert-generic-list'. If you use | |
117 ;; `speedbar-insert-generic-list', also read the doc for | |
118 ;; `speedbar-tag-hierarchy-method' in case you wish to override it. | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
119 ;; The macro `speedbar-with-attached-buffer' brings you back to the |
22735 | 120 ;; buffer speedbar is displaying for. |
21650 | 121 ;; |
22735 | 122 ;; For those functions that make buttons, the "function" should be a |
123 ;; symbol that is the function to call when clicked on. The "token" | |
124 ;; is extra data you can pass along. The "function" must take three | |
125 ;; parameters. They are (TEXT TOKEN INDENT). TEXT is the text of the | |
126 ;; button clicked on. TOKEN is the data passed in when you create the | |
127 ;; button. INDENT is an indentation level, or 0. You can store | |
128 ;; indentation levels with `speedbar-make-tag-line' which creates a | |
129 ;; line with an expander (eg. [+]) and a text button. | |
130 ;; | |
131 ;; Some useful functions when writing expand functions, and click | |
132 ;; functions are `speedbar-change-expand-button-char', | |
133 ;; `speedbar-delete-subblock', and `speedbar-center-buffer-smartly'. | |
134 ;; The variable `speedbar-power-click' is set to t in your functions | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
135 ;; when the user shift-clicks. This is an indication of anything from |
22735 | 136 ;; refreshing cached data to making a buffer appear in a new frame. |
137 ;; | |
138 ;; If you wish to add to the default speedbar menu for the case of | |
139 ;; `foo-mode', create a variable `foo-speedbar-menu-items'. This | |
140 ;; should be a list compatible with the `easymenu' package. It will | |
141 ;; be spliced into the main menu. (Available with click-mouse-3). If | |
142 ;; you wish to have extra key bindings in your special mode, create a | |
143 ;; variable `foo-speedbar-key-map'. Instead of using `make-keymap', | |
144 ;; or `make-sparse-keymap', use the function | |
145 ;; `speedbar-make-specialized-keymap'. This lets you inherit all of | |
146 ;; speedbar's default bindings with low overhead. | |
147 ;; | |
148 ;; Adding a speedbar top-level display mode: | |
149 ;; | |
150 ;; Unlike the specialized modes, there are no name requirements, | |
151 ;; however the methods for writing a button display, menu, and keymap | |
152 ;; are the same. Once you create these items, you can call the | |
153 ;; function `speedbar-add-expansion-list'. It takes one parameter | |
154 ;; which is a list element of the form (NAME MENU KEYMAP &rest | |
155 ;; BUTTON-FUNCTIONS). NAME is a string that will show up in the | |
156 ;; Displays menu item. MENU is a symbol containing the menu items to | |
157 ;; splice in. KEYMAP is a symbol holding the keymap to use, and | |
158 ;; BUTTON-FUNCTIONS are the function names to call, in order, to create | |
159 ;; the display. | |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
160 ;; Another tweakable variable is `speedbar-stealthy-function-list' |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
161 ;; which is of the form (NAME &rest FUNCTION ...). NAME is the string |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
162 ;; name matching `speedbar-add-expansion-list'. (It does not need to |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
163 ;; exist.). This provides additional display info which might be |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
164 ;; time-consuming to calculate. |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
165 ;; Lastly, `speedbar-mode-functions-list' allows you to set special |
40815
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
166 ;; function overrides. At the moment very few functions may be |
18a8015d9546
Minor fixes of the docs in the commentary. From sen_ml@eccosys.com.
Eli Zaretskii <eliz@gnu.org>
parents:
38436
diff
changeset
|
167 ;; overridden, but more will be added as the need is discovered. |
21650 | 168 |
169 ;;; TODO: | |
170 ;; - More functions to create buttons and options | |
171 ;; - Timeout directories we haven't visited in a while. | |
172 | |
173 (require 'assoc) | |
174 (require 'easymenu) | |
175 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
176 (condition-case nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
177 (require 'image) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
178 (error nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
179 |
22735 | 180 (defvar speedbar-xemacsp (string-match "XEmacs" emacs-version) |
181 "Non-nil if we are running in the XEmacs environment.") | |
182 (defvar speedbar-xemacs20p (and speedbar-xemacsp | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
183 (>= emacs-major-version 20))) |
22735 | 184 |
21650 | 185 ;; customization stuff |
186 (defgroup speedbar nil | |
187 "File and tag browser frame." | |
48380
d2b6a3d52d08
(defgroup speedbar): Use group 'etags instead of nonexisting group
Markus Rost <rost@math.uni-bielefeld.de>
parents:
47627
diff
changeset
|
188 :group 'etags |
21658
d8a81542dbf9
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21650
diff
changeset
|
189 :group 'tools |
22250
a77d473867b8
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21658
diff
changeset
|
190 :group 'convenience |
21658
d8a81542dbf9
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
21650
diff
changeset
|
191 :version "20.3") |
21650 | 192 |
193 (defgroup speedbar-faces nil | |
194 "Faces used in speedbar." | |
195 :prefix "speedbar-" | |
196 :group 'speedbar | |
197 :group 'faces) | |
198 | |
199 (defgroup speedbar-vc nil | |
200 "Version control display in speedbar." | |
201 :prefix "speedbar-" | |
202 :group 'speedbar) | |
203 | |
204 ;;; Code: | |
22735 | 205 (defvar speedbar-initial-expansion-mode-alist |
206 '(("buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map | |
207 speedbar-buffer-buttons) | |
208 ("quick buffers" speedbar-buffer-easymenu-definition speedbar-buffers-key-map | |
209 speedbar-buffer-buttons-temp) | |
210 ;; Files last, means first in the Displays menu | |
211 ("files" speedbar-easymenu-definition-special speedbar-file-key-map | |
212 speedbar-directory-buttons speedbar-default-directory-list) | |
213 ) | |
214 "List of named expansion elements for filling the speedbar frame. | |
215 These expansion lists are only valid for regular files. Special modes | |
216 still get to override this list on a mode-by-mode basis. This list of | |
217 lists is of the form (NAME MENU KEYMAP FN1 FN2 ...). NAME is a string | |
218 representing the types of things to be displayed. MENU is an easymenu | |
219 structure used when in this mode. KEYMAP is a local keymap to install | |
220 over the regular speedbar keymap. FN1 ... are functions that will be | |
221 called in order. These functions will always get the default | |
222 directory to use passed in as the first parameter, and a 0 as the | |
223 second parameter. The 0 indicates the uppermost indentation level. | |
224 They must assume that the cursor is at the position where they start | |
225 inserting buttons.") | |
21650 | 226 |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
227 (defvar speedbar-initial-expansion-list-name "files" |
22735 | 228 "A symbol name representing the expansion list to use. |
229 The expansion list `speedbar-initial-expansion-mode-alist' contains | |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
230 the names and associated functions to use for buttons in speedbar.") |
22735 | 231 |
232 (defvar speedbar-previously-used-expansion-list-name "files" | |
233 "Save the last expansion list method. | |
234 This is used for returning to a previous expansion list method when | |
235 the user is done with the current expansion list.") | |
21650 | 236 |
237 (defvar speedbar-stealthy-function-list | |
22735 | 238 '(("files" |
239 speedbar-update-current-file speedbar-check-vc speedbar-check-objects) | |
240 ) | |
21650 | 241 "List of functions to periodically call stealthily. |
22735 | 242 This list is of the form: |
243 '( (\"NAME\" FUNCTION ...) | |
244 ...) | |
245 where NAME is the name of the major display mode these functions are | |
246 for, and the remaining elements FUNCTION are functions to call in order. | |
21650 | 247 Each function must return nil if interrupted, or t if completed. |
248 Stealthy functions which have a single operation should always return | |
249 t. Functions which take a long time should maintain a state (where | |
250 they are in their speedbar related calculations) and permit | |
251 interruption. See `speedbar-check-vc' as a good example.") | |
252 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
253 (defvar speedbar-mode-functions-list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
254 '(("files" (speedbar-item-info . speedbar-files-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
255 (speedbar-line-path . speedbar-files-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
256 ("buffers" (speedbar-item-info . speedbar-buffers-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
257 (speedbar-line-path . speedbar-buffers-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
258 ("quick buffers" (speedbar-item-info . speedbar-buffers-item-info) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
259 (speedbar-line-path . speedbar-buffers-line-path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
260 ) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
261 "List of function tables to use for different major display modes. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
262 It is not necessary to define any functions for a specialized mode. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
263 This just provides a simple way of adding lots of customizations. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
264 Each sublist is of the form: |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
265 (\"NAME\" (FUNCTIONSYMBOL . REPLACEMENTFUNCTION) ...) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
266 Where NAME is the name of the specialized mode. The rest of the list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
267 is a set of dotted pairs of the form FUNCTIONSYMBOL, which is the name |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
268 of a function you would like to replace, and REPLACEMENTFUNCTION, |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
269 which is a function you can call instead. Not all functions can be |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
270 replaced this way. Replaceable functions must provide that |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
271 functionality individually.") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
272 |
21650 | 273 (defcustom speedbar-mode-specific-contents-flag t |
274 "*Non-nil means speedbar will show special mode contents. | |
275 This permits some modes to create customized contents for the speedbar | |
276 frame." | |
277 :group 'speedbar | |
278 :type 'boolean) | |
279 | |
280 (defvar speedbar-special-mode-expansion-list nil | |
22735 | 281 "Default function list for creating specialized button lists. |
282 This list is set by modes that wish to have special speedbar displays. | |
283 The list is of function names. Each function is called with one | |
284 parameter BUFFER, the originating buffer. The current buffer is the | |
285 speedbar buffer.") | |
21650 | 286 |
22735 | 287 (defvar speedbar-special-mode-key-map nil |
288 "Default keymap used when identifying a specialized display mode. | |
289 This keymap is local to each buffer that wants to define special keybindings | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
290 effective when its display is shown.") |
21650 | 291 |
292 (defcustom speedbar-visiting-file-hook nil | |
293 "Hooks run when speedbar visits a file in the selected frame." | |
294 :group 'speedbar | |
295 :type 'hook) | |
296 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
297 (defcustom speedbar-visiting-tag-hook '(speedbar-highlight-one-tag-line) |
21650 | 298 "Hooks run when speedbar visits a tag in the selected frame." |
299 :group 'speedbar | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
300 :type 'hook |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
301 :version "21.1" |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
302 :options '(speedbar-highlight-one-tag-line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
303 speedbar-recenter-to-top |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
304 speedbar-recenter |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
305 )) |
21650 | 306 |
307 (defcustom speedbar-load-hook nil | |
308 "Hooks run when speedbar is loaded." | |
309 :group 'speedbar | |
310 :type 'hook) | |
311 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
312 (defcustom speedbar-reconfigure-keymaps-hook nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
313 "Hooks run when the keymaps are regenerated." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
314 :group 'speedbar |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
315 :version "21.1" |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
316 :type 'hook) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
317 |
21650 | 318 (defcustom speedbar-show-unknown-files nil |
319 "*Non-nil show files we can't expand with a ? in the expand button. | |
320 nil means don't show the file in the list." | |
321 :group 'speedbar | |
322 :type 'boolean) | |
323 | |
324 (defcustom speedbar-update-speed | |
325 (if speedbar-xemacsp | |
326 (if speedbar-xemacs20p | |
327 2 ; 1 is too obrusive in XEmacs | |
328 5) ; when no idleness, need long delay | |
329 1) | |
330 "*Idle time in seconds needed before speedbar will update itself. | |
331 Updates occur to allow speedbar to display directory information | |
332 relevant to the buffer you are currently editing." | |
333 :group 'speedbar | |
334 :type 'integer) | |
335 | |
22735 | 336 ;; When I moved to a repeating timer, I had the horrible missfortune |
337 ;; of loosing the ability for adaptive speed choice. This update | |
338 ;; speed currently causes long delays when it should have been turned off. | |
339 (defcustom speedbar-navigating-speed speedbar-update-speed | |
21650 | 340 "*Idle time to wait after navigation commands in speedbar are executed. |
341 Navigation commands included expanding/contracting nodes, and moving | |
342 between different directories." | |
343 :group 'speedbar | |
344 :type 'integer) | |
345 | |
346 (defcustom speedbar-frame-parameters '((minibuffer . nil) | |
347 (width . 20) | |
348 (border-width . 0) | |
349 (menu-bar-lines . 0) | |
36047
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
350 (tool-bar-lines . 0) |
21650 | 351 (unsplittable . t)) |
352 "*Parameters to use when creating the speedbar frame in Emacs. | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
353 Any parameter supported by a frame may be added. The parameter `height' |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
354 will be initialized to the height of the frame speedbar is |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
355 attached to and added to this list before the new frame is initialized." |
21650 | 356 :group 'speedbar |
357 :type '(repeat (sexp :tag "Parameter:"))) | |
358 | |
359 ;; These values by Hrvoje Niksic <hniksic@srce.hr> | |
360 (defcustom speedbar-frame-plist | |
361 '(minibuffer nil width 20 border-width 0 | |
362 internal-border-width 0 unsplittable t | |
363 default-toolbar-visible-p nil has-modeline-p nil | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
364 menubar-visible-p nil) |
21650 | 365 "*Parameters to use when creating the speedbar frame in XEmacs. |
366 Parameters not listed here which will be added automatically are | |
367 `height' which will be initialized to the height of the frame speedbar | |
368 is attached to." | |
369 :group 'speedbar | |
370 :type '(repeat (group :inline t | |
371 (symbol :tag "Property") | |
372 (sexp :tag "Value")))) | |
373 | |
374 (defcustom speedbar-use-imenu-flag (stringp (locate-library "imenu")) | |
375 "*Non-nil means use imenu for file parsing. nil to use etags. | |
376 XEmacs prior to 20.4 doesn't support imenu, therefore the default is to | |
377 use etags instead. Etags support is not as robust as imenu support." | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
378 :tag "Use Imenu for tags" |
21650 | 379 :group 'speedbar |
380 :type 'boolean) | |
381 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
382 (defvar speedbar-dynamic-tags-function-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
383 '((speedbar-fetch-dynamic-imenu . speedbar-insert-imenu-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
384 (speedbar-fetch-dynamic-etags . speedbar-insert-etags-list)) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
385 "Set to a list of functions which will return and insert a list of tags. |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
386 Each element is of the form ( FETCH . INSERT ) where FETCH |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
387 is a function which takes one parameter (the file to tag) and returns a |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
388 list of tags. The tag list can be of any form as long as the |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
389 corresponding insert method can handle it. If it returns t, then an |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
390 error occurred, and the next fetch routine is tried. |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
391 INSERT is a function which takes an INDENTation level, and a LIST of |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
392 tags to insert. It will then create the speedbar buttons.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
393 |
22735 | 394 (defcustom speedbar-track-mouse-flag t |
395 "*Non-nil means to display info about the line under the mouse." | |
396 :group 'speedbar | |
397 :type 'boolean) | |
398 | |
21650 | 399 (defcustom speedbar-sort-tags nil |
44578
9c2b72b4b303
(speedbar-generic-item-info)
Pavel Janík <Pavel@Janik.cz>
parents:
44225
diff
changeset
|
400 "*If non-nil, sort tags in the speedbar display. *Obsolete*." |
21650 | 401 :group 'speedbar |
402 :type 'boolean) | |
403 | |
22735 | 404 (defcustom speedbar-tag-hierarchy-method |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
405 '(speedbar-prefix-group-tag-hierarchy |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
406 speedbar-trim-words-tag-hierarchy) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
407 "*List of hooks which speedbar will use to organize tags into groups. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
408 Groups are defined as expandable meta-tags. Imenu supports |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
409 such things in some languages, such as separating variables from |
46286
6117ca314143
(speedbar-tag-hierarchy-method): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
46282
diff
changeset
|
410 functions. Each hook takes one argument LST, and may destructively |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
411 create a new list of the same form. LST is a list of elements of the |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
412 form: |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
413 (ELT1 ELT2 ... ELTn) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
414 where each ELT is of the form |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
415 (TAG-NAME-STRING . NUMBER-OR-MARKER) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
416 or |
46286
6117ca314143
(speedbar-tag-hierarchy-method): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
46282
diff
changeset
|
417 (GROUP-NAME-STRING ELT1 ELT2... ELTn)" |
22735 | 418 :group 'speedbar |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
419 :type 'hook |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
420 :options '(speedbar-sort-tag-hierarchy |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
421 speedbar-trim-words-tag-hierarchy |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
422 speedbar-prefix-group-tag-hierarchy |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
423 speedbar-simple-group-tag-hierarchy) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
424 ) |
22735 | 425 |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
426 (defcustom speedbar-tag-group-name-minimum-length 4 |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
427 "*The minimum length of a prefix group name before expanding. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
428 Thus, if the `speedbar-tag-hierarchy-method' includes `prefix-group' |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
429 and one such groups common characters is less than this number of |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
430 characters, then the group name will be changed to the form of: |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
431 worda to wordb |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
432 instead of just |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
433 word |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
434 This way we won't get silly looking listings." |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
435 :group 'speedbar |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
436 :type 'integer) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
437 |
22735 | 438 (defcustom speedbar-tag-split-minimum-length 20 |
439 "*Minimum length before we stop trying to create sub-lists in tags. | |
440 This is used by all tag-hierarchy methods that break large lists into | |
441 sub-lists." | |
442 :group 'speedbar | |
443 :type 'integer) | |
444 | |
445 (defcustom speedbar-tag-regroup-maximum-length 10 | |
446 "*Maximum length of submenus that are regrouped. | |
447 If the regrouping option is used, then if two or more short subgroups | |
448 are next to each other, then they are combined until this number of | |
449 items is reached." | |
450 :group 'speedbar | |
451 :type 'integer) | |
452 | |
21650 | 453 (defcustom speedbar-activity-change-focus-flag nil |
454 "*Non-nil means the selected frame will change based on activity. | |
455 Thus, if a file is selected for edit, the buffer will appear in the | |
456 selected frame and the focus will change to that frame." | |
457 :group 'speedbar | |
458 :type 'boolean) | |
459 | |
460 (defcustom speedbar-directory-button-trim-method 'span | |
461 "*Indicates how the directory button will be displayed. | |
462 Possible values are: | |
463 'span - span large directories over multiple lines. | |
464 'trim - trim large directories to only show the last few. | |
465 nil - no trimming." | |
466 :group 'speedbar | |
467 :type '(radio (const :tag "Span large directories over mutiple lines." | |
468 span) | |
469 (const :tag "Trim large directories to only show the last few." | |
470 trim) | |
471 (const :tag "No trimming." nil))) | |
472 | |
473 (defcustom speedbar-smart-directory-expand-flag t | |
474 "*Non-nil means speedbar should use smart expansion. | |
475 Smart expansion only affects when speedbar wants to display a | |
476 directory for a file in the attached frame. When smart expansion is | |
477 enabled, new directories which are children of a displayed directory | |
478 are expanded in the current framework. If nil, then the current | |
479 hierarchy would be replaced with the new directory." | |
480 :group 'speedbar | |
481 :type 'boolean) | |
482 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
483 (defcustom speedbar-indentation-width 1 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
484 "*When sub-nodes are expanded, the number of spaces used for indentation." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
485 :group 'speedbar |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
486 :version "21.1" |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
487 :type 'integer) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
488 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
489 (defcustom speedbar-hide-button-brackets-flag nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
490 "*Non-nil means speedbar will hide the brackets around the + or -." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
491 :group 'speedbar |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
492 :version "21.1" |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
493 :type 'boolean) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
494 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
495 (defcustom speedbar-use-images (and (or (fboundp 'defimage) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
496 (fboundp 'make-image-specifier)) |
29260
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
497 (if (fboundp 'display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
498 (display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
499 window-system)) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
500 "*Non-nil if speedbar should display icons." |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
501 :group 'speedbar |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
502 :version "21.1" |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
503 :type 'boolean) |
22735 | 504 |
21650 | 505 (defcustom speedbar-before-popup-hook nil |
506 "*Hooks called before popping up the speedbar frame." | |
507 :group 'speedbar | |
508 :type 'hook) | |
509 | |
510 (defcustom speedbar-before-delete-hook nil | |
511 "*Hooks called before deleting the speedbar frame." | |
512 :group 'speedbar | |
513 :type 'hook) | |
514 | |
515 (defcustom speedbar-mode-hook nil | |
516 "*Hooks called after creating a speedbar buffer." | |
517 :group 'speedbar | |
518 :type 'hook) | |
519 | |
520 (defcustom speedbar-timer-hook nil | |
521 "*Hooks called after running the speedbar timer function." | |
522 :group 'speedbar | |
523 :type 'hook) | |
524 | |
525 (defcustom speedbar-verbosity-level 1 | |
526 "*Verbosity level of the speedbar. 0 means say nothing. | |
527 1 means medium level verbosity. 2 and higher are higher levels of | |
528 verbosity." | |
529 :group 'speedbar | |
530 :type 'integer) | |
531 | |
22735 | 532 (defvar speedbar-indicator-separator " " |
533 "String separating file text from indicator characters.") | |
534 | |
21650 | 535 (defcustom speedbar-vc-do-check t |
536 "*Non-nil check all files in speedbar to see if they have been checked out. | |
46286
6117ca314143
(speedbar-tag-hierarchy-method): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
46282
diff
changeset
|
537 Any file checked out is marked with `speedbar-vc-indicator'." |
21650 | 538 :group 'speedbar-vc |
539 :type 'boolean) | |
540 | |
22735 | 541 (defvar speedbar-vc-indicator "*" |
21650 | 542 "Text used to mark files which are currently checked out. |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
543 Other version control systems can be added by examining the function |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
544 `speedbar-vc-path-enable-hook' and `speedbar-vc-in-control-hook'.") |
21650 | 545 |
546 (defcustom speedbar-vc-path-enable-hook nil | |
547 "*Return non-nil if the current path should be checked for Version Control. | |
548 Functions in this hook must accept one parameter which is the path | |
549 being checked." | |
550 :group 'speedbar-vc | |
551 :type 'hook) | |
552 | |
553 (defcustom speedbar-vc-in-control-hook nil | |
554 "*Return non-nil if the specified file is under Version Control. | |
555 Functions in this hook must accept two parameters. The PATH of the | |
556 current file, and the FILENAME of the file being checked." | |
557 :group 'speedbar-vc | |
558 :type 'hook) | |
559 | |
560 (defvar speedbar-vc-to-do-point nil | |
561 "Local variable maintaining the current version control check position.") | |
562 | |
22735 | 563 (defcustom speedbar-obj-do-check t |
564 "*Non-nil check all files in speedbar to see if they have an object file. | |
565 Any file checked out is marked with `speedbar-obj-indicator', and the | |
46288
1b1c4b4ef8d4
(speedbar-obj-do-check): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46286
diff
changeset
|
566 marking is based on `speedbar-obj-alist'." |
22735 | 567 :group 'speedbar-vc |
568 :type 'boolean) | |
569 | |
570 (defvar speedbar-obj-to-do-point nil | |
571 "Local variable maintaining the current version control check position.") | |
572 | |
573 (defvar speedbar-obj-indicator '("#" . "!") | |
574 "Text used to mark files that have a corresponding hidden object file. | |
575 The car is for an up-to-date object. The cdr is for an out of date object. | |
576 The expression `speedbar-obj-alist' defines who gets tagged.") | |
577 | |
578 (defvar speedbar-obj-alist | |
579 '(("\\.\\([cpC]\\|cpp\\|cc\\)$" . ".o") | |
580 ("\\.el$" . ".elc") | |
581 ("\\.java$" . ".class") | |
582 ("\\.f\\(or\\|90\\|77\\)?$" . ".o") | |
583 ("\\.tex$" . ".dvi") | |
584 ("\\.texi$" . ".info")) | |
585 "Alist of file extensions, and their corresponding object file type.") | |
586 | |
587 (defvar speedbar-indicator-regex | |
588 (concat (regexp-quote speedbar-indicator-separator) | |
589 "\\(" | |
590 (regexp-quote speedbar-vc-indicator) | |
591 "\\|" | |
592 (regexp-quote (car speedbar-obj-indicator)) | |
593 "\\|" | |
594 (regexp-quote (cdr speedbar-obj-indicator)) | |
595 "\\)*") | |
596 "Regular expression used when identifying files. | |
597 Permits stripping of indicator characters from a line.") | |
598 | |
599 (defcustom speedbar-scanner-reset-hook nil | |
600 "*Hook called whenever generic scanners are reset. | |
601 Set this to implement your own scanning / rescan safe functions with | |
602 state data." | |
603 :group 'speedbar | |
604 :type 'hook) | |
605 | |
21650 | 606 (defvar speedbar-ignored-modes nil |
607 "*List of major modes which speedbar will not switch directories for.") | |
608 | |
609 (defun speedbar-extension-list-to-regex (extlist) | |
610 "Takes EXTLIST, a list of extensions and transforms it into regexp. | |
22735 | 611 All the preceding `.' are stripped for an optimized expression starting |
612 with `.' followed by extensions, followed by full-filenames." | |
21650 | 613 (let ((regex1 nil) (regex2 nil)) |
614 (while extlist | |
615 (if (= (string-to-char (car extlist)) ?.) | |
616 (setq regex1 (concat regex1 (if regex1 "\\|" "") | |
617 (substring (car extlist) 1))) | |
618 (setq regex2 (concat regex2 (if regex2 "\\|" "") (car extlist)))) | |
619 (setq extlist (cdr extlist))) | |
620 ;; concat all the sub-exressions together, making sure all types | |
621 ;; of parts exist during concatination. | |
622 (concat "\\(" | |
623 (if regex1 (concat "\\(\\.\\(" regex1 "\\)\\)") "") | |
624 (if (and regex1 regex2) "\\|" "") | |
625 (if regex2 (concat "\\(" regex2 "\\)") "") | |
626 "\\)$"))) | |
627 | |
628 (defvar speedbar-ignored-path-regexp nil | |
629 "Regular expression matching paths speedbar will not switch to. | |
630 Created from `speedbar-ignored-path-expressions' with the function | |
631 `speedbar-extension-list-to-regex' (A misnamed function in this case.) | |
632 Use the function `speedbar-add-ignored-path-regexp', or customize the | |
633 variable `speedbar-ignored-path-expressions' to modify this variable.") | |
634 | |
635 (defcustom speedbar-ignored-path-expressions | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
636 '("[/\\]logs?[/\\]\\'") |
21650 | 637 "*List of regular expressions matching directories speedbar will ignore. |
638 They should included paths to directories which are notoriously very | |
639 large and take a long time to load in. Use the function | |
640 `speedbar-add-ignored-path-regexp' to add new items to this list after | |
641 speedbar is loaded. You may place anything you like in this list | |
642 before speedbar has been loaded." | |
643 :group 'speedbar | |
644 :type '(repeat (regexp :tag "Path Regexp")) | |
645 :set (lambda (sym val) | |
646 (setq speedbar-ignored-path-expressions val | |
647 speedbar-ignored-path-regexp | |
648 (speedbar-extension-list-to-regex val)))) | |
649 | |
22735 | 650 (defcustom speedbar-directory-unshown-regexp "^\\(CVS\\|RCS\\|SCCS\\)\\'" |
651 "*Regular expression matching directories not to show in speedbar. | |
652 They should include commonly existing directories which are not | |
653 useful, such as version control." | |
654 :group 'speedbar | |
655 :type 'string) | |
656 | |
21650 | 657 (defvar speedbar-file-unshown-regexp |
658 (let ((nstr "") (noext completion-ignored-extensions)) | |
659 (while noext | |
660 (setq nstr (concat nstr (regexp-quote (car noext)) "\\'" | |
661 (if (cdr noext) "\\|" "")) | |
662 noext (cdr noext))) | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
663 ;; backup refdir lockfile |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
664 (concat nstr "\\|#[^#]+#$\\|\\.\\.?\\'\\|\\.#")) |
21650 | 665 "*Regexp matching files we don't want displayed in a speedbar buffer. |
666 It is generated from the variable `completion-ignored-extensions'") | |
667 | |
668 ;; this is dangerous to customize, because the defaults will probably | |
669 ;; change in the future. | |
670 (defcustom speedbar-supported-extension-expressions | |
22735 | 671 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" |
672 ".el" ".emacs" ".l" ".lsp" ".p" ".java" ".f\\(90\\|77\\|or\\)?") | |
21650 | 673 (if speedbar-use-imenu-flag |
38377
308a2e8895e3
(speedbar-supported-extension-expressions): Add .g to the extension list,
Eli Zaretskii <eliz@gnu.org>
parents:
37891
diff
changeset
|
674 '(".ada" ".p[lm]" ".tcl" ".m" ".scm" ".pm" ".py" ".g" |
22735 | 675 ;; html is not supported by default, but an imenu tags package |
676 ;; is available. Also, html files are nice to be able to see. | |
677 ".s?html" | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
678 "[Mm]akefile\\(\\.in\\)?"))) |
21650 | 679 "*List of regular expressions which will match files supported by tagging. |
680 Do not prefix the `.' char with a double \\ to quote it, as the period | |
681 will be stripped by a simplified optimizer when compiled into a | |
682 singular expression. This variable will be turned into | |
683 `speedbar-file-regexp' for use with speedbar. You should use the | |
684 function `speedbar-add-supported-extension' to add a new extension at | |
685 runtime, or use the configuration dialog to set it in your .emacs | |
686 file." | |
687 :group 'speedbar | |
31562
a2d8210661c8
Add :version to several defcustoms.
Dave Love <fx@gnu.org>
parents:
29260
diff
changeset
|
688 :version "21.1" |
21650 | 689 :type '(repeat (regexp :tag "Extension Regexp")) |
690 :set (lambda (sym val) | |
691 (setq speedbar-supported-extension-expressions val | |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
692 speedbar-file-regexp (speedbar-extension-list-to-regex val)))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
693 |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
694 (defcustom speedbar-scan-subdirs nil |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
695 "*Non-nil means speedbar will check if subdirs are empty. |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
696 That way you don't have to click on them to find out. But this |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
697 incurs extra I/O, hence it slows down directory display |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
698 proportionally to the number of subdirs." |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
699 :group 'speedbar |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
700 :type 'boolean |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
701 :version 21.4) |
21650 | 702 |
703 (defvar speedbar-file-regexp | |
704 (speedbar-extension-list-to-regex speedbar-supported-extension-expressions) | |
705 "Regular expression matching files we know how to expand. | |
706 Created from `speedbar-supported-extension-expression' with the | |
707 function `speedbar-extension-list-to-regex'") | |
708 | |
709 (defun speedbar-add-supported-extension (extension) | |
710 "Add EXTENSION as a new supported extension for speedbar tagging. | |
711 This should start with a `.' if it is not a complete file name, and | |
712 the dot should NOT be quoted in with \\. Other regular expression | |
713 matchers are allowed however. EXTENSION may be a single string or a | |
714 list of strings." | |
44578
9c2b72b4b303
(speedbar-generic-item-info)
Pavel Janík <Pavel@Janik.cz>
parents:
44225
diff
changeset
|
715 (interactive "sExtension: ") |
21650 | 716 (if (not (listp extension)) (setq extension (list extension))) |
717 (while extension | |
718 (if (member (car extension) speedbar-supported-extension-expressions) | |
719 nil | |
720 (setq speedbar-supported-extension-expressions | |
721 (cons (car extension) speedbar-supported-extension-expressions))) | |
722 (setq extension (cdr extension))) | |
723 (setq speedbar-file-regexp (speedbar-extension-list-to-regex | |
724 speedbar-supported-extension-expressions))) | |
725 | |
726 (defun speedbar-add-ignored-path-regexp (path-expression) | |
727 "Add PATH-EXPRESSION as a new ignored path for speedbar tracking. | |
728 This function will modify `speedbar-ignored-path-regexp' and add | |
729 PATH-EXPRESSION to `speedbar-ignored-path-expressions'." | |
22735 | 730 (interactive "sPath regex: ") |
21650 | 731 (if (not (listp path-expression)) |
732 (setq path-expression (list path-expression))) | |
733 (while path-expression | |
734 (if (member (car path-expression) speedbar-ignored-path-expressions) | |
735 nil | |
736 (setq speedbar-ignored-path-expressions | |
737 (cons (car path-expression) speedbar-ignored-path-expressions))) | |
738 (setq path-expression (cdr path-expression))) | |
739 (setq speedbar-ignored-path-regexp (speedbar-extension-list-to-regex | |
740 speedbar-ignored-path-expressions))) | |
741 | |
742 ;; If we don't have custom, then we set it here by hand. | |
743 (if (not (fboundp 'custom-declare-variable)) | |
744 (setq speedbar-file-regexp (speedbar-extension-list-to-regex | |
745 speedbar-supported-extension-expressions) | |
746 speedbar-ignored-path-regexp (speedbar-extension-list-to-regex | |
747 speedbar-ignored-path-expressions))) | |
748 | |
22735 | 749 (defvar speedbar-update-flag (and |
750 (or (fboundp 'run-with-idle-timer) | |
751 (fboundp 'start-itimer) | |
752 (boundp 'post-command-idle-hook)) | |
29260
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
753 (if (fboundp 'display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
754 (display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
755 window-system)) |
21650 | 756 "*Non-nil means to automatically update the display. |
757 When this is nil then speedbar will not follow the attached frame's path. | |
758 When speedbar is active, use: | |
759 | |
760 \\<speedbar-key-map> `\\[speedbar-toggle-updates]' | |
761 | |
762 to toggle this value.") | |
763 | |
764 (defvar speedbar-syntax-table nil | |
765 "Syntax-table used on the speedbar.") | |
766 | |
767 (if speedbar-syntax-table | |
768 nil | |
769 (setq speedbar-syntax-table (make-syntax-table)) | |
770 ;; turn off paren matching around here. | |
771 (modify-syntax-entry ?\' " " speedbar-syntax-table) | |
772 (modify-syntax-entry ?\" " " speedbar-syntax-table) | |
773 (modify-syntax-entry ?( " " speedbar-syntax-table) | |
774 (modify-syntax-entry ?) " " speedbar-syntax-table) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
775 (modify-syntax-entry ?{ " " speedbar-syntax-table) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
776 (modify-syntax-entry ?} " " speedbar-syntax-table) |
21650 | 777 (modify-syntax-entry ?[ " " speedbar-syntax-table) |
778 (modify-syntax-entry ?] " " speedbar-syntax-table)) | |
779 | |
780 (defvar speedbar-key-map nil | |
781 "Keymap used in speedbar buffer.") | |
782 | |
783 (if speedbar-key-map | |
784 nil | |
785 (setq speedbar-key-map (make-keymap)) | |
786 (suppress-keymap speedbar-key-map t) | |
787 | |
788 ;; control | |
789 (define-key speedbar-key-map "g" 'speedbar-refresh) | |
790 (define-key speedbar-key-map "t" 'speedbar-toggle-updates) | |
791 (define-key speedbar-key-map "q" 'speedbar-close-frame) | |
23080
8b7bb810f362
*** empty log message ***
Dan Nicolaescu <done@ece.arizona.edu>
parents:
23073
diff
changeset
|
792 (define-key speedbar-key-map "Q" 'delete-frame) |
21650 | 793 |
794 ;; navigation | |
795 (define-key speedbar-key-map "n" 'speedbar-next) | |
796 (define-key speedbar-key-map "p" 'speedbar-prev) | |
22735 | 797 (define-key speedbar-key-map "\M-n" 'speedbar-restricted-next) |
798 (define-key speedbar-key-map "\M-p" 'speedbar-restricted-prev) | |
799 (define-key speedbar-key-map "\C-\M-n" 'speedbar-forward-list) | |
800 (define-key speedbar-key-map "\C-\M-p" 'speedbar-backward-list) | |
21650 | 801 (define-key speedbar-key-map " " 'speedbar-scroll-up) |
802 (define-key speedbar-key-map [delete] 'speedbar-scroll-down) | |
803 | |
22735 | 804 ;; Short cuts I happen to find useful |
805 (define-key speedbar-key-map "r" | |
806 (lambda () (interactive) | |
807 (speedbar-change-initial-expansion-list | |
808 speedbar-previously-used-expansion-list-name))) | |
809 (define-key speedbar-key-map "b" | |
810 (lambda () (interactive) | |
811 (speedbar-change-initial-expansion-list "quick buffers"))) | |
812 (define-key speedbar-key-map "f" | |
813 (lambda () (interactive) | |
814 (speedbar-change-initial-expansion-list "files"))) | |
815 | |
816 ;; Overrides | |
817 (substitute-key-definition 'switch-to-buffer | |
818 'speedbar-switch-buffer-attached-frame | |
819 speedbar-key-map global-map) | |
21650 | 820 |
821 (if speedbar-xemacsp | |
822 (progn | |
823 ;; mouse bindings so we can manipulate the items on each line | |
824 (define-key speedbar-key-map 'button2 'speedbar-click) | |
825 (define-key speedbar-key-map '(shift button2) 'speedbar-power-click) | |
22735 | 826 ;; Info doc fix from Bob Weiner |
827 (if (featurep 'infodoc) | |
828 nil | |
829 (define-key speedbar-key-map 'button3 'speedbar-xemacs-popup-kludge)) | |
830 (define-key speedbar-key-map '(meta button3) 'speedbar-mouse-item-info) | |
831 ) | |
832 | |
21650 | 833 ;; mouse bindings so we can manipulate the items on each line |
834 (define-key speedbar-key-map [down-mouse-1] 'speedbar-double-click) | |
835 (define-key speedbar-key-map [mouse-2] 'speedbar-click) | |
836 ;; This is the power click for new frames, or refreshing a cache | |
837 (define-key speedbar-key-map [S-mouse-2] 'speedbar-power-click) | |
838 ;; This adds a small unecessary visual effect | |
839 ;;(define-key speedbar-key-map [down-mouse-2] 'speedbar-quick-mouse) | |
840 (define-key speedbar-key-map [M-mouse-2] 'speedbar-mouse-item-info) | |
841 | |
842 (define-key speedbar-key-map [down-mouse-3] 'speedbar-emacs-popup-kludge) | |
843 | |
844 ;; This lets the user scroll as if we had a scrollbar... well maybe not | |
845 (define-key speedbar-key-map [mode-line mouse-2] 'speedbar-mouse-hscroll) | |
22735 | 846 ;; another handy place users might click to get our menu. |
847 (define-key speedbar-key-map [mode-line down-mouse-1] | |
848 'speedbar-emacs-popup-kludge) | |
849 | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
850 ;; We can't switch buffers with the buffer mouse menu. Lets hack it. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
851 (define-key speedbar-key-map [C-down-mouse-1] 'speedbar-hack-buffer-menu) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
852 |
22735 | 853 ;; Lastly, we want to track the mouse. Play here |
854 (define-key speedbar-key-map [mouse-movement] 'speedbar-track-mouse) | |
855 )) | |
856 | |
857 (defun speedbar-make-specialized-keymap () | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
858 "Create a keymap for use with a speedbar major or minor display mode. |
22735 | 859 This basically creates a sparse keymap, and makes it's parent be |
860 `speedbar-key-map'." | |
861 (let ((k (make-sparse-keymap))) | |
862 (set-keymap-parent k speedbar-key-map) | |
863 k)) | |
864 | |
865 (defvar speedbar-file-key-map nil | |
866 "Keymap used in speedbar buffer while files are displayed.") | |
867 | |
868 (if speedbar-file-key-map | |
869 nil | |
870 (setq speedbar-file-key-map (speedbar-make-specialized-keymap)) | |
871 | |
872 ;; Basic tree features | |
873 (define-key speedbar-file-key-map "e" 'speedbar-edit-line) | |
874 (define-key speedbar-file-key-map "\C-m" 'speedbar-edit-line) | |
875 (define-key speedbar-file-key-map "+" 'speedbar-expand-line) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
876 (define-key speedbar-file-key-map "=" 'speedbar-expand-line) |
22735 | 877 (define-key speedbar-file-key-map "-" 'speedbar-contract-line) |
878 | |
879 ;; file based commands | |
880 (define-key speedbar-file-key-map "U" 'speedbar-up-directory) | |
881 (define-key speedbar-file-key-map "I" 'speedbar-item-info) | |
882 (define-key speedbar-file-key-map "B" 'speedbar-item-byte-compile) | |
883 (define-key speedbar-file-key-map "L" 'speedbar-item-load) | |
884 (define-key speedbar-file-key-map "C" 'speedbar-item-copy) | |
885 (define-key speedbar-file-key-map "D" 'speedbar-item-delete) | |
886 (define-key speedbar-file-key-map "O" 'speedbar-item-object-delete) | |
887 (define-key speedbar-file-key-map "R" 'speedbar-item-rename) | |
888 ) | |
21650 | 889 |
890 (defvar speedbar-easymenu-definition-base | |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
891 (append |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
892 '("Speedbar" |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
893 ["Update" speedbar-refresh t] |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
894 ["Auto Update" speedbar-toggle-updates |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
895 :style toggle :selected speedbar-update-flag]) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
896 (if (and (or (fboundp 'defimage) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
897 (fboundp 'make-image-specifier)) |
29260
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
898 (if (fboundp 'display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
899 (display-graphic-p) |
7f1b3013a136
(speedbar-use-images, speedbar-update-flag)
Eli Zaretskii <eliz@gnu.org>
parents:
29130
diff
changeset
|
900 window-system)) |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
901 (list |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
902 ["Use Images" speedbar-toggle-images |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
903 :style toggle :selected speedbar-use-images])) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
904 ) |
21650 | 905 "Base part of the speedbar menu.") |
906 | |
907 (defvar speedbar-easymenu-definition-special | |
908 '(["Edit Item On Line" speedbar-edit-line t] | |
909 ["Show All Files" speedbar-toggle-show-all-files | |
910 :style toggle :selected speedbar-show-unknown-files] | |
22735 | 911 ["Expand File Tags" speedbar-expand-line |
21650 | 912 (save-excursion (beginning-of-line) |
913 (looking-at "[0-9]+: *.\\+. "))] | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
914 ["Flush Cache & Expand" speedbar-flush-expand-line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
915 (save-excursion (beginning-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
916 (looking-at "[0-9]+: *.\\+. "))] |
22735 | 917 ["Contract File Tags" speedbar-contract-line |
21650 | 918 (save-excursion (beginning-of-line) |
919 (looking-at "[0-9]+: *.-. "))] | |
22735 | 920 ; ["Sort Tags" speedbar-toggle-sorting |
921 ; :style toggle :selected speedbar-sort-tags] | |
21650 | 922 "----" |
22735 | 923 ["File/Tag Information" speedbar-item-info t] |
21650 | 924 ["Load Lisp File" speedbar-item-load |
925 (save-excursion | |
926 (beginning-of-line) | |
22735 | 927 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\|$\\)"))] |
21650 | 928 ["Byte Compile File" speedbar-item-byte-compile |
929 (save-excursion | |
930 (beginning-of-line) | |
22735 | 931 (looking-at "[0-9]+: *\\[[+-]\\] .+\\(\\.el\\)\\( \\|$\\)"))] |
932 ["Copy File" speedbar-item-copy | |
21650 | 933 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *\\["))] |
22735 | 934 ["Rename File" speedbar-item-rename |
935 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))] | |
936 ["Delete File" speedbar-item-delete | |
21650 | 937 (save-excursion (beginning-of-line) (looking-at "[0-9]+: *[[<]"))] |
22735 | 938 ["Delete Object" speedbar-item-object-delete |
939 (save-excursion (beginning-of-line) | |
940 (looking-at "[0-9]+: *\\[[+-]\\] [^ \n]+ \\*?[!#]$"))] | |
941 ) | |
21650 | 942 "Additional menu items while in file-mode.") |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
943 |
21650 | 944 (defvar speedbar-easymenu-definition-trailer |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
945 (append |
22735 | 946 (if (and (featurep 'custom) (fboundp 'custom-declare-variable)) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
947 (list ["Customize..." speedbar-customize t])) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
948 (list |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
949 ["Close" speedbar-close-frame t] |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
950 ["Quit" delete-frame t] )) |
21650 | 951 "Menu items appearing at the end of the speedbar menu.") |
952 | |
953 (defvar speedbar-desired-buffer nil | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
954 "Non-nil when speedbar is showing buttons specific to a special mode. |
21650 | 955 In this case it is the originating buffer.") |
956 (defvar speedbar-buffer nil | |
957 "The buffer displaying the speedbar.") | |
958 (defvar speedbar-frame nil | |
959 "The frame displaying speedbar.") | |
960 (defvar speedbar-cached-frame nil | |
961 "The frame that was last created, then removed from the display.") | |
962 (defvar speedbar-full-text-cache nil | |
963 "The last open directory is saved in its entirety for ultra-fast switching.") | |
964 (defvar speedbar-timer nil | |
965 "The speedbar timer used for updating the buffer.") | |
966 (defvar speedbar-attached-frame nil | |
967 "The frame which started speedbar mode. | |
968 This is the frame from which all data displayed in the speedbar is | |
969 gathered, and in which files and such are displayed.") | |
970 | |
971 (defvar speedbar-last-selected-file nil | |
972 "The last file which was selected in speedbar buffer.") | |
973 | |
974 (defvar speedbar-shown-directories nil | |
975 "Maintain list of directories simultaneously open in the current speedbar.") | |
976 | |
977 (defvar speedbar-directory-contents-alist nil | |
978 "An association list of directories and their contents. | |
979 Each sublist was returned by `speedbar-file-lists'. This list is | |
980 maintained to speed up the refresh rate when switching between | |
981 directories.") | |
982 | |
983 (defvar speedbar-power-click nil | |
984 "Never set this by hand. Value is t when S-mouse activity occurs.") | |
985 | |
986 | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
987 ;;; Compatibility |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
988 ;; |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
989 (if (fboundp 'frame-parameter) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
990 |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
991 (defalias 'speedbar-frame-parameter 'frame-parameter) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
992 |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
993 (defun speedbar-frame-parameter (frame parameter) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
994 "Return FRAME's PARAMETER value." |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
995 (cdr (assoc parameter (frame-parameters frame))))) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
996 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
997 (if (fboundp 'make-overlay) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
998 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
999 (defalias 'speedbar-make-overlay 'make-overlay) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1000 (defalias 'speedbar-overlay-put 'overlay-put) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1001 (defalias 'speedbar-delete-overlay 'delete-overlay) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1002 (defalias 'speedbar-overlay-start 'overlay-start) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1003 (defalias 'speedbar-overlay-end 'overlay-end) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1004 (defalias 'speedbar-mode-line-update 'force-mode-line-update)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1005 (defalias 'speedbar-make-overlay 'make-extent) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1006 (defalias 'speedbar-overlay-put 'set-extent-property) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1007 (defalias 'speedbar-delete-overlay 'delete-extent) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1008 (defalias 'speedbar-overlay-start 'extent-start) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1009 (defalias 'speedbar-overlay-end 'extent-end) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1010 (defalias 'speedbar-mode-line-update 'redraw-modeline)) |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1011 |
21650 | 1012 ;;; Mode definitions/ user commands |
1013 ;; | |
1014 | |
1015 ;;;###autoload | |
1016 (defalias 'speedbar 'speedbar-frame-mode) | |
1017 ;;;###autoload | |
1018 (defun speedbar-frame-mode (&optional arg) | |
1019 "Enable or disable speedbar. Positive ARG means turn on, negative turn off. | |
1020 nil means toggle. Once the speedbar frame is activated, a buffer in | |
1021 `speedbar-mode' will be displayed. Currently, only one speedbar is | |
1022 supported at a time. | |
1023 `speedbar-before-popup-hook' is called before popping up the speedbar frame. | |
1024 `speedbar-before-delete-hook' is called before the frame is deleted." | |
1025 (interactive "P") | |
1026 ;; toggle frame on and off. | |
1027 (if (not arg) (if (and (frame-live-p speedbar-frame) | |
1028 (frame-visible-p speedbar-frame)) | |
1029 (setq arg -1) (setq arg 1))) | |
1030 ;; turn the frame off on neg number | |
1031 (if (and (numberp arg) (< arg 0)) | |
1032 (progn | |
1033 (run-hooks 'speedbar-before-delete-hook) | |
1034 (if (and speedbar-frame (frame-live-p speedbar-frame)) | |
1035 (progn | |
1036 (setq speedbar-cached-frame speedbar-frame) | |
1037 (make-frame-invisible speedbar-frame))) | |
1038 (setq speedbar-frame nil) | |
1039 (speedbar-set-timer nil) | |
1040 ;; Used to delete the buffer. This has the annoying affect of | |
1041 ;; preventing whatever took its place from ever appearing | |
1042 ;; as the default after a C-x b was typed | |
1043 ;;(if (bufferp speedbar-buffer) | |
1044 ;; (kill-buffer speedbar-buffer)) | |
1045 ) | |
1046 ;; Set this as our currently attached frame | |
1047 (setq speedbar-attached-frame (selected-frame)) | |
1048 (run-hooks 'speedbar-before-popup-hook) | |
1049 ;; Get the frame to work in | |
1050 (if (frame-live-p speedbar-cached-frame) | |
1051 (progn | |
1052 (setq speedbar-frame speedbar-cached-frame) | |
1053 (make-frame-visible speedbar-frame) | |
1054 ;; Get the buffer to play with | |
1055 (speedbar-mode) | |
1056 (select-frame speedbar-frame) | |
1057 (if (not (eq (current-buffer) speedbar-buffer)) | |
1058 (switch-to-buffer speedbar-buffer)) | |
1059 (set-window-dedicated-p (selected-window) t) | |
1060 (raise-frame speedbar-frame) | |
1061 (speedbar-set-timer speedbar-update-speed) | |
1062 ) | |
1063 (if (frame-live-p speedbar-frame) | |
1064 (raise-frame speedbar-frame) | |
1065 (setq speedbar-frame | |
1066 (if speedbar-xemacsp | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1067 ;; Only guess height if it is not specified. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1068 (if (member 'height speedbar-frame-plist) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1069 (make-frame speedbar-frame-plist) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1070 (make-frame (nconc (list 'height |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1071 (speedbar-needed-height)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1072 speedbar-frame-plist))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1073 (let* ((mh (speedbar-frame-parameter nil 'menu-bar-lines)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1074 (cfx (speedbar-frame-parameter nil 'left)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1075 (cfy (speedbar-frame-parameter nil 'top)) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1076 (cfw (frame-pixel-width)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1077 (params |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1078 ;; Only add a guessed height if one is not specified |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1079 ;; in the input parameters. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1080 (if (assoc 'height speedbar-frame-parameters) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1081 speedbar-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1082 (append |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1083 speedbar-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1084 (list (cons 'height (+ mh (frame-height))))))) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1085 (frame |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1086 (if (or (< emacs-major-version 20) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1087 (not (eq window-system 'x))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1088 (make-frame params) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1089 (let ((x-pointer-shape x-pointer-top-left-arrow) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1090 (x-sensitive-text-pointer-shape |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1091 x-pointer-hand2)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
1092 (make-frame params))))) |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1093 ;; Position speedbar frame. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1094 (if (or (not window-system) (eq window-system 'pc) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1095 (assoc 'left speedbar-frame-parameters) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1096 (assoc 'top speedbar-frame-parameters)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1097 ;; Do no positioning if not on a windowing system, |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1098 ;; or if left/top were specified in the parameters. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1099 frame |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1100 (let ((cfx |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1101 (if (not (consp cfx)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1102 cfx |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1103 ;; If cfx is a list, that means we grow |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1104 ;; from a specific edge of the display. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1105 ;; Convert that to the distance from the |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1106 ;; left side of the display. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1107 (if (eq (car cfx) '-) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1108 ;; A - means distance from the right edge |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1109 ;; of the display, or DW - cfx - framewidth |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1110 (- (x-display-pixel-width) (car (cdr cfx)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1111 (frame-pixel-width)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1112 (car (cdr cfx)))))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1113 (modify-frame-parameters |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1114 frame |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1115 (list |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1116 (cons |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1117 'left |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1118 ;; Decide which side to put it |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1119 ;; on. 200 is just a buffer |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1120 ;; for the left edge of the |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1121 ;; screen. The extra 10 is just |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1122 ;; dressings for window decorations. |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1123 (let ((sfw (frame-pixel-width frame))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1124 (let ((left-guess (- cfx 10 sfw)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1125 (right-guess (+ cfx cfw 5))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1126 (let ((left-margin left-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1127 (right-margin |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1128 (- (x-display-pixel-width) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1129 right-guess 5 sfw))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1130 (cond ((>= left-margin 0) left-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1131 ((>= right-margin 0) right-guess) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1132 ;; otherwise choose side we overlap less |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1133 ((> left-margin right-margin) 0) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1134 (t (- (x-display-pixel-width) sfw 5))))))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1135 (cons 'top cfy))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
1136 frame))))) |
21650 | 1137 ;; reset the selection variable |
1138 (setq speedbar-last-selected-file nil) | |
1139 ;; Put the buffer into the frame | |
1140 (save-window-excursion | |
1141 ;; Get the buffer to play with | |
1142 (speedbar-mode) | |
1143 (select-frame speedbar-frame) | |
1144 (switch-to-buffer speedbar-buffer) | |
1145 (set-window-dedicated-p (selected-window) t)) | |
23372
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
1146 (if (and (or (null window-system) (eq window-system 'pc)) |
64e80b07376b
(speedbar-frame-mode): Check if cfx or cfy is a list, and make sure it
Eric M. Ludlam <zappo@gnu.org>
parents:
23275
diff
changeset
|
1147 (fboundp 'set-frame-name)) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1148 (progn |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1149 (select-frame speedbar-frame) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1150 (set-frame-name "Speedbar"))) |
21650 | 1151 (speedbar-set-timer speedbar-update-speed))))) |
1152 | |
1153 ;;;###autoload | |
1154 (defun speedbar-get-focus () | |
1155 "Change frame focus to or from the speedbar frame. | |
1156 If the selected frame is not speedbar, then speedbar frame is | |
1157 selected. If the speedbar frame is active, then select the attached frame." | |
1158 (interactive) | |
1159 (if (eq (selected-frame) speedbar-frame) | |
1160 (if (frame-live-p speedbar-attached-frame) | |
1161 (select-frame speedbar-attached-frame)) | |
22735 | 1162 ;; If updates are off, then refresh the frame (they want it now...) |
1163 (if (not speedbar-update-flag) | |
1164 (let ((speedbar-update-flag t)) | |
1165 (speedbar-timer-fn))) | |
21650 | 1166 ;; make sure we have a frame |
1167 (if (not (frame-live-p speedbar-frame)) (speedbar-frame-mode 1)) | |
1168 ;; go there | |
22735 | 1169 (select-frame speedbar-frame) |
1170 ) | |
21650 | 1171 (other-frame 0)) |
1172 | |
1173 (defun speedbar-close-frame () | |
1174 "Turn off a currently active speedbar." | |
1175 (interactive) | |
1176 (speedbar-frame-mode -1) | |
1177 (select-frame speedbar-attached-frame) | |
1178 (other-frame 0)) | |
1179 | |
22735 | 1180 (defun speedbar-switch-buffer-attached-frame (&optional buffer) |
1181 "Switch to BUFFER in speedbar's attached frame, and raise that frame. | |
1182 This overrides the default behavior of `switch-to-buffer' which is | |
1183 broken because of the dedicated speedbar frame." | |
1184 (interactive) | |
1185 ;; Assume we are in the speedbar frame. | |
1186 (speedbar-get-focus) | |
1187 ;; Now switch buffers | |
1188 (if buffer | |
1189 (switch-to-buffer buffer) | |
1190 (call-interactively 'switch-to-buffer nil nil))) | |
1191 | |
21650 | 1192 (defmacro speedbar-frame-width () |
1193 "Return the width of the speedbar frame in characters. | |
1194 nil if it doesn't exist." | |
1195 '(frame-width speedbar-frame)) | |
1196 | |
1197 ;; XEmacs function only. | |
1198 (defun speedbar-needed-height (&optional frame) | |
1199 "The needed height for the tool bar FRAME (in characters)." | |
1200 (or frame (setq frame (selected-frame))) | |
1201 ;; The 1 is the missing modeline/minibuffer | |
1202 (+ 1 (/ (frame-pixel-height frame) | |
1203 (face-height 'default frame)))) | |
1204 | |
1205 (defun speedbar-mode () | |
1206 "Major mode for managing a display of directories and tags. | |
1207 \\<speedbar-key-map> | |
1208 The first line represents the default path of the speedbar frame. | |
1209 Each directory segment is a button which jumps speedbar's default | |
1210 directory to that path. Buttons are activated by clicking `\\[speedbar-click]'. | |
1211 In some situations using `\\[speedbar-power-click]' is a `power click' which will | |
1212 rescan cached items, or pop up new frames. | |
1213 | |
1214 Each line starting with <+> represents a directory. Click on the <+> | |
1215 to insert the directory listing into the current tree. Click on the | |
1216 <-> to retract that list. Click on the directory name to go to that | |
1217 directory as the default. | |
1218 | |
1219 Each line starting with [+] is a file. If the variable | |
1220 `speedbar-show-unknown-files' is t, the lines starting with [?] are | |
1221 files which don't have imenu support, but are not expressly ignored. | |
1222 Files are completely ignored if they match `speedbar-file-unshown-regexp' | |
1223 which is generated from `completion-ignored-extensions'. | |
1224 | |
1225 Files with a `*' character after their name are files checked out of a | |
47286
4f937ab8ad22
(speedbar-mode): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
47267
diff
changeset
|
1226 version control system. (Currently only RCS is supported.) New |
21650 | 1227 version control systems can be added by examining the documentation |
47286
4f937ab8ad22
(speedbar-mode): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
47267
diff
changeset
|
1228 for `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p'. |
21650 | 1229 |
22735 | 1230 Files with a `#' or `!' character after them are source files that |
1231 have an object file associated with them. The `!' indicates that the | |
47267
8b5ff870e329
(speedbar-mode): Fix spacing.
Juanma Barranquero <lekktu@gmail.com>
parents:
46288
diff
changeset
|
1232 files is out of date. You can control what source/object associations |
22735 | 1233 exist through the variable `speedbar-obj-alist'. |
1234 | |
21650 | 1235 Click on the [+] to display a list of tags from that file. Click on |
1236 the [-] to retract the list. Click on the file name to edit the file | |
1237 in the attached frame. | |
1238 | |
1239 If you open tags, you might find a node starting with {+}, which is a | |
1240 category of tags. Click the {+} to expand the category. Jump-able | |
1241 tags start with >. Click the name of the tag to go to that position | |
1242 in the selected file. | |
1243 | |
1244 \\{speedbar-key-map}" | |
1245 ;; NOT interactive | |
1246 (save-excursion | |
1247 (setq speedbar-buffer (set-buffer (get-buffer-create " SPEEDBAR"))) | |
1248 (kill-all-local-variables) | |
1249 (setq major-mode 'speedbar-mode) | |
1250 (setq mode-name "Speedbar") | |
1251 (set-syntax-table speedbar-syntax-table) | |
1252 (setq font-lock-keywords nil) ;; no font-locking please | |
1253 (setq truncate-lines t) | |
1254 (make-local-variable 'frame-title-format) | |
1255 (setq frame-title-format "Speedbar") | |
1256 ;; Set this up special just for the speedbar buffer | |
22735 | 1257 ;; Terminal minibuffer stuff does not require this. |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1258 (if (and window-system (not (eq window-system 'pc)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1259 (null default-minibuffer-frame)) |
21650 | 1260 (progn |
1261 (make-local-variable 'default-minibuffer-frame) | |
1262 (setq default-minibuffer-frame speedbar-attached-frame))) | |
22735 | 1263 ;; Correct use of `temp-buffer-show-function': Bob Weiner |
1264 (if (and (boundp 'temp-buffer-show-hook) | |
1265 (boundp 'temp-buffer-show-function)) | |
1266 (progn (make-local-variable 'temp-buffer-show-hook) | |
1267 (setq temp-buffer-show-hook temp-buffer-show-function))) | |
21650 | 1268 (make-local-variable 'temp-buffer-show-function) |
1269 (setq temp-buffer-show-function 'speedbar-temp-buffer-show-function) | |
1270 (if speedbar-xemacsp | |
1271 (progn | |
1272 ;; Argh! mouse-track-click-hook doesn't understand the | |
1273 ;; make-local-hook conventions. | |
1274 (make-local-variable 'mouse-track-click-hook) | |
1275 (add-hook 'mouse-track-click-hook | |
1276 (lambda (event count) | |
1277 (if (/= (event-button event) 1) | |
1278 nil ; Do normal operations. | |
1279 (cond ((eq count 1) | |
1280 (speedbar-quick-mouse event)) | |
1281 ((or (eq count 2) | |
1282 (eq count 3)) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1283 (speedbar-mouse-set-point event) |
21650 | 1284 (speedbar-do-function-pointer) |
1285 (speedbar-quick-mouse event))) | |
1286 ;; Don't do normal operations. | |
1287 t))))) | |
1288 (add-hook 'kill-buffer-hook (lambda () (let ((skilling (boundp 'skilling))) | |
1289 (if skilling | |
1290 nil | |
1291 (if (eq (current-buffer) | |
1292 speedbar-buffer) | |
1293 (speedbar-frame-mode -1))))) | |
1294 t t) | |
23083
2dea437fe88a
(speedbar-with-writable): remove `toggle-read-only'.
Eric M. Ludlam <zappo@gnu.org>
parents:
23080
diff
changeset
|
1295 (toggle-read-only 1) |
21650 | 1296 (speedbar-set-mode-line-format) |
22735 | 1297 (if speedbar-xemacsp |
28925
89a795d90175
(speedbar-recenter): Typo, and fix logic.
Eric M. Ludlam <zappo@gnu.org>
parents:
28902
diff
changeset
|
1298 (set (make-local-variable 'mouse-motion-handler) |
89a795d90175
(speedbar-recenter): Typo, and fix logic.
Eric M. Ludlam <zappo@gnu.org>
parents:
28902
diff
changeset
|
1299 'speedbar-track-mouse-xemacs) |
22735 | 1300 (if speedbar-track-mouse-flag |
28925
89a795d90175
(speedbar-recenter): Typo, and fix logic.
Eric M. Ludlam <zappo@gnu.org>
parents:
28902
diff
changeset
|
1301 (set (make-local-variable 'track-mouse) t)) ;this could be messy. |
22735 | 1302 (setq auto-show-mode nil)) ;no auto-show for Emacs |
21650 | 1303 (run-hooks 'speedbar-mode-hook)) |
1304 (speedbar-update-contents) | |
1305 speedbar-buffer) | |
1306 | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1307 (defmacro speedbar-with-attached-buffer (&rest forms) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1308 "Execute FORMS in the attached frame's special buffer. |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1309 Optionally select that frame if necessary." |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1310 `(save-selected-window |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1311 (speedbar-set-timer speedbar-update-speed) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1312 (select-frame speedbar-attached-frame) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1313 ,@forms |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1314 (speedbar-maybee-jump-to-attached-frame))) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1315 |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1316 (defun speedbar-message (fmt &rest args) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1317 "Like message, but for use in the speedbar frame. |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1318 Argument FMT is the format string, and ARGS are the arguments for message." |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1319 (save-selected-window |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1320 (select-frame speedbar-attached-frame) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1321 (apply 'message fmt args))) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1322 |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1323 (defun speedbar-y-or-n-p (prompt) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1324 "Like `y-or-n-p', but for use in the speedbar frame. |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1325 Argument PROMPT is the prompt to use." |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1326 (save-selected-window |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1327 (if (and default-minibuffer-frame (not (eq default-minibuffer-frame |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1328 speedbar-attached-frame))) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1329 (select-frame speedbar-attached-frame)) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1330 (y-or-n-p prompt))) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1331 |
22735 | 1332 (defun speedbar-show-info-under-mouse (&optional event) |
1333 "Call the info function for the line under the mouse. | |
1334 Optional EVENT is currently not used." | |
1335 (let ((pos (mouse-position))) ; we ignore event until I use it later. | |
1336 (if (equal (car pos) speedbar-frame) | |
1337 (save-excursion | |
1338 (save-window-excursion | |
1339 (apply 'set-mouse-position pos) | |
1340 (speedbar-item-info)))))) | |
1341 | |
21650 | 1342 (defun speedbar-set-mode-line-format () |
1343 "Set the format of the mode line based on the current speedbar environment. | |
1344 This gives visual indications of what is up. It EXPECTS the speedbar | |
1345 frame and window to be the currently active frame and window." | |
1346 (if (and (frame-live-p speedbar-frame) | |
1347 (or (not speedbar-xemacsp) | |
1348 (specifier-instance has-modeline-p))) | |
1349 (save-excursion | |
1350 (set-buffer speedbar-buffer) | |
1351 (let* ((w (or (speedbar-frame-width) 20)) | |
1352 (p1 "<<") | |
1353 (p5 ">>") | |
1354 (p3 (if speedbar-update-flag "SPEEDBAR" "SLOWBAR")) | |
1355 (blank (- w (length p1) (length p3) (length p5) | |
1356 (if line-number-mode 4 0))) | |
1357 (p2 (if (> blank 0) | |
1358 (make-string (/ blank 2) ? ) | |
1359 "")) | |
1360 (p4 (if (> blank 0) | |
1361 (make-string (+ (/ blank 2) (% blank 2)) ? ) | |
1362 "")) | |
1363 (tf | |
1364 (if line-number-mode | |
1365 (list (concat p1 p2 p3) '(line-number-mode " %3l") | |
1366 (concat p4 p5)) | |
1367 (list (concat p1 p2 p3 p4 p5))))) | |
1368 (if (not (equal mode-line-format tf)) | |
1369 (progn | |
1370 (setq mode-line-format tf) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1371 (speedbar-mode-line-update))))))) |
21650 | 1372 |
1373 (defun speedbar-temp-buffer-show-function (buffer) | |
1374 "Placed in the variable `temp-buffer-show-function' in `speedbar-mode'. | |
1375 If a user requests help using \\[help-command] <Key> the temp BUFFER will be | |
1376 redirected into a window on the attached frame." | |
1377 (if speedbar-attached-frame (select-frame speedbar-attached-frame)) | |
1378 (pop-to-buffer buffer nil) | |
1379 (other-window -1) | |
23084
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1380 ;; Fix for using this hook on some platforms: Bob Weiner |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1381 (cond ((not speedbar-xemacsp) |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1382 (run-hooks 'temp-buffer-show-hook)) |
e1613f1c52f8
(speedbar-temp-buffer-show-function): For emacs don't call hook
Eric M. Ludlam <zappo@gnu.org>
parents:
23083
diff
changeset
|
1383 ((fboundp 'run-hook-with-args) |
22735 | 1384 (run-hook-with-args 'temp-buffer-show-hook buffer)) |
1385 ((and (boundp 'temp-buffer-show-hook) | |
1386 (listp temp-buffer-show-hook)) | |
1387 (mapcar (function (lambda (hook) (funcall hook buffer))) | |
1388 temp-buffer-show-hook)))) | |
21650 | 1389 |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1390 (defvar speedbar-previous-menu nil |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1391 "The menu before the last `speedbar-reconfigure-keymaps' was called.") |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1392 |
22735 | 1393 (defun speedbar-reconfigure-keymaps () |
21650 | 1394 "Reconfigure the menu-bar in a speedbar frame. |
1395 Different menu items are displayed depending on the current display mode | |
1396 and the existence of packages." | |
22735 | 1397 (let ((md (append |
1398 speedbar-easymenu-definition-base | |
1399 (if speedbar-shown-directories | |
1400 ;; file display mode version | |
1401 (speedbar-initial-menu) | |
1402 (save-excursion | |
1403 (select-frame speedbar-attached-frame) | |
1404 (if (local-variable-p | |
1405 'speedbar-easymenu-definition-special | |
1406 (current-buffer)) | |
1407 ;; If bound locally, we can use it | |
1408 speedbar-easymenu-definition-special))) | |
1409 ;; Dynamic menu stuff | |
1410 '("-") | |
1411 (list (cons "Displays" | |
1412 (let ((displays nil) | |
1413 (alist speedbar-initial-expansion-mode-alist)) | |
1414 (while alist | |
1415 (setq displays | |
1416 (cons | |
1417 (vector | |
1418 (capitalize (car (car alist))) | |
1419 (list | |
1420 'speedbar-change-initial-expansion-list | |
1421 (car (car alist))) | |
1422 t) | |
1423 displays)) | |
1424 (setq alist (cdr alist))) | |
1425 displays))) | |
1426 ;; The trailer | |
1427 speedbar-easymenu-definition-trailer)) | |
1428 (localmap (save-excursion | |
1429 (let ((cf (selected-frame))) | |
1430 (prog2 | |
1431 (select-frame speedbar-attached-frame) | |
1432 (if (local-variable-p | |
1433 'speedbar-special-mode-key-map | |
1434 (current-buffer)) | |
1435 speedbar-special-mode-key-map) | |
1436 (select-frame cf)))))) | |
1437 (save-excursion | |
1438 (set-buffer speedbar-buffer) | |
1439 (use-local-map (or localmap | |
1440 (speedbar-initial-keymap) | |
1441 ;; This creates a small keymap we can glom the | |
1442 ;; menu adjustments into. | |
1443 (speedbar-make-specialized-keymap))) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1444 ;; Delete the old menu if applicable. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1445 (if speedbar-previous-menu (easy-menu-remove speedbar-previous-menu)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1446 (setq speedbar-previous-menu md) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1447 ;; Now add the new menu |
22735 | 1448 (if (not speedbar-xemacsp) |
1449 (easy-menu-define speedbar-menu-map (current-local-map) | |
1450 "Speedbar menu" md) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1451 (easy-menu-add md (current-local-map)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1452 (set-buffer-menubar (list md)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1453 (run-hooks 'speedbar-reconfigure-keymaps-hook))) |
21650 | 1454 |
1455 | |
1456 ;;; User Input stuff | |
1457 ;; | |
1458 | |
1459 ;; XEmacs: this can be implemented using modeline keymaps, but there | |
1460 ;; is no use, as we have horizontal scrollbar (as the docstring | |
1461 ;; hints.) | |
1462 (defun speedbar-mouse-hscroll (e) | |
1463 "Read a mouse event E from the mode line, and horizontally scroll. | |
1464 If the mouse is being clicked on the far left, or far right of the | |
46286
6117ca314143
(speedbar-tag-hierarchy-method): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
46282
diff
changeset
|
1465 mode-line. This is only useful for non-XEmacs." |
21650 | 1466 (interactive "e") |
1467 (let* ((xp (car (nth 2 (car (cdr e))))) | |
1468 (cpw (/ (frame-pixel-width) | |
1469 (frame-width))) | |
1470 (oc (1+ (/ xp cpw))) | |
1471 ) | |
1472 (cond ((< oc 3) | |
1473 (scroll-left 2)) | |
1474 ((> oc (- (window-width) 3)) | |
1475 (scroll-right 2)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1476 (t (speedbar-message |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1477 "Click on the edge of the modeline to scroll left/right"))) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1478 ;;(speedbar-message "X: Pixel %d Char Pixels %d On char %d" xp cpw oc) |
21650 | 1479 )) |
1480 | |
1481 (defun speedbar-customize () | |
1482 "Customize speedbar using the Custom package." | |
1483 (interactive) | |
1484 (let ((sf (selected-frame))) | |
1485 (select-frame speedbar-attached-frame) | |
1486 (customize-group 'speedbar) | |
1487 (select-frame sf)) | |
1488 (speedbar-maybee-jump-to-attached-frame)) | |
1489 | |
22735 | 1490 (defun speedbar-track-mouse (event) |
1491 "For motion EVENT, display info about the current line." | |
1492 (interactive "e") | |
1493 (if (not speedbar-track-mouse-flag) | |
1494 nil | |
1495 (save-excursion | |
1496 (let ((char (nth 1 (car (cdr event))))) | |
1497 (if (not (numberp char)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1498 (speedbar-message nil) |
22735 | 1499 (goto-char char) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1500 ;; (speedbar-message "%S" event) |
22735 | 1501 (speedbar-item-info) |
1502 ))))) | |
1503 | |
1504 (defun speedbar-track-mouse-xemacs (event) | |
1505 "For motion EVENT, display info about the current line." | |
1506 (if (functionp (default-value 'mouse-motion-handler)) | |
1507 (funcall (default-value 'mouse-motion-handler) event)) | |
1508 (if speedbar-track-mouse-flag | |
1509 (save-excursion | |
1510 (save-window-excursion | |
1511 (condition-case () | |
1512 (progn (mouse-set-point event) | |
1513 ;; Prevent focus-related bugs. | |
1514 (if (eq major-mode 'speedbar-mode) | |
1515 (speedbar-item-info))) | |
1516 (error nil)))))) | |
1517 | |
21650 | 1518 ;; In XEmacs, we make popup menus work on the item over mouse (as |
1519 ;; opposed to where the point happens to be.) We attain this by | |
1520 ;; temporarily moving the point to that place. | |
1521 ;; Hrvoje Niksic <hniksic@srce.hr> | |
1522 (defun speedbar-xemacs-popup-kludge (event) | |
1523 "Pop up a menu related to the clicked on item. | |
1524 Must be bound to EVENT." | |
1525 (interactive "e") | |
22735 | 1526 (select-frame speedbar-frame) |
21650 | 1527 (save-excursion |
1528 (goto-char (event-closest-point event)) | |
1529 (beginning-of-line) | |
1530 (forward-char (min 5 (- (save-excursion (end-of-line) (point)) | |
1531 (save-excursion (beginning-of-line) (point))))) | |
1532 (popup-mode-menu) | |
1533 ;; Wait for menu to bail out. `popup-mode-menu' (and other popup | |
1534 ;; menu functions) return immediately. | |
1535 (let (new) | |
1536 (while (not (misc-user-event-p (setq new (next-event)))) | |
1537 (dispatch-event new)) | |
1538 (dispatch-event new)))) | |
1539 | |
1540 (defun speedbar-emacs-popup-kludge (e) | |
1541 "Pop up a menu related to the clicked on item. | |
1542 Must be bound to event E." | |
1543 (interactive "e") | |
1544 (save-excursion | |
1545 (mouse-set-point e) | |
1546 ;; This gets the cursor where the user can see it. | |
1547 (if (not (bolp)) (forward-char -1)) | |
1548 (sit-for 0) | |
1549 (if (< emacs-major-version 20) | |
1550 (mouse-major-mode-menu e) | |
1551 (mouse-major-mode-menu e nil)))) | |
1552 | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1553 (defun speedbar-hack-buffer-menu (e) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1554 "Control mouse 1 is buffer menu. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1555 This hack overrides it so that the right thing happens in the main |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1556 Emacs frame, not in the speedbar frame. |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1557 Argument E is the event causing this activity." |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1558 (interactive "e") |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1559 (let ((fn (lookup-key global-map (if speedbar-xemacsp |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1560 '(control button1) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1561 [C-down-mouse-1]))) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1562 (newbuff nil)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1563 (unwind-protect |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1564 (save-excursion |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1565 (set-window-dedicated-p (selected-window) nil) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1566 (call-interactively fn) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1567 (setq newbuff (current-buffer))) |
24809
078e0b907e6e
(speedbar-hack-buffer-menu): Fixed so if the user
Karl Heuer <kwzh@gnu.org>
parents:
24475
diff
changeset
|
1568 (switch-to-buffer speedbar-buffer) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1569 (set-window-dedicated-p (selected-window) t)) |
24809
078e0b907e6e
(speedbar-hack-buffer-menu): Fixed so if the user
Karl Heuer <kwzh@gnu.org>
parents:
24475
diff
changeset
|
1570 (if (not (eq newbuff speedbar-buffer)) |
078e0b907e6e
(speedbar-hack-buffer-menu): Fixed so if the user
Karl Heuer <kwzh@gnu.org>
parents:
24475
diff
changeset
|
1571 (speedbar-with-attached-buffer |
078e0b907e6e
(speedbar-hack-buffer-menu): Fixed so if the user
Karl Heuer <kwzh@gnu.org>
parents:
24475
diff
changeset
|
1572 (switch-to-buffer newbuff))))) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1573 |
21650 | 1574 (defun speedbar-next (arg) |
1575 "Move to the next ARGth line in a speedbar buffer." | |
1576 (interactive "p") | |
1577 (forward-line (or arg 1)) | |
1578 (speedbar-item-info) | |
1579 (speedbar-position-cursor-on-line)) | |
1580 | |
1581 (defun speedbar-prev (arg) | |
1582 "Move to the previous ARGth line in a speedbar buffer." | |
1583 (interactive "p") | |
1584 (speedbar-next (if arg (- arg) -1))) | |
1585 | |
22735 | 1586 (defun speedbar-restricted-move (arg) |
1587 "Move to the next ARGth line in a speedbar buffer at the same depth. | |
1588 This means that movement is restricted to a subnode, and that siblings | |
1589 of intermediate nodes are skipped." | |
1590 (if (not (numberp arg)) (signal 'wrong-type-argument (list arg 'numberp))) | |
1591 ;; First find the extent for which we are allowed to move. | |
1592 (let ((depth (save-excursion (beginning-of-line) | |
1593 (if (looking-at "[0-9]+:") | |
1594 (string-to-int (match-string 0)) | |
1595 0))) | |
1596 (crement (if (< arg 0) 1 -1)) ; decrement or increment | |
1597 (lastmatch (point))) | |
1598 (while (/= arg 0) | |
1599 (forward-line (- crement)) | |
1600 (let ((subdepth (save-excursion (beginning-of-line) | |
1601 (if (looking-at "[0-9]+:") | |
1602 (string-to-int (match-string 0)) | |
1603 0)))) | |
1604 (cond ((or (< subdepth depth) | |
1605 (progn (end-of-line) (eobp)) | |
1606 (progn (beginning-of-line) (bobp))) | |
1607 ;; We have reached the end of this block. | |
1608 (goto-char lastmatch) | |
1609 (setq arg 0) | |
1610 (error "End of sub-list")) | |
1611 ((= subdepth depth) | |
1612 (setq lastmatch (point) | |
1613 arg (+ arg crement)))))) | |
1614 (speedbar-position-cursor-on-line))) | |
1615 | |
1616 (defun speedbar-restricted-next (arg) | |
1617 "Move to the next ARGth line in a speedbar buffer at the same depth. | |
1618 This means that movement is restricted to a subnode, and that siblings | |
1619 of intermediate nodes are skipped." | |
1620 (interactive "p") | |
1621 (speedbar-restricted-move (or arg 1)) | |
1622 (speedbar-item-info)) | |
1623 | |
1624 | |
1625 (defun speedbar-restricted-prev (arg) | |
1626 "Move to the previous ARGth line in a speedbar buffer at the same depth. | |
1627 This means that movement is restricted to a subnode, and that siblings | |
1628 of intermediate nodes are skipped." | |
1629 (interactive "p") | |
1630 (speedbar-restricted-move (if arg (- arg) -1)) | |
1631 (speedbar-item-info)) | |
1632 | |
1633 (defun speedbar-navigate-list (arg) | |
1634 "Move across ARG groups of similarly typed items in speedbar. | |
1635 Stop on the first line of the next type of item, or on the last or first item | |
1636 if we reach a buffer boundary." | |
1637 (interactive "p") | |
1638 (beginning-of-line) | |
1639 (if (looking-at "[0-9]+: *[[<{][-+?][]>}] ") | |
1640 (let ((str (regexp-quote (match-string 0)))) | |
1641 (while (looking-at str) | |
1642 (speedbar-restricted-move arg) | |
1643 (beginning-of-line)))) | |
1644 (speedbar-position-cursor-on-line)) | |
1645 | |
1646 (defun speedbar-forward-list () | |
1647 "Move forward over the current list. | |
1648 A LIST in speedbar is a group of similarly typed items, such as directories, | |
1649 files, or the directory button." | |
1650 (interactive) | |
1651 (speedbar-navigate-list 1) | |
1652 (speedbar-item-info)) | |
1653 | |
1654 (defun speedbar-backward-list () | |
1655 "Move backward over the current list. | |
1656 A LIST in speedbar is a group of similarly typed items, such as directories, | |
1657 files, or the directory button." | |
1658 (interactive) | |
1659 (speedbar-navigate-list -1) | |
1660 (speedbar-item-info)) | |
1661 | |
21650 | 1662 (defun speedbar-scroll-up (&optional arg) |
1663 "Page down one screen-full of the speedbar, or ARG lines." | |
1664 (interactive "P") | |
1665 (scroll-up arg) | |
1666 (speedbar-position-cursor-on-line)) | |
1667 | |
1668 (defun speedbar-scroll-down (&optional arg) | |
1669 "Page up one screen-full of the speedbar, or ARG lines." | |
1670 (interactive "P") | |
1671 (scroll-down arg) | |
1672 (speedbar-position-cursor-on-line)) | |
1673 | |
1674 (defun speedbar-up-directory () | |
1675 "Keyboard accelerator for moving the default directory up one. | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
1676 Assumes that the current buffer is the speedbar buffer." |
21650 | 1677 (interactive) |
1678 (setq default-directory (expand-file-name (concat default-directory "../"))) | |
1679 (speedbar-update-contents)) | |
1680 | |
1681 ;;; Speedbar file activity (aka creeping featurism) | |
1682 ;; | |
1683 (defun speedbar-refresh () | |
1684 "Refresh the current speedbar display, disposing of any cached data." | |
1685 (interactive) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1686 (let ((dl speedbar-shown-directories) |
47627
33bcb75e91e8
(speedbar-refresh): Simply bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents:
47286
diff
changeset
|
1687 deactivate-mark) |
21650 | 1688 (while dl |
1689 (adelete 'speedbar-directory-contents-alist (car dl)) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1690 (setq dl (cdr dl))) |
22906
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
1691 (if (<= 1 speedbar-verbosity-level) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1692 (speedbar-message "Refreshing speedbar...")) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1693 (speedbar-update-contents) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1694 (speedbar-stealthy-updates) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1695 ;; Reset the timer in case it got really hosed for some reason... |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1696 (speedbar-set-timer speedbar-update-speed) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
1697 (if (<= 1 speedbar-verbosity-level) |
47627
33bcb75e91e8
(speedbar-refresh): Simply bind deactivate-mark.
Richard M. Stallman <rms@gnu.org>
parents:
47286
diff
changeset
|
1698 (speedbar-message "Refreshing speedbar...done")))) |
21650 | 1699 |
1700 (defun speedbar-item-load () | |
22735 | 1701 "Load the item under the cursor or mouse if it is a Lisp file." |
21650 | 1702 (interactive) |
1703 (let ((f (speedbar-line-file))) | |
1704 (if (and (file-exists-p f) (string-match "\\.el\\'" f)) | |
1705 (if (and (file-exists-p (concat f "c")) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1706 (speedbar-y-or-n-p (format "Load %sc? " f))) |
21650 | 1707 ;; If the compiled version exists, load that instead... |
1708 (load-file (concat f "c")) | |
1709 (load-file f)) | |
22735 | 1710 (error "Not a loadable file")))) |
21650 | 1711 |
1712 (defun speedbar-item-byte-compile () | |
22735 | 1713 "Byte compile the item under the cursor or mouse if it is a Lisp file." |
21650 | 1714 (interactive) |
1715 (let ((f (speedbar-line-file)) | |
1716 (sf (selected-frame))) | |
1717 (if (and (file-exists-p f) (string-match "\\.el\\'" f)) | |
1718 (progn | |
1719 (select-frame speedbar-attached-frame) | |
1720 (byte-compile-file f nil) | |
22735 | 1721 (select-frame sf) |
1722 (speedbar-reset-scanners))) | |
21650 | 1723 )) |
1724 | |
1725 (defun speedbar-mouse-item-info (event) | |
1726 "Provide information about what the user clicked on. | |
1727 This should be bound to a mouse EVENT." | |
1728 (interactive "e") | |
1729 (mouse-set-point event) | |
1730 (speedbar-item-info)) | |
1731 | |
22735 | 1732 (defun speedbar-generic-item-info () |
44578
9c2b72b4b303
(speedbar-generic-item-info)
Pavel Janík <Pavel@Janik.cz>
parents:
44225
diff
changeset
|
1733 "Attempt to derive, and then display information about this line item. |
22735 | 1734 File style information is displayed with `speedbar-item-info'." |
1735 (save-excursion | |
1736 (beginning-of-line) | |
1737 ;; Skip invisible number info. | |
1738 (if (looking-at "\\([0-9]+\\):") (goto-char (match-end 0))) | |
1739 ;; Skip items in "folder" type text characters. | |
1740 (if (looking-at "\\s-*[[<({].[]>)}] ") (goto-char (match-end 0))) | |
1741 ;; Get the text | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1742 (speedbar-message "Text: %s" (buffer-substring-no-properties |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1743 (point) (progn (end-of-line) (point)))))) |
22735 | 1744 |
21650 | 1745 (defun speedbar-item-info () |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1746 "Display info in the mini-buffer about the button the mouse is over. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1747 This function can be replaced in `speedbar-mode-functions-list' as |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
1748 `speedbar-item-info'." |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1749 (interactive) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1750 (let (message-log-max) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1751 (funcall (or (speedbar-fetch-replacement-function 'speedbar-item-info) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1752 'speedbar-generic-item-info)))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1753 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1754 (defun speedbar-item-info-file-helper (&optional filename) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1755 "Display info about a file that is on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1756 nil if not applicable. If FILENAME, then use that instead of reading |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1757 it from the speedbar buffer." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1758 (let* ((item (or filename (speedbar-line-file))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1759 (attr (if item (file-attributes item) nil))) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1760 (if (and item attr) (speedbar-message "%s %-6d %s" (nth 8 attr) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1761 (nth 7 attr) item) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1762 nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1763 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1764 (defun speedbar-item-info-tag-helper () |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1765 "Display info about a tag that is on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1766 nil if not applicable." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1767 (save-excursion |
24321
0e5b7bb19ddc
(speedbar-item-info-tag-helper): Scan the whole line.
Richard M. Stallman <rms@gnu.org>
parents:
24232
diff
changeset
|
1768 (beginning-of-line) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1769 (if (re-search-forward " [-+=]?> \\([^\n]+\\)" |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1770 (save-excursion(end-of-line)(point)) t) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1771 (let ((tag (match-string 1)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1772 (attr (speedbar-line-token)) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1773 (item nil)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1774 (if (and (featurep 'semantic) (semantic-token-p attr)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1775 (speedbar-message (semantic-summerize-nonterminal attr)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1776 (looking-at "\\([0-9]+\\):") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1777 (setq item (file-name-nondirectory (speedbar-line-path))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1778 (speedbar-message "Tag: %s in %s" tag item))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1779 (if (re-search-forward "{[+-]} \\([^\n]+\\)$" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1780 (save-excursion(end-of-line)(point)) t) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1781 (speedbar-message "Group of tags \"%s\"" (match-string 1)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1782 (if (re-search-forward " [+-]?[()|@] \\([^\n]+\\)$" nil t) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1783 (let* ((detailtext (match-string 1)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1784 (detail (or (speedbar-line-token) detailtext)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1785 (parent (save-excursion |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1786 (beginning-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1787 (let ((dep (if (looking-at "[0-9]+:") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1788 (1- (string-to-int (match-string 0))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1789 0))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1790 (re-search-backward (concat "^" |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1791 (int-to-string dep) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1792 ":") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1793 nil t)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1794 (if (looking-at "[0-9]+: +[-+=>]> \\([^\n]+\\)$") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1795 (speedbar-line-token) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1796 nil)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1797 (if (and (featurep 'semantic) (semantic-token-p detail)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1798 (speedbar-message |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1799 (semantic-summerize-nonterminal detail parent)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1800 (if parent |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1801 (speedbar-message "Detail: %s of tag %s" detail |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1802 (if (and (featurep 'semantic) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1803 (semantic-token-p parent)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1804 (semantic-token-name parent) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1805 parent)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1806 (speedbar-message "Detail: %s" detail)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1807 nil))))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1808 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1809 (defun speedbar-files-item-info () |
21650 | 1810 "Display info in the mini-buffer about the button the mouse is over." |
1811 (if (not speedbar-shown-directories) | |
22735 | 1812 (speedbar-generic-item-info) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1813 (or (speedbar-item-info-file-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1814 (speedbar-item-info-tag-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
1815 (speedbar-generic-item-info)))) |
21650 | 1816 |
1817 (defun speedbar-item-copy () | |
1818 "Copy the item under the cursor. | |
1819 Files can be copied to new names or places." | |
1820 (interactive) | |
1821 (let ((f (speedbar-line-file))) | |
22735 | 1822 (if (not f) (error "Not a file")) |
21650 | 1823 (if (file-directory-p f) |
22735 | 1824 (error "Cannot copy directory") |
21650 | 1825 (let* ((rt (read-file-name (format "Copy %s to: " |
1826 (file-name-nondirectory f)) | |
1827 (file-name-directory f))) | |
1828 (refresh (member (expand-file-name (file-name-directory rt)) | |
1829 speedbar-shown-directories))) | |
1830 ;; Create the right file name part | |
1831 (if (file-directory-p rt) | |
1832 (setq rt | |
1833 (concat (expand-file-name rt) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1834 (if (string-match "[/\\]$" rt) "" "/") |
21650 | 1835 (file-name-nondirectory f)))) |
1836 (if (or (not (file-exists-p rt)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1837 (speedbar-y-or-n-p (format "Overwrite %s with %s? " rt f))) |
21650 | 1838 (progn |
1839 (copy-file f rt t t) | |
1840 ;; refresh display if the new place is currently displayed. | |
1841 (if refresh | |
1842 (progn | |
1843 (speedbar-refresh) | |
1844 (if (not (speedbar-goto-this-file rt)) | |
1845 (speedbar-goto-this-file f)))) | |
1846 )))))) | |
1847 | |
1848 (defun speedbar-item-rename () | |
1849 "Rename the item under the cursor or mouse. | |
1850 Files can be renamed to new names or moved to new directories." | |
1851 (interactive) | |
1852 (let ((f (speedbar-line-file))) | |
1853 (if f | |
1854 (let* ((rt (read-file-name (format "Rename %s to: " | |
1855 (file-name-nondirectory f)) | |
1856 (file-name-directory f))) | |
1857 (refresh (member (expand-file-name (file-name-directory rt)) | |
1858 speedbar-shown-directories))) | |
1859 ;; Create the right file name part | |
1860 (if (file-directory-p rt) | |
1861 (setq rt | |
1862 (concat (expand-file-name rt) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1863 (if (string-match "[/\\]\\'" rt) "" "/") |
21650 | 1864 (file-name-nondirectory f)))) |
1865 (if (or (not (file-exists-p rt)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1866 (speedbar-y-or-n-p (format "Overwrite %s with %s? " rt f))) |
21650 | 1867 (progn |
1868 (rename-file f rt t) | |
1869 ;; refresh display if the new place is currently displayed. | |
1870 (if refresh | |
1871 (progn | |
1872 (speedbar-refresh) | |
1873 (speedbar-goto-this-file rt) | |
1874 ))))) | |
22735 | 1875 (error "Not a file")))) |
21650 | 1876 |
1877 (defun speedbar-item-delete () | |
1878 "Delete the item under the cursor. Files are removed from disk." | |
1879 (interactive) | |
1880 (let ((f (speedbar-line-file))) | |
22735 | 1881 (if (not f) (error "Not a file")) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1882 (if (speedbar-y-or-n-p (format "Delete %s? " f)) |
21650 | 1883 (progn |
1884 (if (file-directory-p f) | |
1885 (delete-directory f) | |
1886 (delete-file f)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1887 (speedbar-message "Okie dokie..") |
21650 | 1888 (let ((p (point))) |
1889 (speedbar-refresh) | |
1890 (goto-char p)) | |
1891 )) | |
1892 )) | |
1893 | |
22735 | 1894 (defun speedbar-item-object-delete () |
1895 "Delete the object associated from the item under the cursor. | |
1896 The file is removed from disk. The object is determined from the | |
1897 variable `speedbar-obj-alist'." | |
1898 (interactive) | |
1899 (let* ((f (speedbar-line-file)) | |
1900 (obj nil) | |
1901 (oa speedbar-obj-alist)) | |
1902 (if (not f) (error "Not a file")) | |
1903 (while (and oa (not (string-match (car (car oa)) f))) | |
1904 (setq oa (cdr oa))) | |
1905 (setq obj (concat (file-name-sans-extension f) (cdr (car oa)))) | |
1906 (if (and oa (file-exists-p obj) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
1907 (speedbar-y-or-n-p (format "Delete %s? " obj))) |
22735 | 1908 (progn |
1909 (delete-file obj) | |
1910 (speedbar-reset-scanners))))) | |
1911 | |
21650 | 1912 (defun speedbar-enable-update () |
1913 "Enable automatic updating in speedbar via timers." | |
1914 (interactive) | |
1915 (setq speedbar-update-flag t) | |
1916 (speedbar-set-mode-line-format) | |
1917 (speedbar-set-timer speedbar-update-speed)) | |
1918 | |
1919 (defun speedbar-disable-update () | |
1920 "Disable automatic updating and stop consuming resources." | |
1921 (interactive) | |
1922 (setq speedbar-update-flag nil) | |
1923 (speedbar-set-mode-line-format) | |
1924 (speedbar-set-timer nil)) | |
1925 | |
1926 (defun speedbar-toggle-updates () | |
1927 "Toggle automatic update for the speedbar frame." | |
1928 (interactive) | |
1929 (if speedbar-update-flag | |
1930 (speedbar-disable-update) | |
1931 (speedbar-enable-update))) | |
1932 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1933 (defun speedbar-toggle-images () |
44584
7329202ae660
(speedbar-tag-hierarchy-method)
Pavel Janík <Pavel@Janik.cz>
parents:
44578
diff
changeset
|
1934 "Toggle images for the speedbar frame." |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1935 (interactive) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1936 (setq speedbar-use-images (not speedbar-use-images)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1937 (speedbar-refresh)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
1938 |
21650 | 1939 (defun speedbar-toggle-sorting () |
44584
7329202ae660
(speedbar-tag-hierarchy-method)
Pavel Janík <Pavel@Janik.cz>
parents:
44578
diff
changeset
|
1940 "Toggle sorting for the speedbar frame." |
21650 | 1941 (interactive) |
1942 (setq speedbar-sort-tags (not speedbar-sort-tags))) | |
1943 | |
1944 (defun speedbar-toggle-show-all-files () | |
1945 "Toggle display of files speedbar can not tag." | |
1946 (interactive) | |
1947 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files)) | |
1948 (speedbar-refresh)) | |
1949 | |
1950 ;;; Utility functions | |
1951 ;; | |
1952 (defun speedbar-set-timer (timeout) | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
1953 "Apply a timer with TIMEOUT, or remove a timer if TIMEOUT is nil. |
21650 | 1954 TIMEOUT is the number of seconds until the speedbar timer is called |
1955 again. When TIMEOUT is nil, turn off all timeouts. | |
1956 This function will also enable or disable the `vc-checkin-hook' used | |
1957 to track file check ins, and will change the mode line to match | |
1958 `speedbar-update-flag'." | |
1959 (cond | |
1960 ;; XEmacs | |
1961 (speedbar-xemacsp | |
1962 (if speedbar-timer | |
1963 (progn (delete-itimer speedbar-timer) | |
1964 (setq speedbar-timer nil))) | |
1965 (if timeout | |
1966 (if (and speedbar-xemacsp | |
1967 (or (>= emacs-major-version 20) | |
1968 (>= emacs-minor-version 15))) | |
1969 (setq speedbar-timer (start-itimer "speedbar" | |
1970 'speedbar-timer-fn | |
1971 timeout | |
1972 timeout | |
1973 t)) | |
1974 (setq speedbar-timer (start-itimer "speedbar" | |
1975 'speedbar-timer-fn | |
1976 timeout | |
1977 nil))))) | |
1978 ;; Post 19.31 Emacs | |
1979 ((fboundp 'run-with-idle-timer) | |
1980 (if speedbar-timer | |
1981 (progn (cancel-timer speedbar-timer) | |
1982 (setq speedbar-timer nil))) | |
1983 (if timeout | |
1984 (setq speedbar-timer | |
1985 (run-with-idle-timer timeout t 'speedbar-timer-fn)))) | |
1986 ;; Emacs 19.30 (Thanks twice: ptype@dra.hmg.gb) | |
1987 ((fboundp 'post-command-idle-hook) | |
1988 (if timeout | |
1989 (add-hook 'post-command-idle-hook 'speedbar-timer-fn) | |
1990 (remove-hook 'post-command-idle-hook 'speedbar-timer-fn))) | |
1991 ;; Older or other Emacsen with no timers. Set up so that its | |
1992 ;; obvious this emacs can't handle the updates | |
1993 (t | |
1994 (setq speedbar-update-flag nil))) | |
1995 ;; Apply a revert hook that will reset the scanners. We attach to revert | |
1996 ;; because most reverts occur during VC state change, and this lets our | |
1997 ;; VC scanner fix itself. | |
1998 (if timeout | |
1999 (add-hook 'after-revert-hook 'speedbar-reset-scanners) | |
2000 (remove-hook 'after-revert-hook 'speedbar-reset-scanners) | |
2001 ) | |
2002 ;; change this if it changed for some reason | |
2003 (speedbar-set-mode-line-format)) | |
2004 | |
2005 (defmacro speedbar-with-writable (&rest forms) | |
2006 "Allow the buffer to be writable and evaluate FORMS." | |
2007 (list 'let '((inhibit-read-only t)) | |
2008 (cons 'progn forms))) | |
2009 (put 'speedbar-with-writable 'lisp-indent-function 0) | |
2010 | |
2011 (defun speedbar-select-window (buffer) | |
22735 | 2012 "Select a window in which BUFFER is shown. |
21650 | 2013 If it is not shown, force it to appear in the default window." |
2014 (let ((win (get-buffer-window buffer speedbar-attached-frame))) | |
2015 (if win | |
2016 (select-window win) | |
22735 | 2017 (set-window-buffer (selected-window) buffer)))) |
21650 | 2018 |
2019 (defun speedbar-insert-button (text face mouse function | |
2020 &optional token prevline) | |
2021 "Insert TEXT as the next logical speedbar button. | |
2022 FACE is the face to put on the button, MOUSE is the highlight face to use. | |
2023 When the user clicks on TEXT, FUNCTION is called with the TOKEN parameter. | |
2024 This function assumes that the current buffer is the speedbar buffer. | |
2025 If PREVLINE, then put this button on the previous line. | |
2026 | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2027 This is a convenience function for special modes that create their own |
21650 | 2028 specialized speedbar displays." |
2029 (goto-char (point-max)) | |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2030 (let ((start (point))) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2031 (if (/= (current-column) 0) (insert "\n")) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2032 (put-text-property start (point) 'invisible nil)) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2033 (if prevline (progn (delete-char -1) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2034 (insert " ") ;back up if desired... |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2035 (put-text-property (1- (point)) (point) 'invisible nil))) |
21650 | 2036 (let ((start (point))) |
2037 (insert text) | |
2038 (speedbar-make-button start (point) face mouse function token)) | |
2039 (let ((start (point))) | |
2040 (insert "\n") | |
2041 (put-text-property start (point) 'face nil) | |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
2042 (put-text-property start (point) 'invisible nil) |
21650 | 2043 (put-text-property start (point) 'mouse-face nil))) |
2044 | |
2045 (defun speedbar-make-button (start end face mouse function &optional token) | |
2046 "Create a button from START to END, with FACE as the display face. | |
2047 MOUSE is the mouse face. When this button is clicked on FUNCTION | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2048 will be run with the TOKEN parameter (any Lisp object)." |
21650 | 2049 (put-text-property start end 'face face) |
2050 (put-text-property start end 'mouse-face mouse) | |
2051 (put-text-property start end 'invisible nil) | |
2052 (if function (put-text-property start end 'speedbar-function function)) | |
2053 (if token (put-text-property start end 'speedbar-token token)) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2054 ;; So far the only text we have is less that 3 chars. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2055 (if (<= (- end start) 3) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2056 (speedbar-insert-image-button-maybe start (- end start))) |
21650 | 2057 ) |
2058 | |
22735 | 2059 ;;; Initial Expansion list management |
2060 ;; | |
2061 (defun speedbar-initial-expansion-list () | |
2062 "Return the current default expansion list. | |
2063 This is based on `speedbar-initial-expansion-list-name' referencing | |
2064 `speedbar-initial-expansion-mode-alist'." | |
2065 ;; cdr1 - name, cdr2 - menu | |
2066 (cdr (cdr (cdr (assoc speedbar-initial-expansion-list-name | |
2067 speedbar-initial-expansion-mode-alist))))) | |
2068 | |
2069 (defun speedbar-initial-menu () | |
2070 "Return the current default menu data. | |
2071 This is based on `speedbar-initial-expansion-list-name' referencing | |
2072 `speedbar-initial-expansion-mode-alist'." | |
2073 (symbol-value | |
2074 (car (cdr (assoc speedbar-initial-expansion-list-name | |
2075 speedbar-initial-expansion-mode-alist))))) | |
2076 | |
2077 (defun speedbar-initial-keymap () | |
2078 "Return the current default menu data. | |
2079 This is based on `speedbar-initial-expansion-list-name' referencing | |
2080 `speedbar-initial-expansion-mode-alist'." | |
2081 (symbol-value | |
2082 (car (cdr (cdr (assoc speedbar-initial-expansion-list-name | |
2083 speedbar-initial-expansion-mode-alist)))))) | |
2084 | |
2085 (defun speedbar-initial-stealthy-functions () | |
2086 "Return a list of functions to call stealthily. | |
2087 This is based on `speedbar-initial-expansion-list-name' referencing | |
2088 `speedbar-stealthy-function-list'." | |
2089 (cdr (assoc speedbar-initial-expansion-list-name | |
2090 speedbar-stealthy-function-list))) | |
2091 | |
2092 (defun speedbar-add-expansion-list (new-list) | |
2093 "Add NEW-LIST to the list of expansion lists." | |
2094 (add-to-list 'speedbar-initial-expansion-mode-alist new-list)) | |
2095 | |
2096 (defun speedbar-change-initial-expansion-list (new-default) | |
2097 "Change speedbar's default expansion list to NEW-DEFAULT." | |
2098 (interactive | |
2099 (list | |
2100 (completing-read (format "Speedbar Mode (default %s): " | |
2101 speedbar-previously-used-expansion-list-name) | |
2102 speedbar-initial-expansion-mode-alist | |
2103 nil t "" nil | |
2104 speedbar-previously-used-expansion-list-name))) | |
2105 (setq speedbar-previously-used-expansion-list-name | |
2106 speedbar-initial-expansion-list-name | |
2107 speedbar-initial-expansion-list-name new-default) | |
2108 (speedbar-refresh) | |
2109 (speedbar-reconfigure-keymaps)) | |
2110 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2111 (defun speedbar-fetch-replacement-function (function) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2112 "Return a current mode specific replacement for function, or nil. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2113 Scans `speedbar-mode-functions-list' first for the current mode, then |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2114 for FUNCTION." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2115 (cdr (assoc function |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2116 (cdr (assoc speedbar-initial-expansion-list-name |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2117 speedbar-mode-functions-list))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2118 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2119 (defun speedbar-add-mode-functions-list (new-list) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2120 "Add NEW-LIST to the list of mode functions. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2121 See `speedbar-mode-functions-list' for details." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2122 (add-to-list 'speedbar-mode-functions-list new-list)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
2123 |
22735 | 2124 |
2125 ;;; Special speedbar display management | |
2126 ;; | |
2127 (defun speedbar-maybe-add-localized-support (buffer) | |
2128 "Quick check function called on BUFFERs by the speedbar timer function. | |
2129 Maintains the value of local variables which control speedbars use | |
2130 of the special mode functions." | |
2131 (or speedbar-special-mode-expansion-list | |
2132 (speedbar-add-localized-speedbar-support buffer))) | |
2133 | |
2134 (defun speedbar-add-localized-speedbar-support (buffer) | |
2135 "Add localized speedbar support to BUFFER's mode if it is available." | |
2136 (interactive "bBuffer: ") | |
2137 (if (stringp buffer) (setq buffer (get-buffer buffer))) | |
2138 (if (not (buffer-live-p buffer)) | |
2139 nil | |
2140 (save-excursion | |
2141 (set-buffer buffer) | |
2142 (save-match-data | |
2143 (let ((ms (symbol-name major-mode)) v) | |
2144 (if (not (string-match "-mode$" ms)) | |
2145 nil ;; do nothing to broken mode | |
2146 (setq ms (substring ms 0 (match-beginning 0))) | |
2147 (setq v (intern-soft (concat ms "-speedbar-buttons"))) | |
2148 (make-local-variable 'speedbar-special-mode-expansion-list) | |
2149 (if (not v) | |
2150 (setq speedbar-special-mode-expansion-list t) | |
2151 ;; If it is autoloaded, we need to load it now so that | |
2152 ;; we have access to the varialbe -speedbar-menu-items. | |
2153 ;; Is this XEmacs safe? | |
2154 (let ((sf (symbol-function v))) | |
2155 (if (and (listp sf) (eq (car sf) 'autoload)) | |
2156 (load-library (car (cdr sf))))) | |
2157 (setq speedbar-special-mode-expansion-list (list v)) | |
2158 (setq v (intern-soft (concat ms "-speedbar-key-map"))) | |
2159 (if (not v) | |
2160 nil ;; don't add special keymap | |
2161 (make-local-variable 'speedbar-special-mode-key-map) | |
2162 (setq speedbar-special-mode-key-map | |
2163 (symbol-value v))) | |
2164 (setq v (intern-soft (concat ms "-speedbar-menu-items"))) | |
2165 (if (not v) | |
2166 nil ;; don't add special menus | |
2167 (make-local-variable 'speedbar-easymenu-definition-special) | |
2168 (setq speedbar-easymenu-definition-special | |
2169 (symbol-value v))) | |
2170 ))))))) | |
2171 | |
2172 (defun speedbar-remove-localized-speedbar-support (buffer) | |
2173 "Remove any traces that BUFFER supports speedbar in a specialized way." | |
2174 (save-excursion | |
2175 (set-buffer buffer) | |
2176 (kill-local-variable 'speedbar-special-mode-expansion-list) | |
2177 (kill-local-variable 'speedbar-special-mode-key-map) | |
2178 (kill-local-variable 'speedbar-easymenu-definition-special))) | |
2179 | |
21650 | 2180 ;;; File button management |
2181 ;; | |
2182 (defun speedbar-file-lists (directory) | |
2183 "Create file lists for DIRECTORY. | |
2184 The car is the list of directories, the cdr is list of files not | |
2185 matching ignored headers. Cache any directory files found in | |
2186 `speedbar-directory-contents-alist' and use that cache before scanning | |
46286
6117ca314143
(speedbar-tag-hierarchy-method): Fix typos.
Juanma Barranquero <lekktu@gmail.com>
parents:
46282
diff
changeset
|
2187 the file-system." |
21650 | 2188 (setq directory (expand-file-name directory)) |
2189 ;; If in powerclick mode, then the directory we are getting | |
2190 ;; should be rescanned. | |
2191 (if speedbar-power-click | |
2192 (adelete 'speedbar-directory-contents-alist directory)) | |
2193 ;; find the directory, either in the cache, or build it. | |
2194 (or (cdr-safe (assoc directory speedbar-directory-contents-alist)) | |
2195 (let ((default-directory directory) | |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2196 (case-fold-search read-file-name-completion-ignore-case) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2197 dirs files) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2198 (dolist (file (directory-files directory nil)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2199 (or (string-match speedbar-file-unshown-regexp file) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2200 (string-match speedbar-directory-unshown-regexp file) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2201 (if (file-directory-p file) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2202 (setq dirs (cons file dirs)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2203 (setq files (cons file files))))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2204 (let ((nl `(,(nreverse dirs) ,(nreverse files)))) |
21650 | 2205 (aput 'speedbar-directory-contents-alist directory nl) |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2206 nl)))) |
21650 | 2207 |
2208 (defun speedbar-directory-buttons (directory index) | |
2209 "Insert a single button group at point for DIRECTORY. | |
2210 Each directory path part is a different button. If part of the path | |
2211 matches the user directory ~, then it is replaced with a ~. | |
2212 INDEX is not used, but is required by the caller." | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2213 (let* ((tilde (expand-file-name "~/")) |
21650 | 2214 (dd (expand-file-name directory)) |
2215 (junk (string-match (regexp-quote tilde) dd)) | |
2216 (displayme (if junk | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2217 (concat "~/" (substring dd (match-end 0))) |
21650 | 2218 dd)) |
2219 (p (point))) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2220 (if (string-match "^~[/\\]?\\'" displayme) (setq displayme tilde)) |
21650 | 2221 (insert displayme) |
2222 (save-excursion | |
2223 (goto-char p) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2224 (while (re-search-forward "\\([^/\\]+\\)[/\\]" nil t) |
21650 | 2225 (speedbar-make-button (match-beginning 1) (match-end 1) |
2226 'speedbar-directory-face | |
2227 'speedbar-highlight-face | |
2228 'speedbar-directory-buttons-follow | |
25432
07df7c764669
(speedbar-directory-buttons): Recognize
Richard M. Stallman <rms@gnu.org>
parents:
24809
diff
changeset
|
2229 (if (and (= (match-beginning 1) p) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2230 (not (char-equal (char-after (+ p 1)) ?:))) |
21650 | 2231 (expand-file-name "~/") ;the tilde |
2232 (buffer-substring-no-properties | |
2233 p (match-end 0))))) | |
2234 ;; Nuke the beginning of the directory if it's too long... | |
2235 (cond ((eq speedbar-directory-button-trim-method 'span) | |
2236 (beginning-of-line) | |
2237 (let ((ww (or (speedbar-frame-width) 20))) | |
2238 (move-to-column ww nil) | |
2239 (while (>= (current-column) ww) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2240 (re-search-backward "[/\\]" nil t) |
21650 | 2241 (if (<= (current-column) 2) |
2242 (progn | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2243 (re-search-forward "[/\\]" nil t) |
21650 | 2244 (if (< (current-column) 4) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2245 (re-search-forward "[/\\]" nil t)) |
21650 | 2246 (forward-char -1))) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2247 (if (looking-at "[/\\]?$") |
21650 | 2248 (beginning-of-line) |
2249 (insert "/...\n ") | |
2250 (move-to-column ww nil))))) | |
2251 ((eq speedbar-directory-button-trim-method 'trim) | |
2252 (end-of-line) | |
2253 (let ((ww (or (speedbar-frame-width) 20)) | |
2254 (tl (current-column))) | |
2255 (if (< ww tl) | |
2256 (progn | |
2257 (move-to-column (- tl ww)) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2258 (if (re-search-backward "[/\\]" nil t) |
21650 | 2259 (progn |
2260 (delete-region (point-min) (point)) | |
2261 (insert "$") | |
2262 ))))))) | |
2263 ) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2264 (if (string-match "\\`[/\\][^/\\]+[/\\]\\'" displayme) |
21650 | 2265 (progn |
2266 (insert " ") | |
2267 (let ((p (point))) | |
2268 (insert "<root>") | |
2269 (speedbar-make-button p (point) | |
2270 'speedbar-directory-face | |
2271 'speedbar-highlight-face | |
2272 'speedbar-directory-buttons-follow | |
2273 "/")))) | |
2274 (end-of-line) | |
2275 (insert-char ?\n 1 nil))) | |
2276 | |
2277 (defun speedbar-make-tag-line (exp-button-type | |
2278 exp-button-char exp-button-function | |
2279 exp-button-data | |
2280 tag-button tag-button-function tag-button-data | |
2281 tag-button-face depth) | |
2282 "Create a tag line with EXP-BUTTON-TYPE for the small expansion button. | |
2283 This is the button that expands or contracts a node (if applicable), | |
2284 and EXP-BUTTON-CHAR the character in it (+, -, ?, etc). EXP-BUTTON-FUNCTION | |
2285 is the function to call if it's clicked on. Button types are | |
2286 'bracket, 'angle, 'curly, or nil. EXP-BUTTON-DATA is extra data | |
2287 attached to the text forming the expansion button. | |
2288 | |
2289 Next, TAG-BUTTON is the text of the tag. TAG-BUTTON-FUNCTION is the | |
2290 function to call if clicked on, and TAG-BUTTON-DATA is the data to | |
2291 attach to the text field (such a tag positioning, etc). | |
2292 TAG-BUTTON-FACE is a face used for this type of tag. | |
2293 | |
2294 Lastly, DEPTH shows the depth of expansion. | |
2295 | |
2296 This function assumes that the cursor is in the speedbar window at the | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2297 position to insert a new item, and that the new item will end with a CR." |
21650 | 2298 (let ((start (point)) |
2299 (end (progn | |
2300 (insert (int-to-string depth) ":") | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2301 (point))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2302 (depthspacesize (* depth speedbar-indentation-width))) |
21650 | 2303 (put-text-property start end 'invisible t) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2304 (insert-char ? depthspacesize nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2305 (put-text-property (- (point) depthspacesize) (point) 'invisible nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2306 (let* ((exp-button (cond ((eq exp-button-type 'bracket) "[%c]") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2307 ((eq exp-button-type 'angle) "<%c>") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2308 ((eq exp-button-type 'curly) "{%c}") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2309 (t ">"))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2310 (buttxt (format exp-button exp-button-char)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2311 (start (point)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2312 (end (progn (insert buttxt) (point))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2313 (bf (if exp-button-type 'speedbar-button-face nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2314 (mf (if exp-button-function 'speedbar-highlight-face nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2315 ) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2316 (speedbar-make-button start end bf mf exp-button-function exp-button-data) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2317 (if speedbar-hide-button-brackets-flag |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2318 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2319 (put-text-property start (1+ start) 'invisible t) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2320 (put-text-property end (1- end) 'invisible t))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2321 ) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2322 (insert-char ? 1 nil) |
21650 | 2323 (put-text-property (1- (point)) (point) 'invisible nil) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2324 (let ((start (point)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2325 (end (progn (insert tag-button) (point)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2326 (insert-char ?\n 1 nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2327 (put-text-property (1- (point)) (point) 'invisible nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2328 (speedbar-make-button start end tag-button-face |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2329 (if tag-button-function 'speedbar-highlight-face nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2330 tag-button-function tag-button-data)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2331 )) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
2332 |
21650 | 2333 (defun speedbar-change-expand-button-char (char) |
2334 "Change the expansion button character to CHAR for the current line." | |
2335 (save-excursion | |
2336 (beginning-of-line) | |
2337 (if (re-search-forward ":\\s-*.\\([-+?]\\)" (save-excursion (end-of-line) | |
2338 (point)) t) | |
2339 (speedbar-with-writable | |
2340 (goto-char (match-beginning 1)) | |
2341 (delete-char 1) | |
22735 | 2342 (insert-char char 1 t) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2343 (put-text-property (point) (1- (point)) 'invisible nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2344 ;; make sure we fix the image on the text here. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2345 (speedbar-insert-image-button-maybe (- (point) 2) 3))))) |
21650 | 2346 |
2347 | |
2348 ;;; Build button lists | |
2349 ;; | |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2350 (defun speedbar-insert-files-at-point (files level directory) |
21650 | 2351 "Insert list of FILES starting at point, and indenting all files to LEVEL. |
2352 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we | |
2353 don't know how to manage them. The input parameter FILES is a cons | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2354 cell of the form ( 'DIRLIST . 'FILELIST )." |
21650 | 2355 ;; Start inserting all the directories |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2356 (dolist (dir (car files)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2357 (if (if speedbar-scan-subdirs |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2358 (condition-case nil |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2359 (let ((l (speedbar-file-lists (concat directory dir)))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2360 (or (car l) (cadr l))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2361 (file-error)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2362 (file-readable-p (concat directory dir))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2363 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired dir |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2364 dir 'speedbar-dir-follow nil |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2365 'speedbar-directory-face level) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2366 (speedbar-make-tag-line 'angle ? nil dir |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2367 dir 'speedbar-dir-follow nil |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2368 'speedbar-directory-face level))) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2369 (let ((case-fold-search read-file-name-completion-ignore-case)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2370 (dolist (file (cadr files)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2371 (let* ((known (and (file-readable-p (concat directory file)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2372 (string-match speedbar-file-regexp file))) |
21650 | 2373 (expchar (if known ?+ ??)) |
2374 (fn (if known 'speedbar-tag-file nil))) | |
2375 (if (or speedbar-show-unknown-files (/= expchar ??)) | |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2376 (speedbar-make-tag-line 'bracket expchar fn file |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2377 file 'speedbar-find-file nil |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2378 'speedbar-file-face level)))))) |
21650 | 2379 |
2380 (defun speedbar-default-directory-list (directory index) | |
2381 "Insert files for DIRECTORY with level INDEX at point." | |
2382 (speedbar-insert-files-at-point | |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2383 (speedbar-file-lists directory) index directory) |
21650 | 2384 (speedbar-reset-scanners) |
2385 (if (= index 0) | |
2386 ;; If the shown files variable has extra directories, then | |
2387 ;; it is our responsibility to redraw them all | |
2388 ;; Luckilly, the nature of inserting items into this list means | |
2389 ;; that by reversing it, we can easilly go in the right order | |
2390 (let ((sf (cdr (reverse speedbar-shown-directories)))) | |
2391 (setq speedbar-shown-directories | |
2392 (list (expand-file-name default-directory))) | |
2393 ;; exand them all as we find them | |
2394 (while sf | |
2395 (if (speedbar-goto-this-file (car sf)) | |
2396 (progn | |
2397 (beginning-of-line) | |
2398 (if (looking-at "[0-9]+:[ ]*<") | |
2399 (progn | |
2400 (goto-char (match-end 0)) | |
44225
e47fc6bb028d
(speedbar-default-directory-list): Made robust against deleted directories.
Richard M. Stallman <rms@gnu.org>
parents:
42456
diff
changeset
|
2401 (speedbar-do-function-pointer))))) |
e47fc6bb028d
(speedbar-default-directory-list): Made robust against deleted directories.
Richard M. Stallman <rms@gnu.org>
parents:
42456
diff
changeset
|
2402 (setq sf (cdr sf))) |
21650 | 2403 ))) |
2404 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2405 (defun speedbar-sort-tag-hierarchy (lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2406 "Sort all elements of tag hierarchy LST." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2407 (sort (copy-alist lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2408 (lambda (a b) (string< (car a) (car b))))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2409 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2410 (defun speedbar-prefix-group-tag-hierarchy (lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2411 "Prefix group names for tag hierarchy LST." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2412 (let ((newlst nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2413 (sublst nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2414 (work-list nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2415 (junk-list nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2416 (short-group-list nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2417 (short-start-name nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2418 (short-end-name nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2419 (num-shorts-grouped 0) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2420 (bins (make-vector 256 nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2421 (diff-idx 0)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2422 ;; Break out sub-lists |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2423 (while lst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2424 (if (and (listp (cdr-safe (car-safe lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2425 ;; This one is for bovine tokens |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2426 (not (symbolp (car-safe (cdr-safe (car-safe lst)))))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2427 (setq newlst (cons (car lst) newlst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2428 (setq sublst (cons (car lst) sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2429 (setq lst (cdr lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2430 ;; Reverse newlst because it was made backwards. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2431 ;; Sublist doesn't need reversing because the act |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2432 ;; of binning things will reverse it for us. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2433 (setq newlst (nreverse newlst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2434 ;; Now, first find out how long our list is. Never let a |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2435 ;; list get-shorter than our minimum. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2436 (if (<= (length sublst) speedbar-tag-split-minimum-length) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2437 (setq work-list (nreverse sublst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2438 (setq diff-idx (length (try-completion "" sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2439 ;; Sort the whole list into bins. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2440 (while sublst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2441 (let ((e (car sublst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2442 (s (car (car sublst)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2443 (cond ((<= (length s) diff-idx) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2444 ;; 0 storage bin for shorty. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2445 (aset bins 0 (cons e (aref bins 0)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2446 (t |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2447 ;; stuff into a bin based on ascii value at diff |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2448 (aset bins (aref s diff-idx) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2449 (cons e (aref bins (aref s diff-idx))))))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2450 (setq sublst (cdr sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2451 ;; Go through all our bins Stick singles into our |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2452 ;; junk-list, everything else as sublsts in work-list. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2453 ;; If two neighboring lists are both small, make a grouped |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2454 ;; group combinding those two sub-lists. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2455 (setq diff-idx 0) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2456 (while (> 256 diff-idx) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2457 (let ((l (nreverse;; Reverse the list since they are stuck in |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2458 ;; backwards. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2459 (aref bins diff-idx)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2460 (if l |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2461 (let ((tmp (cons (try-completion "" l) l))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2462 (if (or (> (length l) speedbar-tag-regroup-maximum-length) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2463 (> (+ (length l) (length short-group-list)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2464 speedbar-tag-split-minimum-length)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2465 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2466 ;; We have reached a longer list, so we |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2467 ;; must finish off a grouped group. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2468 (cond |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2469 ((and short-group-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2470 (= (length short-group-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2471 num-shorts-grouped)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2472 ;; All singles? Junk list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2473 (setq junk-list (append short-group-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2474 junk-list))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2475 ((= num-shorts-grouped 1) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2476 ;; Only one short group? Just stick it in |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2477 ;; there by itself. Make a group, and find |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2478 ;; a subexpression |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2479 (let ((subexpression (try-completion |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2480 "" short-group-list))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2481 (if (< (length subexpression) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2482 speedbar-tag-group-name-minimum-length) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2483 (setq subexpression |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2484 (concat short-start-name |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2485 " (" |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2486 (substring |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2487 (car (car short-group-list)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2488 (length short-start-name)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2489 ")"))) |
22735 | 2490 (setq work-list |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2491 (cons (cons subexpression |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2492 short-group-list) |
22735 | 2493 work-list)))) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2494 (short-group-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2495 ;; Multiple groups to be named in a special |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2496 ;; way by displaying the range over which we |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2497 ;; have grouped them. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2498 (setq work-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2499 (cons (cons (concat short-start-name |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2500 " to " |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2501 short-end-name) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2502 (nreverse short-group-list)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2503 work-list)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2504 ;; Reset short group list information every time. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2505 (setq short-group-list nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2506 short-start-name nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2507 short-end-name nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2508 num-shorts-grouped 0))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2509 ;; Ok, now that we cleaned up the short-group-list, |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2510 ;; we can deal with this new list, to decide if it |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2511 ;; should go on one of these sub-lists or not. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2512 (if (< (length l) speedbar-tag-regroup-maximum-length) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2513 (setq short-group-list (append short-group-list l) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2514 num-shorts-grouped (1+ num-shorts-grouped) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2515 short-end-name (car tmp) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2516 short-start-name (if short-start-name |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2517 short-start-name |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2518 (car tmp))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2519 (setq work-list (cons tmp work-list)))))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2520 (setq diff-idx (1+ diff-idx)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2521 ;; Did we run out of things? Drop our new list onto the end. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2522 (cond |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2523 ((and short-group-list (= (length short-group-list) num-shorts-grouped)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2524 ;; All singles? Junk list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2525 (setq junk-list (append short-group-list junk-list))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2526 ((= num-shorts-grouped 1) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2527 ;; Only one short group? Just stick it in |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2528 ;; there by itself. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2529 (setq work-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2530 (cons (cons (try-completion "" short-group-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2531 short-group-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2532 work-list))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2533 (short-group-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2534 ;; Multiple groups to be named in a special |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2535 ;; way by displaying the range over which we |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2536 ;; have grouped them. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2537 (setq work-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2538 (cons (cons (concat short-start-name " to " short-end-name) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2539 short-group-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2540 work-list)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2541 ;; Reverse the work list nreversed when consing. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2542 (setq work-list (nreverse work-list)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2543 ;; Now, stick our new list onto the end of |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2544 (if work-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2545 (if junk-list |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2546 (append newlst work-list junk-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2547 (append newlst work-list)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2548 (append newlst junk-list)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2549 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2550 (defun speedbar-trim-words-tag-hierarchy (lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2551 "Trim all words in a tag hierarchy. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2552 Base trimming information on word separators, and group names. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2553 Argument LST is the list of tags to trim." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2554 (let ((newlst nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2555 (sublst nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2556 (trim-prefix nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2557 (trim-chars 0) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2558 (trimlst nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2559 (while lst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2560 (if (listp (cdr-safe (car-safe lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2561 (setq newlst (cons (car lst) newlst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2562 (setq sublst (cons (car lst) sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2563 (setq lst (cdr lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2564 ;; Get the prefix to trim by. Make sure that we don't trim |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2565 ;; off silly pieces, only complete understandable words. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2566 (setq trim-prefix (try-completion "" sublst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2567 (if (or (= (length sublst) 1) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2568 (not trim-prefix) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2569 (not (string-match "\\(\\w+\\W+\\)+" trim-prefix))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2570 (append (nreverse newlst) (nreverse sublst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2571 (setq trim-prefix (substring trim-prefix (match-beginning 0) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2572 (match-end 0))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2573 (setq trim-chars (length trim-prefix)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2574 (while sublst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2575 (setq trimlst (cons |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2576 (cons (substring (car (car sublst)) trim-chars) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2577 (cdr (car sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2578 trimlst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2579 sublst (cdr sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2580 ;; Put the lists together |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2581 (append (nreverse newlst) trimlst)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2582 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2583 (defun speedbar-simple-group-tag-hierarchy (lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2584 "Create a simple 'Tags' group with orphaned tags. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2585 Argument LST is the list of tags to sort into groups." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2586 (let ((newlst nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2587 (sublst nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2588 (while lst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2589 (if (listp (cdr-safe (car-safe lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2590 (setq newlst (cons (car lst) newlst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2591 (setq sublst (cons (car lst) sublst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2592 (setq lst (cdr lst))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2593 (if (not newlst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2594 (nreverse sublst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2595 (setq newlst (cons (cons "Tags" (nreverse sublst)) newlst)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2596 (nreverse newlst)))) |
22735 | 2597 |
2598 (defun speedbar-create-tag-hierarchy (lst) | |
2599 "Adjust the tag hierarchy in LST, and return it. | |
2600 This uses `speedbar-tag-hierarchy-method' to determine how to adjust | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2601 the list." |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2602 (let* ((f (save-excursion |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2603 (forward-line -1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2604 (speedbar-line-path))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2605 (methods (if (get-file-buffer f) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2606 (save-excursion (set-buffer (get-file-buffer f)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2607 speedbar-tag-hierarchy-method) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2608 speedbar-tag-hierarchy-method)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2609 (lst (if (fboundp 'copy-tree) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2610 (copy-tree lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2611 lst))) |
22735 | 2612 (while methods |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2613 (setq lst (funcall (car methods) lst) |
22735 | 2614 methods (cdr methods))) |
2615 lst)) | |
2616 | |
21650 | 2617 (defun speedbar-insert-generic-list (level lst expand-fun find-fun) |
2618 "At LEVEL, insert a generic multi-level alist LST. | |
2619 Associations with lists get {+} tags (to expand into more nodes) and | |
2620 those with positions just get a > as the indicator. {+} buttons will | |
2621 have the function EXPAND-FUN and the token is the CDR list. The token | |
2622 name will have the function FIND-FUN and not token." | |
2623 ;; Remove imenu rescan button | |
2624 (if (string= (car (car lst)) "*Rescan*") | |
2625 (setq lst (cdr lst))) | |
22735 | 2626 ;; Adjust the list. |
2627 (setq lst (speedbar-create-tag-hierarchy lst)) | |
21650 | 2628 ;; insert the parts |
2629 (while lst | |
2630 (cond ((null (car-safe lst)) nil) ;this would be a separator | |
2631 ((or (numberp (cdr-safe (car-safe lst))) | |
2632 (markerp (cdr-safe (car-safe lst)))) | |
2633 (speedbar-make-tag-line nil nil nil nil ;no expand button data | |
2634 (car (car lst)) ;button name | |
2635 find-fun ;function | |
2636 (cdr (car lst)) ;token is position | |
2637 'speedbar-tag-face | |
2638 (1+ level))) | |
2639 ((listp (cdr-safe (car-safe lst))) | |
2640 (speedbar-make-tag-line 'curly ?+ expand-fun (cdr (car lst)) | |
2641 (car (car lst)) ;button name | |
2642 nil nil 'speedbar-tag-face | |
2643 (1+ level))) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2644 (t (speedbar-message "Ooops!"))) |
21650 | 2645 (setq lst (cdr lst)))) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2646 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2647 (defun speedbar-insert-imenu-list (indent lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2648 "At level INDENT, insert the imenu generated LST." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2649 (speedbar-insert-generic-list indent lst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2650 'speedbar-tag-expand |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2651 'speedbar-tag-find)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
2652 |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2653 (defun speedbar-insert-etags-list (indent lst) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2654 "At level INDENT, insert the etags generated LST." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2655 (speedbar-insert-generic-list indent lst |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2656 'speedbar-tag-expand |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2657 'speedbar-tag-find)) |
21650 | 2658 |
2659 ;;; Timed functions | |
2660 ;; | |
2661 (defun speedbar-update-contents () | |
2662 "Generically update the contents of the speedbar buffer." | |
2663 (interactive) | |
2664 ;; Set the current special buffer | |
2665 (setq speedbar-desired-buffer nil) | |
22735 | 2666 ;; Check for special modes |
2667 (speedbar-maybe-add-localized-support (current-buffer)) | |
2668 ;; Choose the correct method of doodling. | |
21650 | 2669 (if (and speedbar-mode-specific-contents-flag |
22735 | 2670 (listp speedbar-special-mode-expansion-list) |
21650 | 2671 speedbar-special-mode-expansion-list |
2672 (local-variable-p | |
2673 'speedbar-special-mode-expansion-list | |
2674 (current-buffer))) | |
2675 ;;(eq (get major-mode 'mode-class 'special))) | |
2676 (speedbar-update-special-contents) | |
2677 (speedbar-update-directory-contents))) | |
2678 | |
2679 (defun speedbar-update-directory-contents () | |
2680 "Update the contents of the speedbar buffer based on the current directory." | |
2681 (let ((cbd (expand-file-name default-directory)) | |
2682 cbd-parent | |
22735 | 2683 (funclst (speedbar-initial-expansion-list)) |
21650 | 2684 (cache speedbar-full-text-cache) |
2685 ;; disable stealth during update | |
2686 (speedbar-stealthy-function-list nil) | |
2687 (use-cache nil) | |
2688 (expand-local nil) | |
2689 ;; Because there is a bug I can't find just yet | |
2690 (inhibit-quit nil)) | |
2691 (save-excursion | |
2692 (set-buffer speedbar-buffer) | |
2693 ;; If we are updating contents to where we are, then this is | |
2694 ;; really a request to update existing contents, so we must be | |
2695 ;; careful with our text cache! | |
2696 (if (member cbd speedbar-shown-directories) | |
22735 | 2697 (progn |
2698 (setq cache nil) | |
2699 ;; If the current directory is not the last element in the dir | |
2700 ;; list, then we ALSO need to zap the list of expanded directories | |
2701 (if (/= (length (member cbd speedbar-shown-directories)) 1) | |
2702 (setq speedbar-shown-directories (list cbd)))) | |
21650 | 2703 |
2704 ;; Build cbd-parent, and see if THAT is in the current shown | |
2705 ;; directories. First, go through pains to get the parent directory | |
2706 (if (and speedbar-smart-directory-expand-flag | |
2707 (save-match-data | |
2708 (setq cbd-parent cbd) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
2709 (if (string-match "[/\\]$" cbd-parent) |
22735 | 2710 (setq cbd-parent (substring cbd-parent 0 |
2711 (match-beginning 0)))) | |
21650 | 2712 (setq cbd-parent (file-name-directory cbd-parent))) |
2713 (member cbd-parent speedbar-shown-directories)) | |
2714 (setq expand-local t) | |
2715 | |
2716 ;; If this directory is NOT in the current list of available | |
2717 ;; paths, then use the cache, and set the cache to our new | |
2718 ;; value. Make sure to unhighlight the current file, or if we | |
2719 ;; come back to this directory, it might be a different file | |
2720 ;; and then we get a mess! | |
2721 (if (> (point-max) 1) | |
2722 (progn | |
2723 (speedbar-clear-current-file) | |
2724 (setq speedbar-full-text-cache | |
2725 (cons speedbar-shown-directories (buffer-string))))) | |
2726 | |
2727 ;; Check if our new directory is in the list of directories | |
2728 ;; shown in the text-cache | |
2729 (if (member cbd (car cache)) | |
2730 (setq speedbar-shown-directories (car cache) | |
2731 use-cache t) | |
2732 ;; default the shown directories to this list... | |
2733 (setq speedbar-shown-directories (list cbd))) | |
2734 )) | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2735 (if (not expand-local) (setq speedbar-last-selected-file nil)) |
21650 | 2736 (speedbar-with-writable |
2737 (if (and expand-local | |
2738 ;; Find this directory as a speedbar node. | |
2739 (speedbar-path-line cbd)) | |
2740 ;; Open it. | |
2741 (speedbar-expand-line) | |
2742 (erase-buffer) | |
2743 (cond (use-cache | |
2744 (setq default-directory | |
2745 (nth (1- (length speedbar-shown-directories)) | |
2746 speedbar-shown-directories)) | |
2747 (insert (cdr cache))) | |
2748 (t | |
2749 (while funclst | |
2750 (setq default-directory cbd) | |
2751 (funcall (car funclst) cbd 0) | |
2752 (setq funclst (cdr funclst)))))) | |
2753 (goto-char (point-min))))) | |
22735 | 2754 (speedbar-reconfigure-keymaps)) |
21650 | 2755 |
2756 (defun speedbar-update-special-contents () | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2757 "Use the mode-specific variable to fill in the speedbar buffer. |
21650 | 2758 This should only be used by modes classified as special." |
2759 (let ((funclst speedbar-special-mode-expansion-list) | |
2760 (specialbuff (current-buffer))) | |
2761 (save-excursion | |
2762 (setq speedbar-desired-buffer specialbuff) | |
2763 (set-buffer speedbar-buffer) | |
2764 ;; If we are leaving a directory, cache it. | |
2765 (if (not speedbar-shown-directories) | |
2766 ;; Do nothing | |
2767 nil | |
2768 ;; Clean up directory maintenance stuff | |
2769 (speedbar-clear-current-file) | |
2770 (setq speedbar-full-text-cache | |
2771 (cons speedbar-shown-directories (buffer-string)) | |
2772 speedbar-shown-directories nil)) | |
2773 ;; Now fill in the buffer with our newly found specialized list. | |
2774 (speedbar-with-writable | |
2775 (while funclst | |
2776 ;; We do not erase the buffer because these functions may | |
2777 ;; decide NOT to update themselves. | |
2778 (funcall (car funclst) specialbuff) | |
2779 (setq funclst (cdr funclst)))) | |
2780 (goto-char (point-min)))) | |
22735 | 2781 (speedbar-reconfigure-keymaps)) |
21650 | 2782 |
2783 (defun speedbar-timer-fn () | |
22735 | 2784 "Run whenever Emacs is idle to update the speedbar item." |
21650 | 2785 (if (not (and (frame-live-p speedbar-frame) |
2786 (frame-live-p speedbar-attached-frame))) | |
2787 (speedbar-set-timer nil) | |
2788 ;; Save all the match data so that we don't mess up executing fns | |
2789 (save-match-data | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2790 ;; Only do stuff if the frame is visible, not an icon, and if |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2791 ;; it is currently flagged to do something. |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2792 (if (and speedbar-update-flag |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2793 (frame-visible-p speedbar-frame) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2794 (not (eq (frame-visible-p speedbar-frame) 'icon))) |
21650 | 2795 (let ((af (selected-frame))) |
2796 (save-window-excursion | |
2797 (select-frame speedbar-attached-frame) | |
2798 ;; make sure we at least choose a window to | |
2799 ;; get a good directory from | |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2800 (if (window-minibuffer-p (selected-window)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2801 nil |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2802 ;; Check for special modes |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2803 (speedbar-maybe-add-localized-support (current-buffer)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2804 ;; Update for special mode all the time! |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2805 (if (and speedbar-mode-specific-contents-flag |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2806 (listp speedbar-special-mode-expansion-list) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2807 speedbar-special-mode-expansion-list |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2808 (local-variable-p |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2809 'speedbar-special-mode-expansion-list |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2810 (current-buffer))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2811 ;;(eq (get major-mode 'mode-class 'special))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2812 (progn |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2813 (if (<= 2 speedbar-verbosity-level) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2814 (speedbar-message |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2815 "Updating speedbar to special mode: %s..." |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2816 major-mode)) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2817 (speedbar-update-special-contents) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2818 (if (<= 2 speedbar-verbosity-level) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2819 (progn |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2820 (speedbar-message |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2821 "Updating speedbar to special mode: %s...done" |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2822 major-mode) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2823 (speedbar-message nil)))) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2824 ;; Update all the contents if directories change! |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2825 (if (or (member (expand-file-name default-directory) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2826 speedbar-shown-directories) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2827 (and speedbar-ignored-path-regexp |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2828 (string-match |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2829 speedbar-ignored-path-regexp |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2830 (expand-file-name default-directory))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2831 (member major-mode speedbar-ignored-modes) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2832 (eq af speedbar-frame) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2833 (not (buffer-file-name))) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2834 nil |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2835 (if (<= 1 speedbar-verbosity-level) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2836 (speedbar-message "Updating speedbar to: %s..." |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2837 default-directory)) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2838 (speedbar-update-directory-contents) |
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2839 (if (<= 1 speedbar-verbosity-level) |
22906
adfc04c48002
Updated refresh messages to clear themselves.
Eric M. Ludlam <zappo@gnu.org>
parents:
22893
diff
changeset
|
2840 (progn |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2841 (speedbar-message "Updating speedbar to: %s...done" |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2842 default-directory) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2843 (speedbar-message nil))))) |
23073
a0e975baf1e1
(speedbar-timer-fn): Disable updating if the frame
Eric M. Ludlam <zappo@gnu.org>
parents:
23015
diff
changeset
|
2844 (select-frame af))) |
21650 | 2845 ;; Now run stealthy updates of time-consuming items |
22735 | 2846 (speedbar-stealthy-updates))) |
2847 ;; Now run the mouse tracking system | |
2848 (speedbar-show-info-under-mouse))) | |
21650 | 2849 (run-hooks 'speedbar-timer-hook)) |
2850 | |
2851 | |
2852 ;;; Stealthy activities | |
2853 ;; | |
22735 | 2854 (defvar speedbar-stealthy-update-recurse nil |
2855 "Recursion avoidance variable for stealthy update.") | |
2856 | |
21650 | 2857 (defun speedbar-stealthy-updates () |
2858 "For a given speedbar, run all items in the stealthy function list. | |
2859 Each item returns t if it completes successfully, or nil if | |
2860 interrupted by the user." | |
22735 | 2861 (if (not speedbar-stealthy-update-recurse) |
2862 (let ((l (speedbar-initial-stealthy-functions)) | |
2863 (speedbar-stealthy-update-recurse t)) | |
2864 (unwind-protect | |
23085
46deaf6e62a9
(speedbar-stealthy-updates): Do all updates w/ the the buffer writable.
Eric M. Ludlam <zappo@gnu.org>
parents:
23084
diff
changeset
|
2865 (speedbar-with-writable |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2866 (while (and l (funcall (car l))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2867 ;;(sit-for 0) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
2868 (setq l (cdr l)))) |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
2869 ;;(speedbar-message "Exit with %S" (car l)) |
22735 | 2870 )))) |
21650 | 2871 |
2872 (defun speedbar-reset-scanners () | |
2873 "Reset any variables used by functions in the stealthy list as state. | |
2874 If new functions are added, their state needs to be updated here." | |
22735 | 2875 (setq speedbar-vc-to-do-point t |
2876 speedbar-obj-to-do-point t) | |
21650 | 2877 (run-hooks 'speedbar-scanner-reset-hook) |
2878 ) | |
2879 | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2880 (defun speedbar-find-selected-file (file) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2881 "Go to the line where FILE is." |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2882 (goto-char (point-min)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2883 (let ((m nil)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2884 (while (and (setq m (re-search-forward |
37891
2fec97b8ea55
(speedbar-find-selected-file): RE-quote the filename.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
37180
diff
changeset
|
2885 (concat " \\(" (regexp-quote (file-name-nondirectory file)) |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2886 "\\)\\(" speedbar-indicator-regex "\\)?\n") |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2887 nil t)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2888 (not (string= file |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2889 (concat |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2890 (speedbar-line-path |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2891 (save-excursion |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2892 (goto-char (match-beginning 0)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2893 (beginning-of-line) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2894 (save-match-data |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2895 (looking-at "[0-9]+:") |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2896 (string-to-number (match-string 0))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2897 (match-string 1)))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2898 (if m |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2899 (progn |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2900 (goto-char (match-beginning 1)) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2901 (match-string 1))))) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2902 |
21650 | 2903 (defun speedbar-clear-current-file () |
2904 "Locate the file thought to be current, and remove its highlighting." | |
2905 (save-excursion | |
2906 (set-buffer speedbar-buffer) | |
2907 (if speedbar-last-selected-file | |
2908 (speedbar-with-writable | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2909 (if (speedbar-find-selected-file speedbar-last-selected-file) |
21650 | 2910 (put-text-property (match-beginning 1) |
2911 (match-end 1) | |
2912 'face | |
2913 'speedbar-file-face)))))) | |
2914 | |
2915 (defun speedbar-update-current-file () | |
2916 "Find the current file, and update our visuals to indicate its name. | |
2917 This is specific to file names. If the file name doesn't show up, but | |
2918 it should be in the list, then the directory cache needs to be | |
2919 updated." | |
2920 (let* ((lastf (selected-frame)) | |
2921 (newcfd (save-excursion | |
2922 (select-frame speedbar-attached-frame) | |
2923 (let ((rf (if (buffer-file-name) | |
2924 (buffer-file-name) | |
2925 nil))) | |
2926 (select-frame lastf) | |
2927 rf))) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2928 (newcf (if newcfd newcfd)) |
21650 | 2929 (lastb (current-buffer)) |
22735 | 2930 (sucf-recursive (boundp 'sucf-recursive)) |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
2931 (case-fold-search read-file-name-completion-ignore-case)) |
21650 | 2932 (if (and newcf |
2933 ;; check here, that way we won't refresh to newcf until | |
2934 ;; its been written, thus saving ourselves some time | |
2935 (file-exists-p newcf) | |
2936 (not (string= newcf speedbar-last-selected-file))) | |
2937 (progn | |
2938 ;; It is important to select the frame, otherwise the window | |
2939 ;; we want the cursor to move in will not be updated by the | |
2940 ;; search-forward command. | |
2941 (select-frame speedbar-frame) | |
2942 ;; Remove the old file... | |
2943 (speedbar-clear-current-file) | |
2944 ;; now highlight the new one. | |
2945 (set-buffer speedbar-buffer) | |
2946 (speedbar-with-writable | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2947 (if (speedbar-find-selected-file newcf) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2948 ;; put the property on it |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2949 (put-text-property (match-beginning 1) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2950 (match-end 1) |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2951 'face |
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2952 'speedbar-selected-face) |
21650 | 2953 ;; Oops, it's not in the list. Should it be? |
2954 (if (and (string-match speedbar-file-regexp newcf) | |
2955 (string= (file-name-directory newcfd) | |
2956 (expand-file-name default-directory))) | |
2957 ;; yes, it is (we will ignore unknowns for now...) | |
2958 (progn | |
2959 (speedbar-refresh) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
2960 (if (speedbar-find-selected-file newcf) |
21650 | 2961 ;; put the property on it |
2962 (put-text-property (match-beginning 1) | |
2963 (match-end 1) | |
2964 'face | |
2965 'speedbar-selected-face))) | |
2966 ;; if it's not in there now, whatever... | |
2967 )) | |
2968 (setq speedbar-last-selected-file newcf)) | |
2969 (if (not sucf-recursive) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2970 (progn |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2971 (speedbar-center-buffer-smartly) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2972 (speedbar-position-cursor-on-line) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
2973 )) |
21650 | 2974 (set-buffer lastb) |
2975 (select-frame lastf) | |
2976 ))) | |
2977 ;; return that we are done with this activity. | |
2978 t) | |
2979 | |
22735 | 2980 (defun speedbar-add-indicator (indicator-string &optional replace-this) |
2981 "Add INDICATOR-STRING to the end of this speedbar line. | |
2982 If INDICATOR-STRING is space, and REPLACE-THIS is a character, then | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
2983 the existing indicator is removed. If there is already an |
22735 | 2984 indicator, then do not add a space." |
2985 (beginning-of-line) | |
2986 ;; The nature of the beast: Assume we are in "the right place" | |
2987 (end-of-line) | |
2988 (skip-chars-backward (concat " " speedbar-vc-indicator | |
2989 (car speedbar-obj-indicator) | |
2990 (cdr speedbar-obj-indicator))) | |
2991 (if (and (not (looking-at speedbar-indicator-regex)) | |
2992 (not (string= indicator-string " "))) | |
2993 (insert speedbar-indicator-separator)) | |
2994 (speedbar-with-writable | |
2995 (save-excursion | |
2996 (if (and replace-this | |
2997 (re-search-forward replace-this (save-excursion (end-of-line) | |
2998 (point)) | |
2999 t)) | |
3000 (delete-region (match-beginning 0) (match-end 0)))) | |
3001 (end-of-line) | |
3002 (if (not (string= " " indicator-string)) | |
3003 (insert indicator-string)))) | |
3004 | |
3005 ;; Load efs/ange-ftp only if compiling to remove byte-compiler warnings. | |
21650 | 3006 ;; Steven L Baur <steve@xemacs.org> said this was important: |
22735 | 3007 (eval-when-compile (or (featurep 'xemacs) |
3008 (condition-case () (require 'efs) | |
3009 (error (require 'ange-ftp))))) | |
21650 | 3010 |
3011 (defun speedbar-check-vc () | |
3012 "Scan all files in a directory, and for each see if it's checked out. | |
3013 See `speedbar-this-file-in-vc' and `speedbar-vc-check-dir-p' for how | |
3014 to add more types of version control systems." | |
3015 ;; Check for to-do to be reset. If reset but no RCS is available | |
3016 ;; then set to nil (do nothing) otherwise, start at the beginning | |
3017 (save-excursion | |
3018 (set-buffer speedbar-buffer) | |
3019 (if (and speedbar-vc-do-check (eq speedbar-vc-to-do-point t) | |
3020 (speedbar-vc-check-dir-p default-directory) | |
22735 | 3021 (not (or (and (featurep 'ange-ftp) |
3022 (string-match | |
3023 (car (if speedbar-xemacsp | |
3024 ange-ftp-path-format | |
3025 ange-ftp-name-format)) | |
3026 (expand-file-name default-directory))) | |
3027 ;; efs support: Bob Weiner | |
3028 (and (featurep 'efs) | |
3029 (string-match | |
3030 (car efs-path-regexp) | |
3031 (expand-file-name default-directory)))))) | |
21650 | 3032 (setq speedbar-vc-to-do-point 0)) |
3033 (if (numberp speedbar-vc-to-do-point) | |
3034 (progn | |
3035 (goto-char speedbar-vc-to-do-point) | |
3036 (while (and (not (input-pending-p)) | |
3037 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " | |
3038 nil t)) | |
3039 (setq speedbar-vc-to-do-point (point)) | |
3040 (if (speedbar-check-vc-this-line (match-string 1)) | |
22735 | 3041 (speedbar-add-indicator speedbar-vc-indicator |
3042 (regexp-quote speedbar-vc-indicator)) | |
3043 (speedbar-add-indicator " " | |
3044 (regexp-quote speedbar-vc-indicator)))) | |
21650 | 3045 (if (input-pending-p) |
3046 ;; return that we are incomplete | |
3047 nil | |
3048 ;; we are done, set to-do to nil | |
3049 (setq speedbar-vc-to-do-point nil) | |
3050 ;; and return t | |
3051 t)) | |
3052 t))) | |
3053 | |
3054 (defun speedbar-check-vc-this-line (depth) | |
3055 "Return t if the file on this line is check of of a version control system. | |
3056 Parameter DEPTH is a string with the current depth of indentation of | |
3057 the file being checked." | |
3058 (let* ((d (string-to-int depth)) | |
3059 (f (speedbar-line-path d)) | |
3060 (fn (buffer-substring-no-properties | |
3061 ;; Skip-chars: thanks ptype@dra.hmg.gb | |
3062 (point) (progn | |
3063 (skip-chars-forward "^ " | |
3064 (save-excursion (end-of-line) | |
3065 (point))) | |
3066 (point)))) | |
3067 (fulln (concat f fn))) | |
3068 (if (<= 2 speedbar-verbosity-level) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3069 (speedbar-message "Speedbar vc check...%s" fulln)) |
21650 | 3070 (and (file-writable-p fulln) |
3071 (speedbar-this-file-in-vc f fn)))) | |
3072 | |
3073 (defun speedbar-vc-check-dir-p (path) | |
3074 "Return t if we should bother checking PATH for version control files. | |
3075 This can be overloaded to add new types of version control systems." | |
3076 (or | |
3077 ;; Local RCS | |
3078 (file-exists-p (concat path "RCS/")) | |
3079 ;; Local SCCS | |
3080 (file-exists-p (concat path "SCCS/")) | |
3081 ;; Remote SCCS project | |
3082 (let ((proj-dir (getenv "PROJECTDIR"))) | |
3083 (if proj-dir | |
3084 (file-exists-p (concat proj-dir "/SCCS")) | |
3085 nil)) | |
3086 ;; User extension | |
3087 (run-hook-with-args 'speedbar-vc-path-enable-hook path) | |
3088 )) | |
3089 | |
3090 (defun speedbar-this-file-in-vc (path name) | |
3091 "Check to see if the file in PATH with NAME is in a version control system. | |
3092 You can add new VC systems by overriding this function. You can | |
3093 optimize this function by overriding it and only doing those checks | |
3094 that will occur on your system." | |
3095 (or | |
3096 ;; RCS file name | |
3097 (file-exists-p (concat path "RCS/" name ",v")) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3098 (file-exists-p (concat path "RCS/" name)) |
21650 | 3099 ;; Local SCCS file name |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3100 (file-exists-p (concat path "SCCS/s." name)) |
21650 | 3101 ;; Remote SCCS file name |
3102 (let ((proj-dir (getenv "PROJECTDIR"))) | |
3103 (if proj-dir | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3104 (file-exists-p (concat proj-dir "/SCCS/s." name)) |
21650 | 3105 nil)) |
3106 ;; User extension | |
3107 (run-hook-with-args 'speedbar-vc-in-control-hook path name) | |
3108 )) | |
22735 | 3109 |
3110 ;; Objet File scanning | |
3111 (defun speedbar-check-objects () | |
3112 "Scan all files in a directory, and for each see if there is an object. | |
3113 See `speedbar-check-obj-this-line' and `speedbar-obj-alist' for how | |
3114 to add more object types." | |
3115 ;; Check for to-do to be reset. If reset but no RCS is available | |
3116 ;; then set to nil (do nothing) otherwise, start at the beginning | |
3117 (save-excursion | |
3118 (set-buffer speedbar-buffer) | |
3119 (if (and speedbar-obj-do-check (eq speedbar-obj-to-do-point t)) | |
3120 (setq speedbar-obj-to-do-point 0)) | |
3121 (if (numberp speedbar-obj-to-do-point) | |
3122 (progn | |
3123 (goto-char speedbar-obj-to-do-point) | |
3124 (while (and (not (input-pending-p)) | |
3125 (re-search-forward "^\\([0-9]+\\):\\s-*\\[[+-]\\] " | |
3126 nil t)) | |
3127 (setq speedbar-obj-to-do-point (point)) | |
3128 (let ((ind (speedbar-check-obj-this-line (match-string 1)))) | |
3129 (if (not ind) (setq ind " ")) | |
3130 (speedbar-add-indicator ind (concat | |
3131 (car speedbar-obj-indicator) | |
3132 "\\|" | |
3133 (cdr speedbar-obj-indicator))))) | |
3134 (if (input-pending-p) | |
3135 ;; return that we are incomplete | |
3136 nil | |
3137 ;; we are done, set to-do to nil | |
3138 (setq speedbar-obj-to-do-point nil) | |
3139 ;; and return t | |
3140 t)) | |
3141 t))) | |
3142 | |
3143 (defun speedbar-check-obj-this-line (depth) | |
3144 "Return t if the file on this line has an associated object. | |
3145 Parameter DEPTH is a string with the current depth of indentation of | |
3146 the file being checked." | |
3147 (let* ((d (string-to-int depth)) | |
3148 (f (speedbar-line-path d)) | |
3149 (fn (buffer-substring-no-properties | |
3150 ;; Skip-chars: thanks ptype@dra.hmg.gb | |
3151 (point) (progn | |
3152 (skip-chars-forward "^ " | |
3153 (save-excursion (end-of-line) | |
3154 (point))) | |
3155 (point)))) | |
3156 (fulln (concat f fn))) | |
3157 (if (<= 2 speedbar-verbosity-level) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3158 (speedbar-message "Speedbar obj check...%s" fulln)) |
22735 | 3159 (let ((oa speedbar-obj-alist)) |
3160 (while (and oa (not (string-match (car (car oa)) fulln))) | |
3161 (setq oa (cdr oa))) | |
3162 (if (not (and oa (file-exists-p (concat (file-name-sans-extension fulln) | |
3163 (cdr (car oa)))))) | |
3164 nil | |
3165 ;; Find out if the object is out of date or not. | |
3166 (let ((date1 (nth 5 (file-attributes fulln))) | |
3167 (date2 (nth 5 (file-attributes (concat | |
3168 (file-name-sans-extension fulln) | |
3169 (cdr (car oa))))))) | |
3170 (if (or (< (car date1) (car date2)) | |
3171 (and (= (car date1) (car date2)) | |
3172 (< (nth 1 date1) (nth 1 date2)))) | |
3173 (car speedbar-obj-indicator) | |
3174 (cdr speedbar-obj-indicator))))))) | |
21650 | 3175 |
3176 ;;; Clicking Activity | |
3177 ;; | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3178 (defun speedbar-mouse-set-point (e) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3179 "Set POINT based on event E. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3180 Handle clicking on images in XEmacs." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3181 (if (and (fboundp 'event-over-glyph-p) (event-over-glyph-p e)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3182 ;; We are in XEmacs, and clicked on a picture |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3183 (let ((ext (event-glyph-extent e))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3184 ;; This position is back inside the extent where the |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3185 ;; junk we pushed into the property list lives. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3186 (if (extent-end-position ext) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3187 (goto-char (1- (extent-end-position ext))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3188 (mouse-set-point e))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3189 ;; We are not in XEmacs, OR we didn't click on a picture. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3190 (mouse-set-point e))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3191 |
21650 | 3192 (defun speedbar-quick-mouse (e) |
3193 "Since mouse events are strange, this will keep the mouse nicely positioned. | |
3194 This should be bound to mouse event E." | |
3195 (interactive "e") | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3196 (speedbar-mouse-set-point e) |
21650 | 3197 (speedbar-position-cursor-on-line) |
3198 ) | |
3199 | |
3200 (defun speedbar-position-cursor-on-line () | |
3201 "Position the cursor on a line." | |
3202 (let ((oldpos (point))) | |
3203 (beginning-of-line) | |
3204 (if (looking-at "[0-9]+:\\s-*..?.? ") | |
3205 (goto-char (1- (match-end 0))) | |
3206 (goto-char oldpos)))) | |
3207 | |
3208 (defun speedbar-power-click (e) | |
3209 "Activate any speedbar button as a power click. | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3210 A power click will dispose of cached data (if available) or bring a buffer |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3211 up into a different window. |
21650 | 3212 This should be bound to mouse event E." |
3213 (interactive "e") | |
3214 (let ((speedbar-power-click t)) | |
3215 (speedbar-click e))) | |
3216 | |
3217 (defun speedbar-click (e) | |
3218 "Activate any speedbar buttons where the mouse is clicked. | |
3219 This must be bound to a mouse event. A button is any location of text | |
3220 with a mouse face that has a text property called `speedbar-function'. | |
3221 This should be bound to mouse event E." | |
3222 (interactive "e") | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3223 (speedbar-mouse-set-point e) |
21650 | 3224 (speedbar-do-function-pointer) |
3225 (speedbar-quick-mouse e)) | |
3226 | |
3227 (defun speedbar-double-click (e) | |
3228 "Activate any speedbar buttons where the mouse is clicked. | |
3229 This must be bound to a mouse event. A button is any location of text | |
3230 with a mouse face that has a text property called `speedbar-function'. | |
3231 This should be bound to mouse event E." | |
3232 (interactive "e") | |
3233 ;; Emacs only. XEmacs handles this via `mouse-track-click-hook'. | |
3234 (cond ((eq (car e) 'down-mouse-1) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3235 (speedbar-mouse-set-point e)) |
21650 | 3236 ((eq (car e) 'mouse-1) |
3237 (speedbar-quick-mouse e)) | |
3238 ((or (eq (car e) 'double-down-mouse-1) | |
22735 | 3239 (eq (car e) 'triple-down-mouse-1)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3240 (speedbar-mouse-set-point e) |
21650 | 3241 (speedbar-do-function-pointer) |
3242 (speedbar-quick-mouse e)))) | |
3243 | |
3244 (defun speedbar-do-function-pointer () | |
3245 "Look under the cursor and examine the text properties. | |
3246 From this extract the file/tag name, token, indentation level and call | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3247 a function if appropriate." |
21650 | 3248 (let* ((fn (get-text-property (point) 'speedbar-function)) |
3249 (tok (get-text-property (point) 'speedbar-token)) | |
3250 ;; The 1-,+ is safe because scaning starts AFTER the point | |
3251 ;; specified. This lets the search include the character the | |
3252 ;; cursor is on. | |
3253 (tp (previous-single-property-change | |
3254 (1+ (point)) 'speedbar-function)) | |
3255 (np (next-single-property-change | |
3256 (point) 'speedbar-function)) | |
3257 (txt (buffer-substring-no-properties (or tp (point-min)) | |
3258 (or np (point-max)))) | |
3259 (dent (save-excursion (beginning-of-line) | |
3260 (string-to-number | |
3261 (if (looking-at "[0-9]+") | |
3262 (buffer-substring-no-properties | |
3263 (match-beginning 0) (match-end 0)) | |
3264 "0"))))) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3265 ;;(speedbar-message "%S:%S:%S:%s" fn tok txt dent) |
21650 | 3266 (and fn (funcall fn txt tok dent))) |
3267 (speedbar-position-cursor-on-line)) | |
3268 | |
3269 ;;; Reading info from the speedbar buffer | |
3270 ;; | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3271 (defun speedbar-line-text (&optional p) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3272 "Retrieve the text after prefix junk for the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3273 Optional argument P is where to start the search from." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3274 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3275 (if p (goto-char p)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3276 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3277 (if (looking-at (concat |
24232
446e5ef3f423
(speedbar-line-token): Match {...} instead of [...].
Richard M. Stallman <rms@gnu.org>
parents:
24154
diff
changeset
|
3278 "\\([0-9]+\\): *[[<{][-+?][]>}] \\([^ \n]+\\)\\(" |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3279 speedbar-indicator-regex "\\)?")) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3280 (match-string 2) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3281 nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3282 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3283 (defun speedbar-line-token (&optional p) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3284 "Retrieve the token information after the prefix junk for the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3285 Optional argument P is where to start the search from." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3286 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3287 (if p (goto-char p)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3288 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3289 (if (looking-at (concat |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3290 "\\([0-9]+\\): *[[<{]?[-+?=][]>}@()|] \\([^ \n]+\\)\\(" |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3291 speedbar-indicator-regex "\\)?")) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3292 (progn |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3293 (goto-char (match-beginning 2)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3294 (get-text-property (point) 'speedbar-token)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3295 nil))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3296 |
21650 | 3297 (defun speedbar-line-file (&optional p) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3298 "Retrieve the file or whatever from the line at point P. |
21650 | 3299 The return value is a string representing the file. If it is a |
3300 directory, then it is the directory name." | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3301 (save-match-data |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3302 (let ((f (speedbar-line-text p))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3303 (if f |
21650 | 3304 (let* ((depth (string-to-int (match-string 1))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3305 (path (speedbar-line-path depth))) |
36047
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
3306 (if (file-exists-p (concat path f)) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
3307 (concat path f) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
3308 nil)) |
21650 | 3309 nil)))) |
3310 | |
3311 (defun speedbar-goto-this-file (file) | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3312 "If FILE is displayed, go to this line and return t. |
21650 | 3313 Otherwise do not move and return nil." |
3314 (let ((path (substring (file-name-directory (expand-file-name file)) | |
3315 (length (expand-file-name default-directory)))) | |
3316 (dest (point))) | |
3317 (save-match-data | |
3318 (goto-char (point-min)) | |
3319 ;; scan all the directories | |
3320 (while (and path (not (eq path t))) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3321 (if (string-match "^[/\\]?\\([^/\\]+\\)" path) |
21650 | 3322 (let ((pp (match-string 1 path))) |
3323 (if (save-match-data | |
3324 (re-search-forward (concat "> " (regexp-quote pp) "$") | |
3325 nil t)) | |
3326 (setq path (substring path (match-end 1))) | |
3327 (setq path nil))) | |
3328 (setq path t))) | |
3329 ;; find the file part | |
3330 (if (or (not path) (string= (file-name-nondirectory file) "")) | |
3331 ;; only had a dir part | |
3332 (if path | |
3333 (progn | |
3334 (speedbar-position-cursor-on-line) | |
3335 t) | |
3336 (goto-char dest) nil) | |
3337 ;; find the file part | |
3338 (let ((nd (file-name-nondirectory file))) | |
3339 (if (re-search-forward | |
3340 (concat "] \\(" (regexp-quote nd) | |
22735 | 3341 "\\)\\(" speedbar-indicator-regex "\\)$") |
21650 | 3342 nil t) |
3343 (progn | |
3344 (speedbar-position-cursor-on-line) | |
3345 t) | |
3346 (goto-char dest) | |
3347 nil)))))) | |
3348 | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3349 (defun speedbar-line-path (&optional depth) |
21650 | 3350 "Retrieve the pathname associated with the current line. |
3351 This may require traversing backwards from DEPTH and combining the default | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3352 directory with these items. This function is replaceable in |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3353 `speedbar-mode-functions-list' as `speedbar-line-path'." |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3354 (let ((rf (speedbar-fetch-replacement-function 'speedbar-line-path))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3355 (if rf (funcall rf depth) default-directory))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
3356 |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3357 (defun speedbar-files-line-path (&optional depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3358 "Retrieve the pathname associated with the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3359 This may require traversing backwards from DEPTH and combining the default |
21650 | 3360 directory with these items." |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3361 (save-excursion |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3362 (save-match-data |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3363 (if (not depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3364 (progn |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3365 (beginning-of-line) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3366 (looking-at "^\\([0-9]+\\):") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3367 (setq depth (string-to-int (match-string 1))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3368 (let ((path nil)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3369 (setq depth (1- depth)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3370 (while (/= depth -1) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3371 (if (not (re-search-backward (format "^%d:" depth) nil t)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3372 (error "Error building path of tag") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3373 (cond ((looking-at "[0-9]+:\\s-*<->\\s-+\\([^\n]+\\)$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3374 (setq path (concat (buffer-substring-no-properties |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3375 (match-beginning 1) (match-end 1)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3376 "/" |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3377 path))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3378 ((looking-at "[0-9]+:\\s-*[-]\\s-+\\([^\n]+\\)$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3379 ;; This is the start of our path. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3380 (setq path (buffer-substring-no-properties |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3381 (match-beginning 1) (match-end 1)))))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3382 (setq depth (1- depth))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3383 (if (and path |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3384 (string-match (concat speedbar-indicator-regex "$") |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3385 path)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3386 (setq path (substring path 0 (match-beginning 0)))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3387 (concat default-directory path))))) |
21650 | 3388 |
3389 (defun speedbar-path-line (path) | |
3390 "Position the cursor on the line specified by PATH." | |
3391 (save-match-data | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3392 (if (string-match "[/\\]$" path) |
21650 | 3393 (setq path (substring path 0 (match-beginning 0)))) |
3394 (let ((nomatch t) (depth 0) | |
3395 (fname (file-name-nondirectory path)) | |
3396 (pname (file-name-directory path))) | |
3397 (if (not (member pname speedbar-shown-directories)) | |
22735 | 3398 (error "Internal Error: File %s not shown in speedbar" path)) |
21650 | 3399 (goto-char (point-min)) |
3400 (while (and nomatch | |
3401 (re-search-forward | |
3402 (concat "[]>] \\(" (regexp-quote fname) | |
22735 | 3403 "\\)\\(" speedbar-indicator-regex "\\)?$") |
21650 | 3404 nil t)) |
3405 (beginning-of-line) | |
3406 (looking-at "\\([0-9]+\\):") | |
3407 (setq depth (string-to-int (match-string 0)) | |
3408 nomatch (not (string= pname (speedbar-line-path depth)))) | |
3409 (end-of-line)) | |
3410 (beginning-of-line) | |
3411 (not nomatch)))) | |
3412 | |
3413 (defun speedbar-edit-line () | |
3414 "Edit whatever tag or file is on the current speedbar line." | |
3415 (interactive) | |
3416 (or (save-excursion | |
3417 (beginning-of-line) | |
3418 ;; If this fails, then it is a non-standard click, and as such, | |
3419 ;; perfectly allowed. | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3420 (if (re-search-forward "[]>?}] [^ ]" |
21650 | 3421 (save-excursion (end-of-line) (point)) |
3422 t) | |
53487
25ff62ff164d
(speedbar-edit-line): Change regexp to position
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
3423 (progn |
25ff62ff164d
(speedbar-edit-line): Change regexp to position
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
3424 (forward-char -1) |
25ff62ff164d
(speedbar-edit-line): Change regexp to position
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
3425 (speedbar-do-function-pointer)) |
21650 | 3426 nil)) |
3427 (speedbar-do-function-pointer))) | |
3428 | |
28925
89a795d90175
(speedbar-recenter): Typo, and fix logic.
Eric M. Ludlam <zappo@gnu.org>
parents:
28902
diff
changeset
|
3429 (defun speedbar-expand-line (&optional arg) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3430 "Expand the line under the cursor. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3431 With universal argument ARG, flush cached data." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3432 (interactive "P") |
21650 | 3433 (beginning-of-line) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3434 (let ((speedbar-power-click arg)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3435 (condition-case nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3436 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3437 (re-search-forward ":\\s-*.\\+. " |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3438 (save-excursion (end-of-line) (point))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3439 (forward-char -2) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3440 (speedbar-do-function-pointer)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3441 (error (speedbar-position-cursor-on-line))))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
3442 |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3443 (defun speedbar-flush-expand-line () |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3444 "Expand the line under the cursor and flush any cached information." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3445 (interactive) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3446 (speedbar-expand-line 1)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
3447 |
21650 | 3448 (defun speedbar-contract-line () |
3449 "Contract the line under the cursor." | |
3450 (interactive) | |
3451 (beginning-of-line) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3452 (condition-case nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3453 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3454 (re-search-forward ":\\s-*.-. " |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3455 (save-excursion (end-of-line) (point))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3456 (forward-char -2) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3457 (speedbar-do-function-pointer)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3458 (error (speedbar-position-cursor-on-line)))) |
21650 | 3459 |
3460 (if speedbar-xemacsp | |
3461 (defalias 'speedbar-mouse-event-p 'button-press-event-p) | |
3462 (defun speedbar-mouse-event-p (event) | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3463 "Return t if the event is a mouse related event." |
21650 | 3464 ;; And Emacs does it this way |
3465 (if (and (listp event) | |
3466 (member (event-basic-type event) | |
3467 '(mouse-1 mouse-2 mouse-3))) | |
3468 t | |
3469 nil))) | |
3470 | |
3471 (defun speedbar-maybee-jump-to-attached-frame () | |
3472 "Jump to the attached frame ONLY if this was not a mouse event." | |
3473 (if (or (not (speedbar-mouse-event-p last-input-event)) | |
3474 speedbar-activity-change-focus-flag) | |
3475 (progn | |
3476 (select-frame speedbar-attached-frame) | |
3477 (other-frame 0)))) | |
3478 | |
3479 (defun speedbar-find-file (text token indent) | |
3480 "Speedbar click handler for filenames. | |
3481 TEXT, the file will be displayed in the attached frame. | |
3482 TOKEN is unused, but required by the click handler. INDENT is the | |
3483 current indentation level." | |
3484 (let ((cdd (speedbar-line-path indent))) | |
3485 (speedbar-find-file-in-frame (concat cdd text)) | |
3486 (speedbar-stealthy-updates) | |
3487 (run-hooks 'speedbar-visiting-file-hook) | |
3488 ;; Reset the timer with a new timeout when cliking a file | |
3489 ;; in case the user was navigating directories, we can cancel | |
3490 ;; that other timer. | |
3491 (speedbar-set-timer speedbar-update-speed)) | |
3492 (speedbar-maybee-jump-to-attached-frame)) | |
3493 | |
3494 (defun speedbar-dir-follow (text token indent) | |
3495 "Speedbar click handler for directory names. | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3496 Clicking a directory will cause the speedbar to list files in |
21650 | 3497 the subdirectory TEXT. TOKEN is an unused requirement. The |
3498 subdirectory chosen will be at INDENT level." | |
3499 (setq default-directory | |
3500 (concat (expand-file-name (concat (speedbar-line-path indent) text)) | |
3501 "/")) | |
3502 ;; Because we leave speedbar as the current buffer, | |
3503 ;; update contents will change directory without | |
22735 | 3504 ;; having to touch the attached frame. Turn off smart expand just |
3505 ;; in case. | |
3506 (let ((speedbar-smart-directory-expand-flag nil)) | |
3507 (speedbar-update-contents)) | |
21650 | 3508 (speedbar-set-timer speedbar-navigating-speed) |
3509 (setq speedbar-last-selected-file nil) | |
3510 (speedbar-stealthy-updates)) | |
3511 | |
3512 (defun speedbar-delete-subblock (indent) | |
3513 "Delete text from point to indentation level INDENT or greater. | |
3514 Handles end-of-sublist smartly." | |
3515 (speedbar-with-writable | |
23917
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3516 (save-excursion |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3517 (end-of-line) (forward-char 1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3518 (let ((start (point))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3519 (while (and (looking-at "^\\([0-9]+\\):") |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3520 (> (string-to-int (match-string 1)) indent) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3521 (not (eobp))) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3522 (forward-line 1) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3523 (beginning-of-line)) |
4182d24c6d9f
(speedbar-frame-parameters) Add : to custom prompt.
Eric M. Ludlam <zappo@gnu.org>
parents:
23372
diff
changeset
|
3524 (delete-region start (point)))))) |
21650 | 3525 |
3526 (defun speedbar-dired (text token indent) | |
3527 "Speedbar click handler for directory expand button. | |
3528 Clicking this button expands or contracts a directory. TEXT is the | |
3529 button clicked which has either a + or -. TOKEN is the directory to be | |
3530 expanded. INDENT is the current indentation level." | |
3531 (cond ((string-match "+" text) ;we have to expand this dir | |
3532 (setq speedbar-shown-directories | |
3533 (cons (expand-file-name | |
3534 (concat (speedbar-line-path indent) token "/")) | |
3535 speedbar-shown-directories)) | |
3536 (speedbar-change-expand-button-char ?-) | |
3537 (speedbar-reset-scanners) | |
3538 (save-excursion | |
3539 (end-of-line) (forward-char 1) | |
3540 (speedbar-with-writable | |
3541 (speedbar-default-directory-list | |
3542 (concat (speedbar-line-path indent) token "/") | |
3543 (1+ indent))))) | |
3544 ((string-match "-" text) ;we have to contract this node | |
3545 (speedbar-reset-scanners) | |
3546 (let ((oldl speedbar-shown-directories) | |
3547 (newl nil) | |
3548 (td (expand-file-name | |
3549 (concat (speedbar-line-path indent) token)))) | |
3550 (while oldl | |
3551 (if (not (string-match (concat "^" (regexp-quote td)) (car oldl))) | |
3552 (setq newl (cons (car oldl) newl))) | |
3553 (setq oldl (cdr oldl))) | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
3554 (setq speedbar-shown-directories (nreverse newl))) |
21650 | 3555 (speedbar-change-expand-button-char ?+) |
3556 (speedbar-delete-subblock indent) | |
3557 ) | |
22735 | 3558 (t (error "Ooops... not sure what to do"))) |
21650 | 3559 (speedbar-center-buffer-smartly) |
3560 (setq speedbar-last-selected-file nil) | |
3561 (save-excursion (speedbar-stealthy-updates))) | |
3562 | |
3563 (defun speedbar-directory-buttons-follow (text token indent) | |
3564 "Speedbar click handler for default directory buttons. | |
3565 TEXT is the button clicked on. TOKEN is the directory to follow. | |
3566 INDENT is the current indentation level and is unused." | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3567 (if (string-match "^[A-z]:$" token) |
48716
376c832d1ca7
(speedbar-directory-buttons-follow): Don't use directory-sep-char.
Richard M. Stallman <rms@gnu.org>
parents:
48686
diff
changeset
|
3568 (setq default-directory (concat token "/")) |
22735 | 3569 (setq default-directory token)) |
21650 | 3570 ;; Because we leave speedbar as the current buffer, |
3571 ;; update contents will change directory without | |
3572 ;; having to touch the attached frame. | |
3573 (speedbar-update-contents) | |
3574 (speedbar-set-timer speedbar-navigating-speed)) | |
3575 | |
3576 (defun speedbar-tag-file (text token indent) | |
3577 "The cursor is on a selected line. Expand the tags in the specified file. | |
3578 The parameter TEXT and TOKEN are required, where TEXT is the button | |
3579 clicked, and TOKEN is the file to expand. INDENT is the current | |
3580 indentation level." | |
3581 (cond ((string-match "+" text) ;we have to expand this file | |
3582 (let* ((fn (expand-file-name (concat (speedbar-line-path indent) | |
3583 token))) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3584 (mode nil) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3585 (lst (speedbar-fetch-dynamic-tags fn))) |
21650 | 3586 ;; if no list, then remove expando button |
3587 (if (not lst) | |
3588 (speedbar-change-expand-button-char ??) | |
3589 (speedbar-change-expand-button-char ?-) | |
3590 (speedbar-with-writable | |
3591 (save-excursion | |
3592 (end-of-line) (forward-char 1) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3593 (funcall (car lst) indent (cdr lst))))))) |
21650 | 3594 ((string-match "-" text) ;we have to contract this node |
3595 (speedbar-change-expand-button-char ?+) | |
3596 (speedbar-delete-subblock indent)) | |
22735 | 3597 (t (error "Ooops... not sure what to do"))) |
21650 | 3598 (speedbar-center-buffer-smartly)) |
3599 | |
3600 (defun speedbar-tag-find (text token indent) | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3601 "For the tag TEXT in a file TOKEN, go to that position. |
21650 | 3602 INDENT is the current indentation level." |
3603 (let ((file (speedbar-line-path indent))) | |
3604 (speedbar-find-file-in-frame file) | |
3605 (save-excursion (speedbar-stealthy-updates)) | |
3606 ;; Reset the timer with a new timeout when cliking a file | |
3607 ;; in case the user was navigating directories, we can cancel | |
3608 ;; that other timer. | |
3609 (speedbar-set-timer speedbar-update-speed) | |
3610 (goto-char token) | |
3611 (run-hooks 'speedbar-visiting-tag-hook) | |
3612 ;;(recenter) | |
3613 (speedbar-maybee-jump-to-attached-frame) | |
3614 )) | |
3615 | |
3616 (defun speedbar-tag-expand (text token indent) | |
3617 "Expand a tag sublist. Imenu will return sub-lists of specialized tag types. | |
3618 Etags does not support this feature. TEXT will be the button | |
3619 string. TOKEN will be the list, and INDENT is the current indentation | |
3620 level." | |
3621 (cond ((string-match "+" text) ;we have to expand this file | |
3622 (speedbar-change-expand-button-char ?-) | |
3623 (speedbar-with-writable | |
3624 (save-excursion | |
3625 (end-of-line) (forward-char 1) | |
22735 | 3626 (speedbar-insert-generic-list indent token 'speedbar-tag-expand |
21650 | 3627 'speedbar-tag-find)))) |
3628 ((string-match "-" text) ;we have to contract this node | |
3629 (speedbar-change-expand-button-char ?+) | |
3630 (speedbar-delete-subblock indent)) | |
22735 | 3631 (t (error "Ooops... not sure what to do"))) |
21650 | 3632 (speedbar-center-buffer-smartly)) |
3633 | |
3634 ;;; Loading files into the attached frame. | |
3635 ;; | |
3636 (defun speedbar-find-file-in-frame (file) | |
3637 "This will load FILE into the speedbar attached frame. | |
3638 If the file is being displayed in a different frame already, then raise that | |
3639 frame instead." | |
3640 (let* ((buff (find-file-noselect file)) | |
3641 (bwin (get-buffer-window buff 0))) | |
3642 (if bwin | |
3643 (progn | |
3644 (select-window bwin) | |
3645 (raise-frame (window-frame bwin))) | |
3646 (if speedbar-power-click | |
3647 (let ((pop-up-frames t)) (select-window (display-buffer buff))) | |
3648 (select-frame speedbar-attached-frame) | |
3649 (switch-to-buffer buff)))) | |
22735 | 3650 ) |
21650 | 3651 |
3652 ;;; Centering Utility | |
3653 ;; | |
3654 (defun speedbar-center-buffer-smartly () | |
3655 "Recenter a speedbar buffer so the current indentation level is all visible. | |
3656 This assumes that the cursor is on a file, or tag of a file which the user is | |
3657 interested in." | |
3658 (if (<= (count-lines (point-min) (point-max)) | |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
3659 (1- (window-height (selected-window)))) |
21650 | 3660 ;; whole buffer fits |
3661 (let ((cp (point))) | |
3662 (goto-char (point-min)) | |
3663 (recenter 0) | |
3664 (goto-char cp)) | |
3665 ;; too big | |
3666 (let (depth start end exp p) | |
3667 (save-excursion | |
3668 (beginning-of-line) | |
3669 (setq depth (if (looking-at "[0-9]+") | |
3670 (string-to-int (buffer-substring-no-properties | |
3671 (match-beginning 0) (match-end 0))) | |
3672 0)) | |
3673 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth))) | |
3674 (save-excursion | |
3675 (end-of-line) | |
3676 (if (re-search-backward exp nil t) | |
3677 (setq start (point)) | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
3678 (setq start (point-min))) |
21650 | 3679 (save-excursion ;Not sure about this part. |
3680 (end-of-line) | |
3681 (setq p (point)) | |
3682 (while (and (not (re-search-forward exp nil t)) | |
3683 (>= depth 0)) | |
3684 (setq depth (1- depth)) | |
3685 (setq exp (format "^%d:\\s-*[[{<]\\([?+-]\\)[]>}]" depth))) | |
3686 (if (/= (point) p) | |
3687 (setq end (point)) | |
3688 (setq end (point-max))))) | |
3689 ;; Now work out the details of centering | |
3690 (let ((nl (count-lines start end)) | |
3691 (cp (point))) | |
3692 (if (> nl (window-height (selected-window))) | |
3693 ;; We can't fit it all, so just center on cursor | |
3694 (progn (goto-char start) | |
3695 (recenter 1)) | |
3696 ;; we can fit everything on the screen, but... | |
3697 (if (and (pos-visible-in-window-p start (selected-window)) | |
3698 (pos-visible-in-window-p end (selected-window))) | |
3699 ;; we are all set! | |
3700 nil | |
3701 ;; we need to do something... | |
3702 (goto-char start) | |
3703 (let ((newcent (/ (- (window-height (selected-window)) nl) 2)) | |
3704 (lte (count-lines start (point-max)))) | |
3705 (if (and (< (+ newcent lte) (window-height (selected-window))) | |
3706 (> (- (window-height (selected-window)) lte 1) | |
3707 newcent)) | |
3708 (setq newcent (- (window-height (selected-window)) | |
3709 lte 1))) | |
3710 (recenter newcent)))) | |
3711 (goto-char cp))))) | |
3712 | |
3713 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3714 ;;; Tag Management -- List of expanders: |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3715 ;; |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3716 (defun speedbar-fetch-dynamic-tags (file) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3717 "Return a list of tags generated dynamically from FILE. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3718 This uses the entries in `speedbar-dynamic-tags-function-list' |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3719 to find the proper tags. It is up to each of those individual |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3720 functions to do caching and flushing if appropriate." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3721 (save-excursion |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3722 (set-buffer (find-file-noselect file)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3723 ;; If there is a buffer-local value of |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3724 ;; speedbar-dynamic-tags-function-list, it will now be available. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3725 (let ((dtf speedbar-dynamic-tags-function-list) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3726 (ret t)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3727 (while (and (eq ret t) dtf) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3728 (setq ret |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3729 (if (fboundp (car (car dtf))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3730 (funcall (car (car dtf)) (buffer-file-name)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3731 t)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3732 (if (eq ret t) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3733 (setq dtf (cdr dtf)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3734 (if (eq ret t) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3735 ;; No valid tag list, return nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3736 nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3737 ;; We have some tags. Return the list with the insert fn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3738 ;; prepended |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3739 (cons (cdr (car dtf)) ret))))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3740 |
21650 | 3741 ;;; Tag Management -- Imenu |
3742 ;; | |
3743 (if (not speedbar-use-imenu-flag) | |
3744 | |
3745 nil | |
3746 | |
3747 (eval-when-compile (if (locate-library "imenu") (require 'imenu))) | |
3748 | |
3749 (defun speedbar-fetch-dynamic-imenu (file) | |
3750 "Load FILE into a buffer, and generate tags using Imenu. | |
3751 Returns the tag list, or t for an error." | |
3752 ;; Load this AND compile it in | |
3753 (require 'imenu) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3754 (if speedbar-power-click (setq imenu--index-alist nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3755 (condition-case nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3756 (let ((index-alist (imenu--make-index-alist t))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3757 (if speedbar-sort-tags |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3758 (sort (copy-alist index-alist) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3759 (lambda (a b) (string< (car a) (car b)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3760 index-alist)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3761 (error t))) |
21650 | 3762 ) |
3763 | |
3764 ;;; Tag Management -- etags (old XEmacs compatibility part) | |
3765 ;; | |
3766 (defvar speedbar-fetch-etags-parse-list | |
3767 '(;; Note that java has the same parse-group as c | |
3768 ("\\.\\([cChH]\\|c\\+\\+\\|cpp\\|cc\\|hh\\|java\\)\\'" . | |
3769 speedbar-parse-c-or-c++tag) | |
3770 ("^\\.emacs$\\|.\\(el\\|l\\|lsp\\)\\'" . | |
3771 "def[^i]+\\s-+\\(\\(\\w\\|[-_]\\)+\\)\\s-*\C-?") | |
22735 | 3772 ; ("\\.\\([fF]\\|for\\|FOR\\|77\\|90\\)\\'" . |
3773 ; speedbar-parse-fortran77-tag) | |
21650 | 3774 ("\\.tex\\'" . speedbar-parse-tex-string) |
3775 ("\\.p\\'" . | |
3776 "\\(\\(FUNCTION\\|function\\|PROCEDURE\\|procedure\\)\\s-+\\([a-zA-Z0-9_.:]+\\)\\)\\s-*(?^?") | |
3777 ) | |
3778 "Associations of file extensions and expressions for extracting tags. | |
3779 To add a new file type, you would want to add a new association to the | |
3780 list, where the car is the file match, and the cdr is the way to | |
3781 extract an element from the tags output. If the output is complex, | |
3782 use a function symbol instead of regexp. The function should expect | |
3783 to be at the beginning of a line in the etags buffer. | |
3784 | |
3785 This variable is ignored if `speedbar-use-imenu-flag' is non-nil.") | |
3786 | |
3787 (defvar speedbar-fetch-etags-command "etags" | |
3788 "*Command used to create an etags file. | |
3789 | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3790 This variable is ignored if `speedbar-use-imenu-flag' is t.") |
21650 | 3791 |
3792 (defvar speedbar-fetch-etags-arguments '("-D" "-I" "-o" "-") | |
3793 "*List of arguments to use with `speedbar-fetch-etags-command'. | |
3794 This creates an etags output buffer. Use `speedbar-toggle-etags' to | |
3795 modify this list conveniently. | |
3796 | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3797 This variable is ignored if `speedbar-use-imenu-flag' is t.") |
21650 | 3798 |
3799 (defun speedbar-toggle-etags (flag) | |
3800 "Toggle FLAG in `speedbar-fetch-etags-arguments'. | |
3801 FLAG then becomes a member of etags command line arguments. If flag | |
3802 is \"sort\", then toggle the value of `speedbar-sort-tags'. If its | |
3803 value is \"show\" then toggle the value of | |
3804 `speedbar-show-unknown-files'. | |
3805 | |
3806 This function is a convenience function for XEmacs menu created by | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3807 Farzin Guilak <farzin@protocol.com>." |
21650 | 3808 (interactive) |
3809 (cond | |
3810 ((equal flag "sort") | |
3811 (setq speedbar-sort-tags (not speedbar-sort-tags))) | |
3812 ((equal flag "show") | |
3813 (setq speedbar-show-unknown-files (not speedbar-show-unknown-files))) | |
3814 ((or (equal flag "-C") | |
3815 (equal flag "-S") | |
3816 (equal flag "-D")) | |
3817 (if (member flag speedbar-fetch-etags-arguments) | |
3818 (setq speedbar-fetch-etags-arguments | |
3819 (delete flag speedbar-fetch-etags-arguments)) | |
3820 (add-to-list 'speedbar-fetch-etags-arguments flag))) | |
3821 (t nil))) | |
3822 | |
3823 (defun speedbar-fetch-dynamic-etags (file) | |
3824 "For FILE, run etags and create a list of symbols extracted. | |
3825 Each symbol will be associated with its line position in FILE." | |
3826 (let ((newlist nil)) | |
3827 (unwind-protect | |
3828 (save-excursion | |
3829 (if (get-buffer "*etags tmp*") | |
3830 (kill-buffer "*etags tmp*")) ;kill to clean it up | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3831 (if (<= 1 speedbar-verbosity-level) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3832 (speedbar-message "Fetching etags...")) |
21650 | 3833 (set-buffer (get-buffer-create "*etags tmp*")) |
3834 (apply 'call-process speedbar-fetch-etags-command nil | |
3835 (current-buffer) nil | |
3836 (append speedbar-fetch-etags-arguments (list file))) | |
3837 (goto-char (point-min)) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3838 (if (<= 1 speedbar-verbosity-level) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3839 (speedbar-message "Fetching etags...")) |
21650 | 3840 (let ((expr |
3841 (let ((exprlst speedbar-fetch-etags-parse-list) | |
3842 (ans nil)) | |
3843 (while (and (not ans) exprlst) | |
3844 (if (string-match (car (car exprlst)) file) | |
3845 (setq ans (car exprlst))) | |
3846 (setq exprlst (cdr exprlst))) | |
3847 (cdr ans)))) | |
3848 (if expr | |
3849 (let (tnl) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3850 (set-buffer (get-buffer-create "*etags tmp*")) |
21650 | 3851 (while (not (save-excursion (end-of-line) (eobp))) |
3852 (save-excursion | |
3853 (setq tnl (speedbar-extract-one-symbol expr))) | |
3854 (if tnl (setq newlist (cons tnl newlist))) | |
3855 (forward-line 1))) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3856 (speedbar-message |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
3857 "Sorry, no support for a file of that extension")))) |
21650 | 3858 ) |
3859 (if speedbar-sort-tags | |
3860 (sort newlist (lambda (a b) (string< (car a) (car b)))) | |
3861 (reverse newlist)))) | |
3862 | |
3863 ;; This bit donated by Farzin Guilak <farzin@protocol.com> but I'm not | |
3864 ;; sure it's needed with the different sorting method. | |
3865 ;; | |
3866 ;(defun speedbar-clean-etags() | |
3867 ; "Removes spaces before the ^? character, and removes `#define', | |
3868 ;return types, etc. preceding tags. This ensures that the sort operation | |
3869 ;works on the tags, not the return types." | |
3870 ; (save-excursion | |
3871 ; (goto-char (point-min)) | |
3872 ; (while | |
3873 ; (re-search-forward "(?[ \t](?\C-?" nil t) | |
3874 ; (replace-match "\C-?" nil nil)) | |
3875 ; (goto-char (point-min)) | |
3876 ; (while | |
3877 ; (re-search-forward "\\(.*[ \t]+\\)\\([^ \t\n]+.*\C-?\\)" nil t) | |
3878 ; (delete-region (match-beginning 1) (match-end 1))))) | |
3879 | |
3880 (defun speedbar-extract-one-symbol (expr) | |
22735 | 3881 "At point, return nil, or one alist in the form: (SYMBOL . POSITION) |
21650 | 3882 The line should contain output from etags. Parse the output using the |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3883 regular expression EXPR." |
21650 | 3884 (let* ((sym (if (stringp expr) |
3885 (if (save-excursion | |
3886 (re-search-forward expr (save-excursion | |
3887 (end-of-line) | |
3888 (point)) t)) | |
3889 (buffer-substring-no-properties (match-beginning 1) | |
3890 (match-end 1))) | |
3891 (funcall expr))) | |
3892 (pos (let ((j (re-search-forward "[\C-?\C-a]\\([0-9]+\\),\\([0-9]+\\)" | |
3893 (save-excursion | |
3894 (end-of-line) | |
3895 (point)) | |
3896 t))) | |
3897 (if (and j sym) | |
3898 (1+ (string-to-int (buffer-substring-no-properties | |
3899 (match-beginning 2) | |
3900 (match-end 2)))) | |
3901 0)))) | |
3902 (if (/= pos 0) | |
3903 (cons sym pos) | |
3904 nil))) | |
3905 | |
3906 (defun speedbar-parse-c-or-c++tag () | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
3907 "Parse a C or C++ tag, which tends to be a little complex." |
21650 | 3908 (save-excursion |
3909 (let ((bound (save-excursion (end-of-line) (point)))) | |
3910 (cond ((re-search-forward "\C-?\\([^\C-a]+\\)\C-a" bound t) | |
3911 (buffer-substring-no-properties (match-beginning 1) | |
3912 (match-end 1))) | |
3913 ((re-search-forward "\\<\\([^ \t]+\\)\\s-+new(" bound t) | |
3914 (buffer-substring-no-properties (match-beginning 1) | |
3915 (match-end 1))) | |
3916 ((re-search-forward "\\<\\([^ \t(]+\\)\\s-*(\C-?" bound t) | |
3917 (buffer-substring-no-properties (match-beginning 1) | |
3918 (match-end 1))) | |
3919 (t nil)) | |
3920 ))) | |
3921 | |
3922 (defun speedbar-parse-tex-string () | |
3923 "Parse a Tex string. Only find data which is relevant." | |
3924 (save-excursion | |
3925 (let ((bound (save-excursion (end-of-line) (point)))) | |
3926 (cond ((re-search-forward "\\(\\(sub\\)*section\\|chapter\\|cite\\)\\s-*{[^\C-?}]*}?" bound t) | |
3927 (buffer-substring-no-properties (match-beginning 0) | |
3928 (match-end 0))) | |
3929 (t nil))))) | |
3930 | |
3931 | |
22735 | 3932 ;;; BUFFER DISPLAY mode. |
3933 ;; | |
3934 (defvar speedbar-buffers-key-map nil | |
3935 "Keymap used when in the buffers display mode.") | |
3936 | |
3937 (if speedbar-buffers-key-map | |
3938 nil | |
3939 (setq speedbar-buffers-key-map (speedbar-make-specialized-keymap)) | |
3940 | |
3941 ;; Basic tree features | |
3942 (define-key speedbar-buffers-key-map "e" 'speedbar-edit-line) | |
3943 (define-key speedbar-buffers-key-map "\C-m" 'speedbar-edit-line) | |
3944 (define-key speedbar-buffers-key-map "+" 'speedbar-expand-line) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3945 (define-key speedbar-buffers-key-map "=" 'speedbar-expand-line) |
22735 | 3946 (define-key speedbar-buffers-key-map "-" 'speedbar-contract-line) |
3947 | |
3948 ;; Buffer specific keybindings | |
3949 (define-key speedbar-buffers-key-map "k" 'speedbar-buffer-kill-buffer) | |
3950 (define-key speedbar-buffers-key-map "r" 'speedbar-buffer-revert-buffer) | |
3951 | |
3952 ) | |
3953 | |
3954 (defvar speedbar-buffer-easymenu-definition | |
3955 '(["Jump to buffer" speedbar-edit-line t] | |
3956 ["Expand File Tags" speedbar-expand-line | |
3957 (save-excursion (beginning-of-line) | |
3958 (looking-at "[0-9]+: *.\\+. "))] | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3959 ["Flush Cache & Expand" speedbar-flush-expand-line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3960 (save-excursion (beginning-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3961 (looking-at "[0-9]+: *.\\+. "))] |
22735 | 3962 ["Contract File Tags" speedbar-contract-line |
3963 (save-excursion (beginning-of-line) | |
3964 (looking-at "[0-9]+: *.-. "))] | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3965 ["Kill Buffer" speedbar-buffer-kill-buffer |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3966 (save-excursion (beginning-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3967 (looking-at "[0-9]+: *.-. "))] |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3968 ["Revert Buffer" speedbar-buffer-revert-buffer |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3969 (save-excursion (beginning-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3970 (looking-at "[0-9]+: *.-. "))] |
22735 | 3971 ) |
3972 "Menu item elements shown when displaying a buffer list.") | |
3973 | |
3974 (defun speedbar-buffer-buttons (directory zero) | |
3975 "Create speedbar buttons based on the buffers currently loaded. | |
3976 DIRECTORY is the path to the currently active buffer, and ZERO is 0." | |
3977 (speedbar-buffer-buttons-engine nil)) | |
3978 | |
3979 (defun speedbar-buffer-buttons-temp (directory zero) | |
3980 "Create speedbar buttons based on the buffers currently loaded. | |
3981 DIRECTORY is the path to the currently active buffer, and ZERO is 0." | |
3982 (speedbar-buffer-buttons-engine t)) | |
3983 | |
3984 (defun speedbar-buffer-buttons-engine (temp) | |
3985 "Create speedbar buffer buttons. | |
3986 If TEMP is non-nil, then clicking on a buffer restores the previous display." | |
3987 (insert "Active Buffers:\n") | |
3988 (let ((bl (buffer-list))) | |
3989 (while bl | |
3990 (if (string-match "^[ *]" (buffer-name (car bl))) | |
3991 nil | |
3992 (let* ((known (string-match speedbar-file-regexp | |
3993 (buffer-name (car bl)))) | |
3994 (expchar (if known ?+ ??)) | |
3995 (fn (if known 'speedbar-tag-file nil)) | |
3996 (fname (save-excursion (set-buffer (car bl)) | |
3997 (buffer-file-name)))) | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3998 (speedbar-make-tag-line 'bracket expchar fn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
3999 (if fname (file-name-nondirectory fname)) |
22735 | 4000 (buffer-name (car bl)) |
4001 'speedbar-buffer-click temp | |
4002 'speedbar-file-face 0))) | |
4003 (setq bl (cdr bl))) | |
4004 (setq bl (buffer-list)) | |
4005 (insert "Scratch Buffers:\n") | |
4006 (while bl | |
4007 (if (not (string-match "^\\*" (buffer-name (car bl)))) | |
4008 nil | |
4009 (if (eq (car bl) speedbar-buffer) | |
4010 nil | |
4011 (speedbar-make-tag-line 'bracket ?? nil nil | |
4012 (buffer-name (car bl)) | |
4013 'speedbar-buffer-click temp | |
4014 'speedbar-file-face 0))) | |
4015 (setq bl (cdr bl))) | |
4016 (setq bl (buffer-list)) | |
4017 (insert "Hidden Buffers:\n") | |
4018 (while bl | |
4019 (if (not (string-match "^ " (buffer-name (car bl)))) | |
4020 nil | |
4021 (if (eq (car bl) speedbar-buffer) | |
4022 nil | |
4023 (speedbar-make-tag-line 'bracket ?? nil nil | |
4024 (buffer-name (car bl)) | |
4025 'speedbar-buffer-click temp | |
4026 'speedbar-file-face 0))) | |
4027 (setq bl (cdr bl))))) | |
4028 | |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4029 (defun speedbar-buffers-item-info () |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4030 "Display information about the current buffer on the current line." |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4031 (or (speedbar-item-info-tag-helper) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4032 (let* ((item (speedbar-line-text)) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4033 (buffer (if item (get-buffer item) nil))) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4034 (and buffer |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4035 (speedbar-message "%s%s %S %d %s" |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4036 (if (buffer-modified-p buffer) "* " "") |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4037 item |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4038 (save-excursion (set-buffer buffer) major-mode) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4039 (save-excursion (set-buffer buffer) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4040 (buffer-size)) |
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4041 (or (buffer-file-name buffer) "<No file>")))))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4042 |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4043 (defun speedbar-buffers-line-path (&optional depth) |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4044 "Fetch the full path to the file (buffer) specified on the current line. |
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4045 Optional argument DEPTH specifies the current depth of the back search." |
36047
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4046 (save-excursion |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4047 (end-of-line) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4048 (let ((start (point))) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4049 ;; Buffers are always at level 0 |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4050 (if (not (re-search-backward "^0:" nil t)) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4051 nil |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4052 (let* ((bn (speedbar-line-text)) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4053 (buffer (if bn (get-buffer bn)))) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4054 (if buffer |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4055 (if (save-excursion |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4056 (end-of-line) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4057 (eq start (point))) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4058 (file-name-directory (buffer-file-name buffer)) |
e1126269be53
(speedbar-frame-parameters): No toolbar lines.
Eric M. Ludlam <zappo@gnu.org>
parents:
31562
diff
changeset
|
4059 (buffer-file-name buffer)))))))) |
24154
91c00b394901
(speedbar-item-info-file-helper): Add optional arg
Eric M. Ludlam <zappo@gnu.org>
parents:
23917
diff
changeset
|
4060 |
22735 | 4061 (defun speedbar-buffer-click (text token indent) |
4062 "When the users clicks on a buffer-button in speedbar. | |
4063 TEXT is the buffer's name, TOKEN and INDENT are unused." | |
4064 (if speedbar-power-click | |
4065 (let ((pop-up-frames t)) (select-window (display-buffer text))) | |
4066 (select-frame speedbar-attached-frame) | |
4067 (switch-to-buffer text) | |
4068 (if token (speedbar-change-initial-expansion-list | |
4069 speedbar-previously-used-expansion-list-name)))) | |
4070 | |
4071 (defun speedbar-buffer-kill-buffer () | |
4072 "Kill the buffer the cursor is on in the speedbar buffer." | |
4073 (interactive) | |
4074 (or (save-excursion | |
4075 (beginning-of-line) | |
4076 ;; If this fails, then it is a non-standard click, and as such, | |
4077 ;; perfectly allowed. | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
4078 (if (re-search-forward "[]>?}] [^ ]" |
22735 | 4079 (save-excursion (end-of-line) (point)) |
4080 t) | |
4081 (let ((text (progn | |
4082 (forward-char -1) | |
4083 (buffer-substring (point) (save-excursion | |
4084 (end-of-line) | |
4085 (point)))))) | |
4086 (if (and (get-buffer text) | |
24475
1e20dcb26ff7
Added commentary about stealthy functions.
Karl Heuer <kwzh@gnu.org>
parents:
24321
diff
changeset
|
4087 (speedbar-y-or-n-p (format "Kill buffer %s? " text))) |
22893
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
4088 (kill-buffer text)) |
322179a8fd20
(speedbar-update-current-file): Added call to
Eric M. Ludlam <zappo@gnu.org>
parents:
22735
diff
changeset
|
4089 (speedbar-refresh)))))) |
22735 | 4090 |
4091 (defun speedbar-buffer-revert-buffer () | |
4092 "Revert the buffer the cursor is on in the speedbar buffer." | |
4093 (interactive) | |
4094 (save-excursion | |
4095 (beginning-of-line) | |
4096 ;; If this fails, then it is a non-standard click, and as such, | |
4097 ;; perfectly allowed | |
22950
606be1490be7
(speedbar-edit-line, speedbar-buffer-kill-buffer,
Eric M. Ludlam <zappo@gnu.org>
parents:
22906
diff
changeset
|
4098 (if (re-search-forward "[]>?}] [^ ]" |
22735 | 4099 (save-excursion (end-of-line) (point)) |
4100 t) | |
4101 (let ((text (progn | |
4102 (forward-char -1) | |
4103 (buffer-substring (point) (save-excursion | |
4104 (end-of-line) | |
4105 (point)))))) | |
4106 (if (get-buffer text) | |
4107 (progn | |
4108 (set-buffer text) | |
4109 (revert-buffer t))))))) | |
4110 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4111 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4112 ;;; Useful hook values and such. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4113 ;; |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4114 (defvar speedbar-highlight-one-tag-line nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4115 "Overlay used for highlighting the most recently jumped to tag line.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4116 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4117 (defun speedbar-highlight-one-tag-line () |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4118 "Highlight the current line, unhighlighting a previously jumped to line." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4119 (speedbar-unhighlight-one-tag-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4120 (setq speedbar-highlight-one-tag-line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4121 (speedbar-make-overlay (save-excursion (beginning-of-line) (point)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4122 (save-excursion (end-of-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4123 (forward-char 1) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4124 (point)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4125 (speedbar-overlay-put speedbar-highlight-one-tag-line 'face |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4126 'speedbar-highlight-face) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4127 (add-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4128 ) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4129 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4130 (defun speedbar-unhighlight-one-tag-line () |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
4131 "Unhighlight the currently highlighted line." |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4132 (if speedbar-highlight-one-tag-line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4133 (progn |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4134 (speedbar-delete-overlay speedbar-highlight-one-tag-line) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4135 (setq speedbar-highlight-one-tag-line nil))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4136 (remove-hook 'pre-command-hook 'speedbar-unhighlight-one-tag-line)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4137 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4138 (defun speedbar-recenter-to-top () |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4139 "Recenter the current buffer so POINT is on the top of the window." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4140 (recenter 1)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4141 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4142 (defun speedbar-recenter () |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4143 "Recenter the current buffer so POINT is in the center of the window." |
28925
89a795d90175
(speedbar-recenter): Typo, and fix logic.
Eric M. Ludlam <zappo@gnu.org>
parents:
28902
diff
changeset
|
4144 (recenter (/ (window-height (selected-window)) 2))) |
22735 | 4145 |
4146 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4147 ;;; Color loading section. |
21650 | 4148 ;; |
4149 (defface speedbar-button-face '((((class color) (background light)) | |
4150 (:foreground "green4")) | |
4151 (((class color) (background dark)) | |
4152 (:foreground "green3"))) | |
4153 "Face used for +/- buttons." | |
4154 :group 'speedbar-faces) | |
4155 | |
4156 (defface speedbar-file-face '((((class color) (background light)) | |
4157 (:foreground "cyan4")) | |
4158 (((class color) (background dark)) | |
4159 (:foreground "cyan")) | |
42456
8a4077ab418c
(various face definitions): Use :weight, not :bold.
Richard M. Stallman <rms@gnu.org>
parents:
41576
diff
changeset
|
4160 (t (:weight bold))) |
21650 | 4161 "Face used for file names." |
4162 :group 'speedbar-faces) | |
4163 | |
4164 (defface speedbar-directory-face '((((class color) (background light)) | |
4165 (:foreground "blue4")) | |
4166 (((class color) (background dark)) | |
4167 (:foreground "light blue"))) | |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
4168 "Face used for directory names." |
21650 | 4169 :group 'speedbar-faces) |
4170 (defface speedbar-tag-face '((((class color) (background light)) | |
4171 (:foreground "brown")) | |
4172 (((class color) (background dark)) | |
4173 (:foreground "yellow"))) | |
4174 "Face used for displaying tags." | |
4175 :group 'speedbar-faces) | |
4176 | |
4177 (defface speedbar-selected-face '((((class color) (background light)) | |
4178 (:foreground "red" :underline t)) | |
4179 (((class color) (background dark)) | |
4180 (:foreground "red" :underline t)) | |
4181 (t (:underline t))) | |
4182 "Face used to underline the file in the active window." | |
4183 :group 'speedbar-faces) | |
4184 | |
4185 (defface speedbar-highlight-face '((((class color) (background light)) | |
4186 (:background "green")) | |
4187 (((class color) (background dark)) | |
4188 (:background "sea green")) | |
48686
ee68dbd692ce
(speedbar-highlight-face): Fix face spec.
Andreas Schwab <schwab@suse.de>
parents:
48380
diff
changeset
|
4189 (((class grayscale mono) |
21650 | 4190 (background light)) |
4191 (:background "black")) | |
48686
ee68dbd692ce
(speedbar-highlight-face): Fix face spec.
Andreas Schwab <schwab@suse.de>
parents:
48380
diff
changeset
|
4192 (((class grayscale mono) |
21650 | 4193 (background dark)) |
4194 (:background "white"))) | |
4195 "Face used for highlighting buttons with the mouse." | |
4196 :group 'speedbar-faces) | |
4197 | |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4198 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4199 ;;; Image loading and inlining |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4200 ;; |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4201 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4202 ;;; Some images if defimage is available: |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4203 (eval-when-compile |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4204 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4205 (if (fboundp 'defimage) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4206 (defalias 'defimage-speedbar 'defimage) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4207 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4208 (if (not (fboundp 'make-glyph)) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
48716
diff
changeset
|
4209 |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4210 (defmacro defimage-speedbar (variable imagespec docstring) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4211 "Don't bother loading up an image... |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
4212 Argument VARIABLE is the variable to define. |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4213 Argument IMAGESPEC is the list defining the image to create. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4214 Argument DOCSTRING is the documentation for VARIABLE." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4215 `(defvar ,variable nil ,docstring)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4216 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4217 ;; ELSE |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4218 (defun speedbar-find-image-on-load-path (image) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4219 "Find the image file IMAGE on the load path." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4220 (let ((l load-path) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4221 (r nil)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4222 (while (and l (not r)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4223 (if (file-exists-p (concat (car l) "/" image)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4224 (setq r (concat (car l) "/" image))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4225 (setq l (cdr l))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4226 r)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4227 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4228 (defun speedbar-convert-emacs21-imagespec-to-xemacs (spec) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
4229 "Convert the Emacs21 image SPEC into an XEmacs image spec." |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4230 (let* ((sl (car spec)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4231 (itype (nth 1 sl)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4232 (ifile (nth 3 sl))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4233 (vector itype ':file (speedbar-find-image-on-load-path ifile)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4234 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4235 (defmacro defimage-speedbar (variable imagespec docstring) |
46282
015a7038f5db
(speedbar-make-specialized-keymap): Fix docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
44584
diff
changeset
|
4236 "Define VARIABLE as an image if `defimage' is not available. |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4237 IMAGESPEC is the image data, and DOCSTRING is documentation for the image." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4238 `(defvar ,variable |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4239 ;; The Emacs21 version of defimage looks just like the XEmacs image |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4240 ;; specifier, except that it needs a :type keyword. If we line |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4241 ;; stuff up right, we can use this cheat to support XEmacs specifiers. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4242 (condition-case nil |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4243 (make-glyph |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4244 (make-image-specifier |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4245 (speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4246 'buffer) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4247 (error nil)) |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4248 ,docstring))))) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4249 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4250 (defimage-speedbar speedbar-directory-plus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4251 ((:type xpm :file "sb-dir-plus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4252 "Image used for closed directories with stuff in them.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4253 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4254 (defimage-speedbar speedbar-directory-minus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4255 ((:type xpm :file "sb-dir-minus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4256 "Image used for open directories with stuff in them.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4257 |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4258 (defimage-speedbar speedbar-directory |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4259 ((:type xpm :file "sb-dir.xpm" :ascent center)) |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4260 "Image used for empty or unreadable directories.") |
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4261 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4262 (defimage-speedbar speedbar-page-plus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4263 ((:type xpm :file "sb-pg-plus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4264 "Image used for closed files with stuff in them.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4265 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4266 (defimage-speedbar speedbar-page-minus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4267 ((:type xpm :file "sb-pg-minus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4268 "Image used for open files with stuff in them.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4269 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4270 (defimage-speedbar speedbar-page |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4271 ((:type xpm :file "sb-pg.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4272 "Image used for files that can't be opened.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4273 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4274 (defimage-speedbar speedbar-tag |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4275 ((:type xpm :file "sb-tag.xpm" :ascent center)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4276 "Image used for tags.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4277 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4278 (defimage-speedbar speedbar-tag-plus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4279 ((:type xpm :file "sb-tag-plus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4280 "Image used for closed tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4281 |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4282 (defimage-speedbar speedbar-tag-minus |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4283 ((:type xpm :file "sb-tag-minus.xpm" :ascent center)) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4284 "Image used for open tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4285 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4286 (defimage-speedbar speedbar-tag-gt |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4287 ((:type xpm :file "sb-tag-gt.xpm" :ascent center)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4288 "Image used for open tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4289 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4290 (defimage-speedbar speedbar-tag-v |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4291 ((:type xpm :file "sb-tag-v.xpm" :ascent center)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4292 "Image used for open tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4293 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4294 (defimage-speedbar speedbar-tag-type |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4295 ((:type xpm :file "sb-tag-type.xpm" :ascent center)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4296 "Image used for open tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4297 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4298 (defimage-speedbar speedbar-mail |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4299 ((:type xpm :file "sb-mail.xpm" :ascent center)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4300 "Image used for open tag groups.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4301 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4302 (defvar speedbar-expand-image-button-alist |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4303 '(("<+>" . speedbar-directory-plus) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4304 ("<->" . speedbar-directory-minus) |
56647
d21a8e697065
(speedbar-scan-subdirs): New option.
Daniel Pfeiffer <occitan@esperanto.org>
parents:
53487
diff
changeset
|
4305 ("< >" . speedbar-directory) |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4306 ("[+]" . speedbar-page-plus) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4307 ("[-]" . speedbar-page-minus) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4308 ("[?]" . speedbar-page) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4309 ("{+}" . speedbar-tag-plus) |
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4310 ("{-}" . speedbar-tag-minus) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4311 ("<M>" . speedbar-mail) |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4312 (" =>" . speedbar-tag) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4313 (" +>" . speedbar-tag-gt) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4314 (" ->" . speedbar-tag-v) |
29130
b37210b05707
(speedbar-easymenu-definition-base): Image toggle fix.
Eric M. Ludlam <zappo@gnu.org>
parents:
28925
diff
changeset
|
4315 (">" . speedbar-tag) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4316 ("@" . speedbar-tag-type) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4317 (" @" . speedbar-tag-type) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4318 ) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4319 "List of text and image associations.") |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4320 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4321 (defun speedbar-insert-image-button-maybe (start length) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4322 "Insert an image button based on text starting at START for LENGTH chars. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4323 If buttontext is unknown, just insert that text. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4324 If we have an image associated with it, use that image." |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4325 (if speedbar-use-images |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4326 (let* ((bt (buffer-substring start (+ length start))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4327 (a (assoc bt speedbar-expand-image-button-alist))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4328 ;; Regular images (created with `insert-image' are intangible |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4329 ;; which (I suppose) make them more compatible with XEmacs 21. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4330 ;; Unfortunatly, there is a giant pile o code dependent on the |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4331 ;; underlying text. This means if we leave it tangible, then I |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4332 ;; don't have to change said giant piles o code. |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4333 (if (and a (symbol-value (cdr a))) |
37180
fc838f090bbe
(speedbar-insert-image-button-maybe): Check for `xemacs' feature
Eric M. Ludlam <zappo@gnu.org>
parents:
36047
diff
changeset
|
4334 (if (featurep 'xemacs) |
28902
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4335 (add-text-properties (+ start (length bt)) start |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4336 (list 'end-glyph (symbol-value (cdr a)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4337 'rear-nonsticky (list 'display) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4338 'invisible t |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4339 'detachable t)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4340 (add-text-properties start (+ start (length bt)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4341 (list 'display (symbol-value (cdr a)) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4342 'rear-nonsticky (list 'display)))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4343 ;(message "Bad text [%s]" (buffer-substring start (+ start length))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4344 )))) |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4345 |
5292e9f1f2ca
Updated the commentary section.
Eric M. Ludlam <zappo@gnu.org>
parents:
26659
diff
changeset
|
4346 |
21650 | 4347 ;; some edebug hooks |
4348 (add-hook 'edebug-setup-hook | |
4349 (lambda () | |
4350 (def-edebug-spec speedbar-with-writable def-body))) | |
4351 | |
4352 (provide 'speedbar) | |
4353 | |
4354 ;; run load-time hooks | |
4355 (run-hooks 'speedbar-load-hook) | |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38377
diff
changeset
|
4356 |
52401 | 4357 ;;; arch-tag: 4477e6d1-f78c-48b9-a503-387d3c9767d5 |
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
38377
diff
changeset
|
4358 ;;; speedbar.el ends here |