From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Date: Wed, 08 Feb 2017 20:27:31 -0500 Message-ID: <877f50f918.fsf@alphaville.usersys.redhat.com> References: 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]:56616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbdWY-0003Ey-2W for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:27:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbdWU-0005vs-5q for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:27:50 -0500 Received: from [195.159.176.226] (port=59629 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cbdWU-0005uh-0H for emacs-orgmode@gnu.org; Wed, 08 Feb 2017 20:27:46 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cbdWJ-0004n6-Vn for emacs-orgmode@gnu.org; Thu, 09 Feb 2017 02:27:35 +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 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. -- Nick