Skip to content

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

@bastibe

Description

@bastibe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions