Here is something working, probably not yet all cases proof

(defun local/set-priority1 ()
  (org-with-wide-buffer
   (when (org-goto-first-child)
     (let ((ls (remove nil (cl-loop collect (local/set-priority1) while 
(org-goto-sibling)))))
       (outline-up-heading 1)
       (if ls (org-priority (seq-min ls)))))
   (if (eq 'todo (org-element-property :todo-type (org-element-at-point)))
       (string-to-number (org-entry-get nil "PRIORITY")))))

(defun local/set-priority2 ()
  (save-excursion
    (outline-up-heading (- (org-element-property :level (org-element-at-point)) 
1))
    (local/set-priority1)))


Ihor Radchenko <yanta...@posteo.net> writes:

> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Attention, ce courriel provient d'Internet. L'emetteur n'est peut-etre pas 
> celui que vous pensez. 
> Merci de considerer ce point en lisant ce courriel, avant d'y repondre, de 
> cliquer sur les liens ou d'ouvrir les pieces jointes.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Edouard Debry <edouard.de...@gmail.com> writes:
>
>> But this involves org skills a bit beyond my understanding, I wonder if you 
>> could give
>> me some piece of advices on how to do that :
>> - is there a suitable hook for this function ?
>
> No hook, but you can advice `org-priority' using :after advice.
>
>> - when in a given tree, how can I select the top level heading ?
>
> (while (org-up-heading-safe))
>
> Try to play with this using M-: with point at different headings.
>
>> - when at a given heading, how can I change programmatically the priority ?
>
> (org-priority 1), for example.
>
>> For this latter question, I tried (org-entry-put nil "PRIORITY" "2"), but it 
>> replied that
>>
>>  org-priority: Priority must be between ‘0’ and ‘5’
>
> That's because `org-entry-put' converts the argument into number,
> assuming a single-character string like "A". This is probably a bug.

___________________________________________________________________________________________________________________________________

This email and any attachments are confidential to the intended recipient and 
may also be privileged.
If you are not the intended recipient please delete it from your system and 
notify the sender. 
You should not copy it or use it for any purpose nor disclose or distribute its 
contents to any other person.
 

Ce courriel et ses pieces-jointes sont envoyes de maniere confidentielle et 
doivent etre traites avec attention.
Si vous n'etes pas le destinataire, merci de le detruire et d'en informer son 
auteur. 
Vous ne devez pas copier, utiliser, reveler ou diffuser son contenu a quiconque.

Reply via email to