From: Matt Price <moptop99@gmail.com>
To: Nicolas Goaziou <n.goaziou@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: org-element-property syntax (turning strings into keyword symbols)
Date: Sat, 9 Nov 2013 11:15:12 -0500 [thread overview]
Message-ID: <CAN_Dec-xd=ZLqUcykupS2O0Vho7Zt=DgCe68WwbdWzZ90nh+oA@mail.gmail.com> (raw)
In-Reply-To: <87fvr6818g.fsf@gmail.com>
On Sat, Nov 9, 2013 at 2:48 AM, Nicolas Goaziou <n.goaziou@gmail.com> wrote:
> Hello,
>
> Matt Price <moptop99@gmail.com> writes:
>
>> This works fine. Now when I come back to this buffer I want to check
>> whether any of the properties are actually there. So I am trying
>> something like this:
>>
>> (let ((hasprops nil))
>> (dolist prop org-writers-room-properties
>> (if (org-element-property (car prop) (org-element-at-point))
>> (setq hasprops t))
>> (if (hasprops)
>> (etc.))
>>
>> However this doesn't work because (1) the car of "prop" (which is in
>> fact the property name) is not necessarily capitalized and
>
> Then `upcase' the property name first. I assume you will only refer to
> user-defined properties so their equivalent keyword will always be in
> upper cases.
>
>> (2) the "property" parameter of org-element-property is not a string,
>> but a "keyword symbol". Somehow I have to turn my string into the
>> appropriate keyword symbol. Does anyone know how to do this?
>
> Use `intern'.
>
> For efficiency reasons, I also suggest to store `org-element-at-point'
> in a variable instead of computing it again each time you are looking
> for a property:
>
> (let ((hashprops nil)
> (element (org-element-at-point)))
> (dolist (prop org-writers-room-properties)
> (if (org-element-property (intern (concat ":" (upcase prop))) element)
> ...)))
>
ah, thank you so much for this. I don't know how I would ever have
found intern on my own. makes my life much easier!
>
> Regards,
>
> --
> Nicolas Goaziou
prev parent reply other threads:[~2013-11-09 16:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-09 6:29 org-element-property syntax (turning strings into keyword symbols) Matt Price
2013-11-09 7:48 ` Nicolas Goaziou
2013-11-09 16:15 ` Matt Price [this message]
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='CAN_Dec-xd=ZLqUcykupS2O0Vho7Zt=DgCe68WwbdWzZ90nh+oA@mail.gmail.com' \
--to=moptop99@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=n.goaziou@gmail.com \
/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).