Joon Ro <joon...@outlook.com> 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