[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] org-ref breaks org-repair-export-blocks

From: Julien Cubizolles
Subject: [O] org-ref breaks org-repair-export-blocks
Date: Wed, 11 May 2016 18:26:10 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux)

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/";)
(require 'org-ref)
(defun org-repair-export-blocks ()
  "Repair export blocks and INCLUDE keywords in current buffer."
  (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")
       (goto-char (point-min))
       (let ((block-re (concat "^[ \t]*#\\+BEGIN_" back-end-re)))
           (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)
                   (goto-char (org-element-property :end element))
                   (save-match-data (search-backward "_"))
                   (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) 
               (replace-match "EXPORT \\1" nil nil nil 1)))))))))

: org-repair-export-blocks

P_{ext} = P_0
--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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]