From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Abrahamsen Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Date: Wed, 08 Feb 2017 17:36:35 -0800 Message-ID: <878tpgi1r0.fsf@pellet> References: <877f50f918.fsf@alphaville.usersys.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbdfL-0006CW-Cf for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:36:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbdfI-0000bZ-5g for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:36:55 -0500 Received: from [195.159.176.226] (port=44300 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbdfH-0000az-VT for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:36:52 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cbdfA-0006Ov-07 for emacs-orgmode@gnu.org; Thu, 09 Feb 2017 02:36:44 +0100 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: emacs-orgmode@gnu.org Nick Dokos writes: > Joon Ro writes: > >> So far I have done: >> >> (defun org/parse-headings (backend) >> (if (member backend '(latex)) >> (org-map-entries >> (lambda () >> (progn >> (insert-string "#+LATEX: \\newpage") >> )) >> "+newpage") >> ) >> ) >> >> (add-hook 'org-export-before-parsing-hook 'org/parse-headings) >> >> This puts #+LATEX: \\newpage before the subheading, but the problem is if I try to do (insert-string "#+LATEX: \\newpage"), exporting gets stuck with the message "org-babel-exp process txt >> at position 280541...". I suspect inserting a string messes up the position. How would I insert string with the newline character before a heading? >> > See the doc for org-map-entries - it says: > > ,---- > | The call to FUNC will be wrapped into a save-excursion form, so FUNC > | does not need to preserve point. After evaluation, the cursor will be > | moved to the end of the line (presumably of the headline of the > | processed entry) and search continues from there. Under some > | circumstances, this may not produce the wanted results. For example, > | if you have removed (e.g. archived) the current (sub)tree it could > | mean that the next entry will be skipped entirely. In such cases, you > | can specify the position from where search should continue by making > | FUNC set the variable ‘org-map-continue-from’ to the desired buffer > | position. > `---- > > So you'll have to manipulate org-map-continue-from appropriately. I would think it would be easier to add at export time using `org-export-filter-headline-functions'. Eric