function save_clipboard_image
set imagepathwindows (wslpath -w $argv)
powershell.exe -Command "(Get-Clipboard -Format image).save('$imagepathwindows')"
end
(defun org-download-windows-image (windows_path)
"Download an image from a Windows path and insert it into the current Org file."
(interactive "sWindows Path: ")
(let ((path (substring (shell-command-to-string (concat "wslpath " windows_path)) 0 -1)))
(org-download-image path)))
可以输入图片在 Windows 中的路径把它插入到 org 里。但这样插入截图要先保存下来,再复制路径粘贴到 emacs 中,非常麻烦。
(use-package org-download
:config
(if IS-WSL
;;(setenv "XDG_SESSION_TYPE" "wayland")
;; Windows 11 sniptshot use imge/bmp instead of png
(defun org-download-clipboard (&optional basename)
"Capture the image from the clipboard and insert the resulting file."
(interactive)
(let ((org-download-screenshot-method
(if (executable-find "wl-paste")
"wl-paste -t image/bmp | convert bmp:- %s"
(user-error
"Please install the \"wl-paste\" program included in wl-clipboard"))))
(org-download-screenshot basename)))))