emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Grant Rettke <gcr@wisdomandwonder.com>
Cc: Sebastien Vauban <sva-news@mygooglest.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: paste from clip to code block
Date: Mon, 07 Sep 2015 16:18:51 -0400	[thread overview]
Message-ID: <m2oaheq8yc.fsf@andrew.cmu.edu> (raw)
In-Reply-To: <CAAjq1mcNF==+ezW7VAxzXAcvtrJOOHGwim9v1Vuf5gwbtNtxkA@mail.gmail.com>

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 <jkitchin@andrew.cmu.edu> 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	other threads:[~2015-09-07 20:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-17  7:21 paste from clip to code block Xebar Saram
2015-04-17 13:56 ` John Kitchin
2015-04-17 14:36   ` Xebar Saram
2015-04-17 15:08   ` Jorge A. Alfaro-Murillo
2015-04-17 15:17     ` John Kitchin
2015-05-07  7:59       ` Sebastien Vauban
2015-09-05 20:15         ` Grant Rettke
2015-09-07 14:09           ` John Kitchin
2015-09-07 16:39             ` Grant Rettke
2015-09-07 20:18               ` John Kitchin [this message]

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=m2oaheq8yc.fsf@andrew.cmu.edu \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=gcr@wisdomandwonder.com \
    --cc=sva-news@mygooglest.com \
    /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).