emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ivan Necas <necasik@gmail.com>
To: emacs-orgmode@gnu.org
Subject: PATCH: Possibility to yank target of link at point to kill ring
Date: Thu, 10 Jan 2019 22:37:15 +0100	[thread overview]
Message-ID: <CAFmwT7V5mydcZ-nMUok1FXJ0Skj0o0036GOyr2FNnBd7o2wUTg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

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

[-- Attachment #2: 0001-org-Add-org-yank-link-at-point.patch --]
[-- Type: text/x-patch, Size: 1179 bytes --]

From 1f38afd4c26d2a8c6238040c6a40eb7dbd1f32ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ivan=20Ne=C4=8Das?= <necasik@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	other threads:[~2019-01-10 21:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 21:37 Ivan Necas [this message]
2019-01-10 22:09 ` PATCH: Possibility to yank target of link at point to kill ring Ivan Necas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFmwT7V5mydcZ-nMUok1FXJ0Skj0o0036GOyr2FNnBd7o2wUTg@mail.gmail.com \
    --to=necasik@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).