emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] org-babel: insert named source block


From: Deepak Cherian
Subject: Re: [O] org-babel: insert named source block
Date: Wed, 15 Nov 2017 16:12:24 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0

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 <address@hidden> 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 via email to

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