From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cecil Westerhof Subject: Re: API problem Date: Wed, 22 Jan 2014 22:57:37 +0100 Message-ID: References: <8738kgvthz.fsf@gmail.com> <87r47zvjgb.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1135ec948a825604f096366c Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W65nn-0006AI-U5 for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 16:57:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W65nm-0006te-ON for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 16:57:39 -0500 Received: from mail-qa0-x236.google.com ([2607:f8b0:400d:c00::236]:52284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W65nm-0006tY-H4 for emacs-orgmode@gnu.org; Wed, 22 Jan 2014 16:57:38 -0500 Received: by mail-qa0-f54.google.com with SMTP id i13so1241480qae.13 for ; Wed, 22 Jan 2014 13:57:37 -0800 (PST) In-Reply-To: <87r47zvjgb.fsf@gmail.com> 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 --001a1135ec948a825604f096366c Content-Type: text/plain; charset=ISO-8859-1 2014/1/22 Nicolas Goaziou > Cecil Westerhof writes: > > > I have an org-file wth the folowing: > > - [ ] A (setq struct (org-list-struct)) > > - [-] B (org-list-get-checkbox 41 struct) > > - [ ] C (org-list-set-checkbox 41 struct "[X]") > > - [ ] D (org-list-get-checkbox 41 struct) > > - [ ] E (org-list-write-struct struct (org-list-parents-alist struct)) > > > > In A I fill the struct. > > B displays "[-]" > > C displays "[X]" > > D displays "[X]", so the struct is correctly updated. > > E gives: # > > > > What is going wrong here? > > See `org-list-write-struct' docstring. Basically, STRUCT doesn't match > real structure anymore since step C. You need to provide the original > structure as a third argument so `org-list-write-struct' can modify > buffer by set difference. > > (let* ((struct (org-list-struct)) > (old (copy-tree struct))) > (org-list-set-checkbox (line-beginning-position) struct "[X]") > (org-list-write-struct struct (org-list-parents-alist struct) old)) > This works, so I can continue. But one thing I do not understand. When you do an org-list-write-struct, you want to change the structure. So why is old-struct optional? -- Cecil Westerhof --001a1135ec948a825604f096366c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
2014= /1/22 Nicolas Goaziou <n.goaziou@gmail.com>
Cecil Westerhof <cldwesterhof@gmail.com> writes:

> I have an org-file wth the folowing:
> - [ ] A (setq struct (org-list-struct))
> - [-] B (org-list-get-checkbox 41 struct)
> - [ ] C (org-list-set-checkbox 41 struct "[X]")
> - [ ] D (org-list-get-checkbox 41 struct)
> - [ ] E (org-list-write-struct struct (org-list-parents-alist struct))=
>
> In A I fill the struct.
> B displays "[-]"
> C displays "[X]"
> D displays "[X]", so the struct is correctly updated.
> E gives: #<marker in no buffer>
>
> What is going wrong here?

See `org-list-write-struct' docstring. Basically, STRUCT doesn= 9;t match
real structure anymore since step C. You need to provide the original
structure as a third argument so `org-list-write-struct' can modify
buffer by set difference.

=A0 (let* ((struct (org-list-struct))
=A0 =A0 =A0 =A0 =A0(old (copy-tree struct)))
=A0 =A0 (org-list-set-checkbox (line-beginning-position) struct "[X]&q= uot;)
=A0 =A0 (org-list-write-struct struct (org-list-parents-alist struct) old))=

This works, so I can continue.
But one thing I do not understand. When you do an org-li= st-write-struct, you want to change the structure. So why is old-struct opt= ional?
=A0


--
Cecil Westerhof
--001a1135ec948a825604f096366c--