]> git.eshelyaron.com Git - emacs.git/commitdiff
* vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
authorDan Nicolaescu <dann@ics.uci.edu>
Sat, 28 Jun 2008 07:30:47 +0000 (07:30 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Sat, 28 Jun 2008 07:30:47 +0000 (07:30 +0000)
(vc-string-prefix-p): Move function ...
* vc.el (vc-string-prefix-p): ... here.

lisp/ChangeLog
lisp/vc-dir.el
lisp/vc.el

index 1df394338dcbd95926173726cd090fc724eec318..7087c1a3606fc17ec1a0da7043e10eff275c8f66 100644 (file)
@@ -1,3 +1,9 @@
+2008-06-28  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * vc-dir.el (vc-dir-hide-up-to-date): Also hide empty directories.
+       (vc-string-prefix-p): Move function ...
+       * vc.el (vc-string-prefix-p): ... here.
+
 2008-06-27  Juanma Barranquero  <lekktu@gmail.com>
 
        * vc-dir.el (vc-dir): Complete only directory names.
index 17f8b5d91cb5cd40eaaed53a924cb2d910dd55a4..df7caca120c1e891394f2acd5815c00d1da770cc 100644 (file)
@@ -478,11 +478,6 @@ If a prefix argument is given, move by that many lines."
            (funcall mark-unmark-function))))
     (funcall mark-unmark-function)))
 
-(defun vc-string-prefix-p (prefix string)
-  (let ((lpref (length prefix)))
-    (and (>= (length string) lpref)
-        (eq t (compare-strings prefix nil nil string nil lpref)))))
-
 (defun vc-dir-parent-marked-p (arg)
   ;; Return nil if none of the parent directories of arg is marked.
   (let* ((argdir (vc-dir-node-directory arg))
@@ -938,9 +933,29 @@ outside of VC) and one wants to do some operation on it."
 (defun vc-dir-hide-up-to-date ()
   "Hide up-to-date items from display."
   (interactive)
-  (ewoc-filter
-   vc-ewoc
-   (lambda (crt) (not (eq (vc-dir-fileinfo->state crt) 'up-to-date)))))
+  (let ((crt (ewoc-nth vc-ewoc -1))
+       (first (ewoc-nth vc-ewoc 0)))
+    ;; Go over from the last item to the first and remove the
+    ;; up-to-date files and directories with no child files.
+    (while (not (eq crt first))
+      (let* ((data (ewoc-data crt))
+            (dir (vc-dir-fileinfo->directory data))
+            (next (ewoc-next vc-ewoc crt))
+            (prev (ewoc-prev vc-ewoc crt))
+            ;; ewoc-delete does not work without this...
+            (inhibit-read-only t))
+         (when (or
+                ;; Remove directories with no child files.
+                (and dir
+                     (or
+                      ;; Nothing follows this directory.
+                      (not next)
+                      ;; Next item is a directory.
+                      (vc-dir-fileinfo->directory (ewoc-data next))))
+                ;; Remove files in the up-to-date state.
+                (eq (vc-dir-fileinfo->state data) 'up-to-date))
+           (ewoc-delete vc-ewoc crt))
+         (setq crt prev)))))
 
 (defun vc-dir-status-printer (fileentry)
   (vc-call-backend vc-dir-backend 'status-printer fileentry))
index 6cc1dd9c6807503e5295dfbbbcd9770e71d9cb4f..c27688e669cb8ef862b9621d63ae57851cf90409 100644 (file)
 ;;
 ;; - vc-dir toolbar needs more icons.
 ;;
-;; - vc-dir-hide-up-to-date needs to hide directories that do not have
-;;   any children anymore.
-;;
 ;;; Code:
 
 (require 'vc-hooks)
@@ -2476,6 +2473,11 @@ to provide the `find-revision' operation instead."
 
 ;; These things should probably be generally available
 
+(defun vc-string-prefix-p (prefix string)
+  (let ((lpref (length prefix)))
+    (and (>= (length string) lpref)
+        (eq t (compare-strings prefix nil nil string nil lpref)))))
+
 (defun vc-file-tree-walk (dirname func &rest args)
   "Walk recursively through DIRNAME.
 Invoke FUNC f ARGS on each VC-managed file f underneath it."