* org-ref breaks org-repair-export-blocks
@ 2016-05-11 16:26 Julien Cubizolles
2016-05-11 16:39 ` John Kitchin
0 siblings, 1 reply; 2+ messages in thread
From: Julien Cubizolles @ 2016-05-11 16:26 UTC (permalink / raw)
To: emacs-orgmode
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: org-ref breaks org-repair-export-blocks
2016-05-11 16:26 org-ref breaks org-repair-export-blocks Julien Cubizolles
@ 2016-05-11 16:39 ` John Kitchin
0 siblings, 0 replies; 2+ messages in thread
From: John Kitchin @ 2016-05-11 16:39 UTC (permalink / raw)
To: Julien Cubizolles; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 2815 bytes --]
What seems to be happening is those blocks are no longer special block, but
instead an export-block. If you change special-block to export block, then
it works for me with org-ref loaded.
I don't know why (or even how) org-ref would be changing that though.
On Wed, May 11, 2016 at 12:26 PM, Julien Cubizolles <j.cubizolles@free.fr>
wrote:
> #+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
>
John
-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
[-- Attachment #2: Type: text/html, Size: 4657 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-05-11 16:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-11 16:26 org-ref breaks org-repair-export-blocks Julien Cubizolles
2016-05-11 16:39 ` John Kitchin
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).