Skip to content

Instantly share code, notes, and snippets.

@Luctins
Created November 18, 2021 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Luctins/73922233a16036f45d7d040d5a01d355 to your computer and use it in GitHub Desktop.
Save Luctins/73922233a16036f45d7d040d5a01d355 to your computer and use it in GitHub Desktop.
(defun org-format-hyperlink (link-text-start link-text-end)
"Format the selected text as a orgmode link prompting for the link"
(interactive "r")
;(setq clip (shell-command-to-string "xclip -selection clip -t TEXT -o"))
(setq dest-link (read-string "Link to insert: ")); nil nil (nth 0 kill-ring)))
(if (not (string-blank-p dest-link))
(progn (goto-char link-text-start)
(setq tmp-link (concat `"[[" dest-link `"][" (buffer-substring link-text-start link-text-end) '"]]"))
(delete-region link-text-start link-text-end)
(insert tmp-link))
(message "Empty link")
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment