From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: org-ref breaks org-repair-export-blocks Date: Wed, 11 May 2016 12:39:49 -0400 Message-ID: References: <878tzg5zod.fsf@free.fr> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1146a02aaccb30053293b020 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49337) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XAv-0006Hu-2t for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:39:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b0XAs-0002Wa-8i for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:39:51 -0400 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]:37441) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b0XAr-0002W6-VE for emacs-orgmode@gnu.org; Wed, 11 May 2016 12:39:50 -0400 Received: by mail-wm0-x22d.google.com with SMTP id a17so92825209wme.0 for ; Wed, 11 May 2016 09:39:49 -0700 (PDT) In-Reply-To: <878tzg5zod.fsf@free.fr> 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: Julien Cubizolles Cc: "emacs-orgmode@gnu.org" --001a1146a02aaccb30053293b020 Content-Type: text/plain; charset=UTF-8 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 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 --001a1146a02aaccb30053293b020 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
What seems to be happening is t= hose blocks are no longer special block, but instead an export-block. If yo= u change special-block to export block, then it works for me with org-ref l= oaded.

I don't know why (or even how) org-ref would be changing that though.<= /div>


On Wed, May 11, 2016 at 12:26 PM, Julien Cubizolle= s <j.cubizolles@free.fr> wrote:
#+BEGIN_SRC elisp
(require 'package)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa= /")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0("melpa" . "http://melpa.milkbox.n= et/packages/")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0("gnu" . "http://elpa.gnu.org/packages/= ")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0("org" . "http://orgmode.org/elpa/"= )
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0("marmalade" . "http://marmalade-= repo.org/packages/")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0))
(package-initialize)
(require 'org-ref)
(defun org-repair-export-blocks ()
=C2=A0 "Repair export blocks and INCLUDE keywords in current buffer.&q= uot;
=C2=A0 (interactive)
=C2=A0 (when (eq major-mode 'org-mode)
=C2=A0 =C2=A0 (let ((case-fold-search t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (back-end-re (regexp-opt
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 '("HTML" "ASCII" "LATEX" "= ;ODT" "MARKDOWN" "MD" "ORG"
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 "MAN" "BEAMER" "TEXINFO" &q= uot;GROFF" "KOMA-LETTER")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 t)))
=C2=A0 =C2=A0 =C2=A0 (org-with-wide-buffer
=C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-char (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((block-re (concat "^[ \t]*#\\+BEGIN_&= quot; back-end-re)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-excursion
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward block-re= nil t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((element (save-match-= data (org-element-at-point))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (eq (org-eleme= nt-type element) 'special-block)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-excursi= on
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(goto-= char (org-element-property :end element))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(save-= match-data (search-backward "_"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(forwa= rd-char)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(inser= t "EXPORT")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(delet= e-region (point) (line-end-position)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(replace-matc= h "EXPORT \\1" nil nil nil 1))))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((include-re
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (format "^[ \t]*#\\+I= NCLUDE: .*?%s[ \t]*$" back-end-re)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(while (re-search-forward include-re nil = t)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(let ((element (save-match-data (o= rg-element-at-point))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when (and (eq (org-element= -type element) 'keyword)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (string=3D (org-element-property :key element)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"INCLUDE"))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(replace-match "= ;EXPORT \\1" nil nil nil 1)))))))))
#+END_SRC

#+RESULTS:
: org-repair-export-blocks

#+BEGIN_LATEX
\begin{equation*}
P_{ext} =3D P_0
\end{equation*}
#+END_LATEX



John

-= ----------------------------------
Professor John Kitchin=C2=A0
Doher= ty Hall A207F
Department of Chemical Engineering
Carnegie Mellon Univ= ersity
Pittsburgh, PA 15213
412-268-7803
--001a1146a02aaccb30053293b020--