Untitled

mail@pastecode.io avatar
unknown
lisp
7 months ago
767 B
1
Indexable
Never
(defun insert-image-link-from-clipboard ()
  "Inserts an org-mode image link using the clipboard content as the image URL."
  (interactive)
  (let* ((mac-clipboard-content (gui-selection-value))
         (clip-content (if mac-clipboard-content
                           (progn
                             (kill-new mac-clipboard-content)
                             mac-clipboard-content)
                         (substring-no-properties (current-kill 0)))))
    (if clip-content
        (if (string-match-p "^http" clip-content)
            (progn
              (insert (format "[img%s](img%s)" clip-content))
              (org-display-inline-images))
          (message "Clipboard content does not start with 'http'."))
      (message "Clipboard is empty."))))