From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joon Ro Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Date: Sat, 11 Feb 2017 19:40:10 +0000 Message-ID: References: , <877f50f918.fsf@alphaville.usersys.redhat.com>, Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="_000_CY4PR15MB162285B69F6854954F9A51D4EB470CY4PR15MB1622namp_" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ccdWq-00071u-Ex for emacs-orgmode@gnu.org; Sat, 11 Feb 2017 14:40:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ccdWn-0006zp-AQ for emacs-orgmode@gnu.org; Sat, 11 Feb 2017 14:40:16 -0500 Received: from snt004-omc1s11.hotmail.com ([65.55.90.22]:64102) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ccdWm-0006za-TU for emacs-orgmode@gnu.org; Sat, 11 Feb 2017 14:40:13 -0500 In-Reply-To: Content-Language: en-US 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: Nick Dokos , "emacs-orgmode@gnu.org" --_000_CY4PR15MB162285B69F6854954F9A51D4EB470CY4PR15MB1622namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I spoke too early - if I have two headings with :newpage: tag in a row, my = current code below skips the second heading. It seems (setq org-map-continue-from (outline-next-heading)) in my code is = the problem .. any help will be appreciated! (defun org/parse-headings-newpage (backend) ; add \newpage to headings with :newpage: tag (if (member backend '(latex)) (org-map-entries (lambda () (insert-string "#+LATEX: \\newpage\n") (if (outline-next-heading) (setq org-map-continue-from (outline-next-heading))) ) "+newpage")) ) (add-hook 'org-export-before-parsing-hook 'org/parse-headings-newpage) ________________________________ From: Emacs-orgmode o= n behalf of Joon Ro Sent: Wednesday, February 8, 2017 8:58:40 PM To: Nick Dokos; emacs-orgmode@gnu.org Subject: Re: [O] Adding #+LATEX: \newpage before section header using org-e= xport-before-parsing-hook > So you'll have to manipulate org-map-continue-from appropriately. Thanks a lot! Adding (setq org-map-continue-from (outline-next-heading)) af= ter insert-string seemed to solve the problem. (I added "newpage" to org-tags-exclude-from-inheritance, so the newpage doe= s not get applied to subheadings) (defun org/parse-headings-latex-newpage (backend) ; add \newpage to headings with :newpage: tag (if (member backend '(latex)) (org-map-entries (lambda () (progn (insert-string "#+LATEX: \\newpage\n") (setq org-map-continue-from (outline-next-heading)) )) "+newpage")) ) (add-hook 'org-export-before-parsing-hook 'org/parse-headings-latex-newpage= ) (add-to-list 'org-tags-exclude-from-inheritance '"newpage") Best, Joon --_000_CY4PR15MB162285B69F6854954F9A51D4EB470CY4PR15MB1622namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

I spoke too early - if I have two headings with :newpage: tag in a row, = my current code below skips the second heading. 

It seems (setq org-map-continue-from (outline-next-heading)) i= n my code is the problem .. any help will be appreciated!



(defun org/parse-headings-newpage (backend)
  ; add \newpage to headings with :newpage: tag
  (if (member backend '(latex))
      (org-map-entries
       (lambda ()
         (insert-string "#+LATEX: \\= newpage\n")
         (if (outline-next-heading)
           (setq org-map-continue-from (= outline-next-heading)))
         )
       "+newpage"))
)

(add-hook 'org-export-before-parsing-hook 'org/parse-headings-newpage)=



From: Emacs-orgmode <ema= cs-orgmode-bounces+joon.ro=3Doutlook.com@gnu.org> on behalf of Joon = Ro <joon.ro@outlook.com>
Sent: Wednesday, February 8, 2017 8:58:40 PM
To: Nick Dokos; emacs-orgmode@gnu.org
Subject: Re: [O] Adding #+LATEX: \newpage before section header = using org-export-before-parsing-hook
 

So you'll have to manipulate org-map-continue-from appropriately= .


Thanks a lot! Adding (setq org-map-continue-from (outli= ne-next-heading)) after insert-string seemed to solve the problem. 
(I added "newpage" to&nbs= p;org-tags-exclude-from-inheritance, so the newpage does not get applied to subheadings)

(defun org/parse-headings-latex-newpage (backend)
  ; add \newpage to headings with :newpage: tag
  (if (member backend '(latex))
      (org-map-entries
       (lambda ()
         (progn
           (insert-string "#+LA= TEX: \\newpage\n")
           (setq org-map-continue-from (= outline-next-heading))
           ))
       "+newpage"))
)

(add-hook 'org-export-before-parsing-hook 'org/parse-headings-latex-ne= wpage)
(add-to-list 'org-tags-exclude-from-inheritance '"newpage")<= /div>

Best,
Joon
--_000_CY4PR15MB162285B69F6854954F9A51D4EB470CY4PR15MB1622namp_--