Browse Source

Install new exporter into Org innards

* contrib/lisp/org-mime.el (org-mime-htmlize, org-mime-compose): Use
  new exporter.
* lisp/ob-haskell.el (org-babel-haskell-export-to-lhs): Use new
  exporter.
* lisp/ob-latex.el (org-babel-execute:latex): Use new exporter.
* lisp/ob-org.el (org-babel-execute:org): Use new exporter.
* lisp/org-agenda.el (org-agenda-menu, org-agenda-write): Use new
  iCalendar export back-end.
* lisp/org-table.el (org-table-export, orgtbl-export): Remove
  dependency on `org-exp' library.
(org-table-clean-before-export): New function.
(org-table-colgroup-info): New variable.
(orgtbl-to-html): Use to new HTML export back-end.
* lisp/org.el (org-modules): Remove modules relative to obsolete
  export framework and add those relative to the new one.
(org-create-formula-image-with-dvipng, org-format-latex
org-create-formula-image-with-imagemagick): Use new exporter.
(org-indent-line): INCLUDE keywords are indented like regular
keywords.
(org-mode-map): Bind C-c C-e to new export dispatcher.
(org-menu): Install new exporter in menu.
Nicolas Goaziou 7 years ago
parent
commit
0a01e52aa1
7 changed files with 186 additions and 116 deletions
  1. 20 13
      contrib/lisp/org-mime.el
  2. 8 3
      lisp/ob-haskell.el
  3. 15 15
      lisp/ob-latex.el
  4. 6 5
      lisp/ob-org.el
  5. 3 9
      lisp/org-agenda.el
  6. 75 23
      lisp/org-table.el
  7. 59 48
      lisp/org.el

+ 20 - 13
contrib/lisp/org-mime.el

@@ -57,6 +57,9 @@
 ;;; Code:
 (require 'cl)
 
+(declare-function org-export-string-as "ox"
+		  (string backend &optional body-only ext-plist))
+
 (defcustom org-mime-use-property-inheritance nil
   "Non-nil means al MAIL_ properties apply also for sublevels."
   :group 'org-mime
@@ -195,6 +198,8 @@ and images in a multipart/related part."
 html using `org-mode'.  If called with an active region only
 export that region, otherwise export the entire body."
   (interactive "P")
