summaryrefslogtreecommitdiff
path: root/lisp/speedbar.el
diff options
context:
space:
mode:
authorDaniel Pfeiffer <occitan@esperanto.org>2004-08-11 20:00:11 +0000
committerDaniel Pfeiffer <occitan@esperanto.org>2004-08-11 20:00:11 +0000
commit048526bd2d7c479248ae5b23225fddee312a0eba (patch)
tree26bf6d76e8ab204c7c8809a337d42c99061acdcc /lisp/speedbar.el
parent2a15eb73df90655c012a78713ae9b33278c3206e (diff)
downloademacs-048526bd2d7c479248ae5b23225fddee312a0eba.tar.gz
(speedbar-scan-subdirs): New option.
(speedbar-file-lists): Don't ignore file-name case on Unix and use dolist. (speedbar-insert-files-at-point): Take an extra argument and use it to optionally find out if a subdir is empty. Also unreadable files don't get expand buttons. (speedbar-directory-plus): New image (bitmap already existed unused). (speedbar-expand-image-button-alist): Use it.
Diffstat (limited to 'lisp/speedbar.el')
-rw-r--r--lisp/speedbar.el85
1 files changed, 49 insertions, 36 deletions
diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index f8e9386585d..0556af489ef 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -689,8 +689,16 @@ file."
:type '(repeat (regexp :tag "Extension Regexp"))
:set (lambda (sym val)
(setq speedbar-supported-extension-expressions val
- speedbar-file-regexp (speedbar-extension-list-to-regex val)))
- )
+ speedbar-file-regexp (speedbar-extension-list-to-regex val))))
+
+(defcustom speedbar-scan-subdirs nil
+ "*Non-nil means speedbar will check if subdirs are empty.
+That way you don't have to click on them to find out. But this
+incurs extra I/O, hence it slows down directory display
+proportionally to the number of subdirs."
+ :group 'speedbar
+ :type 'boolean
+ :version 21.4)
(defvar speedbar-file-regexp
(speedbar-extension-list-to-regex speedbar-supported-extension-expressions)
@@ -2185,21 +2193,17 @@ the file-system."
;; find the directory, either in the cache, or build it.
(or (cdr-safe (assoc directory speedbar-directory-contents-alist))
(let ((default-directory directory)
- (dir (directory-files directory nil))
- (dirs nil)
- (files nil))
- (while dir
- (if (not
- (or (string-match speedbar-file-unshown-regexp (car dir))
- (string-match speedbar-directory-unshown-regexp (car dir))))
- (if (file-directory-p (car dir))
- (setq dirs (cons (car dir) dirs))
- (setq files (cons (car dir) files))))
- (setq dir (cdr dir)))
- (let ((nl (cons (nreverse dirs) (list (nreverse files)))))
+ (case-fold-search read-file-name-completion-ignore-case)
+ dirs files)
+ (dolist (file (directory-files directory nil))
+ (or (string-match speedbar-file-unshown-regexp file)
+ (string-match speedbar-directory-unshown-regexp file)
+ (if (file-directory-p file)
+ (setq dirs (cons file dirs))
+ (setq files (cons file files)))))
+ (let ((nl `(,(nreverse dirs) ,(nreverse files))))
(aput 'speedbar-directory-contents-alist directory nl)
- nl))
- ))
+ nl))))
(defun speedbar-directory-buttons (directory index)
"Insert a single button group at point for DIRECTORY.
@@ -2343,34 +2347,40 @@ position to insert a new item, and that the new item will end with a CR."
;;; Build button lists
;;
-(defun speedbar-insert-files-at-point (files level)
+(defun speedbar-insert-files-at-point (files level directory)
"Insert list of FILES starting at point, and indenting all files to LEVEL.
Tag expandable items with a +, otherwise a ?. Don't highlight ? as we
don't know how to manage them. The input parameter FILES is a cons
cell of the form ( 'DIRLIST . 'FILELIST )."
;; Start inserting all the directories
- (let ((dirs (car files)))
- (while dirs
- (speedbar-make-tag-line 'angle ?+ 'speedbar-dired (car dirs)
- (car dirs) 'speedbar-dir-follow nil
- 'speedbar-directory-face level)
- (setq dirs (cdr dirs))))
- (let ((lst (car (cdr files)))
- (case-fold-search t))
- (while lst
- (let* ((known (string-match speedbar-file-regexp (car lst)))
+ (dolist (dir (car files))
+ (if (if speedbar-scan-subdirs
+ (condition-case nil
+ (let ((l (speedbar-file-lists (concat directory dir))))
+ (or (car l) (cadr l)))
+ (file-error))
+ (file-readable-p (concat directory dir)))
+ (speedbar-make-tag-line 'angle ?+ 'speedbar-dired dir
+ dir 'speedbar-dir-follow nil
+ 'speedbar-directory-face level)
+ (speedbar-make-tag-line 'angle ? nil dir
+ dir 'speedbar-dir-follow nil
+ 'speedbar-directory-face level)))
+ (let ((case-fold-search read-file-name-completion-ignore-case))
+ (dolist (file (cadr files))
+ (let* ((known (and (file-readable-p (concat directory file))
+ (string-match speedbar-file-regexp file)))
(expchar (if known ?+ ??))
(fn (if known 'speedbar-tag-file nil)))
(if (or speedbar-show-unknown-files (/= expchar ??))
- (speedbar-make-tag-line 'bracket expchar fn (car lst)
- (car lst) 'speedbar-find-file nil
- 'speedbar-file-face level)))
- (setq lst (cdr lst)))))
+ (speedbar-make-tag-line 'bracket expchar fn file
+ file 'speedbar-find-file nil
+ 'speedbar-file-face level))))))
(defun speedbar-default-directory-list (directory index)
"Insert files for DIRECTORY with level INDEX at point."
(speedbar-insert-files-at-point
- (speedbar-file-lists directory) index)
+ (speedbar-file-lists directory) index directory)
(speedbar-reset-scanners)
(if (= index 0)
;; If the shown files variable has extra directories, then
@@ -2918,7 +2928,7 @@ updated."
(newcf (if newcfd newcfd))
(lastb (current-buffer))
(sucf-recursive (boundp 'sucf-recursive))
- (case-fold-search t))
+ (case-fold-search read-file-name-completion-ignore-case))
(if (and newcf
;; check here, that way we won't refresh to newcf until
;; its been written, thus saving ourselves some time
@@ -4235,9 +4245,7 @@ IMAGESPEC is the image data, and DOCSTRING is documentation for the image."
(speedbar-convert-emacs21-imagespec-to-xemacs (quote ,imagespec)))
'buffer)
(error nil))
- ,docstring))
-
-)))
+ ,docstring)))))
(defimage-speedbar speedbar-directory-plus
((:type xpm :file "sb-dir-plus.xpm" :ascent center))
@@ -4247,6 +4255,10 @@ IMAGESPEC is the image data, and DOCSTRING is documentation for the image."
((:type xpm :file "sb-dir-minus.xpm" :ascent center))
"Image used for open directories with stuff in them.")
+(defimage-speedbar speedbar-directory
+ ((:type xpm :file "sb-dir.xpm" :ascent center))
+ "Image used for empty or unreadable directories.")
+
(defimage-speedbar speedbar-page-plus
((:type xpm :file "sb-pg-plus.xpm" :ascent center))
"Image used for closed files with stuff in them.")
@@ -4290,6 +4302,7 @@ IMAGESPEC is the image data, and DOCSTRING is documentation for the image."
(defvar speedbar-expand-image-button-alist
'(("<+>" . speedbar-directory-plus)
("<->" . speedbar-directory-minus)
+ ("< >" . speedbar-directory)
("[+]" . speedbar-page-plus)
("[-]" . speedbar-page-minus)
("[?]" . speedbar-page)