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.
[-- 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 --]
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
[-- 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 --]
[-- 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 --]
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
[-- 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 --]
[-- 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 --]