Hi,

I often need to copy target of a link to kill ring, so I decided to
write a small function to do that.
Would it make sense to pull this into org-mode directly?

Thanks for consideration and potential review.

-- Ivan
From 1f38afd4c26d2a8c6238040c6a40eb7dbd1f32ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Ne=C4=8Das?= <neca...@gmail.com>
Date: Thu, 10 Jan 2019 22:21:38 +0100
Subject: [PATCH] org: Add org-yank-link-at-point

* lisp/org.el (org-yank-link-at-point): New function to yank the
  target of a link at point to kill ring.

TINYCHANGE
---
 lisp/org.el | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index ea1607d85..6d13d8c92 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9791,6 +9791,15 @@ Use TAB to complete link prefixes, then RET for type-specific completion support
     ;; Redisplay so as the new link has proper invisible characters.
     (sit-for 0)))
 
+(defun org-yank-link-at-point ()
+  "Yank target of a link at point"
+  (interactive)
+  (if (org-in-regexp org-bracket-link-regexp 1)
+      (let ((link (match-string-no-properties 1)))
+        (kill-new link)
+        (message "Link '%s' yanked" link))
+    (user-error "No link found")))
+
 (defun org-link-try-special-completion (type)
   "If there is completion support for link type TYPE, offer it."
   (let ((fun (org-link-get-parameter type :complete)))
-- 
2.20.1

Reply via email to