help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dired-like interface for ibuffer?


From: Daniel Martín
Subject: Re: Dired-like interface for ibuffer?
Date: Thu, 23 Nov 2023 00:59:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13)

Galen Boyer <galendboyer@gmail.com> writes:

> Hi all,
>
> My description of "dired-like interface for ibuffer"
>
> Basically, when I go to ibuffer, or, let me call it, dibuffer-mode (ie
> dired-ibuffer) Everything I've opened that has an associated directory
> shows organized by the directories they are in.
>
> Might something like dibuffer-mode already exist? maybe a this could be
> accomplished with some combination of ibuffer slickness.
>
> Maybe there is a repository that has something like this?
>
> --
> Galen Boyer

You could customize ibuffer with a filter group that groups by buffer
directory.  Something like this, from
https://emacs.stackexchange.com/questions/10621/how-to-get-ibuffer-to-use-directory-tree-as-filter-groups/17731#17731
(you can test it by pressing / D in ibuffer):

(defun get-all-buffer-directories ()
  "Return a list of all directories that have at least one file
being visited."
  (interactive)
  (let (l)
    (dolist (e (sort (mapcar 'file-name-directory
                             (cl-remove-if-not 'identity
                                               (mapcar 'buffer-file-name
                                                       (buffer-list))))
                     'string<))
      (unless (string= (car l) e)
        (setq l (cons e l))))
    l))

(defun ibuffer-set-filter-groups-by-directory ()
  "Set the current filter groups to filter by directory."
  (interactive)
  (setq ibuffer-filter-groups
        (mapcar (lambda (dir)
                  (cons (format "%s" dir) `((directory . ,dir))))
                (get-all-buffer-directories)))
  (ibuffer-update nil t))

(define-key ibuffer-mode-map
            (kbd "/ D") 'ibuffer-set-filter-groups-by-directory)            


reply via email to

[Prev in Thread] Current Thread [Next in Thread]