diff options
author | Romain Francoise <romain@orebokech.com> | 2006-03-23 07:05:33 +0000 |
---|---|---|
committer | Romain Francoise <romain@orebokech.com> | 2006-03-23 07:05:33 +0000 |
commit | fde057aac8743ec04145f99d2de634fa6e2c37c7 (patch) | |
tree | 09009ac960505501c02efd3899a158f48fd1452b /lisp/ibuf-ext.el | |
parent | e9e33c19b8ae7878f448804a54c338a4d83536a1 (diff) | |
download | emacs-fde057aac8743ec04145f99d2de634fa6e2c37c7.tar.gz |
(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.
Diffstat (limited to 'lisp/ibuf-ext.el')
-rw-r--r-- | lisp/ibuf-ext.el | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/lisp/ibuf-ext.el b/lisp/ibuf-ext.el index 183da83816d..292e158c097 100644 --- a/lisp/ibuf-ext.el +++ b/lisp/ibuf-ext.el @@ -511,9 +511,11 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." 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 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." (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 @@ To evaluate a form without viewing the buffer, see `ibuffer-do-eval'." (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) |