Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find-file windows drive name #773

Closed
kReoSo opened this issue Nov 14, 2016 · 11 comments
Closed

find-file windows drive name #773

kReoSo opened this issue Nov 14, 2016 · 11 comments

Comments

@kReoSo
Copy link

@kReoSo kReoSo commented Nov 14, 2016

It seems windows drive name cannot be deleted when using find-file. I tried to access my samba share using //server/share, but the find-file command always prefixed with the drive name, such as d:/server/share. Are there any commands to disable drive letter?

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Nov 14, 2016

I don't know how to solve this. But patches welcome, if someone manages to figure it out.

@kReoSo
Copy link
Author

@kReoSo kReoSo commented Nov 14, 2016

I found one. The function ivy--magic-file-slash returns the drive letter when the user types //. It seems we need a pattern returns (ivy--cd "//").

@fpopineau
Copy link
Contributor

@fpopineau fpopineau commented Dec 22, 2016

Actually, IIRC //host/share/ are valid POSIX pathnames, and the current behavior in ivy.el does not honor them. The following patch simply requires that 3 '/' be typed in a row to get back to the root directory, else the user can go on typing its //host/share/ pathname or whatever.

$ diff -u swiper/ivy.el ~/.emacs.d/elpa/ivy-20161216.630/ivy.el
--- swiper/ivy.el       2016-12-22 18:16:33.490786500 +0100
+++ /c/Home/.emacs.d/elpa/ivy-20161216.630/ivy.el       2016-12-22 22:49:19.175019300 +0100
@@ -2234,7 +2234,9 @@
 (defun ivy--magic-file-slash ()
   (cond ((member ivy-text ivy--all-candidates)
          (ivy--cd (expand-file-name ivy-text ivy--directory)))
-        ((string-match "//\\'" ivy-text)
+        ((and (string-match "//\\'" ivy-text)
+              (= 0 (string-match "//\\'" ivy-text))))
+        ((string-match "///\\'" ivy-text)
          (if (and default-directory
                   (string-match "\\`[[:alpha:]]:/" default-directory))
              (ivy--cd (match-string 0 default-directory))
@richardxday
Copy link

@richardxday richardxday commented Mar 2, 2020

Is there a reason why this patch hasn't made into the code? Is there an alternative way to access //server/share files?

I've just tested it and it works on windows and allows access to //server/share files. I will continue to test it on both Windows and Linux and report any issues.

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Mar 3, 2020

@richardxday The patch hasn't made it since // is a very common way to access the root directory.

Could someone please link to a description of //server/share type path and how I can test it?

Does /smb:server/share not work for you?

@fpopineau
Copy link
Contributor

@fpopineau fpopineau commented Mar 3, 2020

As I already said above, //server/share is a valid POSIX name, and the syntax /smb:server/share is not known from Windows.
Maybe you can make it an option?

@richardxday
Copy link

@richardxday richardxday commented Mar 3, 2020

@fpopineau I think that would be a great idea: a pref for this behaviour, I don't mind using '///' for root if it allows //server/share access

@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Mar 4, 2020

the syntax /smb:server/share is not known from Windows

On Linux, when you go to the root with //, you get all kinds of connection methods, like ssh:, ftp:, docker:, and smb:. Is that not the case on Windows?

@richardxday
Copy link

@richardxday richardxday commented Mar 4, 2020

No, you just get the files and directories in the root of your current drive. You can change drives by typing something like 'd:' then pressing slash but you cannot get to a network address because that requires double slash - which just takes back to the root of the drive!

@abo-abo abo-abo closed this in c84bc31 Mar 4, 2020
@abo-abo
Copy link
Owner

@abo-abo abo-abo commented Mar 4, 2020

Thanks, please test.

@mohkale
Copy link
Contributor

@mohkale mohkale commented Mar 9, 2020

@abo-abo in regards to ssh:, ftp:, docker:, smb: not showing up on windows etc. that was what issue #2248 was about. Sorry if that wasn't clear enough 😅.

As for this new behavior, I can't say I'm very fond of having a different magic slash effect on unix and on windows (as I use both). Wouldn't a less intrusive approach here be to retain the // taking you to the home directory, but appending another // (or even just a single /) at that point has the current affect. If that's not possible, could you at least make triple /// optional, I don't use this weird path notation anyways.

Also, through the method outlined in #2248 I can get tramp protocol completion on windows, but I'm not seeing smb as an option. For now, the following protocols do appear to be available.

adb:
doas:
fcp:
ftp:
gcssh:
krlogin:
ksu:
nc:
plink:
plinkx:
pscp:
psftp:
rclone:
rcp:
remcp:
remsh:
rsh:
rsync:
scp:
scpx:
sg:
ssh:
sshx:
su:
sudo:
sudoedit:
telnet:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.