[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom function for killing the thing at point

From: Juan Manuel Macías
Subject: Re: Custom function for killing the thing at point
Date: Fri, 13 Aug 2021 22:46:00 +0000

Hi Rodrigo,

Thanks for sharing, it seems interesting and useful. But I think this
function is missing in your post: `my/kill-new'.

Best regards,

Juan Manuel 

Rodrigo Morales writes:

> I just created this function for copying the thing under the cursor (it
> works for some #+BEGIN blocks and links). I think it would be useful for
> others, so I'm creating this post for getting feedback on the Elisp code
> and sharing it to those interested.
> #+BEGIN_SRC elisp
> (defun my/org-kill-thing-at-point ()
>   "Kill the thing at point.
> The following things are currently supported
> - #+BEGIN_SRC <<any>>
> - #+BEGIN_EXPORT <<any>>
> - #+BEGIN_EXAMPLE <<any>>
> - Org links (the description is not copied)"
>   (interactive)
>   (let* (content
>          (element (org-element-context))
>          (type (org-element-type element)))
>     (cond ((or (eq type 'src-block)
>                (eq type 'export-block)
>                (eq type 'example-block)
>                (eq type 'comment-block))
>            (setq content (plist-get (cadr element) :value)))
>           ((eq type 'link)
>            (setq content (plist-get (cadr element) :raw-link)))
>           (t
>            (error "The element at point couldn't be copied.")))
>     (my/kill-new content)))
> #+BEGIN_SRC elisp
> (define-key org-mode-map (kbd "C-c c") 'my/org-kill-thing-at-point)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]