92 |
;; into sub-lists. A long flat list can be used instead if needed. |
;; into sub-lists. A long flat list can be used instead if needed. |
93 |
;; Other filters can be easily added. |
;; Other filters can be easily added. |
94 |
;; |
;; |
95 |
;; AUC-TEX users: The imenu tags for AUC-TEX mode doesn't work very |
;; 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. |
;; well. Use the imenu keywords from tex-mode.el for better results. |
97 |
;; |
;; |
98 |
;; This file requires the library package assoc (association lists) |
;; This file requires the library package assoc (association lists) |
665 |
"*Regexp matching files we don't want displayed in a speedbar buffer. |
"*Regexp matching files we don't want displayed in a speedbar buffer. |
666 |
It is generated from the variable `completion-ignored-extensions'") |
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) |
670 |
|
|
671 |
;; this is dangerous to customize, because the defaults will probably |
;; this is dangerous to customize, because the defaults will probably |
672 |
;; change in the future. |
;; change in the future. |
673 |
(defcustom speedbar-supported-extension-expressions |
(defcustom speedbar-supported-extension-expressions |
692 |
:type '(repeat (regexp :tag "Extension Regexp")) |
:type '(repeat (regexp :tag "Extension Regexp")) |
693 |
:set (lambda (sym val) |
:set (lambda (sym val) |
694 |
(setq speedbar-supported-extension-expressions val |
(setq speedbar-supported-extension-expressions val |
695 |
speedbar-file-regexp (speedbar-extension-list-to-regex val))) |
speedbar-file-regexp (speedbar-extension-list-to-regex val)))) |
|
) |
|
696 |
|
|
697 |
(defvar speedbar-file-regexp |
(defvar speedbar-file-regexp |
698 |
(speedbar-extension-list-to-regex speedbar-supported-extension-expressions) |
(speedbar-extension-list-to-regex speedbar-supported-extension-expressions) |
700 |
Created from `speedbar-supported-extension-expression' with the |
Created from `speedbar-supported-extension-expression' with the |
701 |
function `speedbar-extension-list-to-regex'") |
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) |
711 |
|
|
712 |
(defun speedbar-add-supported-extension (extension) |
(defun speedbar-add-supported-extension (extension) |
713 |
"Add EXTENSION as a new supported extension for speedbar tagging. |
"Add EXTENSION as a new supported extension for speedbar tagging. |
714 |
This should start with a `.' if it is not a complete file name, and |
This should start with a `.' if it is not a complete file name, and |
1298 |
(toggle-read-only 1) |
(toggle-read-only 1) |
1299 |
(speedbar-set-mode-line-format) |
(speedbar-set-mode-line-format) |
1300 |
(if speedbar-xemacsp |
(if speedbar-xemacsp |
1301 |
(set (make-local-variable 'mouse-motion-handler) |
(with-no-warnings |
1302 |
'speedbar-track-mouse-xemacs) |
(set (make-local-variable 'mouse-motion-handler) |
1303 |
|
'speedbar-track-mouse-xemacs)) |
1304 |
(if speedbar-track-mouse-flag |
(if speedbar-track-mouse-flag |
1305 |
(set (make-local-variable 'track-mouse) t)) ;this could be messy. |
(set (make-local-variable 'track-mouse) t)) ;this could be messy. |
1306 |
(setq auto-show-mode nil)) ;no auto-show for Emacs |
(setq auto-show-mode nil)) ;no auto-show for Emacs |
1349 |
frame and window to be the currently active frame and window." |
frame and window to be the currently active frame and window." |
1350 |
(if (and (frame-live-p speedbar-frame) |
(if (and (frame-live-p speedbar-frame) |
1351 |
(or (not speedbar-xemacsp) |
(or (not speedbar-xemacsp) |
1352 |
(specifier-instance has-modeline-p))) |
(with-no-warnings |
1353 |
|
(specifier-instance has-modeline-p)))) |
1354 |
(save-excursion |
(save-excursion |
1355 |
(set-buffer speedbar-buffer) |
(set-buffer speedbar-buffer) |
1356 |
(let* ((w (or (speedbar-frame-width) 20)) |
(let* ((w (or (speedbar-frame-width) 20)) |
1551 |
;; This gets the cursor where the user can see it. |
;; This gets the cursor where the user can see it. |
1552 |
(if (not (bolp)) (forward-char -1)) |
(if (not (bolp)) (forward-char -1)) |
1553 |
(sit-for 0) |
(sit-for 0) |
1554 |
(if (< emacs-major-version 20) |
(mouse-major-mode-menu e nil))) |
|
(mouse-major-mode-menu e) |
|
|
(mouse-major-mode-menu e nil)))) |
|
1555 |
|
|
1556 |
(defun speedbar-hack-buffer-menu (e) |
(defun speedbar-hack-buffer-menu (e) |
1557 |
"Control mouse 1 is buffer menu. |
"Control mouse 1 is buffer menu. |
2196 |
;; find the directory, either in the cache, or build it. |
;; find the directory, either in the cache, or build it. |
2197 |
(or (cdr-safe (assoc directory speedbar-directory-contents-alist)) |
(or (cdr-safe (assoc directory speedbar-directory-contents-alist)) |
2198 |
(let ((default-directory directory) |
(let ((default-directory directory) |
2199 |
(dir (directory-files directory nil)) |
(case-fold-search read-file-name-completion-ignore-case) |
2200 |
(dirs nil) |
dirs files) |
2201 |
(files nil)) |
(dolist (file (directory-files directory nil)) |
2202 |
(while dir |
(or (string-match speedbar-file-unshown-regexp file) |
2203 |
(if (not |
(string-match speedbar-directory-unshown-regexp file) |
2204 |
(or (string-match speedbar-file-unshown-regexp (car dir)) |
(if (file-directory-p file) |
2205 |
(string-match speedbar-directory-unshown-regexp (car dir)))) |
(setq dirs (cons file dirs)) |
2206 |
(if (file-directory-p (car dir)) |
(setq files (cons file files))))) |
2207 |
(setq dirs (cons (car dir) dirs)) |
(let ((nl `(,(nreverse dirs) ,(nreverse files)))) |
|
(setq files (cons (car dir) files)))) |
|
|
(setq dir (cdr dir))) |
|
|
(let ((nl (cons (nreverse dirs) (list (nreverse files))))) |
|
2208 |
(aput 'speedbar-directory-contents-alist directory nl) |
(aput 'speedbar-directory-contents-alist directory nl) |
2209 |
nl)) |
nl)))) |
|
)) |
|
2210 |
|
|
2211 |
(defun speedbar-directory-buttons (directory index) |
(defun speedbar-directory-buttons (directory index) |
2212 |
"Insert a single button group at point for DIRECTORY. |
"Insert a single button group at point for DIRECTORY. |
2350 |
|
|
2351 |
;;; Build button lists |
;;; Build button lists |
2352 |
;; |
;; |
2353 |
(defun speedbar-insert-files-at-point (files level) |
(defun speedbar-insert-files-at-point (files level directory) |
2354 |
"Insert list of FILES starting at point, and indenting all files to LEVEL. |
"Insert list of FILES starting at point, and indenting all files to LEVEL. |
2355 |
Tag expandable items with a +, otherwise a ?. Don't highlight ? as we |
Tag expandable items with a +, otherwise a ?. Don't highlight ? as we |
2356 |
don't know how to manage them. The input parameter FILES is a cons |
don't know how to manage them. The input parameter FILES is a cons |
2357 |
cell of the form ( 'DIRLIST . 'FILELIST )." |
cell of the form ( 'DIRLIST . 'FILELIST )." |
2358 |
;; Start inserting all the directories |
;; Start inserting all the directories |
2359 |
(let ((dirs (car files))) |
(dolist (dir (car files)) |
2360 |
(while dirs |
(if (if speedbar-scan-subdirs |
2361 |
(speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs) |
(condition-case nil |
2362 |
(car dirs) 'speedbar-dir-follow nil |
(let ((l (speedbar-file-lists (concat directory dir)))) |
2363 |
'speedbar-directory-face level) |
(or (car l) (cadr l))) |
2364 |
(setq dirs (cdr dirs)))) |
(file-error)) |
2365 |
(let ((lst (car (cdr files))) |
(file-readable-p (concat directory dir))) |
2366 |
(case-fold-search t)) |
(speedbar-make-tag-line 'angle ?+ 'speedbar-dired dir |
2367 |
(while lst |
dir 'speedbar-dir-follow nil |
2368 |
(let* ((known (string-match speedbar-file-regexp (car lst))) |
'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))) |
2376 |
(expchar (if known ?+ ??)) |
(expchar (if known ?+ ??)) |
2377 |
(fn (if known 'speedbar-tag-file nil))) |
(fn (if known 'speedbar-tag-file nil))) |
2378 |
(if (or speedbar-show-unknown-files (/= expchar ??)) |
(if (or speedbar-show-unknown-files (/= expchar ??)) |
2379 |
(speedbar-make-tag-line 'bracket expchar fn (car lst) |
(speedbar-make-tag-line 'bracket expchar fn file |
2380 |
(car lst) 'speedbar-find-file nil |
file 'speedbar-find-file nil |
2381 |
'speedbar-file-face level))) |
'speedbar-file-face level)))))) |
|
(setq lst (cdr lst))))) |
|
2382 |
|
|
2383 |
(defun speedbar-default-directory-list (directory index) |
(defun speedbar-default-directory-list (directory index) |
2384 |
"Insert files for DIRECTORY with level INDEX at point." |
"Insert files for DIRECTORY with level INDEX at point." |
2385 |
(speedbar-insert-files-at-point |
(speedbar-insert-files-at-point |
2386 |
(speedbar-file-lists directory) index) |
(speedbar-file-lists directory) index directory) |
2387 |
(speedbar-reset-scanners) |
(speedbar-reset-scanners) |
2388 |
(if (= index 0) |
(if (= index 0) |
2389 |
;; If the shown files variable has extra directories, then |
;; If the shown files variable has extra directories, then |
2931 |
(newcf (if newcfd newcfd)) |
(newcf (if newcfd newcfd)) |
2932 |
(lastb (current-buffer)) |
(lastb (current-buffer)) |
2933 |
(sucf-recursive (boundp 'sucf-recursive)) |
(sucf-recursive (boundp 'sucf-recursive)) |
2934 |
(case-fold-search t)) |
(case-fold-search read-file-name-completion-ignore-case)) |
2935 |
(if (and newcf |
(if (and newcf |
2936 |
;; check here, that way we won't refresh to newcf until |
;; check here, that way we won't refresh to newcf until |
2937 |
;; its been written, thus saving ourselves some time |
;; its been written, thus saving ourselves some time |
4248 |
(speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec))) |
(speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec))) |
4249 |
'buffer) |
'buffer) |
4250 |
(error nil)) |
(error nil)) |
4251 |
,docstring)) |
,docstring))))) |
|
|
|
|
))) |
|
4252 |
|
|
4253 |
(defimage-speedbar speedbar-directory-plus |
(defimage-speedbar speedbar-directory-plus |
4254 |
((:type xpm :file "sb-dir-plus.xpm" :ascent center)) |
((:type xpm :file "sb-dir-plus.xpm" :ascent center)) |
4258 |
((:type xpm :file "sb-dir-minus.xpm" :ascent center)) |
((:type xpm :file "sb-dir-minus.xpm" :ascent center)) |
4259 |
"Image used for open directories with stuff in them.") |
"Image used for open directories with stuff in them.") |
4260 |
|
|
4261 |
|
(defimage-speedbar speedbar-directory |
4262 |
|
((:type xpm :file "sb-dir.xpm" :ascent center)) |
4263 |
|
"Image used for empty or unreadable directories.") |
4264 |
|
|
4265 |
(defimage-speedbar speedbar-page-plus |
(defimage-speedbar speedbar-page-plus |
4266 |
((:type xpm :file "sb-pg-plus.xpm" :ascent center)) |
((:type xpm :file "sb-pg-plus.xpm" :ascent center)) |
4267 |
"Image used for closed files with stuff in them.") |
"Image used for closed files with stuff in them.") |
4305 |
(defvar speedbar-expand-image-button-alist |
(defvar speedbar-expand-image-button-alist |
4306 |
'(("<+>" . speedbar-directory-plus) |
'(("<+>" . speedbar-directory-plus) |
4307 |
("<->" . speedbar-directory-minus) |
("<->" . speedbar-directory-minus) |
4308 |
|
("< >" . speedbar-directory) |
4309 |
("[+]" . speedbar-page-plus) |
("[+]" . speedbar-page-plus) |
4310 |
("[-]" . speedbar-page-minus) |
("[-]" . speedbar-page-minus) |
4311 |
("[?]" . speedbar-page) |
("[?]" . speedbar-page) |