wslutilities/documentation

Suggestion: Wiki page about Emacs integration

Schievel1 opened this issue · 2 comments

First of all, thanks for this utils set, awesome work! It helps me on a daily basis now.

Many people use Emacs in WSL, as the windows version is kind of slow and half baked.
I wrote a small elisp function that lets you open the current buffer marked files in dired (the emacs file manager) through wslview.
(I bound it to shift-return in dired) Now I browse my whole work files using dired and I can open files in word. Like the unwashed masses use Eclipse.

Maybe you want to add that to the wiki?

(defun my/wslview-open(&optional @fname)
  "Use wslview to open file in Windows."
  (interactive)
  (let* (
         ($file-list
          (if @fname
              (progn (list @fname))
            (if (string-equal major-mode "dired-mode")
                (dired-get-marked-files)
              (list (buffer-file-name)))))
         ($do-it-p (if (<= (length $file-list) 5)
                       t
                     (y-or-n-p "Open more than 5 files? "))))
    (when $do-it-p
        (mapc
         (lambda ($fpath)
           (shell-command
            (concat "wslview " (shell-quote-argument $fpath))))  $file-list)
        (when (not (string-equal major-mode "dired-mode"))
            (revert-buffer)))))

Thanks for the suggestion! I will transfer this issue under documentation instead; Also feel free to make a PR to contribute yourself

Sure thing, I did not notice the repo for the wiki. I will make a PR to it later.