emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Deepak Cherian <dpak.cherian@gmail.com>
To: "Berry, Charles" <ccberry@ucsd.edu>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: org-babel: insert named source block
Date: Wed, 15 Nov 2017 16:12:24 -0800	[thread overview]
Message-ID: <2114c571-bb72-0174-f03d-885ca2e1f5ca@gmail.com> (raw)
In-Reply-To: <4B3272F6-C119-4353-B2B9-99BEBB5AFC37@ucsd.edu>

Thanks. That works well, but only shows named source blocks in the 
particular file.

Is there a way to make it show library of babel blocks too?

Deepak

On 11/15/2017 02:56 PM, Berry, Charles wrote:
>> On Nov 15, 2017, at 11:04 AM, Deepak Cherian <dpak.cherian@gmail.com> wrote:
>>
>> Has anyone here managed to configure ivy or helm to show a list of named source blocks that org knows about?
>>
>> I am imagining this workflow:
>> 1. M-x org-babel-insert-named-source-block (imaginary function)
>> 2. List of named source blocks pops up
>> 3. Hit enter and "#+call: name-of-source-block()" is inserted at point.
>>
> org has its own function for listing  named src-blocks.
>
> #+BEGIN_SRC emacs-lisp
>    (defun my-insert-named-src-block
>        ( &optional template )
>      (interactive)
>      (let ((template (or template "#+call: %s()\n"))
> 	  (src-block
> 	   (completing-read "Enter src block name[or TAB or ENTER]: " (org-babel-src-block-names))))
>        (unless (string-equal "" src-block)
> 	(insert (format template src-block)))))
> #+END_SRC
>
> M-x my-insert-named-src-block TAB <click on name>
>
> HTH,
>
> Chuck

  reply	other threads:[~2017-11-16  0:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 19:04 org-babel: insert named source block Deepak Cherian
2017-11-15 22:56 ` Berry, Charles
2017-11-16  0:12   ` Deepak Cherian [this message]
2017-11-16  4:21     ` Berry, Charles

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=2114c571-bb72-0174-f03d-885ca2e1f5ca@gmail.com \
    --to=dpak.cherian@gmail.com \
    --cc=ccberry@ucsd.edu \
    --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).