From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bill Wishon Subject: Re: Question about adding to inherited properties Date: Thu, 19 Apr 2012 17:06:40 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d04426aa41b1d3804be111024 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51004) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL1N8-0007J0-Bb for emacs-orgmode@gnu.org; Thu, 19 Apr 2012 20:06:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SL1N5-0007Qb-VO for emacs-orgmode@gnu.org; Thu, 19 Apr 2012 20:06:45 -0400 Received: from mail-lpp01m010-f41.google.com ([209.85.215.41]:59231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL1N5-0007QC-JI for emacs-orgmode@gnu.org; Thu, 19 Apr 2012 20:06:43 -0400 Received: by lagz14 with SMTP id z14so7908449lag.0 for ; Thu, 19 Apr 2012 17:06:40 -0700 (PDT) In-Reply-To: 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: emacs-orgmode@gnu.org --f46d04426aa41b1d3804be111024 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable First, let me say that I'm only a novice elisp hacker... That said after spending some time debugging I think there may be a disconnect between the example in the org-manual and the function org-entry-get-with-inheritance. The manual shows an example in section 7.1 where a GENRES+ adds to a GENRES property statement in a parent heading. But the docs and code in the org-entry-get-with-inheritance function seem to implement a model that only looks up the outline if you don't find anything on the current heading, even if it's a "+" property. (defun org-entry-get-with-inheritance (property &optional literal-nil) "Get entry property, and search higher levels if not present. The search will stop at the first ancestor which has the property defined. If the value found is \"nil\", return nil to show that the property should be considered as undefined (this is the meaning of nil here). However, if LITERAL-NIL is set, return the string value \"nil\" instead." (move-marker org-entry-property-inherited-from nil) (let (tmp) (unless (org-before-first-heading-p) (save-excursion (save-restriction (widen) (catch 'ex (while t (when (setq tmp (org-entry-get nil property nil 'literal-nil)) >>> In my previous example when we get here org-entry-get returns the value of the property GENRES which is "Baroque" and executes the following three functions including the throw, which stops the loop. >>> Based on the documentation I would think that this function should check to see if the current property is a "GENRES+" vs. a "GENRES" property and continue up the outline looking for more GENRES+ properties and only stop when we find a plain GENRES or reach the top. This looks like what the (org-up-heading-safe) below is trying to do, but never gets executed because org-entry-get returned a positive value of "Baroque" when searching for GENRES on the current entry. (org-back-to-heading t) (move-marker org-entry-property-inherited-from (point)) (throw 'ex tmp)) (or (org-up-heading-safe) (throw 'ex nil))))))) (setq tmp (or tmp (cdr (assoc property org-file-properties)) (cdr (assoc property org-global-properties)) (cdr (assoc property org-global-properties-fixed)))) (if literal-nil tmp (org-not-nil tmp)))) Thoughts? ~>Bill On Wed, Apr 18, 2012 at 4:05 PM, Bill Wishon wrote: > Hi Org-mode Community, > > I can't get the example in section 7.1 of the org-mode manual to work as = I > expect. Perhaps someone can help me see what I'm doing wrong. > > I tried creating this buffer: > > * CD collection > ** Classic > :PROPERTIES: > :GENRES: Classic > :END: > *** Goldberg Variations > :PROPERTIES: > :Title: Goldberg Variations > :Composer: J.S. Bach > :Artist: Glen Gould > :Publisher: Deutsche Grammophon > :NDisks: 1 > :GENRES+: Baroque > :END: > > Then I set the org-use-property-inheritance variable to include GENRES. > > Then I wrote the following function > > (defun bill-test (property) > "print all inheirited properties" > (interactive "MProperty: ") > (message (concat property " =3D " (org-entry-get (point) property t)))) > > Which prints "GENRES =3D Baroque" when I run it with the point on Goldber= g > Variations, based on the manual I expected this to print "GENRES =3D Clas= sic > Baroque=94. > > While I think they should all do the same thing, I also tried the > following ways of calling org-entry-get just in case all with the same > result. > (org-entry-get (point) property 'selective) > (org-entry-get nil property t) > (org-entry-get nil property 'selective) > > I'm using org-version 7.8.09 on Windows with emacs "GNU Emacs 23.3.1 > (i386-mingw-nt6.1.7601) of 2011-03-10 on 3249CTO". > > Any pointers about what I'm doing wrong would be great. > > Thanks, > ~>Bill > --f46d04426aa41b1d3804be111024 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable First, let me say that I'm only a novice elisp hacker...=A0 That said a= fter spending some time debugging I think there may be a disconnect between= the example in the org-manual and the function org-entry-get-with-inherita= nce.=A0 The manual shows an example in section 7.1 where a GENRES+ adds to = a GENRES property statement in a parent heading.=A0=A0 But the docs and cod= e in the org-entry-get-with-inheritance function seem to implement a model = that only looks up the outline if you don't find anything on the curren= t heading, even if it's a "+" property.

(defun org-entry-get-with-inheritance (property &optional literal-n= il)
=A0 "Get entry property, and search higher levels if not presen= t.
The search will stop at the first ancestor which has the property def= ined.
If the value found is \"nil\", return nil to show that the proper= ty
should be considered as undefined (this is the meaning of nil here).<= br>However, if LITERAL-NIL is set, return the string value \"nil\"= ; instead."
=A0 (move-marker org-entry-property-inherited-from nil)
=A0 (let (tmp)=A0=A0=A0 (unless (org-before-first-heading-p)
=A0=A0=A0=A0=A0 (save-e= xcursion
=A0=A0=A0 (save-restriction
=A0=A0=A0 =A0 (widen)
=A0=A0= =A0 =A0 (catch 'ex
=A0=A0=A0 =A0=A0=A0 (while t
=A0=A0=A0 =A0=A0=A0=A0=A0 (when (setq tmp (org-entry-get nil property nil &= #39;literal-nil))

>>> In my previous example when we get he= re org-entry-get returns the value of the property GENRES which is "Ba= roque" and executes the following three functions including the throw,= which stops the loop.=A0
>>> Based on the documentation I would think that this function sh= ould check to see if the current property is a "GENRES+" vs. a &q= uot;GENRES" property and continue up the outline looking for more GENR= ES+ properties and only stop when we find a plain GENRES or reach the top.= =A0 This looks like what the (org-up-heading-safe) below is trying to do, b= ut never gets executed because org-entry-get returned a positive value of &= quot;Baroque" when searching for GENRES on the current entry.

=A0=A0=A0 =A0=A0=A0 (org-back-to-heading t)
=A0=A0=A0 =A0=A0=A0 (mov= e-marker org-entry-property-inherited-from (point))
=A0=A0=A0 =A0=A0=A0 = (throw 'ex tmp))
=A0=A0=A0 =A0=A0=A0=A0=A0 (or (org-up-heading-safe)= (throw 'ex nil)))))))
=A0=A0=A0 (setq tmp (or tmp
=A0=A0=A0 =A0=A0=A0 =A0 (cdr (assoc property org-file-properties))
=A0= =A0=A0 =A0=A0=A0 =A0 (cdr (assoc property org-global-properties))
=A0=A0= =A0 =A0=A0=A0 =A0 (cdr (assoc property org-global-properties-fixed))))
= =A0=A0=A0 (if literal-nil tmp (org-not-nil tmp))))

Thoughts?

~>Bill

On Wed, Ap= r 18, 2012 at 4:05 PM, Bill Wishon <bill@wishon.org> wrote:
Hi Org-mode Community,

I can't get the example in section 7.1 of= the org-mode manual to work as I expect.=A0 Perhaps someone can help me se= e what I'm doing wrong.=A0

I tried creating this buffer:
* CD collection
** Classic
=A0:PROPERTIES:
=A0:GENRES: Classic
= =A0:END:
*** Goldberg Variations
=A0:PROPERTIES:
=A0:Title:=A0=A0= =A0 Goldberg Variations
=A0:Composer: J.S. Bach
=A0:Artist:=A0=A0 Gle= n Gould
=A0:Publisher: Deutsche Grammophon
=A0:NDisks:=A0=A0 1
=A0:GENRES+:=A0=A0 Baroque
=A0:END:

Then I= set the org-use-property-inheritance variable to include GENRES.

Th= en I wrote the following function

(defun bill-test (property)
=A0= "print all inheirited properties"
=A0 (interactive "MProperty: ")
=A0 (message (concat property = " =3D " (org-entry-get (point) property t))))

Which prints= "GENRES =3D Baroque" when I run it with the point on Goldberg Va= riations, based on the manual I expected this to print "GENRES =3D Cla= ssic Baroque=94.

While I think they should all do the same thing, I also = tried the following ways of calling org-entry-get just in case all with the= same result.
(org-entry-get (point) property 'selective)
(org-en= try-get nil property t)
(org-entry-get nil property 'selective)

I'm using org-versio= n 7.8.09 on Windows with emacs "GNU Emacs 23.3.1 (i386-mingw-nt6.1.760= 1) of 2011-03-10 on 3249CTO".

Any pointers about what I'm d= oing wrong would be great.

Thanks,
~>Bill

--f46d04426aa41b1d3804be111024--