From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastian Christ Subject: Re: [PATCH] ox-extra.el: Fix filtering of latex header blocks Date: Sun, 11 Oct 2015 10:21:51 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56363) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlBtT-00064r-CI for emacs-orgmode@gnu.org; Sun, 11 Oct 2015 04:22:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlBtQ-0000IZ-8o for emacs-orgmode@gnu.org; Sun, 11 Oct 2015 04:22:11 -0400 Received: from plane.gmane.org ([80.91.229.3]:37231) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlBtQ-0000I3-1j for emacs-orgmode@gnu.org; Sun, 11 Oct 2015 04:22:08 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZlBtO-0007uf-98 for emacs-orgmode@gnu.org; Sun, 11 Oct 2015 10:22:06 +0200 Received: from ip5f586b34.dynamic.kabel-deutschland.de ([95.88.107.52]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Oct 2015 10:22:06 +0200 Received: from rudolfo.christ by ip5f586b34.dynamic.kabel-deutschland.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 11 Oct 2015 10:22:06 +0200 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-ox-extra.el-Fix-filtering-of-latex-header-blocks.patch >From d9890ab84c92ec60e76913d2a1b3967353819500 Mon Sep 17 00:00:00 2001 From: Sebastian Christ 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 | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --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 --=-=-=--