views:

76

answers:

1

On windows, how could I open a dired buffer showing all drive letters. When you do C-x d you should always provide a directory, but I want to start at the drive letters level instead of a root directory of a particular drive.

If no standard solution exists, do you have one (an extension to dired ?) ? or links to articles on the subject ?

+1  A: 

In dired you can only view directories, and since no directory exists which contains your drive letters, you can't see a list of them.

To do this you'd have to write an emacs-lisp extension for dired.

AFAIK there's no existing extension, however, a call to wmic can give you a listing of drive letters and volume names, which would be a good starting point.

The wmic command:

wmic logicaldisk get caption,drivetype,providername,volumename

Calling it from emacs-lisp and getting the result as a string.

(let (sh-output volumes)
  (setq sh-output (shell-command-to-string "wmic LogicalDisk get Caption,DriveType,ProviderName,VolumeName"))
)

Will give you a list of the volumes (DriveType : 3 = HDD, 4 = Network Mapping, 5 = Optical.)

However, you can't get dired to recognize a buffer with this output, so you'd need to create a major mode for browsing windows volumes, which would show this listing and bind RET to find the drive letter on the current line and do a dired at it's root.

If you just want the drive letters listed...

(let (sh-output volumes)
  (setq sh-output (shell-command-to-string "wmic LogicalDisk get Caption"))
)

Will do that.

slomojo
I have edited my question to ask for any existing solution to this problem or links to articles on the subject.
Jérôme Radix
@Jerome, try wmic to get the text output you need for the drives.
slomojo
Thx for the wmic command, I'll try to code something if I have time...
Jérôme Radix
@Jerome, I'm back on a Windows box so I'll have a look quickly see if I can do something too.
slomojo