Mercurial > emacs
comparison lisp/speedbar.el @ 89966:d8411455de48
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-32
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-486
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-487
Tweak permissions
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-488
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-489
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-490
Update from CVS: man/fixit.texi (Spelling): Fix typo.
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-491
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-494
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-495
Update from CVS: Add missing lisp/mh-e files
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-496
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-499
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-500
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-513
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Fri, 27 Aug 2004 07:00:34 +0000 |
parents | 68c22ea6027c c36d40df2cc6 |
children | e24e2e78deda |
comparison
equal
deleted
inserted
replaced
89965:5e9097d1ad99 | 89966:d8411455de48 |
---|---|
90 ;; which controls how tags are layed out. It is actually a list of | 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 | 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. | 92 ;; into sub-lists. A long flat list can be used instead if needed. |
93 ;; Other filters can be easily added. | 93 ;; Other filters can be easily added. |
94 ;; | 94 ;; |
95 ;; AUC-TEX users: The imenu tags for AUC-TEX mode doesn't work very | 95 ;; AUCTEX users: The imenu tags for AUCTEX mode doesn't work very |
96 ;; well. Use the imenu keywords from tex-mode.el for better results. | 96 ;; well. Use the imenu keywords from tex-mode.el for better results. |
97 ;; | 97 ;; |
98 ;; This file requires the library package assoc (association lists) | 98 ;; This file requires the library package assoc (association lists) |
99 ;; | 99 ;; |
100 ;;; Developing for speedbar | 100 ;;; Developing for speedbar |
662 noext (cdr noext))) | 662 noext (cdr noext))) |
663 ;; backup refdir lockfile | 663 ;; backup refdir lockfile |
664 (concat nstr "\\|#[^#]+#$\\|\\.\\.?\\'\\|\\.#")) | 664 (concat nstr "\\|#[^#]+#$\\|\\.\\.?\\'\\|\\.#")) |
665 "*Regexp matching files we don't want displayed in a speedbar buffer. | 665 "*Regexp matching files we don't want displayed in a speedbar buffer. |
666 It is generated from the variable `completion-ignored-extensions'") | 666 It is generated from the variable `completion-ignored-extensions'") |
667 | |
668 ;; Compiler silencing trick. The real defvar comes later in this file. | |
669 (defvar speedbar-file-regexp) | |
667 | 670 |
668 ;; this is dangerous to customize, because the defaults will probably | 671 ;; this is dangerous to customize, because the defaults will probably |
669 ;; change in the future. | 672 ;; change in the future. |
670 (defcustom speedbar-supported-extension-expressions | 673 (defcustom speedbar-supported-extension-expressions |
671 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" | 674 (append '(".[ch]\\(\\+\\+\\|pp\\|c\\|h\\|xx\\)?" ".tex\\(i\\(nfo\\)?\\)?" |
687 :group 'speedbar | 690 :group 'speedbar |
688 :version "21.1" | 691 :version "21.1" |
689 :type '(repeat (regexp :tag "Extension Regexp")) | 692 :type '(repeat (regexp :tag "Extension Regexp")) |
690 :set (lambda (sym val) | 693 :set (lambda (sym val) |
691 (setq speedbar-supported-extension-expressions val | 694 (setq speedbar-supported-extension-expressions val |
692 speedbar-file-regexp (speedbar-extension-list-to-regex val))) | 695 speedbar-file-regexp (speedbar-extension-list-to-regex val)))) |
693 ) | |
694 | 696 |
695 (defvar speedbar-file-regexp | 697 (defvar speedbar-file-regexp |
696 (speedbar-extension-list-to-regex speedbar-supported-extension-expressions) | 698 (speedbar-extension-list-to-regex speedbar-supported-extension-expressions) |
697 "Regular expression matching files we know how to expand. | 699 "Regular expression matching files we know how to expand. |
698 Created from `speedbar-supported-extension-expression' with the | 700 Created from `speedbar-supported-extension-expression' with the |
699 function `speedbar-extension-list-to-regex'") | 701 function `speedbar-extension-list-to-regex'") |
702 | |
703 (defcustom speedbar-scan-subdirs nil | |
704 "*Non-nil means speedbar will check if subdirs are empty. | |
705 That way you don't have to click on them to find out. But this | |
706 incurs extra I/O, hence it slows down directory display | |
707 proportionally to the number of subdirs." | |
708 :group 'speedbar | |
709 :type 'boolean | |
710 :version 21.4) | |
700 | 711 |
701 (defun speedbar-add-supported-extension (extension) | 712 (defun speedbar-add-supported-extension (extension) |
702 "Add EXTENSION as a new supported extension for speedbar tagging. | 713 "Add EXTENSION as a new supported extension for speedbar tagging. |
703 This should start with a `.' if it is not a complete file name, and | 714 This should start with a `.' if it is not a complete file name, and |
704 the dot should NOT be quoted in with \\. Other regular expression | 715 the dot should NOT be quoted in with \\. Other regular expression |
1285 (speedbar-frame-mode -1))))) | 1296 (speedbar-frame-mode -1))))) |
1286 t t) | 1297 t t) |
1287 (toggle-read-only 1) | 1298 (toggle-read-only 1) |
1288 (speedbar-set-mode-line-format) | 1299 (speedbar-set-mode-line-format) |
1289 (if speedbar-xemacsp | 1300 (if speedbar-xemacsp |
1290 (set (make-local-variable 'mouse-motion-handler) | 1301 (with-no-warnings |
1291 'speedbar-track-mouse-xemacs) | 1302 (set (make-local-variable 'mouse-motion-handler) |
1303 'speedbar-track-mouse-xemacs)) | |
1292 (if speedbar-track-mouse-flag | 1304 (if speedbar-track-mouse-flag |
1293 (set (make-local-variable 'track-mouse) t)) ;this could be messy. | 1305 (set (make-local-variable 'track-mouse) t)) ;this could be messy. |
1294 (setq auto-show-mode nil)) ;no auto-show for Emacs | 1306 (setq auto-show-mode nil)) ;no auto-show for Emacs |
1295 (run-hooks 'speedbar-mode-hook)) | 1307 (run-hooks 'speedbar-mode-hook)) |
1296 (speedbar-update-contents) | 1308 (speedbar-update-contents) |
1335 "Set the format of the mode line based on the current speedbar environment. | 1347 "Set the format of the mode line based on the current speedbar environment. |
1336 This gives visual indications of what is up. It EXPECTS the speedbar | 1348 This gives visual indications of what is up. It EXPECTS the speedbar |
1337 frame and window to be the currently active frame and window." | 1349 frame and window to be the currently active frame and window." |
1338 (if (and (frame-live-p speedbar-frame) | 1350 (if (and (frame-live-p speedbar-frame) |
1339 (or (not speedbar-xemacsp) | 1351 (or (not speedbar-xemacsp) |
1340 (specifier-instance has-modeline-p))) | 1352 (with-no-warnings |
1353 (specifier-instance has-modeline-p)))) | |
1341 (save-excursion | 1354 (save-excursion |
1342 (set-buffer speedbar-buffer) | 1355 (set-buffer speedbar-buffer) |
1343 (let* ((w (or (speedbar-frame-width) 20)) | 1356 (let* ((w (or (speedbar-frame-width) 20)) |
1344 (p1 "<<") | 1357 (p1 "<<") |
1345 (p5 ">>") | 1358 (p5 ">>") |
1536 (save-excursion | 1549 (save-excursion |
1537 (mouse-set-point e) | 1550 (mouse-set-point e) |
1538 ;; This gets the cursor where the user can see it. | 1551 ;; This gets the cursor where the user can see it. |
1539 (if (not (bolp)) (forward-char -1)) | 1552 (if (not (bolp)) (forward-char -1)) |
1540 (sit-for 0) | 1553 (sit-for 0) |
1541 (if (< emacs-major-version 20) | 1554 (mouse-major-mode-menu e nil))) |
1542 (mouse-major-mode-menu e) | |
1543 (mouse-major-mode-menu e nil)))) | |
1544 | 1555 |
1545 (defun speedbar-hack-buffer-menu (e) | 1556 (defun speedbar-hack-buffer-menu (e) |
1546 "Control mouse 1 is buffer menu. | 1557 "Control mouse 1 is buffer menu. |
1547 This hack overrides it so that the right thing happens in the main | 1558 This hack overrides it so that the right thing happens in the main |
1548 Emacs frame, not in the speedbar frame. | 1559 Emacs frame, not in the speedbar frame. |
2183 (if speedbar-power-click | 2194 (if speedbar-power-click |
2184 (adelete 'speedbar-directory-contents-alist directory)) | 2195 (adelete 'speedbar-directory-contents-alist directory)) |
2185 ;; find the directory, either in the cache, or build it. | 2196 ;; find the directory, either in the cache, or build it. |
2186 (or (cdr-safe (assoc directory speedbar-directory-contents-alist)) | 2197 (or (cdr-safe (assoc directory speedbar-directory-contents-alist)) |
2187 (let ((default-directory directory) | 2198 (let ((default-directory directory) |
2188 (dir (directory-files directory nil)) | 2199 (case-fold-search read-file-name-completion-ignore-case) |
2189 (dirs nil) | 2200 dirs files) |
2190 (files nil)) | 2201 (dolist (file (directory-files directory nil)) |
2191 (while dir | 2202 (or (string-match speedbar-file-unshown-regexp file) |
2192 (if (not | 2203 (string-match speedbar-directory-unshown-regexp file) |
2193 (or (string-match speedbar-file-unshown-regexp (car dir)) | 2204 (if (file-directory-p file) |
2194 (string-match speedbar-directory-unshown-regexp (car dir)))) | 2205 (setq dirs (cons file dirs)) |
2195 (if (file-directory-p (car dir)) | 2206 (setq files (cons file files))))) |
2196 (setq dirs (cons (car dir) dirs)) | 2207 (let ((nl `(,(nreverse dirs) ,(nreverse files)))) |
2197 (setq files (cons (car dir) files)))) | |
2198 (setq dir (cdr dir))) | |
2199 (let ((nl (cons (nreverse dirs) (list (nreverse files))))) | |
2200 (aput 'speedbar-directory-contents-alist directory nl) | 2208 (aput 'speedbar-directory-contents-alist directory nl) |
2201 nl)) | 2209 nl)))) |
2202 )) | |
2203 | 2210 |
2204 (defun speedbar-directory-buttons (directory index) | 2211 (defun speedbar-directory-buttons (directory index) |
2205 "Insert a single button group at point for DIRECTORY. | 2212 "Insert a single button group at point for DIRECTORY. |
2206 Each directory path part is a different button. If part of the path | 2213 Each directory path part is a different button. If part of the path |
2207 matches the user directory ~, then it is replaced with a ~. | 2214 matches the user directory ~, then it is replaced with a ~. |
2341 (speedbar-insert-image-button-maybe (- (point) 2) 3))))) | 2348 (speedbar-insert-image-button-maybe (- (point) 2) 3))))) |
2342 | 2349 |
2343 | 2350 |
2344 ;;; Build button lists | 2351 ;;; Build button lists |
2345 ;; | 2352 ;; |
2346 (defun speedbar-insert-files-at-point (files level) | 2353 (defun speedbar-insert-files-at-point (files level directory) |
2347 "Insert list of FILES starting at point, and indenting all files to LEVEL. | 2354 "Insert list of FILES starting at point, and indenting all files to LEVEL. |
2348 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we | 2355 Tag expandable items with a +, otherwise a ?. Don't highlight ? as we |
2349 don't know how to manage them. The input parameter FILES is a cons | 2356 don't know how to manage them. The input parameter FILES is a cons |
2350 cell of the form ( 'DIRLIST . 'FILELIST )." | 2357 cell of the form ( 'DIRLIST . 'FILELIST )." |
2351 ;; Start inserting all the directories | 2358 ;; Start inserting all the directories |
2352 (let ((dirs (car files))) | 2359 (dolist (dir (car files)) |
2353 (while dirs | 2360 (if (if speedbar-scan-subdirs |
2354 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs) | 2361 (condition-case nil |
2355 (car dirs) 'speedbar-dir-follow nil | 2362 (let ((l (speedbar-file-lists (concat directory dir)))) |
2356 'speedbar-directory-face level) | 2363 (or (car l) (cadr l))) |
2357 (setq dirs (cdr dirs)))) | 2364 (file-error)) |
2358 (let ((lst (car (cdr files))) | 2365 (file-readable-p (concat directory dir))) |
2359 (case-fold-search t)) | 2366 (speedbar-make-tag-line 'angle ?+ 'speedbar-dired dir |
2360 (while lst | 2367 dir 'speedbar-dir-follow nil |
2361 (let* ((known (string-match speedbar-file-regexp (car lst))) | 2368 'speedbar-directory-face level) |
2369 (speedbar-make-tag-line 'angle ? nil dir | |
2370 dir 'speedbar-dir-follow nil | |
2371 'speedbar-directory-face level))) | |
2372 (let ((case-fold-search read-file-name-completion-ignore-case)) | |
2373 (dolist (file (cadr files)) | |
2374 (let* ((known (and (file-readable-p (concat directory file)) | |
2375 (string-match speedbar-file-regexp file))) | |
2362 (expchar (if known ?+ ??)) | 2376 (expchar (if known ?+ ??)) |
2363 (fn (if known 'speedbar-tag-file nil))) | 2377 (fn (if known 'speedbar-tag-file nil))) |
2364 (if (or speedbar-show-unknown-files (/= expchar ??)) | 2378 (if (or speedbar-show-unknown-files (/= expchar ??)) |
2365 (speedbar-make-tag-line 'bracket expchar fn (car lst) | 2379 (speedbar-make-tag-line 'bracket expchar fn file |
2366 (car lst) 'speedbar-find-file nil | 2380 file 'speedbar-find-file nil |
2367 'speedbar-file-face level))) | 2381 'speedbar-file-face level)))))) |
2368 (setq lst (cdr lst))))) | |
2369 | 2382 |
2370 (defun speedbar-default-directory-list (directory index) | 2383 (defun speedbar-default-directory-list (directory index) |
2371 "Insert files for DIRECTORY with level INDEX at point." | 2384 "Insert files for DIRECTORY with level INDEX at point." |
2372 (speedbar-insert-files-at-point | 2385 (speedbar-insert-files-at-point |
2373 (speedbar-file-lists directory) index) | 2386 (speedbar-file-lists directory) index directory) |
2374 (speedbar-reset-scanners) | 2387 (speedbar-reset-scanners) |
2375 (if (= index 0) | 2388 (if (= index 0) |
2376 ;; If the shown files variable has extra directories, then | 2389 ;; If the shown files variable has extra directories, then |
2377 ;; it is our responsibility to redraw them all | 2390 ;; it is our responsibility to redraw them all |
2378 ;; Luckilly, the nature of inserting items into this list means | 2391 ;; Luckilly, the nature of inserting items into this list means |
2916 (select-frame lastf) | 2929 (select-frame lastf) |
2917 rf))) | 2930 rf))) |
2918 (newcf (if newcfd newcfd)) | 2931 (newcf (if newcfd newcfd)) |
2919 (lastb (current-buffer)) | 2932 (lastb (current-buffer)) |
2920 (sucf-recursive (boundp 'sucf-recursive)) | 2933 (sucf-recursive (boundp 'sucf-recursive)) |
2921 (case-fold-search t)) | 2934 (case-fold-search read-file-name-completion-ignore-case)) |
2922 (if (and newcf | 2935 (if (and newcf |
2923 ;; check here, that way we won't refresh to newcf until | 2936 ;; check here, that way we won't refresh to newcf until |
2924 ;; its been written, thus saving ourselves some time | 2937 ;; its been written, thus saving ourselves some time |
2925 (file-exists-p newcf) | 2938 (file-exists-p newcf) |
2926 (not (string= newcf speedbar-last-selected-file))) | 2939 (not (string= newcf speedbar-last-selected-file))) |
4233 (make-glyph | 4246 (make-glyph |
4234 (make-image-specifier | 4247 (make-image-specifier |
4235 (speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec))) | 4248 (speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec))) |
4236 'buffer) | 4249 'buffer) |
4237 (error nil)) | 4250 (error nil)) |
4238 ,docstring)) | 4251 ,docstring))))) |
4239 | |
4240 ))) | |
4241 | 4252 |
4242 (defimage-speedbar speedbar-directory-plus | 4253 (defimage-speedbar speedbar-directory-plus |
4243 ((:type xpm :file "sb-dir-plus.xpm" :ascent center)) | 4254 ((:type xpm :file "sb-dir-plus.xpm" :ascent center)) |
4244 "Image used for closed directories with stuff in them.") | 4255 "Image used for closed directories with stuff in them.") |
4245 | 4256 |
4246 (defimage-speedbar speedbar-directory-minus | 4257 (defimage-speedbar speedbar-directory-minus |
4247 ((:type xpm :file "sb-dir-minus.xpm" :ascent center)) | 4258 ((:type xpm :file "sb-dir-minus.xpm" :ascent center)) |
4248 "Image used for open directories with stuff in them.") | 4259 "Image used for open directories with stuff in them.") |
4249 | 4260 |
4261 (defimage-speedbar speedbar-directory | |
4262 ((:type xpm :file "sb-dir.xpm" :ascent center)) | |
4263 "Image used for empty or unreadable directories.") | |
4264 | |
4250 (defimage-speedbar speedbar-page-plus | 4265 (defimage-speedbar speedbar-page-plus |
4251 ((:type xpm :file "sb-pg-plus.xpm" :ascent center)) | 4266 ((:type xpm :file "sb-pg-plus.xpm" :ascent center)) |
4252 "Image used for closed files with stuff in them.") | 4267 "Image used for closed files with stuff in them.") |
4253 | 4268 |
4254 (defimage-speedbar speedbar-page-minus | 4269 (defimage-speedbar speedbar-page-minus |
4288 "Image used for open tag groups.") | 4303 "Image used for open tag groups.") |
4289 | 4304 |
4290 (defvar speedbar-expand-image-button-alist | 4305 (defvar speedbar-expand-image-button-alist |
4291 '(("<+>" . speedbar-directory-plus) | 4306 '(("<+>" . speedbar-directory-plus) |
4292 ("<->" . speedbar-directory-minus) | 4307 ("<->" . speedbar-directory-minus) |
4308 ("< >" . speedbar-directory) | |
4293 ("[+]" . speedbar-page-plus) | 4309 ("[+]" . speedbar-page-plus) |
4294 ("[-]" . speedbar-page-minus) | 4310 ("[-]" . speedbar-page-minus) |
4295 ("[?]" . speedbar-page) | 4311 ("[?]" . speedbar-page) |
4296 ("{+}" . speedbar-tag-plus) | 4312 ("{+}" . speedbar-tag-plus) |
4297 ("{-}" . speedbar-tag-minus) | 4313 ("{-}" . speedbar-tag-minus) |