From mboxrd@z Thu Jan 1 00:00:00 1970 From: Julien Cubizolles Subject: org-ref breaks org-repair-export-blocks Date: Wed, 11 May 2016 18:26:10 +0200 Message-ID: <878tzg5zod.fsf@free.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42683) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Wy3-00082K-H5 for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:26:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0Wxz-0002mC-82 for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:26:34 -0400 Received: from plane.gmane.org ([80.91.229.3]:44016) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0Wxz-0002lm-0B for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:26:31 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1b0Wxx-0000h9-7O for emacs-orgmode@gnu.org; Wed, 11 May 2016 18:26:29 +0200 Received: from gas45-3-82-244-252-119.fbx.proxad.net ([82.244.252.119]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 May 2016 18:26:29 +0200 Received: from j.cubizolles by gas45-3-82-244-252-119.fbx.proxad.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 11 May 2016 18:26:29 +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" To: emacs-orgmode@gnu.org Consider the following --8<---------------cut here---------------start------------->8--- #+BEGIN_SRC elisp (require 'package) (setq package-archives '(("ELPA" . "http://tromey.com/elpa/") ("melpa" . "http://melpa.milkbox.net/packages/") ("gnu" . "http://elpa.gnu.org/packages/") ("org" . "http://orgmode.org/elpa/") ("marmalade" . "http://marmalade-repo.org/packages/") )) (package-initialize) (require 'org-ref) (defun org-repair-export-blocks () "Repair export blocks and INCLUDE keywords in current buffer." (interactive) (when (eq major-mode 'org-mode) (let ((case-fold-search t) (back-end-re (regexp-opt '("HTML" "ASCII" "LATEX" "ODT" "MARKDOWN" "MD" "ORG" "MAN" "BEAMER" "TEXINFO" "GROFF" "KOMA-LETTER") t))) (org-with-wide-buffer (goto-char (point-min)) (let ((block-re (concat "^[ \t]*#\\+BEGIN_" back-end-re))) (save-excursion (while (re-search-forward block-re nil t) (let ((element (save-match-data (org-element-at-point)))) (when (eq (org-element-type element) 'special-block) (save-excursion (goto-char (org-element-property :end element)) (save-match-data (search-backward "_")) (forward-char) (insert "EXPORT") (delete-region (point) (line-end-position))) (replace-match "EXPORT \\1" nil nil nil 1)))))) (let ((include-re (format "^[ \t]*#\\+INCLUDE: .*?%s[ \t]*$" back-end-re))) (while (re-search-forward include-re nil t) (let ((element (save-match-data (org-element-at-point)))) (when (and (eq (org-element-type element) 'keyword) (string= (org-element-property :key element) "INCLUDE")) (replace-match "EXPORT \\1" nil nil nil 1))))))))) #+END_SRC #+RESULTS: : org-repair-export-blocks #+BEGIN_LATEX \begin{equation*} P_{ext} = P_0 \end{equation*} #+END_LATEX --8<---------------cut here---------------end--------------->8--- After evaluating the elisp source block, org-repair-export-blocks doesn't repair the LATEX block. However, (require 'org-ref) is commented out, org-repair-export-blocks does its job. Julien.