emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to call org-set-property from a function
@ 2016-01-05 22:14 Julien Cubizolles
  2016-01-05 22:24 ` Marcin Borkowski
  2016-01-05 22:27 ` Rasmus
  0 siblings, 2 replies; 9+ messages in thread
From: Julien Cubizolles @ 2016-01-05 22:14 UTC (permalink / raw)
  To: emacs-orgmode

I have the following function to automate the creation of a new entry:

#+begin_src emacs-lisp
  (interactive)
  (save-excursion
    (org-beamer-select-environment)
    (org-set-tags-command)
    )
#+end_src

I'd like to add the possibility to set some properties through
(org-set-property) but I can't figure out how to call it in its
interactive way, so that it prompts me for a property and value ? Of
course adding (org-set-property) or (interactive (org-set-property))
doesn't work.

Also, I will sometimes need to include several different
properties. What would be the right way to run a loop where a new
property is set until the user answers something like C-return at the
prompt ?

Julien.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 22:14 How to call org-set-property from a function Julien Cubizolles
@ 2016-01-05 22:24 ` Marcin Borkowski
  2016-01-05 22:34   ` Julien Cubizolles
  2016-01-05 22:27 ` Rasmus
  1 sibling, 1 reply; 9+ messages in thread
From: Marcin Borkowski @ 2016-01-05 22:24 UTC (permalink / raw)
  To: Julien Cubizolles; +Cc: emacs-orgmode


On 2016-01-05, at 23:14, Julien Cubizolles <j.cubizolles@free.fr> wrote:

> I have the following function to automate the creation of a new entry:
>
> #+begin_src emacs-lisp
>   (interactive)
>   (save-excursion
>     (org-beamer-select-environment)
>     (org-set-tags-command)
>     )
> #+end_src
>
> I'd like to add the possibility to set some properties through
> (org-set-property) but I can't figure out how to call it in its
> interactive way, so that it prompts me for a property and value? Of
> course adding (org-set-property) or (interactive (org-set-property))
> doesn't work.

What about call-interactively?

> Also, I will sometimes need to include several different
> properties. What would be the right way to run a loop where a new
> property is set until the user answers something like C-return at the
> prompt?

That I don't know.

> Julien.

Hth,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 22:14 How to call org-set-property from a function Julien Cubizolles
  2016-01-05 22:24 ` Marcin Borkowski
@ 2016-01-05 22:27 ` Rasmus
  2016-01-05 23:07   ` Julien Cubizolles
  1 sibling, 1 reply; 9+ messages in thread
From: Rasmus @ 2016-01-05 22:27 UTC (permalink / raw)
  To: emacs-orgmode

Hi Julien,


Julien Cubizolles <j.cubizolles@free.fr> writes:

> I have the following function to automate the creation of a new entry:
>
> #+begin_src emacs-lisp
>   (interactive)
>   (save-excursion
>     (org-beamer-select-environment)
>     (org-set-tags-command)
>     )
> #+end_src
>
> I'd like to add the possibility to set some properties through
> (org-set-property) but I can't figure out how to call it in its
> interactive way, so that it prompts me for a property and value ? Of
> course adding (org-set-property) or (interactive (org-set-property))
> doesn't work.

