all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] ox-extra.el: Fix filtering of latex header blocks
@ 2015-10-09 16:13 Sebastian Christ
  2015-10-11  8:21 ` Sebastian Christ
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sebastian Christ @ 2015-10-09 16:13 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi group,

I'd like to provide a patch to
ox-extra.el. `org-latex-header-blocks-filter' still calls
`org-edit-src-find-region-and-lang' and raises therefore an undefined
function error.

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: 2358 bytes --]

From 34b76e06bda5739e433c95b451915c8b804a1733 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'.
---
 contrib/lisp/ox-extra.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/contrib/lisp/ox-extra.el b/contrib/lisp/ox-extra.el
index e6d45cc..bb838fc 100644
--- a/contrib/lisp/ox-extra.el
+++ b/contrib/lisp/ox-extra.el
@@ -71,18 +71,22 @@
 		       (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 (third pos))
+                     (end (second pos))
+                     (post-affiliated (first pos))
+                     (contents-lines
+                      (cdr (butlast
+                            (split-string
+                             (buffer-substring-no-properties post-affiliated
+                                                             end)
+                             "\n")
+                            2))))
+                (goto-char beg)
+                (delete-region beg end)
+                (dolist (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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-12-08 10:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-09 16:13 [PATCH] ox-extra.el: Fix filtering of latex header blocks Sebastian Christ
2015-10-11  8:21 ` Sebastian Christ
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.