From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Price Subject: Re: strange results with org-map-entries Date: Wed, 11 Jan 2017 09:01:47 -0500 Message-ID: References: <87r34av567.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11444e64a58ca30545d20ae4 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33722) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cRJTS-0001fU-QB for emacs-orgmode@gnu.org; Wed, 11 Jan 2017 09:02:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cRJTJ-00075w-0d for emacs-orgmode@gnu.org; Wed, 11 Jan 2017 09:01:58 -0500 Received: from mail-io0-x233.google.com ([2607:f8b0:4001:c06::233]:36540) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cRJTI-00074v-MI for emacs-orgmode@gnu.org; Wed, 11 Jan 2017 09:01:48 -0500 Received: by mail-io0-x233.google.com with SMTP id j13so75574402iod.3 for ; Wed, 11 Jan 2017 06:01:48 -0800 (PST) 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" To: Nicolas Goaziou Cc: Org Mode --001a11444e64a58ca30545d20ae4 Content-Type: text/plain; charset=UTF-8 On Tue, Jan 10, 2017 at 7:34 PM, Matt Price wrote: > > > On Tue, Jan 10, 2017 at 6:58 PM, Nicolas Goaziou > wrote: > >> Hello, >> >> Matt Price writes: >> >> > What's going on here? Can anyone else reproduce this? I'm seeing it on >> org >> > 9.0.3 up to date as of today, emacs git from 2017-01-04. >> >> You mark a region then jump around the buffer with `org-map-entries'. At >> some point the region contains no headline, but you request a subtree >> export, hence the error. >> > > But what about the weird export results, where files don't seem to contain > the expected content? And is there a better way (than marking and bouncing) > to constrain org-map-entries to first-level headings only? > Well, I can't answer the first question, about the wierd export results, but here at least is a better way, using org-element-map: (defun mwp-org-export-all-to-org () (interactive) (org-element-map (org-element-parse-buffer)'headline (lambda (headline) (let ((begin (org-element-property :begin headline)) (level (org-element-property :level headline)) (commentedp (org-element-property :commentedp headline)) (tags (org-element-property :tags headline))) (unless (or (> level 1) commentedp (member "noexport" tags) ;; I would prefer to get the exclude-tags dynamically but ;; I'm not sure how to do it properly -- need to access exclude-tags somehow ;; (cl-loop for k in (plist-get options :exclude-tags) ;; thereis (member k tags)) ) (save-excursion (goto-char begin) (org-org-export-to-org nil t ))))))) On Tue, Jan 10, 2017 at 7:34 PM, Matt Price wrote: > > > On Tue, Jan 10, 2017 at 6:58 PM, Nicolas Goaziou > wrote: > >> Hello, >> >> Matt Price writes: >> >> > What's going on here? Can anyone else reproduce this? I'm seeing it on >> org >> > 9.0.3 up to date as of today, emacs git from 2017-01-04. >> >> You mark a region then jump around the buffer with `org-map-entries'. At >> some point the region contains no headline, but you request a subtree >> export, hence the error. >> > > But what about the weird export results, where files don't seem to contain > the expected content? And is there a better way (than marking and bouncing) > to constrain org-map-entries to first-level headings only? > --001a11444e64a58ca30545d20ae4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


On Tue, Jan 10, 2017 at 7:34 PM, Matt Price <moptop99@gmail.com&g= t; wrote:


<= span class=3D"gmail-">On Tue, Jan 10, 2017 at 6:58 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
Hello,

Matt Price <mopt= op99@gmail.com> writes:

> What's going on here? Can anyone else reproduce this? I'm seei= ng it on org
> 9.0.3 up to date as of today, emacs git from 2017-01-04.

You mark a region then jump around the buffer with `org-map-entries&= #39;. At
some point the region contains no headline, but you request a subtree
export, hence the error.

But wha= t about the weird export results, where files don't seem to contain the= expected content? And is there a better way (than marking and bouncing) to= constrain org-map-entries to first-level headings only?=C2=A0

Well, I can't a= nswer the first question, about the wierd export results, but here at least= is a better way, using org-element-map:

(defun mwp-org-export-all-t= o-org ()
=C2=A0 (interactive)
=C2=A0 (org-element-map (org-element-pa= rse-buffer)'headline
=C2=A0=C2=A0=C2=A0 (lambda (headline)
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 (let ((begin (org-element-property :begin headline= ))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (l= evel (org-element-property :level headline))
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (commentedp (org-element-property := commentedp headline))
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 (tags (org-element-property :tags headline)))
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless (or (> level 1)
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 commentedp
=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 (member "noexport" tags)
=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 ;; I would prefer to get the exclude-tags dynamically but=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; I'm not sure how to do it= properly -- need to access exclude-tags somehow
=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ;; (cl-loop for k in (plist-get options :exclude-tags)=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;;=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 thereis (member k=C2=A0 tags))
=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 )
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 (save-excursion
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 (goto-char begin)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (org-org-export-to-org nil t )))))))

On = Tue, Jan 10, 2017 at 7:34 PM, Matt Price <moptop99@gmail.com> wrote:


On Tue, Ja= n 10, 2017 at 6:58 PM, Nicolas Goaziou <mail@nicolasgoaziou.fr>= ; wrote:
Hello,

Matt Price <mopt= op99@gmail.com> writes:

> What's going on here? Can anyone else reproduce this? I'm seei= ng it on org
> 9.0.3 up to date as of today, emacs git from 2017-01-04.

You mark a region then jump around the buffer with `org-map-entries&= #39;. At
some point the region contains no headline, but you request a subtree
export, hence the error.

But wha= t about the weird export results, where files don't seem to contain the= expected content? And is there a better way (than marking and bouncing) to= constrain org-map-entries to first-level headings only?=C2=A0

--001a11444e64a58ca30545d20ae4--