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 <o...@mat.ucm.es> wrote:

> >>> "IR" == Ihor Radchenko <yanta...@gmail.com> writes:
>
> > Uwe Brauer <o...@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).
>

Reply via email to