From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: org-element-property syntax (turning strings into keyword symbols) Date: Sat, 09 Nov 2013 08:48:15 +0100 Message-ID: <87fvr6818g.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vf3H9-0001aO-RX for emacs-orgmode@gnu.org; Sat, 09 Nov 2013 02:48:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vf3Gw-0003iW-O8 for emacs-orgmode@gnu.org; Sat, 09 Nov 2013 02:48:11 -0500 Received: from mail-ea0-x22c.google.com ([2a00:1450:4013:c01::22c]:59116) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vf3Gw-0003iK-GV for emacs-orgmode@gnu.org; Sat, 09 Nov 2013 02:47:58 -0500 Received: by mail-ea0-f172.google.com with SMTP id h11so784838eaj.3 for ; Fri, 08 Nov 2013 23:47:57 -0800 (PST) In-Reply-To: (Matt Price's message of "Sat, 9 Nov 2013 01:29:40 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Matt Price Cc: Org Mode Hello, Matt Price 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) ...))) Regards, -- Nicolas Goaziou