emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] paste from clip to code block


From: John Kitchin
Subject: Re: [O] paste from clip to code block
Date: Mon, 07 Sep 2015 16:18:51 -0400

For example with the cursor on a src-block press C-c l to store a link
to that name, and later type C-c C-l to insert a link to that
src-block.

It would look a little like this:
#+BEGIN_SRC emacs-lisp
(defun org-src-block-store-link ()
  (let* ((object (org-element-context)))
    (when (equal (org-element-type object) 'src-block)
      (org-store-link-props
       :type "src-block"
       :link (concat "src-block:" (org-element-property :name object))))))

(add-hook 'org-store-link-functions 'org-src-block-store-link)

(org-add-link-type
 "src-block"
 (lambda (label)
   (org-mark-ring-push)
   (widen)
   (goto-char (point-min))
   (re-search-forward (regexp-quote (format "#+NAME: %s" label)))
   (beginning-of-line)))
#+END_SRC

it only works in the current file though.


Grant Rettke writes:

> On Mon, Sep 7, 2015 at 9:09 AM, John Kitchin <address@hidden> wrote:
>> Neat. Do you have some handy way to store a link to the source block, or
>> jump to them?
>
> I don't, but please tell us more about what you mean.

--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu



reply via email to

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