From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: [PATCH 4/5] Simplify org-export-format-source-code-or-example Date: Thu, 23 Jun 2011 21:26:37 +0530 Message-ID: <81sjr07d8q.fsf@gmail.com> References: <81aad88s5j.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZmGD-0006mf-Pm for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:56:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QZmGB-0003Ue-VQ for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:56:05 -0400 Received: from mail-pv0-f169.google.com ([74.125.83.169]:35738) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QZmGB-0003UV-HK for emacs-orgmode@gnu.org; Thu, 23 Jun 2011 11:56:03 -0400 Received: by pvc12 with SMTP id 12so1485510pvc.0 for ; Thu, 23 Jun 2011 08:56:02 -0700 (PDT) In-Reply-To: <81aad88s5j.fsf@gmail.com> (Jambunathan K.'s message of "Thu, 23 Jun 2011 21:19:12 +0530") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain PATCH-4/5 org-odt compatibility patch Addtional Note: Diff looks primarily because of un-indentation. Effective changes are just couple of lines. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0004-Simplify-org-export-format-source-code-or-example.patch >From 923402f12f30a39d54e16c0b105db2b1f20c2a7c Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 23 Jun 2011 12:06:33 +0530 Subject: [PATCH 4/5] Simplify org-export-format-source-code-or-example. * lisp/org-exp.el (org-export-format-source-code-or-example): Simplify. Also add `org-native-text' as a text property to the formatted text and throw error for unknown backends. --- lisp/org-exp.el | 142 +++++++++++++++++++++++++++---------------------------- 1 files changed, 70 insertions(+), 72 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 5008b65..83216dc 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2540,12 +2540,9 @@ INDENT was the original indentation of the block." cont rpllbl fmt)) ((eq org-export-current-backend 'docbook) (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt)) - (concat "\n#+BEGIN_DOCBOOK\n" - (org-add-props (concat "\n") - '(org-protected t org-example t)) - "#+END_DOCBOOK\n")) + (concat "\n")) ((eq org-export-current-backend 'html) ;; We are exporting to HTML (when lang @@ -2615,78 +2612,79 @@ INDENT was the original indentation of the block." (setq rtn (org-export-number-lines rtn 1 1 num cont rpllbl fmt))) (if (string-match "\\(\\`<[^>]*>\\)\n" rtn) (setq rtn (replace-match "\\1" t nil rtn))) - (concat "\n#+BEGIN_HTML\n" (org-add-props rtn '(org-protected t org-example t)) "\n#+END_HTML\n\n")) + rtn) ((eq org-export-current-backend 'latex) (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt)) - (concat - "#+BEGIN_LaTeX\n" - (org-add-props - (cond - ((and lang org-export-latex-listings) - (flet ((make-option-string - (pair) - (concat (first pair) - (if (> (length (second pair)) 0) - (concat "=" (second pair)))))) - (let* ((lang-sym (intern lang)) - (minted-p (eq org-export-latex-listings 'minted)) - (listings-p (not minted-p)) - (backend-lang - (or (cadr - (assq - lang-sym - (cond - (minted-p org-export-latex-minted-langs) - (listings-p org-export-latex-listings-langs)))) - lang)) - (custom-environment - (cadr - (assq - lang-sym - org-export-latex-custom-lang-environments)))) - (concat - (when (and listings-p (not custom-environment)) - (format - "\\lstset{%s}\n" - (mapconcat - #'make-option-string - (append org-export-latex-listings-options - `(("language" ,backend-lang))) ","))) - (when (and caption org-export-latex-listings-w-names) - (format - "\n%s $\\equiv$ \n" - (replace-regexp-in-string "_" "\\\\_" caption))) - (cond - (custom-environment - (format "\\begin{%s}\n%s\\end{%s}\n" - custom-environment rtn custom-environment)) - (listings-p - (format "\\begin{%s}\n%s\\end{%s}\n" - "lstlisting" rtn "lstlisting")) - (minted-p - (format - "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n" - (mapconcat #'make-option-string - org-export-latex-minted-options ",") - backend-lang rtn))))))) - (t (concat (car org-export-latex-verbatim-wrap) - rtn (cdr org-export-latex-verbatim-wrap)))) - '(org-protected t org-example t)) - "#+END_LaTeX\n")) + (cond + ((and lang org-export-latex-listings) + (flet ((make-option-string + (pair) + (concat (first pair) + (if (> (length (second pair)) 0) + (concat "=" (second pair)))))) + (let* ((lang-sym (intern lang)) + (minted-p (eq org-export-latex-listings 'minted)) + (listings-p (not minted-p)) + (backend-lang + (or (cadr + (assq + lang-sym + (cond + (minted-p org-export-latex-minted-langs) + (listings-p org-export-latex-listings-langs)))) + lang)) + (custom-environment + (cadr + (assq + lang-sym + org-export-latex-custom-lang-environments)))) + (concat + (when (and listings-p (not custom-environment)) + (format + "\\lstset{%s}\n" + (mapconcat + #'make-option-string + (append org-export-latex-listings-options + `(("language" ,backend-lang))) ","))) + (when (and caption org-export-latex-listings-w-names) + (format + "\n%s $\\equiv$ \n" + (replace-regexp-in-string "_" "\\\\_" caption))) + (cond + (custom-environment + (format "\\begin{%s}\n%s\\end{%s}\n" + custom-environment rtn custom-environment)) + (listings-p + (format "\\begin{%s}\n%s\\end{%s}\n" + "lstlisting" rtn "lstlisting")) + (minted-p + (format + "\\begin{minted}[%s]{%s}\n%s\\end{minted}\n" + (mapconcat #'make-option-string + org-export-latex-minted-options ",") + backend-lang rtn))))))) + (t (concat (car org-export-latex-verbatim-wrap) + rtn (cdr org-export-latex-verbatim-wrap))))) ((eq org-export-current-backend 'ascii) ;; This is not HTML or LaTeX, so just make it an example. (setq rtn (org-export-number-lines rtn 0 0 num cont rpllbl fmt)) (concat caption "\n" - "#+BEGIN_ASCII\n" - (org-add-props - (concat - (mapconcat - (lambda (l) (concat " " l)) - (org-split-string rtn "\n") - "\n") - "\n") - '(org-protected t org-example t)) - "#+END_ASCII\n")))) + (concat + (mapconcat + (lambda (l) (concat " " l)) + (org-split-string rtn "\n") + "\n") + "\n") + )) + (t + (error "Don't know how to markup source or example block in %s" + (upcase backend-name))))) + (setq rtn + (concat + "\n#+BEGIN_" backend-name "\n" + (org-add-props rtn + '(org-protected t org-example t org-native-text t)) + "\n#+END_" backend-name "\n\n")) (org-add-props rtn nil 'original-indentation indent)))) (defun org-export-number-lines (text &optional skip1 skip2 number cont -- 1.7.2.3 --=-=-=--