emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Joon Ro <joon.ro@outlook.com>
To: Nick Dokos <ndokos@gmail.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook
Date: Sat, 11 Feb 2017 19:40:10 +0000	[thread overview]
Message-ID: <CY4PR15MB162285B69F6854954F9A51D4EB470@CY4PR15MB1622.namprd15.prod.outlook.com> (raw)
In-Reply-To: <CY4PR15MB162220D13B56950184DED64FEB450@CY4PR15MB1622.namprd15.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]

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 <emacs-orgmode-bounces+joon.ro=outlook.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 (outline-next-heading)) after insert-string seemed to solve the problem.
(I added "newpage" to 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 "#+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

[-- Attachment #2: Type: text/html, Size: 4419 bytes --]

      reply	other threads:[~2017-02-11 19:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-08 19:52 Adding #+LATEX: \newpage before section header using org-export-before-parsing-hook Joon Ro
2017-02-08 19:53 ` Joon Ro
2017-02-08 20:48 ` Thomas S. Dye
2017-02-09  0:01   ` Joon Ro
2017-02-09  1:27     ` Nick Dokos
2017-02-09  1:36       ` Eric Abrahamsen
2017-02-09  2:58       ` Joon Ro
2017-02-11 19:40         ` Joon Ro [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CY4PR15MB162285B69F6854954F9A51D4EB470@CY4PR15MB1622.namprd15.prod.outlook.com \
    --to=joon.ro@outlook.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=ndokos@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).