+  (require 'ox-org)
+  (require 'ox-html)
   (let* ((region-p (org-region-active-p))
          (html-start (or (and region-p (region-beginning))
                          (save-excursion
@@ -208,7 +213,7 @@ export that region, otherwise export the entire body."
 			   (buffer-substring html-start html-end)))
          (tmp-file (make-temp-name (expand-file-name
 				    "mail" temporary-file-directory)))
-         (body (org-export-string raw-body 'org (file-name-directory tmp-file)))
+         (body (org-export-string-as raw-body 'org t))
          ;; because we probably don't want to skip part of our mail
          (org-export-skip-text-before-1st-heading nil)
          ;; because we probably don't want to export a huge style file
@@ -220,8 +225,7 @@ export that region, otherwise export the entire body."
          ;; to hold attachments for inline html images
          (html-and-images
           (org-mime-replace-images
-           (org-export-string raw-body 'html (file-name-directory tmp-file))
-           tmp-file))
+	   (org-export-string-as raw-body 'html t) tmp-file))
          (html-images (unless arg (cdr html-and-images)))
          (html (org-mime-apply-html-hook
                 (if arg
@@ -296,26 +300,29 @@ export that region, otherwise export the entire body."
     (let ((fmt (if (symbolp fmt) fmt (intern fmt))))
       (cond
        ((eq fmt 'org)
-	(insert (org-export-string (org-babel-trim (bhook body 'org)) 'org)))
+	(require 'ox-org)
+	(insert (org-export-string-as
+		 (org-babel-trim (bhook body 'org)) 'org t)))
        ((eq fmt 'ascii)
-	(insert (org-export-string
-		 (concat "#+Title:\n" (bhook body 'ascii)) 'ascii)))
+	(require 'ox-ascii)
+	(insert (org-export-string-as
+		 (concat "#+Title:\n" (bhook body 'ascii)) 'ascii t)))
        ((or (eq fmt 'html) (eq fmt 'html-ascii))
+	(require 'ox-ascii)
+	(require 'ox-org)
 	(let* ((org-link-file-path-type 'absolute)
 	       ;; we probably don't want to export a huge style file
 	       (org-export-htmlize-output-type 'inline-css)
-	       (html-and-images (org-mime-replace-images
-				 (org-export-string
-				  (bhook body 'html)
-				  'html (file-name-nondirectory file))
-				 file))
+	       (html-and-images
+		(org-mime-replace-images
+		 (org-export-string-as (bhook body 'html) 'html t) file))
 	       (images (cdr html-and-images))
 	       (html (org-mime-apply-html-hook (car html-and-images))))
 	  (insert (org-mime-multipart
-		   (org-export-string
+		   (org-export-string-as
 		    (org-babel-trim
 		     (bhook body (if (eq fmt 'html) 'org 'ascii)))
-		    (if (eq fmt 'html) 'org 'ascii))
+		    (if (eq fmt 'html) 'org 'ascii) t)
 		   html)
 		  (mapconcat 'identity images "\n"))))))))
 

+ 8 - 3
lisp/ob-haskell.el

@@ -146,8 +146,9 @@ specifying a variable of the same value."
     (format "%S" var)))
 
 (defvar org-src-preserve-indentation)
-(declare-function org-export-as-latex "org-latex"
-		  (arg &optional ext-plist to-buffer body-only pub-dir))
+(declare-function org-export-to-file "ox"
+		  (backend file
+			   &optional subtreep visible-only body-only ext-plist))
 (defun org-babel-haskell-export-to-lhs (&optional arg)
   "Export to a .lhs file with all haskell code blocks escaped.
 When called with a prefix argument the resulting
@@ -191,7 +192,11 @@ constructs (header arguments, no-web syntax etc...) are ignored."
         (indent-code-rigidly (match-beginning 0) (match-end 0) indentation)))
     (save-excursion
       ;; export to latex w/org and save as .lhs
-      (find-file tmp-org-file) (funcall 'org-export-as-latex nil)
+      (require 'ox-latex)
+      (find-file tmp-org-file)
+      ;; Ensure we do not clutter kill ring with incomplete results.
+      (let (org-export-copy-to-kill-ring)
+	(org-export-to-file 'latex tmp-tex-file))
       (kill-buffer nil)
       (delete-file tmp-org-file)
       (find-file tmp-tex-file)

+ 15 - 15
lisp/ob-latex.el

@@ -35,7 +35,7 @@
 (declare-function org-create-formula-image "org" (string tofile options buffer))
 (declare-function org-splice-latex-header "org"
 		  (tpl def-pkg pkg snippets-p &optional extra))
-(declare-function org-export-latex-fix-inputenc "org-latex" ())
+(declare-function org-latex--guess-inputenc "ox-latex" (header))
 (defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("latex" . "tex"))
 
@@ -89,20 +89,21 @@ This function is called by `org-babel-execute-src-block'."
           (org-create-formula-image
            body out-file org-format-latex-options in-buffer))
          ((or (string-match "\\.pdf$" out-file) imagemagick)
-	  (require 'org-latex)
+	  (require 'ox-latex)
 	  (with-temp-file tex-file
 	    (insert
-	     (org-splice-latex-header
-	      org-format-latex-header
-	      (delq
-	       nil
-	       (mapcar
-		(lambda (el)
-		  (unless (and (listp el) (string= "hyperref" (cadr el)))
-		    el))
-		org-export-latex-default-packages-alist))
-	      org-export-latex-packages-alist
-	      org-format-latex-header-extra)
+	     (org-latex--guess-inputenc
+	      (org-splice-latex-header
+	       org-format-latex-header
+	       (delq
+		nil
+		(mapcar
+		 (lambda (el)
+		   (unless (and (listp el) (string= "hyperref" (cadr el)))
+		     el))
+		 org-export-latex-default-packages-alist))
+	       org-export-latex-packages-alist
+	       org-format-latex-header-extra))
 	     (if fit "\n\\usepackage[active, tightpage]{preview}\n" "")
 	     (if border (format "\\setlength{\\PreviewBorder}{%s}" border) "")
 	     (if height (concat "\n" (format "\\pdfpageheight %s" height)) "")
@@ -119,8 +120,7 @@ This function is called by `org-babel-execute-src-block'."
 	     (if fit
 		 (concat "\n\\begin{document}\n\\begin{preview}\n" body
 			 "\n\\end{preview}\n\\end{document}\n")
-	       (concat "\n\\begin{document}\n" body "\n\\end{document}\n")))
-	    (org-export-latex-fix-inputenc))
+	       (concat "\n\\begin{document}\n" body "\n\\end{document}\n"))))
           (when (file-exists-p out-file) (delete-file out-file))
 	  (let ((transient-pdf-file (org-babel-latex-tex-to-pdf tex-file)))
 	    (cond

+ 6 - 5
lisp/ob-org.el

@@ -29,7 +29,8 @@
 ;;; Code:
 (require 'ob)
 
-(declare-function org-export-string "org-exp" (string fmt &optional dir))
+(declare-function org-export-string-as "ox"
+		  (string backend &optional body-only ext-plist))
 
 (defvar org-babel-default-header-args:org
   '((:results . "raw silent") (:exports . "code"))
@@ -53,10 +54,10 @@ This function is called by `org-babel-execute-src-block'."
 	(body (org-babel-expand-body:org
 	       (replace-regexp-in-string "^," "" body) params)))
     (cond
-     ((member "latex" result-params) (org-export-string
-				      (concat "#+Title: \n" body) "latex"))
-     ((member "html" result-params)  (org-export-string body "html"))
-     ((member "ascii" result-params) (org-export-string body "ascii"))
+     ((member "latex" result-params)
+      (org-export-string-as (concat "#+Title: \n" body) 'latex t))
+     ((member "html" result-params) (org-export-string-as  body 'html t))
+     ((member "ascii" result-params) (org-export-string-as body 'ascii t))
      (t body))))
 
 (defun org-babel-prep-session:org (session params)

+ 3 - 9
lisp/org-agenda.el

@@ -2363,7 +2363,7 @@ The following commands are available:
      ["Holidays" org-agenda-holidays (org-agenda-check-type nil 'agenda 'timeline)]
      ["Convert" org-agenda-convert-date (org-agenda-check-type nil 'agenda 'timeline)]
      "--"
-     ["Create iCalendar File" org-export-icalendar-combine-agenda-files t])
+     ["Create iCalendar File" org-icalendar-combine-agenda-files t])
     "--"
     ["Undo Remote Editing" org-agenda-undo org-agenda-undo-list]
     "--"
@@ -3349,14 +3349,8 @@ If AGENDA-BUFFER-NAME, use this as the buffer name for the agenda to write."
 	       (delete-file (concat (file-name-sans-extension file) ".ps"))
 	       (message "PDF written to %s" file))
 	      ((string-match "\\.ics\\'" file)
-	       (require 'org-icalendar)
-	       (let ((org-agenda-marker-table
-		      (org-create-marker-find-array
-		       (org-agenda-collect-markers)))
-		     (org-icalendar-verify-function 'org-check-agenda-marker-table)
-		     (org-combined-agenda-icalendar-file file))
-		 (apply 'org-export-icalendar 'combine
-			(org-agenda-files nil 'ifmode))))
+	       (require 'ox-icalendar)
+	       (org-icalendar-export-current-agenda (expand-file-name file)))
 	      (t
 	       (let ((bs (buffer-string)))
 		 (find-file file)

+ 75 - 23
lisp/org-table.el

@@ -38,9 +38,8 @@
   (require 'cl))
 (require 'org)
 
-(declare-function org-table-clean-before-export "org-exp"
-		  (lines &optional maybe-quoted))
-(declare-function org-format-org-table-html "org-html" (lines &optional splice))
+(declare-function org-export-string-as "ox"
+		  (string backend &optional body-only ext-plist))
 (declare-function aa2u "ext:ascii-art-to-unicode" ())
 (defvar orgtbl-mode) ; defined below
 (defvar orgtbl-mode-menu) ; defined when orgtbl mode get initialized
@@ -419,6 +418,70 @@ available parameters."
 			 (org-split-string (match-string 1 line)
 					   "[ \t]*|[ \t]*")))))))
 
+(defvar org-table-colgroup-info nil)	; Dynamically scoped.
+(defun org-table-clean-before-export (lines &optional maybe-quoted)
+  "Check if the table has a marking column.
+If yes remove the column and the special lines."
+  (setq org-table-colgroup-info nil)
+  (if (memq nil
+	    (mapcar
+	     (lambda (x) (or (string-match "^[ \t]*|-" x)
+			     (string-match
+			      (if maybe-quoted
+				  "^[ \t]*| *\\\\?\\([\#!$*_^ /]\\) *|"
+				"^[ \t]*| *\\([\#!$*_^ /]\\) *|")
+			      x)))
+	     lines))
+      ;; No special marking column
+      (progn
+	(setq org-table-clean-did-remove-column nil)
+	(delq nil
+	      (mapcar
+	       (lambda (x)
+		 (cond
+		  ((org-table-colgroup-line-p x)
+		   ;; This line contains colgroup info, extract it
+		   ;; and then discard the line
+		   (setq org-table-colgroup-info
+			 (mapcar (lambda (x)
+				   (cond ((member x '("<" "&lt;")) :start)
+					 ((member x '(">" "&gt;")) :end)
+					 ((member x '("<>" "&lt;&gt;")) :startend)))
+				 (org-split-string x "[ \t]*|[ \t]*")))
+		   nil)
+		  ((org-table-cookie-line-p x)
+		   ;; This line contains formatting cookies, discard it
+		   nil)
+		  (t x)))
+	       lines)))
+    ;; there is a special marking column
+    (setq org-table-clean-did-remove-column t)
+    (delq nil
+	  (mapcar
+	   (lambda (x)
+	     (cond
+	      ((org-table-colgroup-line-p x)
+	       ;; This line contains colgroup info, extract it
+	       ;; and then discard the line
+	       (setq org-table-colgroup-info
+		     (mapcar (lambda (x)
+			       (cond ((member x '("<" "&lt;")) :start)
+				     ((member x '(">" "&gt;")) :end)
+				     ((member x '("<>" "&lt;&gt;")) :startend)))
+			     (cdr (org-split-string x "[ \t]*|[ \t]*"))))
+	       nil)
+	      ((org-table-cookie-line-p x)
+	       ;; This line contains formatting cookies, discard it
+	       nil)
+	      ((string-match "^[ \t]*| *\\([!_^/$]\\|\\\\\\$\\) *|" x)
+	       ;; ignore this line
+	       nil)
+	      ((or (string-match "^\\([ \t]*\\)|-+\\+" x)
+		   (string-match "^\\([ \t]*\\)|[^|]*|" x))
+	       ;; remove the first column
+	       (replace-match "\\1|" t nil x))))
+	   lines))))
+
 (defconst org-table-translate-regexp
   (concat "\\(" "@[-0-9I$]+" "\\|" "[a-zA-Z]\\{1,2\\}\\([0-9]+\\|&\\)" "\\)")
   "Match a reference that needs translation, for reference display.")
@@ -579,9 +642,7 @@ whether it is set locally or up in the hierarchy, then on the
 extension of the given file name, and finally on the variable
 `org-table-export-default-format'."
   (interactive)
-  (unless (org-at-table-p)
-    (error "No table at point"))
-  (require 'org-exp)
+  (unless (org-at-table-p) (error "No table at point"))
   (org-table-align) ;; make sure we have everything we need
   (let* ((beg (org-table-begin))
 	 (end (org-table-end))
@@ -4296,7 +4357,6 @@ overwritten, and the table is not marked as requiring realignment."
   "Regular expression matching exponentials as produced by calc.")
 
 (defun orgtbl-export (table target)
-  (require 'org-exp)
   (let ((func (intern (concat "orgtbl-to-" (symbol-name target))))
 	(lines (org-split-string table "[ \t]*\n[ \t]*"))
 	org-table-last-alignment org-table-last-column-widths
@@ -4745,22 +4805,14 @@ Currently this function recognizes the following parameters:
 The general parameters :skip and :skipcols have already been applied when
 this function is called.  The function does *not* use `orgtbl-to-generic',
 so you cannot specify parameters for it."
-  (let* ((splicep (plist-get params :splice))
-	 (html-table-tag org-export-html-table-tag)
-	 html)
-    ;; Just call the formatter we already have
-    ;; We need to make text lines for it, so put the fields back together.
-    (setq html (org-format-org-table-html
-		(mapcar
-		 (lambda (x)
-		   (if (eq x 'hline)
-		       "|----+----|"
-		     (concat "| " (mapconcat 'org-html-expand x " | ") " |")))
-		 table)
-		splicep))
-    (if (string-match "\n+\\'" html)
-	(setq html (replace-match "" t t html)))
-    html))
+  (require 'ox-html)
+  (let ((output (org-export-string-as
+		 (orgtbl-to-orgtbl table nil) 'html t '(:with-tables t))))
+    (if (not (plist-get params :splice)) output
+      (org-trim
+       (replace-regexp-in-string
+	"\\`<table .*>\n" ""
+	(replace-regexp-in-string "</table>\n*\\'" "" output))))))
 
 ;;;###autoload
 (defun orgtbl-to-texinfo (table params)

+ 59 - 48
lisp/org.el

@@ -125,7 +125,7 @@ Stars are put in group 1 and the trimmed body in group 2.")
 
 (declare-function orgtbl-mode "org-table" (&optional arg))
 (declare-function org-clock-out "org-clock" (&optional switch-to-state fail-quietly at-time))
-(declare-function org-beamer-mode "org-beamer" ())
+(declare-function org-beamer-mode "ox-beamer" ())
 (declare-function org-table-edit-field "org-table" (arg))
 (declare-function org-table-justify-field-maybe "org-table" (&optional new))
 (declare-function org-id-get-create "org-id" (&optional force))
@@ -140,19 +140,28 @@ Stars are put in group 1 and the trimmed body in group 2.")
 (autoload 'org-element-at-point "org-element")
 (autoload 'org-element-type "org-element")
 
+(declare-function org-element--parse-objects "org-element"
+		  (beg end acc restriction))
 (declare-function org-element-at-point "org-element" (&optional keep-trail))
-(declare-function org-element-type "org-element" (element))
-(declare-function org-element-context "org-element" (&optional element))
 (declare-function org-element-contents "org-element" (element))
+(declare-function org-element-context "org-element" (&optional element))
+(declare-function org-element-interpret-data "org-element"
+		  (data &optional parent))
+(declare-function org-element-map "org-element"
+		  (data types fun &optional info first-match no-recursion))
+(declare-function org-element-nested-p "org-element" (elem-a elem-b))
+(declare-function org-element-parse-buffer "org-element"
+		  (&optional granularity visible-only))
 (declare-function org-element-property "org-element" (property element))
 (declare-function org-element-put-property "org-element"
 		  (element property value))
-(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion))
-(declare-function org-element-nested-p "org-element" (elem-a elem-b))
 (declare-function org-element-swap-A-B "org-element" (elem-a elem-b))
-(declare-function org-element--parse-objects "org-element" (beg end acc restriction))
-(declare-function org-element-parse-buffer "org-element" (&optional granularity visible-only))
-(declare-function org-element-interpret-data "org-element" (data &optional parent))
+(declare-function org-element--parse-objects "org-element"
+		  (beg end acc restriction))
+(declare-function org-element-parse-buffer "org-element"
+		  (&optional granularity visible-only))
+(declare-function org-element-interpret-data "org-element"
+		  (data &optional parent))
 
 ;; load languages based on value of `org-babel-load-languages'
 (defvar org-babel-load-languages)
@@ -325,22 +334,18 @@ When MESSAGE is non-nil, display a message with the version."
   (when (featurep 'org)
     (org-load-modules-maybe 'force)))
 
-(when (org-bound-and-true-p org-modules)
-  (let ((a (member 'org-infojs org-modules)))
-    (and a (setcar a 'org-jsinfo))))
-
-(defcustom org-modules '(org-bbdb org-bibtex org-docview org-gnus org-info org-jsinfo org-irc org-mew org-mhe org-rmail org-vm org-w3m org-wl)
+(defcustom org-modules '(ox-ascii org-bbdb org-bibtex org-docview org-gnus ox-html org-info org-irc ox-latex org-mew org-mhe org-rmail org-vm org-w3m org-wl)
   "Modules that should always be loaded together with org.el.
 If a description starts with <C>, the file is not part of Emacs
-and loading it will require that you have downloaded and properly installed
-the org-mode distribution.
+and loading it will require that you have downloaded and properly
+installed the Org mode distribution.
 
 You can also use this system to load external packages (i.e. neither Org
 core modules, nor modules from the CONTRIB directory).  Just add symbols
 to the end of the list.  If the package is called org-xyz.el, then you need
 to add the symbol `xyz', and the package must have a call to
 
-   (provide 'org-xyz)"
+   \(provide 'org-xyz)"
   :group 'org
   :set 'org-set-modules
   :type
@@ -353,7 +358,16 @@ to add the symbol `xyz', and the package must have a call to
 	(const :tag "   gnus:              Links to GNUS folders/messages" org-gnus)
 	(const :tag "   id:                Global IDs for identifying entries" org-id)
 	(const :tag "   info:              Links to Info nodes" org-info)
-	(const :tag "   jsinfo:            Set up Sebastian Rose's JavaScript org-info.js" org-jsinfo)
+	(const :tag "   ascii              Export buffer to ASCII format" ox-ascii)
+	(const :tag "   beamer             Export buffer to LaTeX Beamer presentation" ox-beamer)
+	(const :tag "   html               Export buffer to HTML format" ox-html)
+	(const :tag "   icalendar          Export buffer to iCalendar format" ox-icalendar)
+	(const :tag "   latex              Export buffer to LaTeX format" ox-latex)
+	(const :tag "   man                Export buffer to MAN format" ox-man)
+	(const :tag "   md                 Export buffer to Markdown format" ox-md)
+	(const :tag "   odt                Export buffer to ODT format" ox-odt)
+	(const :tag "   texinfo            Export buffer to Texinfo format" ox-texinfo)
+	(const :tag "   infojs:            Set up Sebastian Rose's JavaScript org-info.js" ox-jsinfo)
 	(const :tag "   habit:             Track your consistency with habits" org-habit)
 	(const :tag "   inlinetask:        Tasks independent of outline hierarchy" org-inlinetask)
 	(const :tag "   irc:               Links to IRC/ERC chat sessions" org-irc)
@@ -362,18 +376,17 @@ to add the symbol `xyz', and the package must have a call to
 	(const :tag "   mhe:               Links to MHE folders/messages" org-mhe)
 	(const :tag "   protocol:          Intercept calls from emacsclient" org-protocol)
 	(const :tag "   rmail:             Links to RMAIL folders/messages" org-rmail)
-	(const :tag "   special-blocks:    Turn blocks into LaTeX envs and HTML divs" org-special-blocks)
 	(const :tag "   vm:                Links to VM folders/messages" org-vm)
 	(const :tag "   wl:                Links to Wanderlust folders/messages" org-wl)
 	(const :tag "   w3m:               Special cut/paste from w3m to Org-mode." org-w3m)
 	(const :tag "   mouse:             Additional mouse support" org-mouse)
-	(const :tag "   TaskJuggler:       Export tasks to a TaskJuggler project" org-taskjuggler)
 
 	(const :tag "C  annotate-file:     Annotate a file with org syntax" org-annotate-file)
 	(const :tag "C  bookmark:          Org-mode links to bookmarks" org-bookmark)
 	(const :tag "C  checklist:         Extra functions for checklists in repeated tasks" org-checklist)
 	(const :tag "C  choose:            Use TODO keywords to mark decisions states" org-choose)
 	(const :tag "C  collector:         Collect properties into tables" org-collector)
+	(const :tag "C  confluence         Export buffer to Confluence Wiki format" ox-confluence)
 	(const :tag "C  depend:            TODO dependencies for Org-mode\n\t\t\t(PARTIALLY OBSOLETE, see built-in dependency support))" org-depend)
 	(const :tag "C  drill:             Flashcards and spaced repetition for Org-mode" org-drill)
 	(const :tag "C  elisp-symbol:      Org-mode links to emacs-lisp symbols" org-elisp-symbol)
@@ -383,11 +396,13 @@ to add the symbol `xyz', and the package must have a call to
 	(const :tag "C  expiry:            Expiry mechanism for Org-mode entries" org-expiry)
 	(const :tag "C  exp-bibtex:        Export citations using BibTeX" org-exp-bibtex)
 	(const :tag "C  git-link:          Provide org links to specific file version" org-git-link)
+	(const :tag "C  groff              Export buffer to Groff format" ox-groff)
 	(const :tag "C  interactive-query: Interactive modification of tags query\n\t\t\t(PARTIALLY OBSOLETE, see secondary filtering)" org-interactive-query)
 
         (const :tag "C  invoice:           Help manage client invoices in Org-mode" org-invoice)
 
 	(const :tag "C  jira:              Add a jira:ticket protocol to Org-mode" org-jira)
+	(const :tag "C  koma-letter        Export buffer to KOMA Scrlttrl2 format" ox-koma-letter)
 	(const :tag "C  learn:             SuperMemo's incremental learning algorithm" org-learn)
 	(const :tag "C  mairix:            Hook mairix search into Org-mode for different MUAs" org-mairix)
 	(const :tag "C  notmuch:           Provide org links to notmuch searches or messages" org-notmuch)
@@ -4034,7 +4049,7 @@ Normal means, no org-mode-specific context."
 (declare-function org-indent-mode "org-indent" (&optional arg))
 (declare-function parse-time-string "parse-time" (string))
 (declare-function org-attach-reveal "org-attach" (&optional if-exists))
-(declare-function org-export-latex-fix-inputenc "org-latex" ())
+(declare-function org-latex--guess-inputenc "ox-latex" (header))
 (declare-function orgtbl-send-table "org-table" (&optional maybe))
 (defvar remember-data-file)
 (defvar texmathp-why)
@@ -4146,11 +4161,11 @@ If TABLE-TYPE is non-nil, also check for table.el-type tables."
 	(re-search-forward org-table-any-border-regexp nil 1))))
   (unless quietly (message "Mapping tables: done")))
 
-;; Declare and autoload functions from org-exp.el  & Co
+;; Declare and autoload functions from ox.el and al.
 
-(declare-function org-default-export-plist "org-exp")
-(declare-function org-infile-export-plist "org-exp")
-(declare-function org-get-current-options "org-exp")
+(declare-function org-export-get-environment "ox"
+		  (&optional backend subtreep ext-plist))
+(declare-function org-latex--guess-inputenc "ox-latex" (header))
 
 ;; Declare and autoload functions from org-agenda.el
 
@@ -17752,7 +17767,7 @@ Some of the options can be changed using the variable
 	 (matchers (plist-get opt :matchers))
 	 (re-list org-latex-regexps)
 	 (org-format-latex-header-extra
-	  (plist-get (org-infile-export-plist) :latex-header-extra))
+	  (plist-get (org-export-get-environment) :latex-header-extra))
 	 (cnt 0) txt hash link beg end re e checkdir
 	 string
 	 m n block-type block linkfile movefile ov)
@@ -17986,7 +18001,6 @@ share a good deal of logic."
 ;; This function borrows from Ganesh Swami's latex2png.el
 (defun org-create-formula-image-with-dvipng (string tofile options buffer)
   "This calls dvipng."
-  (require 'org-latex)
   (let* ((tmpdir (if (featurep 'xemacs)
 		     (temp-directory)
 		   temporary-file-directory))
@@ -18009,14 +18023,14 @@ share a good deal of logic."
     (if (eq bg 'default) (setq bg (org-dvipng-color :background))
       (unless (string= bg "Transparent") (setq bg (org-dvipng-color-format bg))))
     (with-temp-file texfile
-      (insert (org-splice-latex-header
-	       org-format-latex-header
-	       org-export-latex-default-packages-alist
-	       org-export-latex-packages-alist t
-	       org-format-latex-header-extra))
-      (insert "\n\\begin{document}\n" string "\n\\end{document}\n")
-      (require 'org-latex)
-      (org-export-latex-fix-inputenc))
+      (require 'ox-latex)
+      (insert (org-latex--guess-inputenc
+	       (org-splice-latex-header
+		org-format-latex-header
+		org-export-latex-default-packages-alist
+		org-export-latex-packages-alist t
+		org-format-latex-header-extra)))
+      (insert "\n\\begin{document}\n" string "\n\\end{document}\n"))
     (let ((dir default-directory))
       (condition-case nil
 	  (progn
@@ -18056,7 +18070,6 @@ share a good deal of logic."
 (defvar org-latex-to-pdf-process) ;; Defined in org-latex.el
 (defun org-create-formula-image-with-imagemagick (string tofile options buffer)
   "This calls convert, which is included into imagemagick."
-  (require 'org-latex)
   (let* ((tmpdir (if (featurep 'xemacs)
 		     (temp-directory)
 		   temporary-file-directory))
@@ -18080,11 +18093,13 @@ share a good deal of logic."
       (setq bg (org-latex-color-format
 		(if (string= bg "Transparent") "white" bg))))
     (with-temp-file texfile
-      (insert (org-splice-latex-header
-	       org-format-latex-header
-	       org-export-latex-default-packages-alist
-	       org-export-latex-packages-alist t
-	       org-format-latex-header-extra))
+      (require 'ox-latex)
+      (insert (org-latex--guess-inputenc
+	       (org-splice-latex-header
+		org-format-latex-header
+		org-export-latex-default-packages-alist
+		org-export-latex-packages-alist t
+		org-format-latex-header-extra)))
       (insert "\n\\begin{document}\n"
 	      "\\definecolor{fg}{rgb}{" fg "}\n"
 	      "\\definecolor{bg}{rgb}{" bg "}\n"
@@ -18092,9 +18107,7 @@ share a good deal of logic."
 	      "\n{\\color{fg}\n"
 	      string
 	      "\n}\n"
-	      "\n\\end{document}\n" )
-      (require 'org-latex)
-      (org-export-latex-fix-inputenc))
+	      "\n\\end{document}\n"))
     (let ((dir default-directory) cmd cmds latex-frags-cmds)
       (condition-case nil
 	  (progn
@@ -18567,7 +18580,7 @@ BEG and END default to the buffer boundaries."
 (org-defkey org-mode-map "\C-c\C-a" 'org-attach)
 (org-defkey org-mode-map "\C-c}"    'org-table-toggle-coordinate-overlays)
 (org-defkey org-mode-map "\C-c{"    'org-table-toggle-formula-debugger)
-(org-defkey org-mode-map "\C-c\C-e" 'org-export)
+(org-defkey org-mode-map "\C-c\C-e" 'org-export-dispatch)
 (org-defkey org-mode-map "\C-c:"    'org-toggle-fixed-width-section)
 (org-defkey org-mode-map "\C-c\C-x\C-f" 'org-emphasize)
 (org-defkey org-mode-map "\C-c\C-xf"    'org-footnote-action)
@@ -20358,7 +20371,7 @@ See the individual commands for more information."
      ["Timeline" org-timeline t]
      ["Tags/Property tree" org-match-sparse-tree t])
     "--"
-    ["Export/Publish..." org-export t]
+    ["Export/Publish..." org-export-dispatch t]
     ("LaTeX"
      ["Org CDLaTeX mode" org-cdlatex-mode :style toggle
       :selected org-cdlatex-mode]
@@ -20368,7 +20381,7 @@ See the individual commands for more information."
       (org-inside-LaTeX-fragment-p)]
      ["Insert citation" org-reftex-citation t]
      "--"
-     ["Template for BEAMER" (progn (require 'org-beamer)
+     ["Template for BEAMER" (progn (require 'ox-beamer)
 				   (org-insert-beamer-options-template)) t])
     "--"
     ("MobileOrg"
@@ -21501,8 +21514,6 @@ function installs the following ones: \"property\",
       (cond
        ;; Headings
        ((looking-at org-outline-regexp) (setq column 0))
-       ;; Included files
-       ((looking-at "#\\+include:") (setq column 0))
        ;; Footnote definition
        ((looking-at org-footnote-definition-re) (setq column 0))
        ;; Literal examples