Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.

Commit e6f41d9

Browse files
committed
Merge branch 'Schievel1-emacs-docs'
2 parents 55e6d07 + 2de1e12 commit e6f41d9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

emacs.org

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#+title: Emacs
2+
3+
Emacs' built in file manager Dired is often used to browse files. And Emacs is often used in WSL on Windows, because the windows-native GNU Emacs is kind of meh.
4+
But sadly some typical files we have to deal with on windows are files Emacs can't handle very well. (Mostly MS Office files)
5+
6+
To use Emacs' Dired in WSL Emacs to open files in Windows, the ~wslview~ command from Wslutilities can be used.
7+
8+
Put this in init.el:
9+
#+begin_src emacs-lisp
10+
(defun my/wslview-open(&optional @fname)
11+
"Use wslview to open file in Windows."
12+
(interactive)
13+
(let* (
14+
($file-list
15+
(if @fname
16+
(progn (list @fname))
17+
(if (string-equal major-mode "dired-mode")
18+
(dired-get-marked-files)
19+
(list (buffer-file-name)))))
20+
($do-it-p (if (<= (length $file-list) 5)
21+
t
22+
(y-or-n-p "Open more than 5 files? "))))
23+
(when $do-it-p
24+
(mapc
25+
(lambda ($fpath)
26+
(shell-command
27+
(concat "wslview " (shell-quote-argument $fpath)))) $file-list)
28+
(when (not (string-equal major-mode "dired-mode"))
29+
(revert-buffer)))))
30+
#+end_src
31+
32+
Now, when you mark files in Dired using ~m~ (or if nothing is marked, the file under point is used) run ~M-x my/wslview-open~ to open the marked files using whatever is the appropriate program in Windows.
33+
If more then five files where marked, Emacs will prompt in the minibuffer if that many files should really be opened.
34+
Also, if you are not in a Dired buffer and you run ~M-x my/wslview-open~, the file of the currently open buffer will be opened with the appropriate program in Windows.

0 commit comments

Comments
 (0)