tags:

views:

70

answers:

1

Hi, does anyone know of a good way to distinguish dired-mode buffer names from other types of buffers in the minibuffer while using ido-mode? For instance... showing a forward-slash at end of a dired-mode buffer name?

+3  A: 

You could simply change the dired-mode buffers to always have /s at the end of their names. This code does that.

(add-hook 'dired-mode-hook 'ensure-buffer-name-ends-in-slash)
(defun ensure-buffer-name-ends-in-slash ()
  "change buffer name to end with slash"
  (let ((name (buffer-name)))
    (if (not (string-match "/$" name))
        (rename-buffer (concat name "/") t))))
Trey Jackson
One problem though: it doesn't resolve name conflicts nicely when two directories have the same name.
Wei Hu
@WeiHu - Of course not, the question wasn't asking for a solution to that problem. I personally use uniquify for resolving similarly named buffers: http://www.gnu.org/software/emacs/manual/html_node/emacs/Uniquify.html
Trey Jackson
@Trey, my point was that with your solution, opening two directories with identical names would issue an annoying error message, and the one opened later wouldn't have `/` at the end.
Wei Hu
@WeiHu Got it, fixed. Thanks
Trey Jackson
Beautiful! Thank you.
Stephen