Does this do what you want:

     (call-interactively 'org-set-property) 

> Also, I will sometimes need to include several different
> properties. What would be the right way to run a loop where a new
> property is set until the user answers something like C-return at the
> prompt ?

Here's naive approach.  Probably you can find a more elegant way.

    (condition-case nil
        (while t
          (call-interactively 'org-set-property))
      (quit nil))

Rasmus

-- 
Spil noget med Slayer!

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 22:24 ` Marcin Borkowski
@ 2016-01-05 22:34   ` Julien Cubizolles
  0 siblings, 0 replies; 9+ messages in thread
From: Julien Cubizolles @ 2016-01-05 22:34 UTC (permalink / raw)
  To: emacs-orgmode

Marcin Borkowski <mbork@mbork.pl> writes:


> What about call-interactively?
Thanks, that's the way to do it:

#+begin_src emacs-lisp
  (interactive)
  (save-excursion
    (org-beamer-select-environment)
    (org-set-tags-command)
      (call-interactively 'org-set-property)
    )
#+end_src

>> Also, I will sometimes need to include several different
>> properties. What would be the right way to run a loop where a new
>> property is set until the user answers something like C-return at the
>> prompt?
>
> That I don't know.

I can still run C-x-p afterwards, I've already saved many keystrokes.

Julien.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 22:27 ` Rasmus
@ 2016-01-05 23:07   ` Julien Cubizolles
  2016-01-05 23:34     ` Rasmus
  0 siblings, 1 reply; 9+ messages in thread
From: Julien Cubizolles @ 2016-01-05 23:07 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:


> Does this do what you want:
>
>      (call-interactively 'org-set-property) 

Thanks, indeed it does, Marcin beat you to it though :-)

>> Also, I will sometimes need to include several different
>> properties. What would be the right way to run a loop where a new
>> property is set until the user answers something like C-return at the
>> prompt ?
>
> Here's naive approach.  Probably you can find a more elegant way.
>
>     (condition-case nil
>         (while t
>           (call-interactively 'org-set-property))
>       (quit nil))

That's working, I'm breaking out of the loop with C-g, is that what you
intended ?

Julien.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 23:07   ` Julien Cubizolles
@ 2016-01-05 23:34     ` Rasmus
  2016-01-06  0:24       ` Julien Cubizolles
  2016-01-06  0:38       ` Julien Cubizolles
  0 siblings, 2 replies; 9+ messages in thread
From: Rasmus @ 2016-01-05 23:34 UTC (permalink / raw)
  To: emacs-orgmode

Julien Cubizolles <j.cubizolles@free.fr> writes:

> Rasmus <rasmus@gmx.us> writes:
>
>
>> Does this do what you want:
>>
>>      (call-interactively 'org-set-property) 
>
> Thanks, indeed it does, Marcin beat you to it though :-)
>
>>> Also, I will sometimes need to include several different
>>> properties. What would be the right way to run a loop where a new
>>> property is set until the user answers something like C-return at the
>>> prompt ?
>>
>> Here's naive approach.  Probably you can find a more elegant way.
>>
>>     (condition-case nil
>>         (while t
>>           (call-interactively 'org-set-property))
>>       (quit nil))
>
> That's working, I'm breaking out of the loop with C-g, is that what you
> intended ?

Yes.

When you enter no value (C-j when ido is enabled) it insert :: VALUE.

For more fine grained control you probably need to write something akin to
org-set-property and check the actual values (e.g. to signal quit if an
empty quote is returned).

Rasmus

-- 
And when I’m finished thinking, I have to die a lot

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 23:34     ` Rasmus
@ 2016-01-06  0:24       ` Julien Cubizolles
  2016-01-06  0:38       ` Julien Cubizolles
  1 sibling, 0 replies; 9+ messages in thread
From: Julien Cubizolles @ 2016-01-06  0:24 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:


> When you enter no value (C-j when ido is enabled) 

or C-return with helm.

> it insert :: VALUE.

But then you end up with a malformed drawer, so C-g is better for the
moment.

> For more fine grained control you probably need to write something akin to
> org-set-property and check the actual values (e.g. to signal quit if an
> empty quote is returned).

I'll give it a try someday.

Thanks for your help,

Julien.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-05 23:34     ` Rasmus
  2016-01-06  0:24       ` Julien Cubizolles
@ 2016-01-06  0:38       ` Julien Cubizolles
  2016-01-06  0:53         ` Rasmus
  1 sibling, 1 reply; 9+ messages in thread
From: Julien Cubizolles @ 2016-01-06  0:38 UTC (permalink / raw)
  To: emacs-orgmode

Rasmus <rasmus@gmx.us> writes:


> For more fine grained control you probably need to write something akin to
> org-set-property and check the actual values (e.g. to signal quit if an
> empty quote is returned).

Actually, shouldn't org-set-property check for an empty quote for the
property name since it will result :: ie a malformed drawer ?

Julien.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: How to call org-set-property from a function
  2016-01-06  0:38       ` Julien Cubizolles
@ 2016-01-06  0:53         ` Rasmus
  0 siblings, 0 replies; 9+ messages in thread
From: Rasmus @ 2016-01-06  0:53 UTC (permalink / raw)
  To: emacs-orgmode

Julien Cubizolles <j.cubizolles@free.fr> writes:

> Rasmus <rasmus@gmx.us> writes:
>
>
>> For more fine grained control you probably need to write something akin to
>> org-set-property and check the actual values (e.g. to signal quit if an
>> empty quote is returned).
>
> Actually, shouldn't org-set-property check for an empty quote for the
> property name since it will result :: ie a malformed drawer 

It's a bug.

     http://orgmode.org/worg/dev/org-syntax.html#Node_Properties

Please start a new thread, and feel free to suggest a patch.

Thanks,
Rasmus

-- 
One thing that is clear: it's all down hill from here 

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-01-06  0:53 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 22:14 How to call org-set-property from a function Julien Cubizolles
2016-01-05 22:24 ` Marcin Borkowski
2016-01-05 22:34   ` Julien Cubizolles
2016-01-05 22:27 ` Rasmus
2016-01-05 23:07   ` Julien Cubizolles
2016-01-05 23:34     ` Rasmus
2016-01-06  0:24       ` Julien Cubizolles
2016-01-06  0:38       ` Julien Cubizolles
2016-01-06  0:53         ` Rasmus

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).