emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Turn function into interactive


From: Berry, Charles
Subject: Re: Turn function into interactive
Date: Mon, 30 Dec 2019 18:43:40 +0000


> On Dec 29, 2019, at 9:26 PM, Lawrence Bottorff <address@hidden> wrote:
> 
> I've discovered org-outline-level which when in a code block under a given 
> header delivers as expected:
> 
> * This old level
> #+BEGIN_SRC emacs-lisp
> (org-current-level)
> #+END_SRC
> 
> #+RESULTS:
> : 1
> 
> Now, how could I turn this into an interactive callable with M-x? My stab in 
> the dark
> 
> (defun my-insert-level ()
>   (interactive)
>   (insert (org-outline-level)))

> doesn't seem to be working. 

It works, but just isn't what you wanted. ;-)

Note:

,----[ C-h f insert RET ]
| insert is a built-in function in ‘C source code’.
| 
| (insert &rest ARGS)
| 
| Insert the arguments, either strings or characters, at point.
| Point and after-insertion markers move forward to end up
|  after the inserted text.
| [...]
`-----


So try something like

(defun my-insert-level ()
  (interactive)
  (insert (format "%d" (org-outline-level))))

To insert a string.

HTH,

Chuck

reply via email to

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