From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Question about adding to inherited properties Date: Fri, 20 Apr 2012 00:08:09 -0400 Message-ID: <9494.1334894889@alphaville> References: Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:39901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL591-0000MS-Ty for emacs-orgmode@gnu.org; Fri, 20 Apr 2012 00:08:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SL58z-0007j5-Fi for emacs-orgmode@gnu.org; Fri, 20 Apr 2012 00:08:27 -0400 Received: from g6t0184.atlanta.hp.com ([15.193.32.61]:6890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SL58z-0007g5-Au for emacs-orgmode@gnu.org; Fri, 20 Apr 2012 00:08:25 -0400 In-Reply-To: Message from Bill Wishon of "Thu\, 19 Apr 2012 17\:06\:40 PDT." 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: Bill Wishon Cc: eric.schulte@gmail.com, emacs-orgmode@gnu.org Bill Wishon wrote: > First, let me say that I'm only a novice elisp hacker...=C2=A0 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.=C2=A0 The manual shows an example in > section 7.1 where a GENRES+ adds to a GENRES property statement in a > parent heading.=C2=A0=C2=A0 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) > =C2=A0 "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." > =C2=A0 (move-marker org-entry-property-inherited-from nil) > =C2=A0 (let (tmp) > =C2=A0=C2=A0=C2=A0 (unless (org-before-first-heading-p) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (save-excursion > =C2=A0=C2=A0=C2=A0 (save-restriction > =C2=A0=C2=A0=C2=A0 =C2=A0 (widen) > =C2=A0=C2=A0=C2=A0 =C2=A0 (catch 'ex > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (while t > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (when (setq tmp (org-en= try-get nil property nil 'literal-nil)) >=20 > >>> 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.=C2=A0 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. >=20 > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (org-back-to-heading t) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (move-marker org-entry-property-inh= erited-from (point)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (throw 'ex tmp)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (or (org-up-heading-saf= e) (throw 'ex nil))))))) > =C2=A0=C2=A0=C2=A0 (setq tmp (or tmp > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (cdr (assoc property org-fil= e-properties)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (cdr (assoc property org-glo= bal-properties)) > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 (cdr (assoc property org-glo= bal-properties-fixed)))) > =C2=A0=C2=A0=C2=A0 (if literal-nil tmp (org-not-nil tmp)))) >=20 > Thoughts? >=20 Eric Schulte (cc:ed) implemented accumulating properties with commit 3af89e696a32afcc39f2e3bdb6132ac588d530ae. The commit adds a function org-update-property-plist which takes care of the '+' case in property names. But as you observed, it does not seem to work. I don't really understand what should be happening: what I do know is that when org-entry-get calls the above function, the props parameter is nil, whereas the function expects it to contain the inherited sestting. So it may be that the function is expecting something that is not going to happen or org-entry-get passes it the wrong thing somehow. I don't know whi= ch one of these two is correct (or perhaps some other thing is wrong), but in any case there does seem to be a disconnect. Nick > ~>Bill >=20 > On Wed, Apr 18, 2012 at 4:05 PM, Bill Wishon wrote: >=20 > Hi Org-mode Community, >=20=20=20=20 > I can't get the example in section 7.1 of the org-mode manual to work= as I expect.=C2=A0 Perhaps > someone can help me see what I'm doing wrong.=C2=A0 >=20=20=20=20 > I tried creating this buffer: >=20=20=20=20 > * CD collection > ** Classic > =C2=A0:PROPERTIES: > =C2=A0:GENRES: Classic > =C2=A0:END: > *** Goldberg Variations > =C2=A0:PROPERTIES: > =C2=A0:Title:=C2=A0=C2=A0=C2=A0 Goldberg Variations > =C2=A0:Composer: J.S. Bach > =C2=A0:Artist:=C2=A0=C2=A0 Glen Gould > =C2=A0:Publisher: Deutsche Grammophon > =C2=A0:NDisks:=C2=A0=C2=A0 1 > =C2=A0:GENRES+:=C2=A0=C2=A0 Baroque > =C2=A0:END: >=20=20=20=20 > Then I set the org-use-property-inheritance variable to include GENRE= S. >=20=20=20=20 > Then I wrote the following function >=20=20=20=20 > (defun bill-test (property) > =C2=A0 "print all inheirited properties" > =C2=A0 (interactive "MProperty: ") > =C2=A0 (message (concat property " =3D " (org-entry-get (point) prope= rty t)))) >=20=20=20=20 > Which prints "GENRES =3D Baroque" when I run it with the point on Gol= dberg Variations, based on > the manual I expected this to print "GENRES =3D Classic Baroque=E2=80= =9D. >=20=20=20=20 > While I think they should all do the same thing, I also tried the fol= lowing 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) >=20=20=20=20 > 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". >=20=20=20=20 > Any pointers about what I'm doing wrong would be great. >=20=20=20=20 > Thanks, > ~>Bill >=20 >=20 > ---------------------------------------------------- > Alternatives: >=20 > ----------------------------------------------------