changeset 69642:297538763ac1

(ibuffer-read-filter-group-name): Use `ibuffer-generate-filter-groups' to make completion list match the filter groups that are really displayed in the Ibuffer buffer. (ibuffer-generate-filter-groups): Add new args noempty, nodefault.
author Romain Francoise <romain@orebokech.com>
date Thu, 23 Mar 2006 07:05:33 +0000
parents f3cbe79b8375
children c775cf3fd17d
files lisp/ChangeLog lisp/ibuf-ext.el
diffstat 2 files changed, 31 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Mar 23 05:51:44 2006 +0000
+++ b/lisp/ChangeLog	Thu Mar 23 07:05:33 2006 +0000
@@ -1,3 +1,10 @@
+2006-03-23  Romain Francoise  <romain@orebokech.com>
+
+	* ibuf-ext.el (ibuffer-read-filter-group-name):
+	Use `ibuffer-generate-filter-groups' to make completion list match
+	the filter groups that are really displayed in the Ibuffer buffer.
+	(ibuffer-generate-filter-groups): Add new args noempty, nodefault.
+
 2006-03-23  Kenichi Handa  <handa@m17n.org>
 
 	* international/mule-cmds.el (sort-coding-systems): Describe that
--- a/lisp/ibuf-ext.el	Thu Mar 23 05:51:44 2006 +0000
+++ b/lisp/ibuf-ext.el	Thu Mar 23 07:05:33 2006 +0000
@@ -511,9 +511,11 @@
 		   buf
 		   (cdr filter))))))))))
 
-(defun ibuffer-generate-filter-groups (bmarklist)
-  (let ((filter-group-alist (append ibuffer-filter-groups
-				       (list (cons "Default" nil)))))
+(defun ibuffer-generate-filter-groups (bmarklist &optional noempty nodefault)
+  (let ((filter-group-alist (if nodefault
+				ibuffer-filter-groups
+			      (append ibuffer-filter-groups
+				      (list (cons "Default" nil))))))
 ;;     (dolist (hidden ibuffer-hidden-filter-groups)
 ;;       (setq filter-group-alist (ibuffer-delete-alist
 ;; 				   hidden filter-group-alist)))
@@ -529,11 +531,13 @@
 	    (aset vec i hip-crowd)
 	    (incf i)
 	    (setq bmarklist lamers))))
-      (let ((ret nil))
+      (let (ret)
 	(dotimes (j i ret)
-	  (push (cons (car (nth j filter-group-alist))
-		      (aref vec j))
-		ret))))))
+	  (let ((bufs (aref vec j)))
+	    (unless (and noempty (null bufs))
+	      (push (cons (car (nth j filter-group-alist))
+			  bufs)
+		    ret))))))))
 
 ;;;###autoload
 (defun ibuffer-filters-to-filter-group (name)
@@ -575,11 +579,19 @@
 (defun ibuffer-read-filter-group-name (msg &optional nodefault noerror)
   (when (and (not noerror) (null ibuffer-filter-groups))
     (error "No filter groups active"))
-  (let ((groups (mapcar #'car ibuffer-filter-groups)))
-    (completing-read msg (if nodefault
-			     groups
-			   (cons "Default" groups))
-		     nil t)))
+  ;; `ibuffer-generate-filter-groups' returns all non-hidden filter
+  ;; groups, possibly excluding empty groups or Default.
+  ;; We add `ibuffer-hidden-filter-groups' to the list, excluding
+  ;; Default if necessary.
+  (completing-read msg (nconc
+			(ibuffer-generate-filter-groups
+			 (ibuffer-current-state-list)
+			 (not ibuffer-show-empty-filter-groups)
+			 nodefault)
+			(if nodefault
+			    (remove "Default" ibuffer-hidden-filter-groups)
+			  ibuffer-hidden-filter-groups))
+		   nil t))
 
 ;;;###autoload
 (defun ibuffer-decompose-filter-group (group)