emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Berry, Charles" <ccberry@health.ucsd.edu>
To: Lawrence Bottorff <borgauf@gmail.com>
Cc: emacs-orgmode Mailinglist <emacs-orgmode@gnu.org>
Subject: Re: Turn function into interactive
Date: Mon, 30 Dec 2019 18:43:40 +0000	[thread overview]
Message-ID: <3AE1FD14-1B78-4128-8DD4-316324FEC259@ucsd.edu> (raw)
In-Reply-To: <CAFAhFSXc6jp5UsVe795dCBY55URP1tZ7LSSDr3xX8sQDJSUYsw@mail.gmail.com>



> On Dec 29, 2019, at 9:26 PM, Lawrence Bottorff <borgauf@gmail.com> 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	other threads:[~2019-12-30 18:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-30  5:26 Turn function into interactive Lawrence Bottorff
2019-12-30 18:43 ` Berry, Charles [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=3AE1FD14-1B78-4128-8DD4-316324FEC259@ucsd.edu \
    --to=ccberry@health.ucsd.edu \
    --cc=borgauf@gmail.com \
    --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).