emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: Re: org-set-properties for various (all) headings
Date: Tue, 19 Jul 2022 16:53:30 +0200	[thread overview]
Message-ID: <875yjt6tn9.fsf@mat.ucm.es> (raw)
In-Reply-To: CAFyQvY2W9r=v-+sYwW41Yfv97EH8_vQFGQWP0HeNd5FOw1eVvA@mail.gmail.com

[-- Attachment #1: Type: text/plain, Size: 2115 bytes --]

>>> "KM" == Kaushal Modi <kaushal.modi@gmail.com> writes:

> Check out org-map-entries. I have one example here:
> https://scripter.co/looping-through-org-mode-headings/#example-modifying-a-property-in-all-headings
> .

Very nice thanks however one question.

I started as test with 


#+begin_src 
** TODO Test
   :PROPERTIES:
   :Sent:     [ ]
   :END:

** WAIT Test2
   :PROPERTIES:
   :Sent:     [ ]
   :END:

** TODO Test3
   :PROPERTIES:
   :Sent:     [ ]
   :END:

#+end_src

I then used the code:
#+begin_src elisp :noexport
(defun test/set-property-at-heading ()
  "Function to be called at the beginning of an Org heading."
(interactive)
  (let ((el (org-element-at-point)))
    (org-set-property "foo" (org-element-property :title el))))
(org-map-entries #'test/set-property-at-heading)

#+end_src

And indeed ended up with 

#+begin_src 
#+COLUMNS: %TODO %40ITEM(Task) %40SUMMARY(Summary) %Received(Rec)
** TODO Test
   :PROPERTIES:
   :Sent:     [ ]
   :foo:      Test
   :END:

** WAIT Test2
   :PROPERTIES:
   :Sent:     [ ]
   :foo:      Test2
   :END:

** TODO Test3
   :PROPERTIES:
   :Sent:     [ ]
   :foo:      Test3
   :END:
#+end_src


However I wanted to insert a checkbox not a title so I tried 

#+begin_src 

#+begin_src elisp :noexport
(defun my-set-property-at-heading ()
  "Function to be called at the beginning of an Org heading."
  (interactive)
  (let ((el (org-element-at-point)))
    (org-set-property "New" (org-element-property "[ ]" el)))))
(org-map-entries #'my-set-property-at-heading)
            
#+end_src

But this did not work, I am either asked all the time (but I have 200
headers), or it does not work at all. I also tried

#+begin_src elisp :noexport
(defun my-set-property-at-heading ()
  "Function to be called at the beginning of an Org heading."
  (interactive)
  (let ((el (org-element-at-point)))
    (org-set-property "New2" (org-element-property :checkbox el))))
(org-map-entries #'my-set-property-at-heading)
            
#+end_src


Thanks again 

Uwe Brauer 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

  reply	other threads:[~2022-07-19 15:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-19  8:14 org-set-properties for various (all) headings Uwe Brauer
2022-07-19 10:56 ` Kaushal Modi
2022-07-19 14:53   ` Uwe Brauer [this message]
2022-07-19 16:30     ` Kaushal Modi
2022-07-19 16:56       ` Uwe Brauer
2022-07-19 18:07         ` Kaushal Modi
2022-07-20  5:31           ` Uwe Brauer
2022-07-20  7:33             ` Ihor Radchenko
2022-07-20  8:05               ` Uwe Brauer
2022-07-20 13:00                 ` Kaushal Modi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875yjt6tn9.fsf@mat.ucm.es \
    --to=oub@mat.ucm.es \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).