3

I'm beginning to think that dired (+ extensions) is the file browser I've always been looking for. Under Windows, however, dired does not allow to switch to other drives easily. While most things are happening within one drive anyway, sometimes I would like to be able to switch to some USB-drive, for example. But, in order to get there, I have to know the drive letter and put it in manually with find-files.

Is there a better ways to see, and switch between, drives under windows?

3 Answers 3

1

If you use Dired+ then this is taken care of for you. As explained here:

Dired+ loads library w32-browser.el if Emacs is running on Microsoft Windows, using it to extend Dired in a few ways. (In addition to being bound to the keys indicated here, these operations are added to the Dired+ menus, including the mouse-3 context menu.)

...

  • ^ -- When at the root of a Windows drive (e.g. C:/) and you use ^ (dired-up-directory), you get a list of drives to choose from.

IOW, use ^ at the root folder of any drive to get to a list of all available drives.

6
  • 1
    Yes, this should be the way to go, but diredp-w32-drives keeps showing me the C-drive only. This is under Windows 10. Any idea what could be causing thins?
    – Timm
    Commented Mar 26, 2017 at 18:57
  • No idea. I don't have Windows 10. See what you can find out, debugging, and send me email about it (see the file header for email). Load the *.el file, then M-x debug-on-entry diredp-w32-drives.
    – Drew
    Commented Mar 26, 2017 at 21:56
  • debug-on-entry doesn't show anything suspicious. When I call dired-w32-drives, a buffer *Windows Drives* is shown with one entry [C: Local disk], even though I have my USB-stick attached (which is visible in Windows Explorer). I guess it should appear there as well as [D: CORSAIR] or similarly.
    – Timm
    Commented Mar 30, 2017 at 3:42
  • @Timm: Yep, it should. What does the shell command net use show you when you do that at a Windows command prompt? If it doesn't show you all of the drives then that's the problem.
    – Drew
    Commented Mar 30, 2017 at 14:42
  • When I execute net use (with both PowerShell and cmd), it sais that "there are no entries in the list". Yet I can switch to the drive with d:.
    – Timm
    Commented Mar 31, 2017 at 15:27
1

The best way to include other local drives (such as a flash drive) in diredp-w32-drives-mode is to add these drives to the variable diredp-w32-local-drives defined in dired+.el.

This is what mine looks like after editing:

;;;###autoload
(defcustom diredp-w32-local-drives
  '(("C:" "Local disk")
    ("G:" "Google Drive File Stream")
    ("D:" "Removable Drive 1")
    ("E:" "Removable Drive 2"))
  "*Local MS Windows drives that you want to use for `diredp-w32-drives'.
Each entry is a list (DRIVE DESCRIPTION), where DRIVE is the drive
name and DESCRIPTION describes DRIVE."
  :type '(alist
          :key-type   (string        :tag "Drive name")
          :value-type (group (string :tag "Drive description")))
  :group 'Dired-Plus)
0

Ancient question, but a solution I did was to change defun diredp-w32-drives

I changed

        (insert (shell-command-to-string "net use"))
    (goto-char (point-min))
    (while (re-search-forward "[A-Z]: +\\\\\\\\[^ ]+" nil t nil)

to

(insert (shell-command-to-string "wmic logicaldisk get name"))
    (goto-char (point-min))
    (while (re-search-forward "[^C]:+" nil t nil)

Seems like it does the job on windows 11. C is ignored in the regex since it's added with defcustom diredp-w32-local-drives

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.