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

Dumb-jump in Windows Emacs with WSL files does not jump correctly #429

Open
bastibe opened this issue Jan 11, 2023 · 0 comments
Open

Dumb-jump in Windows Emacs with WSL files does not jump correctly #429

bastibe opened this issue Jan 11, 2023 · 0 comments

Comments

@bastibe
Copy link

bastibe commented Jan 11, 2023

I'm using Emacs on Windows to work on files in a WSL virtual machine. Windows maps the WSL's directory structure into a virtual network drive at //wsl$/Ubuntu-20.04/home/.... However, running ag on such a path has two issues:

  • CMD.exe prints an error message that it can't be invoked in a UNC path (such as //wsl$)
  • ag reports paths as starting with /wsl$/ instead of //wsl$/, which dumb-jump interprets as a path relative to PWD instead of an absolute path.

At the moment, I'm using the following workaround:

  (defun fix-WSL-errors (orig-fun resp &rest args)
    (let* (;; CMD.exe likes to inject a useless error message, so filter it out:
           (filtered (replace-regexp-in-string "'[^']+'\nCMD.EXE was started with the above path as the current directory.\nUNC paths are not supported.  Defaulting to Windows directory.\n" "" resp))
           ;; for some reason, ag returns paths as /wsl$/... instead of //wsl$/..., which
           ;; dumb-jump interprets as a relative path instead of an absolute one,
           ;; so fix that:
           (fixed (replace-regexp-in-string "^\\\\wsl\\$" "\\\\\\\\wsl$" filtered)))
      (apply orig-fun fixed args)))
  (advice-add 'dumb-jump-parse-ag-response :around #'fix-WSL-errors)

I don't know if that's something dumb-jump can fix, or if this needs to be forwarded to ag or indeed Microsoft.

@bastibe bastibe changed the title Dumb-jump does not work if Emacs opens a WSL file Dumb-jump in Windows Emacs with WSL files does not jump correctly Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant