From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: [PATCH] Re: [BUG] htmlp and latexp Date: Tue, 22 Feb 2011 11:08:57 -0800 Message-ID: References: <4D5B8E60.4070307@christianmoe.com> <871v38s1gw.fsf@gnu.org> <87d3mpekpg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from [140.186.70.92] (port=49109 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Prxbc-0006RV-T3 for emacs-orgmode@gnu.org; Tue, 22 Feb 2011 14:09:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Prxbb-0002uE-4u for emacs-orgmode@gnu.org; Tue, 22 Feb 2011 14:09:04 -0500 Received: from mail-gw0-f51.google.com ([74.125.83.51]:46732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Prxba-0002ts-Rv for emacs-orgmode@gnu.org; Tue, 22 Feb 2011 14:09:03 -0500 Received: by gwb15 with SMTP id 15so567585gwb.38 for ; Tue, 22 Feb 2011 11:09:02 -0800 (PST) In-Reply-To: <87d3mpekpg.fsf@gnu.org> (Bastien's message of "Fri, 18 Feb 2011 10:49:31 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bastien Cc: Org , mail@christianmoe.com Bastien writes: > Hi Dan, > > Dan Davison writes: > >> I was thinking that if it were defvard in org.el, say as >> >> (defvar org-export-current-backend nil) >> >> then any code could use (null org-export-current-backend) to test >> whether org is currently exporting or not. Otherwise, the code has to be >> certain that it has been called during export if it is going to access >> the variable. > > I agree this would be a good idea. If you have time, please send a > patch. Otherwise, I just put it [somewhere] in my own todo list... Here's a patch. I note that Eric S pointed out in a separate thread that org-current-export-file can be used for a similar purpose. Incidentally, I would suggest that org-current-export-file and org-current-export-dir are renamed so that they are within the org-export-* namespace. There are other areas of Org where I think the naming should be standardised, notably in org-src.el: the distinction between org-src-* and org-edit-src-* is unclear IMO. I think this is kind of important, because in learning emacs one does makes use of these namespace conventions, e.g. C-h v TAB. How much change would there be if we demanded that *all* variables defined in org-foo.el are named within the org-foo-* namespace? Dan commit ac9baa44c7c0baeb8ed3133ed79bc22c4eb6acc7 Author: Dan Davison Date: Sun Feb 20 08:55:39 2011 -0800 New variable storing current export backend symbol, or nil. * lisp/org-exp.el (org-export-current-backend): Variable to hold current export backend symbol when export is in progress. (org-export-preprocess-string): Bind `org-export-current-backend' to backend symbols during export. * lisp/org-exp-blocks.el (org-export-blocks-format-ditaa): Dynamically scoped variable `backend' renamed as `org-export-current-backend' (org-export-blocks-format-dot): Dynamically scoped variable `backend' renamed as `org-export-current-backend' (org-export-blocks-format-comment): Dynamically scoped variable `backend' renamed as `org-export-current-backend' * lisp/org-exp.el (org-export-convert-protected-spaces): Dynamically scoped variable `backend' renamed as `org-export-current-backend' * lisp/org-publish.el (org-publish-project-alist): Dynamically scoped variable `backend' renamed as `org-export-current-backend' (org-export-current-backend): Dynamically scoped variable `backend' renamed as `org-export-current-backend' (org-publish-aux-preprocess): Dynamically scoped variable `backend' renamed as `org-export-current-backend' * lisp/org-special-blocks.el (org-export-current-backend): Dynamically scoped variable `backend' renamed as `org-export-current-backend' (org-special-blocks-make-special-cookies): Dynamically scoped variable `backend' renamed as `org-export-current-backend' diff --git a/lisp/org-exp-blocks.el b/lisp/org-exp-blocks.el index 1fac3bf..15549b8 100644 --- a/lisp/org-exp-blocks.el +++ b/lisp/org-exp-blocks.el @@ -242,7 +242,7 @@ passed to the ditaa utility as command line arguments." "\n"))) (prog1 (cond - ((member backend '(html latex docbook)) + ((member org-export-current-backend '(html latex docbook)) (unless (file-exists-p out-file) (mapc ;; remove old hashed versions of this file (lambda (file) @@ -301,7 +301,7 @@ digraph data_relationships { (out-file (concat (car out-file-parts) "_" hash "." (cdr out-file-parts)))) (prog1 (cond - ((member backend '(html latex docbook)) + ((member org-export-current-backend '(html latex docbook)) (unless (file-exists-p out-file) (mapc ;; remove old hashed versions of this file (lambda (file) @@ -333,7 +333,7 @@ other backends, it converts the comment into an EXAMPLE segment." (let ((owner (if headers (car headers))) (title (if (cdr headers) (mapconcat 'identity (cdr headers) " ")))) (cond - ((eq backend 'html) ;; We are exporting to HTML + ((eq org-export-current-backend 'html) ;; We are exporting to HTML (concat "#+BEGIN_HTML\n" "
(match-end 1) (match-beginning 1))) (setq entry (match-string 1)) - (when (eq backend 'latex) + (when (eq org-export-current-backend 'latex) (replace-match (format "\\index{%s}" entry) t t)) (save-excursion (ignore-errors (org-back-to-heading t)) diff --git a/lisp/org-special-blocks.el b/lisp/org-special-blocks.el index 54fb6cb..f253787 100644 --- a/lisp/org-special-blocks.el +++ b/lisp/org-special-blocks.el @@ -45,11 +45,12 @@ by org-special-blocks. These blocks will presumably be interpreted by other mechanisms.") -(defvar backend) ; dynamically scoped +(defvar org-export-current-backend) ; dynamically scoped (defun org-special-blocks-make-special-cookies () "Adds special cookies when #+begin_foo and #+end_foo tokens are seen. This is run after a few special cases are taken care of." - (when (or (eq backend 'html) (eq backend 'latex)) + (when (or (eq org-export-current-backend 'html) + (eq org-export-current-backend 'latex)) (goto-char (point-min)) (while (re-search-forward "^[ \t]*#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t) (unless (org-string-match-p org-special-blocks-ignore-regexp (match-string 2)) > > Thanks!