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.
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, runningag
on such a path has two issues://wsl$
)/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:
I don't know if that's something dumb-jump can fix, or if this needs to be forwarded to
ag
or indeed Microsoft.