org-download

a fork of abo-abo's org-download
git clone https://git.trogloxene.org/org-download.git
Log | Files | Refs | README

commit d740cca6d39e4ac9907d86a61bf4a40b908f9270
parent 768716b6fcc814b06360b99ad70bce44c0eb4a32
Author: Oleh Krehel <ohwoeowho@gmail.com>
Date:   Thu, 13 Aug 2020 12:51:18 +0200

org-download.el (org-download-clipboard): Add

Customizes `org-download-screenshot-method' to capture the clipboard
for multiple operating systems.

Allows us to use `org-download-screenshot' for actual screenshots.

Fixes #75

Diffstat:
MREADME.md | 3+++
Morg-download.el | 19+++++++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -66,3 +66,6 @@ Customize `org-download-backend` to choose between `url-retrieve` ;; Drag-and-drop to `dired` (add-hook 'dired-mode-hook 'org-download-enable) ``` + +## Pasting from the clipboard +If you have the image stored in the clipboard, use `org-download-clipboard`. diff --git a/org-download.el b/org-download.el @@ -379,6 +379,25 @@ The screenshot tool is determined by `org-download-screenshot-method'." (org-download-image org-download-screenshot-file) (delete-file org-download-screenshot-file))) +(defun org-download-clipboard () + "Capture the image from the clipboard and insert the resulting file." + (interactive) + (let ((org-download-screenshot-method + (cl-case system-type + (gnu/linux + "xclip -selection clipboard -t image/png -o > %s") + ((windows-nt cygwin) + (if (executable-find "convert") + "convert clipboard: %s" + (user-error + "Please install the \"convert\" program included in ImageMagick."))) + ((darwin berkeley-unix) + (if (executable-find "pngpaste") + "pngpaste %s" + (user-error + "Please install the \"pngpaste\" program from Homebrew.")))))) + (org-download-screenshot))) + (declare-function org-attach-dir "org-attach") (declare-function org-attach-attach "org-attach") (declare-function org-attach-sync "org-attach")