From: Jambunathan K <kjambunathan@gmail.com> To: emacs-orgmode@gnu.org Subject: [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends Date: Thu, 23 Jun 2011 21:23:26 +0530 [thread overview] Message-ID: <811uyk8ryh.fsf@gmail.com> (raw) In-Reply-To: <81aad88s5j.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 23 Jun 2011 21:19:12 +0530") [-- Attachment #1: Type: text/plain, Size: 35 bytes --] PATCH-2/5: org-odt compatibility [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: 0002-org-exp.el-Allow-easy-plugging-in-of-new-backends.patch --] [-- Type: text/x-patch, Size: 4164 bytes --] From 2bc4854fb86a96b69e53db00603e0b2f8f47fe08 Mon Sep 17 00:00:00 2001 From: Jambunathan K <kjambunathan@gmail.com> Date: Thu, 23 Jun 2011 02:16:30 +0530 Subject: [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends. * lisp/org-exp.el (org-export-backends): New variable. (org-export-select-backend-specific-text): Use above variable. Also mark text between #+BACKEND and #+BEGIN_BACKEND...#+END_BACKEND with org-native-text property. This text property is currently used only by the new line-oriented generic exporter (which is not yet part of the repo). --- lisp/org-exp.el | 41 +++++++++++++++++++++-------------------- 1 files changed, 21 insertions(+), 20 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 3f4c468..96554a3 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -1661,52 +1661,53 @@ from the buffer." (add-text-properties beg (if (bolp) (1- (point)) (point)) '(org-protected t))))) +(defvar org-export-backends + '(docbook html beamer ascii latex) + "List of Org supported export backends.") + (defun org-export-select-backend-specific-text () - (let ((formatters - '((docbook "DOCBOOK" "BEGIN_DOCBOOK" "END_DOCBOOK") - (html "HTML" "BEGIN_HTML" "END_HTML") - (beamer "BEAMER" "BEGIN_BEAMER" "END_BEAMER") - (ascii "ASCII" "BEGIN_ASCII" "END_ASCII") - (latex "LaTeX" "BEGIN_LaTeX" "END_LaTeX"))) + (let ((formatters org-export-backends) (case-fold-search t) - fmt beg beg-content end end-content ind) + backend backend-name beg beg-content end end-content ind) (while formatters - (setq fmt (pop formatters)) - ;; Handle #+backend: stuff + (setq backend (pop formatters) + backend-name (symbol-name backend)) + + ;; Handle #+BACKEND: stuff (goto-char (point-min)) - (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" (cadr fmt) + (while (re-search-forward (concat "^\\([ \t]*\\)#\\+" backend-name ":[ \t]*\\(.*\\)") nil t) - (if (not (eq (car fmt) org-export-current-backend)) + (if (not (eq backend org-export-current-backend)) (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))) (replace-match "\\1\\2" t) (add-text-properties (point-at-bol) (min (1+ (point-at-eol)) (point-max)) - `(org-protected t original-indentation ,ind)))) - ;; Delete #+attr_Backend: stuff of another backend. Those + `(org-protected t original-indentation ,ind org-native-text t)))) + ;; Delete #+ATTR_BACKEND: stuff of another backend. Those ;; matching the current backend will be taken care of by ;; `org-export-attach-captions-and-attributes' (goto-char (point-min)) - (while (re-search-forward (concat "^\\([ \t]*\\)#\\+attr_" (cadr fmt) + (while (re-search-forward (concat "^\\([ \t]*\\)#\\+ATTR_" backend-name ":[ \t]*\\(.*\\)") nil t) (setq ind (org-get-indentation)) - (when (not (eq (car fmt) org-export-current-backend)) + (when (not (eq backend org-export-current-backend)) (delete-region (point-at-bol) (min (1+ (point-at-eol)) (point-max))))) - ;; Handle #+begin_backend and #+end_backend stuff + ;; Handle #+BEGIN_BACKEND and #+END_BACKEND stuff (goto-char (point-min)) - (while (re-search-forward (concat "^[ \t]*#\\+" (caddr fmt) "\\>.*\n?") + (while (re-search-forward (concat "^[ \t]*#\\+BEGIN_" backend-name "\\>.*\n?") nil t) (setq beg (match-beginning 0) beg-content (match-end 0)) (setq ind (save-excursion (goto-char beg) (org-get-indentation))) - (when (re-search-forward (concat "^[ \t]*#\\+" (cadddr fmt) "\\>.*\n?") + (when (re-search-forward (concat "^[ \t]*#\\+END_" backend-name "\\>.*\n?") nil t) (setq end (match-end 0) end-content (match-beginning 0)) - (if (eq (car fmt) org-export-current-backend) + (if (eq backend org-export-current-backend) ;; yes, keep this (progn (add-text-properties beg-content end-content - `(org-protected t original-indentation ,ind)) + `(org-protected t original-indentation ,ind org-native-text t)) (delete-region (match-beginning 0) (match-end 0)) (save-excursion (goto-char beg) -- 1.7.2.3
next prev parent reply other threads:[~2011-06-23 15:52 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-06-23 15:49 org-odt compatibility patches Jambunathan K 2011-06-23 15:52 ` [PATCH 1/5] org-export: Reserve a slot for OpenDocumentExporter Jambunathan K 2011-06-23 15:53 ` Jambunathan K [this message] 2011-06-23 15:54 ` [PATCH 3/5] Support custom formatters for marking up source or example blocks Jambunathan K 2011-06-23 15:56 ` [PATCH 4/5] Simplify org-export-format-source-code-or-example Jambunathan K 2011-06-23 15:57 ` [PATCH 5/5] Control insertion point for footnote definitions during pre-process Jambunathan K 2011-06-24 8:05 ` org-odt compatibility patches Carsten Dominik 2011-06-24 8:42 ` Jambunathan K 2011-06-24 8:55 ` Jambunathan K 2011-06-24 10:52 ` Bastien 2011-06-24 10:47 ` Bastien 2011-06-24 10:49 ` Bastien 2011-06-25 5:19 ` Jambunathan K 2011-06-25 8:54 ` Bastien
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=811uyk8ryh.fsf@gmail.com \ --to=kjambunathan@gmail.com \ --cc=emacs-orgmode@gnu.org \ --subject='Re: [PATCH 2/5] org-exp.el: Allow easy plugging in of new backends' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this 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).