总算是用WSL的spacemacs给折腾好了,给大家总结一下

windows

#63

emacs原来还有内置的输入法。


#64

哈哈,几个借助PowerShell实现的高仿程序

1.在windows下截图(当然是Snipaste)简单编辑后复制到剪贴板,往emacs里粘贴图片文件到当前文件目录下的images里(暂时不会自动插入链接,需要时再动手加),写笔记时截图感觉好用啊,哈哈哈

(defun my-yank-image-from-win-clipboard-through-powershell()
  "to simplify the logic, use c:/Users/Public as temporary directoy, and move it into current directoy"
  (interactive)
  (let* ((powershell "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")
         (file-name (format-time-string "screenshot_%Y%m%d_%H%M%S.png"))
         ;; (file-path-powershell (concat "c:/Users/\$env:USERNAME/" file-name))
         (file-path-wsl (concat "./images/" file-name))
         )
    ;; (shell-command (concat powershell " -command \"(Get-Clipboard -Format Image).Save(\\\"C:/Users/\\$env:USERNAME/" file-name "\\\")\""))
    (shell-command (concat powershell " -command \"(Get-Clipboard -Format Image).Save(\\\"C:/Users/Public/" file-name "\\\")\""))
    (rename-file (concat "/mnt/c/Users/Public/" file-name) file-path-wsl)
    ))
  1. 接下来,在wsl的emacs中打开win10的文件管理器,看名字就知道,仿的谁… …
(defun xah-open-in-desktop-from-wsl()
  "open desktop by send command from wsl into powershell"
  (interactive)
  (let* ((powershell "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")
         (directory (replace-regexp-in-string "/mnt/\\([a-zA-Z]\\)" "\\1:" default-directory))
         )
    (shell-command (concat powershell " -command \"start " directory "\""))
    )
  )
  1. 再次高仿,使用win10下的默认程序打开文件
(defun xah-open-in-xternal-app-from-wsl()
  "open desktop by send command from wsl into powershell"
  (interactive)
  (let* ((powershell "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe")
         (directory (replace-regexp-in-string "/mnt/\\([a-zA-Z]\\)" "\\1:" default-directory))
         (-file-list
          (if (string-equal major-mode "dired-mode")
              (dired-get-marked-files)
            (list (buffer-file-name))))
         )
    (shell-command (concat powershell " -command \"start " (replace-regexp-in-string "/mnt/\\([a-zA-Z]\\)" "\\1:" (nth 0 -file-list)) "\""))
    )
  )

#65

看到了国外网友的博客上的一个设置: https://nickjanetakis.com/blog/launching-wsl-programs-from-a-right-click-windows-menu 。跟上面的知乎专栏的内容功能差不多。