[Top][All Lists]

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

shell-command in Windows 7

From: 42 147
Subject: shell-command in Windows 7
Date: Fri, 14 Apr 2017 10:53:22 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

I've been using this code to create functions that open files / folders within Emacs in Windows 7:

(defun open-buffer-path ()
"Run explorer on the directory of the current buffer."
(shell-command (concat "explorer " (replace-regexp-in-string "/" "\\\\" (file-name-directory (buffer-file-name)) t t))))

(defun firefox ()
(shell-command (concat "explorer " (replace-regexp-in-string "/" "\\\\" "E:\\Program Files\\Mozilla Firefox\\firefox.exe" t t))))

This worked fine for a while. Then I erased one of my older OSes on a different partition and created an NTFS partition for extra Windows 7 storage. This did not change the drive number of Windows 7 at all. But for some reason, after that repartitioning, the above code only works if I alternative between the two different directory string types. Thus if I had the above before, on system reboot, I have to replace it all with:

(defun .emacs-open ()
"Run explorer on the directory of the current buffer."
(shell-command (concat "explorer " (replace-regexp-in-string "/" "\\\\" "E:/Users/John/AppData/Roaming/" t t))))

And vice-versa, otherwise Emacs is unable to open the file / directory I want, and just opens to the same default directory when I call each function. I created a workaround in which I press F12 to alternate between the two load files (I put these settings in a dedicated .el), but I'm very curious why this happens, and ideally a workaround like this would not be necessary.

reply via email to

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