From: Sebastian Christ <rudolfo.christ@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] ox-extra.el: Fix filtering of latex header blocks
Date: Sun, 11 Oct 2015 10:21:51 +0200 [thread overview]
Message-ID: <m2si5hx1b4.fsf@gmail.com> (raw)
In-Reply-To: m2a8rskojt.fsf@gmail.com
[-- Attachment #1: Type: text/plain, Size: 212 bytes --]
And of course,
the previous patch contains a bug. I should have tested it with multiple
latex header blocks. Sorry for the inconvenience. The attached patch
should (hopefully) fix that.
Best wishes,
Sebastian
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-extra.el-Fix-filtering-of-latex-header-blocks.patch --]
[-- Type: text/x-patch, Size: 2653 bytes --]
From d9890ab84c92ec60e76913d2a1b3967353819500 Mon Sep 17 00:00:00 2001
From: Sebastian Christ <rudolfo.christ@gmail.com>
Date: Fri, 9 Oct 2015 17:37:39 +0200
Subject: [PATCH] ox-extra.el: Fix filtering of latex header blocks
* ox-extra.el (org-latex-header-blocks-filter): Use `org-element' API to
find begin and end of latex header blocks.
`org-latex-header-blocks-filter' still called
`org-edit-src-find-region-and-lang' and raised an undefined function
error because the funtion was removed from org-mode. This is fixed by determining the
begin and end of the latex block via `org-element'.
---
| 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
--git a/contrib/lisp/ox-extra.el b/contrib/lisp/ox-extra.el
index e6d45cc..669d54f 100644
--- a/contrib/lisp/ox-extra.el
+++ b/contrib/lisp/ox-extra.el
@@ -71,18 +71,24 @@
(org-element-property :end block)
(org-element-property :post-affiliated block)))))))
(mapc (lambda (pos)
- (goto-char (nth 2 pos))
- (destructuring-bind
- (beg end &rest ignore)
- (org-edit-src-find-region-and-lang)
- (let ((contents-lines (split-string
- (buffer-substring-no-properties beg end)
- "\n")))
- (delete-region (nth 0 pos) (nth 1 pos))
- (dolist (line contents-lines)
- (insert (concat "#+latex_header: "
- (replace-regexp-in-string "\\` *" "" line)
- "\n"))))))
+ (let* ((beg (first pos))
+ (end (second pos))
+ (post-affiliated (third pos))
+ (contents-lines (split-string
+ (buffer-substring-no-properties beg
+ end)
+ "\n")))
+ (goto-char post-affiliated)
+ (delete-region beg end)
+ (dolist (line (remove-if (lambda (line)
+ (or
+ (string-prefix-p "#+HEADER:" line)
+ (string-prefix-p "#+BEGIN_LaTeX" line)
+ (string-prefix-p "#+END_LaTeX" line)))
+ contents-lines))
+ (insert (concat "#+latex_header: "
+ (replace-regexp-in-string "\\` *" "" line)
+ "\n")))))
;; go in reverse, to avoid wrecking the numeric positions
;; earlier in the file
(reverse positions)))))
--
2.6.1
next prev parent reply other threads:[~2015-10-11 8:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 16:13 [PATCH] ox-extra.el: Fix filtering of latex header blocks Sebastian Christ
2015-10-11 8:21 ` Sebastian Christ [this message]
2015-11-09 6:30 ` Kyle Meyer
2015-11-10 9:54 ` Sebastian Christ
2015-11-10 15:11 ` Kyle Meyer
2015-11-12 19:30 ` Sebastian Christ
2015-11-10 16:57 ` Aaron Ecay
2015-11-12 19:23 ` Sebastian Christ
2015-12-08 10:12 ` Sebastian Christ
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=m2si5hx1b4.fsf@gmail.com \
--to=rudolfo.christ@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).