* org-set-property (at point)? Save-excursion seems not to work
@ 2022-04-25 8:13 Uwe Brauer
2022-04-25 12:36 ` [the culprit] (was: org-set-property (at point)? Save-excursion seems not to work) Uwe Brauer
0 siblings, 1 reply; 8+ messages in thread
From: Uwe Brauer @ 2022-04-25 8:13 UTC (permalink / raw)
To: emacs-orgmode
Hi
I tried
(defun my-org-set-property ()
(interactive)
(save-excursion
(org-set-property nil nil)))
Or
(defun my-org-set-property ()
(interactive)
(save-excursion
(call-interactively #'org-set-property)))
But it does not help, org-set-property sets always a new property at the
end of the property list.
Any idea what to do (besides touching the function itself)
Regards
Uwe Brauer
--
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [the culprit] (was: org-set-property (at point)? Save-excursion seems not to work)
2022-04-25 8:13 org-set-property (at point)? Save-excursion seems not to work Uwe Brauer
@ 2022-04-25 12:36 ` Uwe Brauer
2022-04-26 4:20 ` Ihor Radchenko
0 siblings, 1 reply; 8+ messages in thread
From: Uwe Brauer @ 2022-04-25 12:36 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 634 bytes --]
>>> "UB" == Uwe Brauer <oub@mat.ucm.es> writes:
> Hi
> I tried
> (defun my-org-set-property ()
> (interactive)
> (save-excursion
> (org-set-property nil nil)))
> Or
> (defun my-org-set-property ()
> (interactive)
> (save-excursion
> (call-interactively #'org-set-property)))
> But it does not help, org-set-property sets always a new property at the
> end of the property list.
> Any idea what to do (besides touching the function itself)
It seems that the culprit is the function
org-entry-put
which always puts a new entry at the end of the property section.
Uwe Brauer
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit] (was: org-set-property (at point)? Save-excursion seems not to work)
2022-04-25 12:36 ` [the culprit] (was: org-set-property (at point)? Save-excursion seems not to work) Uwe Brauer
@ 2022-04-26 4:20 ` Ihor Radchenko
2022-04-26 6:42 ` [the culprit] Uwe Brauer
0 siblings, 1 reply; 8+ messages in thread
From: Ihor Radchenko @ 2022-04-26 4:20 UTC (permalink / raw)
To: Uwe Brauer; +Cc: emacs-orgmode
Uwe Brauer <oub@mat.ucm.es> writes:
>> But it does not help, org-set-property sets always a new property at the
>> end of the property list.
>
>> Any idea what to do (besides touching the function itself)
>
>
> It seems that the culprit is the function
> org-entry-put
> which always puts a new entry at the end of the property section.
You are right, org-set-property adds the property to the end of property
drawer. I do not think that its docstring suggests anything different.
Do you want to propose a new feature request? I guess patches are welcome.
Best,
Ihor
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit]
2022-04-26 4:20 ` Ihor Radchenko
@ 2022-04-26 6:42 ` Uwe Brauer
2022-04-26 13:08 ` John Kitchin
0 siblings, 1 reply; 8+ messages in thread
From: Uwe Brauer @ 2022-04-26 6:42 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1165 bytes --]
>>> "IR" == Ihor Radchenko <yantar92@gmail.com> writes:
> Uwe Brauer <oub@mat.ucm.es> writes:
>>> But it does not help, org-set-property sets always a new property at the
>>> end of the property list.
>>
>>> Any idea what to do (besides touching the function itself)
>>
>>
>> It seems that the culprit is the function
>> org-entry-put
>> which always puts a new entry at the end of the property section.
> You are right, org-set-property adds the property to the end of property
> drawer. I do not think that its docstring suggests anything different.
> Do you want to propose a new feature request? I guess patches are welcome.
The question is what would be the best solution?
1. Change the behavior for org-entry-put
2. Or just for org-set-property.
If it is the first option, then maybe a variable should be added
org-set-property-at-line say, what could be t or nil.
Recently I use drawers that have a lot of properties, that I want a bit
organised, but if new properties are added always at the end, that
complicates things. What do others think (I don't have the feeling that
large drawers are very common).
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit]
2022-04-26 6:42 ` [the culprit] Uwe Brauer
@ 2022-04-26 13:08 ` John Kitchin
2022-04-26 13:48 ` Ihor Radchenko
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: John Kitchin @ 2022-04-26 13:08 UTC (permalink / raw)
To: org-mode-email
[-- Attachment #1: Type: text/plain, Size: 2312 bytes --]
This seems like something that could (should?) go in a personal config, as
a custom function, or advice.
You could, for example do something like this (lightly tested)
#+BEGIN_SRC emacs-lisp
(defun my-put (property value here)
(interactive (list nil nil current-prefix-arg))
(if (null here)
(org-set-property property value)
(let* ((property (or property (org-read-property-name)))
(value (or value (org-read-property-value property))))
(save-excursion
(beginning-of-line)
(search-forward ":")
(backward-char)
(insert (format ":%s: %s\n" property value))))))
#+END_SRC
if you call it as M-x my-put, it just uses org-set-property.
If you call it as C-u M-x my-put, it inserts the property before the point.
It does not check you are in a property drawer, which could be a good idea.
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
On Tue, Apr 26, 2022 at 2:43 AM Uwe Brauer <oub@mat.ucm.es> wrote:
> >>> "IR" == Ihor Radchenko <yantar92@gmail.com> writes:
>
> > Uwe Brauer <oub@mat.ucm.es> writes:
> >>> But it does not help, org-set-property sets always a new property at
> the
> >>> end of the property list.
> >>
> >>> Any idea what to do (besides touching the function itself)
> >>
> >>
> >> It seems that the culprit is the function
> >> org-entry-put
> >> which always puts a new entry at the end of the property section.
>
> > You are right, org-set-property adds the property to the end of property
> > drawer. I do not think that its docstring suggests anything different.
>
> > Do you want to propose a new feature request? I guess patches are
> welcome.
>
> The question is what would be the best solution?
>
> 1. Change the behavior for org-entry-put
>
> 2. Or just for org-set-property.
>
> If it is the first option, then maybe a variable should be added
> org-set-property-at-line say, what could be t or nil.
>
> Recently I use drawers that have a lot of properties, that I want a bit
> organised, but if new properties are added always at the end, that
> complicates things. What do others think (I don't have the feeling that
> large drawers are very common).
>
[-- Attachment #2: Type: text/html, Size: 3403 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit]
2022-04-26 13:08 ` John Kitchin
@ 2022-04-26 13:48 ` Ihor Radchenko
2022-04-27 13:12 ` Uwe Brauer
2022-04-27 18:49 ` Uwe Brauer
2 siblings, 0 replies; 8+ messages in thread
From: Ihor Radchenko @ 2022-04-26 13:48 UTC (permalink / raw)
To: John Kitchin; +Cc: org-mode-email
John Kitchin <jkitchin@andrew.cmu.edu> writes:
> This seems like something that could (should?) go in a personal config, as
> a custom function, or advice.
If it does not cost performance, I do not see any problem with adding
DWIM behaviour if point is inside drawer when calling org-set-property.
Best,
Ihor
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit]
2022-04-26 13:08 ` John Kitchin
2022-04-26 13:48 ` Ihor Radchenko
@ 2022-04-27 13:12 ` Uwe Brauer
2022-04-27 18:49 ` Uwe Brauer
2 siblings, 0 replies; 8+ messages in thread
From: Uwe Brauer @ 2022-04-27 13:12 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 757 bytes --]
>>> "JK" == John Kitchin <jkitchin@andrew.cmu.edu> writes:
> This seems like something that could (should?) go in a personal config, as
> a custom function, or advice.
> You could, for example do something like this (lightly tested)
> #+BEGIN_SRC emacs-lisp
> (defun my-put (property value here)
> (interactive (list nil nil current-prefix-arg))
> (if (null here)
> (org-set-property property value)
> (let* ((property (or property (org-read-property-name)))
> (value (or value (org-read-property-value property))))
> (save-excursion
> (beginning-of-line)
> (search-forward ":")
> (backward-char)
> (insert (format ":%s: %s\n" property value))))))
> #+END_SRC
Thanks very much. I will test it and report back as soon as possible.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [the culprit]
2022-04-26 13:08 ` John Kitchin
2022-04-26 13:48 ` Ihor Radchenko
2022-04-27 13:12 ` Uwe Brauer
@ 2022-04-27 18:49 ` Uwe Brauer
2 siblings, 0 replies; 8+ messages in thread
From: Uwe Brauer @ 2022-04-27 18:49 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1398 bytes --]
>>> "JK" == John Kitchin <jkitchin@andrew.cmu.edu> writes:
> This seems like something that could (should?) go in a personal config, as
> a custom function, or advice.
> You could, for example do something like this (lightly tested)
> #+BEGIN_SRC emacs-lisp
> (defun my-put (property value here)
> (interactive (list nil nil current-prefix-arg))
> (if (null here)
> (org-set-property property value)
> (let* ((property (or property (org-read-property-name)))
> (value (or value (org-read-property-value property))))
> (save-excursion
> (beginning-of-line)
> (search-forward ":")
> (backward-char)
> (insert (format ":%s: %s\n" property value))))))
> #+END_SRC
I tested it, and for my org files this is slightly better:
#+BEGIN_SRC emacs-lisp
(defun my-put (property value here)
(interactive (list nil nil current-prefix-arg))
(if (null here)
(org-set-property property value)
(let* ((property (or property (org-read-property-name)))
(value (or value (org-read-property-value property))))
(save-excursion
(beginning-of-line)
(search-forward ":")
(backward-char)
(insert (format ":%s: %s\n" property value))
(indent-for-tab-command nil)))))
#+END_SRC
But this might be just me. In any case I think this functionality is
very helpful.
Uwe Brauer
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-04-27 18:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-25 8:13 org-set-property (at point)? Save-excursion seems not to work Uwe Brauer
2022-04-25 12:36 ` [the culprit] (was: org-set-property (at point)? Save-excursion seems not to work) Uwe Brauer
2022-04-26 4:20 ` Ihor Radchenko
2022-04-26 6:42 ` [the culprit] Uwe Brauer
2022-04-26 13:08 ` John Kitchin
2022-04-26 13:48 ` Ihor Radchenko
2022-04-27 13:12 ` Uwe Brauer
2022-04-27 18:49 ` Uwe Brauer
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.