Browse Source

Remove unnecessary linking to export framework

* lisp/org-clock.el (org-clocktable-defaults,
  org-clocktable-write-default): Avoid requiring the whole export
  framework just to check one variable.
* lisp/org-footnote.el (org-footnote-section): Update
  docstring.
(org-footnote-normalize): Remove all export related part from the
  function.
* lisp/org-inlinetask.el (org-inlinetask-export,
  org-inlinetask-export-templates): Removed variables.
(org-inlinetask-export-handler): Removed function.
* lisp/org-plot.el: Remove dependency on `org-exp' library.
* lisp/org.el (org-additional-option-like-keywords): Remove variable.
(org-get-export-keywords): New function.
(org-options-keywords): Update default list of keywords.
(org-remove-flyspell-overlays-in): Apply changes to keywords
compilation.
(org-highlight-latex-fragments-and-specials)
org-latex-and-specials-regexp,
org-export-html-special-string-regexps): Remove variables.
(org-compute-latex-and-specials-regexp,
org-do-latex-and-special-faces, org-remove-file-link-modifiers):
Remove functions.
(org-set-regexps-and-options, org-set-font-lock-defaults): Apply all
removals.
(org-use-sub-superscripts): Fix docstring.  Remove unused group.
(org-match-sexp-depth): Make it a defconst instead of a defcustom in
order to remove `org-export-translation' group completely.

The new export framework shouldn't be as much interleaved with Org
core as with the previous one.  For example, export options, which are
back-end dependent, shouldn't interfere with the display of the
buffer.
Nicolas Goaziou 12 years ago
parent
commit
a2f56264c9
5 changed files with 92 additions and 448 deletions
  1. 4 3
      lisp/org-clock.el
  2. 32 99
      lisp/org-footnote.el
  3. 16 171
      lisp/org-inlinetask.el
  4. 0 1
      lisp/org-plot.el
  5. 40 174
      lisp/org.el

+ 4 - 3
lisp/org-clock.el

@@ -26,11 +26,11 @@
 
 ;; This file contains the time clocking code for Org-mode
 
-(require 'org-exp)
 ;;; Code:
 
 (eval-when-compile
   (require 'cl))
+(require 'org)
 
 (declare-function calendar-absolute-from-iso "cal-iso" (&optional date))
 (declare-function notifications-notify "notifications" (&rest params))
@@ -273,7 +273,7 @@ string as argument."
 (defcustom org-clocktable-defaults
   (list
    :maxlevel 2
-   :lang org-export-default-language
+   :lang (or (org-bound-and-true-p org-export-default-language) "en")
    :scope 'file
    :block nil
    :wstart 1
@@ -2317,7 +2317,8 @@ from the dynamic block definition."
   ;; well-defined number of columns...
   (let* ((hlchars '((1 . "*") (2 . "/")))
 	 (lwords (assoc (or (plist-get params :lang)
-			    org-export-default-language)
+			    (org-bound-and-true-p org-export-default-language)
+			    "en")
 			org-clock-clocktable-language-setup))
 	 (multifile (plist-get params :multifile))
 	 (block (plist-get params :block))

+ 32 - 99
lisp/org-footnote.el

@@ -42,8 +42,6 @@
 (declare-function org-back-to-heading "org" (&optional invisible-ok))
 (declare-function org-combine-plists "org" (&rest plists))
 (declare-function org-end-of-subtree "org"  (&optional invisible-ok to-heading))
-(declare-function org-export-preprocess-string "org-exp"
-		  (string &rest parameters))
 (declare-function org-fill-paragraph "org" (&optional justify))
 (declare-function org-icompleting-read "org" (&rest args))
 (declare-function org-id-uuid "org-id" ())
@@ -96,15 +94,19 @@
   :group 'org)
 
 (defcustom org-footnote-section "Footnotes"
-  "Outline heading containing footnote definitions before export.
-This can be nil, to place footnotes locally at the end of the current
-outline node.  If can also be the name of a special outline heading
-under which footnotes should be put.
+  "Outline heading containing footnote definitions.
+
+This can be nil, to place footnotes locally at the end of the
+current outline node.  If can also be the name of a special
+outline heading under which footnotes should be put.
+
 This variable defines the place where Org puts the definition
-automatically, i.e. when creating the footnote, and when sorting the notes.
-However, by hand you may place definitions *anywhere*.
-If this is a string, during export, all subtrees starting with this
-heading will be removed after extracting footnote definitions."
+automatically, i.e. when creating the footnote, and when sorting
+the notes.  However, by hand you may place definitions
+*anywhere*.
+
+If this is a string, during export, all subtrees starting with
+this heading will be ignored."
   :group 'org-footnote
   :type '(choice
 	  (string :tag "Collect footnotes under heading")
@@ -182,8 +184,6 @@ extracted will be filled again."
     (not (or (org-in-commented-line)
 	     (org-in-indented-comment-line)
 	     (org-inside-LaTeX-fragment-p)
-	     ;; Avoid protected environments (LaTeX export)
-	     (get-text-property (point) 'org-protected)
 	     ;; Avoid literal example.
 	     (org-in-verbatim-emphasis)
 	     (save-excursion
@@ -602,38 +602,15 @@ With prefix arg SPECIAL, offer additional commands in a menu."
       (org-footnote-goto-previous-reference (car tmp)))
      (t (org-footnote-new)))))
 
-(defvar org-footnote-insert-pos-for-preprocessor 'point-max
-  "See `org-footnote-normalize'.")
-
-(defvar org-export-footnotes-seen) ; silence byte-compiler
-(defvar org-export-footnotes-data) ; silence byte-compiler
-
 ;;;###autoload
-(defun org-footnote-normalize (&optional sort-only export-props)
+(defun org-footnote-normalize (&optional sort-only)
   "Collect the footnotes in various formats and normalize them.
 
 This finds the different sorts of footnotes allowed in Org, and
-normalizes them to the usual [N] format that is understood by the
-Org-mode exporters.
+normalizes them to the usual [N] format.
 
 When SORT-ONLY is set, only sort the footnote definitions into the
-referenced sequence.
-
-If Org is amidst an export process, EXPORT-PROPS will hold the
-export properties of the buffer.
-
-When EXPORT-PROPS is non-nil, the default action is to insert
-normalized footnotes towards the end of the pre-processing
-buffer.  Some exporters (docbook, odt...) expect footnote
-definitions to be available before any references to them.  Such
-exporters can let bind `org-footnote-insert-pos-for-preprocessor'
-to symbol `point-min' to achieve the desired behaviour.
-
-Additional note on `org-footnote-insert-pos-for-preprocessor':
-1. This variable has not effect when FOR-PREPROCESSOR is nil.
-2. This variable (potentially) obviates the need for extra scan
-   of pre-processor buffer as witnessed in
-   `org-export-docbook-get-footnotes'."
+referenced sequence."
   ;; This is based on Paul's function, but rewritten.
   ;;
   ;; Re-create `org-with-limited-levels', but not limited to Org
@@ -643,17 +620,12 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	       org-inlinetask-min-level
 	       (1- org-inlinetask-min-level)))
 	 (nstars (and limit-level
-		      (if org-odd-levels-only
-			  (and limit-level (1- (* limit-level 2)))
+		      (if org-odd-levels-only (1- (* limit-level 2))
 			limit-level)))
 	 (org-outline-regexp
 	  (concat "\\*" (if nstars (format "\\{1,%d\\} " nstars) "+ ")))
-	 ;; Determine the highest marker used so far.
-	 (ref-table (when export-props org-export-footnotes-seen))
-	 (count (if (and export-props ref-table)
-		    (apply 'max (mapcar (lambda (e) (nth 1 e)) ref-table))
-		  0))
-	 ins-point ref)
+	 (count 0)
+	 ins-point ref ref-table)
     (save-excursion
       ;; 1. Find every footnote reference, extract the definition, and
       ;;    collect that data in REF-TABLE.  If SORT-ONLY is nil, also
@@ -675,15 +647,10 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	  ;; Replace footnote reference with [MARKER].  Maybe fill
 	  ;; paragraph once done.  If SORT-ONLY is non-nil, only move
 	  ;; to the end of reference found to avoid matching it twice.
-	  ;; If EXPORT-PROPS isn't nil, also add `org-footnote'
-	  ;; property to it, so it can be easily recognized by
-	  ;; exporters.
 	  (if sort-only (goto-char (nth 2 ref))
 	    (delete-region (nth 1 ref) (nth 2 ref))
 	    (goto-char (nth 1 ref))
-	    (let ((new-ref (format "[%d]" marker)))
-	      (when export-props (org-add-props new-ref '(org-footnote t)))
-	      (insert new-ref))
+	    (insert (format "[%d]" marker))
 	    (and inlinep
 		 org-footnote-fill-after-inline-note-extraction
 		 (org-fill-paragraph)))
@@ -691,22 +658,9 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	  ;; type (INLINEP) and position (POS) to REF-TABLE if data
 	  ;; was unknown.
 	  (unless a
-	    (let ((def (or (nth 3 ref)	; inline
-			   (and export-props
-				(cdr (assoc lbl org-export-footnotes-data)))
+	    (let ((def (or (nth 3 ref)	; Inline definition.
 			   (nth 3 (org-footnote-get-definition lbl)))))
-	      (push (list lbl marker
-			  ;; When exporting, each definition goes
-			  ;; through `org-export-preprocess-string' so
-			  ;; it is ready to insert in the
-			  ;; backend-specific buffer.
-			  (if (and export-props def)
-			      (let ((parameters
-				     (org-combine-plists
-				      export-props
-				      '(:todo-keywords t :tags t :priority t))))
-				(apply #'org-export-preprocess-string def parameters))
-			    def)
+	      (push (list lbl marker def
 			  ;; Reference beginning position is a marker
 			  ;; to preserve it during further buffer
 			  ;; modifications.
@@ -728,14 +682,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	(unless (bolp) (newline)))
        ;; No footnote section set: Footnotes will be added at the end
        ;; of the section containing their first reference.
-       ;; Nevertheless, in an export situation, set insertion point to
-       ;; `point-max' by default.
-       ((derived-mode-p 'org-mode)
-	(when export-props
-	  (goto-char (point-max))
-	  (skip-chars-backward " \r\t\n")
-	  (forward-line)
-	  (delete-region (point) (point-max))))
+       ((derived-mode-p 'org-mode))
        (t
 	;; Remove any left-over tag in the buffer, if one is set up.
 	(when org-footnote-tag-for-non-org-mode-files
@@ -753,14 +700,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 		 (re-search-backward message-signature-separator nil t))
 	    (beginning-of-line)
 	  (goto-char (point-max)))))
-      ;; During export, `org-footnote-insert-pos-for-preprocessor' has
-      ;; precedence over previously found position.
-      (setq ins-point
-	    (copy-marker
-	     (if (and export-props
-		      (eq org-footnote-insert-pos-for-preprocessor 'point-min))
-		 (point-min)
-	       (point))))
+      (setq ins-point (point-marker))
       ;; 3. Clean-up REF-TABLE.
       (setq ref-table
 	    (delq nil
@@ -791,26 +731,22 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
        ;; No footnote: exit.
        ((not ref-table))
        ;; Cases when footnotes should be inserted in one place.
-       ((or (not (derived-mode-p 'org-mode))
-	    org-footnote-section
-	    export-props)
+       ((or (not (derived-mode-p 'org-mode)) org-footnote-section)
 	;; Insert again the section title, if any.  Ensure that title,
 	;; or the subsequent footnotes, will be separated by a blank
 	;; lines from the rest of the document.  In an Org buffer,
 	;; separate section with a blank line, unless explicitly
 	;; stated in `org-blank-before-new-entry'.
-	(cond
-	 ((not (derived-mode-p 'org-mode))
-	  (skip-chars-backward " \t\n\r")
-	  (delete-region (point) ins-point)
-	  (unless (bolp) (newline))
-	  (when org-footnote-tag-for-non-org-mode-files
-	    (insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
-	 ((and org-footnote-section (not export-props))
+	(if (not (derived-mode-p 'org-mode))
+	    (progn (skip-chars-backward " \t\n\r")
+		   (delete-region (point) ins-point)
+		   (unless (bolp) (newline))
+		   (when org-footnote-tag-for-non-org-mode-files
+		     (insert "\n" org-footnote-tag-for-non-org-mode-files "\n")))
 	  (when (and (cdr (assq 'heading org-blank-before-new-entry))
 		     (zerop (save-excursion (org-back-over-empty-lines))))
 	    (insert "\n"))
-	  (insert "* " org-footnote-section "\n")))
+	  (insert "* " org-footnote-section "\n"))
 	(set-marker ins-point nil)
 	;; Insert the footnotes, separated by a blank line.
 	(insert
@@ -820,10 +756,7 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	    (set-marker (nth 4 x) nil)
 	    (format "\n[%s] %s" (nth (if sort-only 0 1) x) (nth 2 x)))
 	  ref-table "\n"))
-	(unless (eobp) (insert "\n\n"))
-	;; When exporting, add newly inserted markers along with their
-	;; associated definition to `org-export-footnotes-seen'.
-	(when export-props (setq org-export-footnotes-seen ref-table)))
+	(unless (eobp) (insert "\n\n")))
        ;; Each footnote definition has to be inserted at the end of
        ;; the section where its first reference belongs.
        (t

+ 16 - 171
lisp/org-inlinetask.el

@@ -27,31 +27,25 @@
 ;;; Commentary:
 ;;
 ;; This module implements inline tasks in Org-mode.  Inline tasks are
-;; tasks that have all the properties of normal outline nodes, including
-;; the ability to store meta data like scheduling dates, TODO state, tags
-;; and properties.  However, these nodes are treated specially by the
-;; visibility cycling and export commands.
+;; tasks that have all the properties of normal outline nodes,
+;; including the ability to store meta data like scheduling dates,
+;; TODO state, tags and properties.  However, these nodes are treated
+;; specially by the visibility cycling.
 ;;
-;; Visibility cycling exempts these nodes from cycling.  So whenever their
-;; parent is opened, so are these tasks.  This will only work with
-;; `org-cycle', so if you are also using other commands to show/hide
-;; entries, you will occasionally find these tasks to behave like
-;; all other outline nodes, seemingly splitting the text of the parent
-;; into children.
+;; Visibility cycling exempts these nodes from cycling.  So whenever
+;; their parent is opened, so are these tasks.  This will only work
+;; with `org-cycle', so if you are also using other commands to
+;; show/hide entries, you will occasionally find these tasks to behave
+;; like all other outline nodes, seemingly splitting the text of the
+;; parent into children.
 ;;
-;; Export commands do not treat these nodes as part of the sectioning
-;; structure, but as a special inline text that is either removed, or
-;; formatted in some special way.  This in handled by
-;; `org-inlinetask-export' and `org-inlinetask-export-templates'
-;; variables.
+;; Special fontification of inline tasks, so that they can be
+;; immediately recognized.  From the stars of the headline, only the
+;; first and the last two will be visible, the others will be hidden
+;; using the `org-hide' face.
 ;;
-;; Special fontification of inline tasks, so that they can be immediately
-;; recognized.  From the stars of the headline, only the first and the
-;; last two will be visible, the others will be hidden using the
-;; `org-hide' face.
-;;
-;; An inline task is identified solely by a minimum outline level, given
-;; by the variable `org-inlinetask-min-level', default 15.
+;; An inline task is identified solely by a minimum outline level,
+;; given by the variable `org-inlinetask-min-level', default 15.
 ;;
 ;; If you need to have a time planning line (DEADLINE etc), drawers,
 ;; for example LOGBOOK of PROPERTIES, or even normal text as part of
@@ -111,69 +105,6 @@ When nil, the first star is not shown."
   :tag "Org Inline Tasks"
   :group 'org-structure)
 
-(defcustom org-inlinetask-export t
-  "Non-nil means export inline tasks.
-When nil, they will not be exported."
-  :group 'org-inlinetask
-  :type 'boolean)
-
-(defvar org-inlinetask-export-templates
-  '((html "<div class=\"inlinetask\"><b>%s%s</b><br />%s</div>"
-	  '((unless (eq todo "")
-	      (format "<span class=\"%s %s\">%s%s</span> "
-		      class todo todo priority))
-	    heading content))
-    (odt "%s" '((org-odt-format-inlinetask heading content
-					   todo priority tags)))
-
-    (latex "\\begin\{description\}\n\\item[%s%s]~%s\\end\{description\}"
-	   '((unless (eq todo "") (format "\\textsc\{%s%s\} " todo priority))
-	     heading content))
-    (ascii "     -- %s%s%s"
-	   '((unless (eq todo "") (format "%s%s " todo priority))
-	     heading
-	     (unless (eq content "")
-	       (format "\n         ¦ %s"
-		       (mapconcat 'identity (org-split-string content "\n")
-				  "\n         ¦ ")))))
-    (docbook "<variablelist>
-<varlistentry>
-<term>%s%s</term>
-<listitem><para>%s</para></listitem>
-</varlistentry>
-</variablelist>"
-	     '((unless (eq todo "") (format "%s%s " todo priority))
-	       heading content)))
-  "Templates for inline tasks in various exporters.
-
-This variable is an alist in the shape of \(BACKEND STRING OBJECTS\).
-
-BACKEND is the name of the backend for the template \(ascii, html...\).
-
-STRING is a format control string.
-
-OBJECTS is a list of elements to be substituted into the format
-string.  They can be of any type, from a string to a form
-returning a value (thus allowing conditional insertion).  A nil
-object will be substituted as the empty string.  Obviously, there
-must be at least as many objects as %-sequences in the format
-string.
-
-Moreover, the following special keywords are provided: `todo',
-`priority', `heading', `content', `tags'.  If some of them are not
-defined in an inline task, their value is the empty string.
-
-As an example, valid associations are:
-
-\(html \"<ul><li>%s <p>%s</p></li></ul>\" \(heading content\)\)
-
-or, with the additional package \"todonotes\" for LaTeX,
-
-\(latex \"\\todo[inline]{\\textbf{\\textsf{%s %s}}\\linebreak{} %s}\"
-       '\(\(unless \(eq todo \"\"\)
-	   \(format \"\\textsc{%s%s}\" todo priority\)\)
-	 heading content\)\)\)")
-
 (defvar org-odd-levels-only)
 (defvar org-keyword-time-regexp)
 (defvar org-drawer-regexp)
@@ -328,89 +259,6 @@ If the task has an end part, also demote it."
 	    (goto-char beg)
 	    (org-fixup-indentation diff)))))))
 
-(defvar org-export-current-backend) ; dynamically bound in org-exp.el
-(defun org-inlinetask-export-handler ()
-  "Handle headlines with level larger or equal to `org-inlinetask-min-level'.
-Either remove headline and meta data, or do special formatting."
-  (goto-char (point-min))
-  (let* ((keywords-re (concat "^[ \t]*" org-keyword-time-regexp))
-	 (inline-re (concat (org-inlinetask-outline-regexp) ".*")))
-    (while (re-search-forward inline-re nil t)
-      (let ((headline (match-string 0))
-	    (beg (point-at-bol))
-	    (end (copy-marker (save-excursion
-				(org-inlinetask-goto-end) (point))))
-	    content)
-	;; Delete SCHEDULED, DEADLINE...
-	(while (re-search-forward keywords-re end t)
-	  (delete-region (point-at-bol) (1+ (point-at-eol))))
-	(goto-char beg)
-	;; Delete drawers
-	(while (re-search-forward org-drawer-regexp end t)
-	  (when (save-excursion (re-search-forward org-property-end-re nil t))
-	    (delete-region beg (1+ (match-end 0)))))
-	;; Get CONTENT, if any.
-	(goto-char beg)
-	(forward-line 1)
-	(unless (= (point) end)
-	  (setq content (buffer-substring (point)
-					  (save-excursion (goto-char end)
-							  (forward-line -1)
-							  (point)))))
-	;; Remove the task.
-	(goto-char beg)
-	(delete-region beg end)
-	(when (and org-inlinetask-export
-		   (assq org-export-current-backend
-			 org-inlinetask-export-templates))
-	  ;; Format CONTENT, if appropriate.
-	  (setq content
-		(if (not (and content (string-match "\\S-" content)))
-		    ""
-		  ;; Ensure CONTENT has minimal indentation, a single
-		  ;; newline character at its boundaries, and isn't
-		  ;; protected.
-		  (when (string-match "\\`\\([ \t]*\n\\)+" content)
-		    (setq content (substring content (match-end 0))))
-		  (when (string-match "[ \t\n]+\\'" content)
-		    (setq content (substring content 0 (match-beginning 0))))
-		  (org-add-props
-		      (concat "\n\n" (org-remove-indentation content) "\n\n")
-		      '(org-protected nil org-native-text nil))))
-
-	  (when (string-match org-complex-heading-regexp headline)
-	    (let* ((nil-to-str
-		    (function
-		     ;; Change nil arguments into empty strings.
-		     (lambda (el) (or (eval el) ""))))
-		   ;;  Set up keywords provided to templates.
-		   (todo (or (match-string 2 headline) ""))
-		   (class (or (and (eq "" todo) "")
-			      (if (member todo org-done-keywords) "done" "todo")))
-		   (priority (or (match-string 3 headline) ""))
-		   (heading (or (match-string 4 headline) ""))
-		   (tags (or (match-string 5 headline) ""))
-		   ;; Read `org-inlinetask-export-templates'.
-		   (backend-spec (assq org-export-current-backend
-				       org-inlinetask-export-templates))
-		   (format-str (org-add-props (nth 1 backend-spec)
-				   '(org-protected t org-native-text t)))
-		   (tokens (cadr (nth 2 backend-spec)))
-		   ;; Build export string.  Ensure it won't break
-		   ;; surrounding lists by giving it arbitrary high
-		   ;; indentation.
-		   (export-str (org-add-props
-				   (eval (append '(format format-str)
-						 (mapcar nil-to-str tokens)))
-				   '(original-indentation 1000))))
-	      ;; Ensure task starts a new paragraph.
-	      (unless (or (bobp)
-			  (save-excursion (forward-line -1)
-					  (looking-at "[ \t]*$")))
-		(insert "\n"))
-	      (insert export-str)
-	      (unless (bolp) (insert "\n")))))))))
-
 (defun org-inlinetask-get-current-indentation ()
   "Get the indentation of the last non-while line above this one."
   (save-excursion
@@ -476,9 +324,6 @@ Either remove headline and meta data, or do special formatting."
 			    org-inlinetask-min-level))
     (replace-match "")))
 
-(eval-after-load "org-exp"
-  '(add-hook 'org-export-preprocess-before-backend-specifics-hook
-	     'org-inlinetask-export-handler))
 (eval-after-load "org"
   '(add-hook 'org-font-lock-hook 'org-inlinetask-fontify))
 

+ 0 - 1
lisp/org-plot.el

@@ -30,7 +30,6 @@
 
 ;;; Code:
 (require 'org)
-(require 'org-exp)
 (require 'org-table)
 (eval-when-compile
   (require 'cl))

+ 40 - 174
lisp/org.el

@@ -533,7 +533,7 @@ the following lines anywhere in the buffer:
 	  (const :tag "Globally (slow on startup in large files)" t)))
 
 (defcustom org-use-sub-superscripts t
-  "Non-nil means interpret \"_\" and \"^\" for export.
+  "Non-nil means interpret \"_\" and \"^\" for display.
 When this option is turned on, you can use TeX-like syntax for sub- and
 superscripts.  Several characters after \"_\" or \"^\" will be
 considered as a single item - so grouping with {} is normally not
@@ -546,27 +546,18 @@ sub- or superscripts.
 			 terminated by almost any nonword/nondigit char.
  x_{i^2} or   x^(2-i)    braces or parenthesis do grouping.
 
-Still, ambiguity is possible - so when in doubt use {} to enclose the
-sub/superscript.  If you set this variable to the symbol `{}',
-the braces are *required* in order to trigger interpretations as
-sub/superscript.  This can be helpful in documents that need \"_\"
-frequently in plain text.
-
-Not all export backends support this, but HTML does.
-
-This option can also be set with the #+OPTIONS line, e.g. \"^:nil\"."
+Still, ambiguity is possible - so when in doubt use {} to enclose
+the sub/superscript.  If you set this variable to the symbol
+`{}', the braces are *required* in order to trigger
+interpretations as sub/superscript.  This can be helpful in
+documents that need \"_\" frequently in plain text."
   :group 'org-startup
-  :group 'org-export-translation
   :version "24.1"
   :type '(choice
 	  (const :tag "Always interpret" t)
 	  (const :tag "Only with braces" {})
 	  (const :tag "Never interpret" nil)))
 
-(if (fboundp 'defvaralias)
-    (defvaralias 'org-export-with-sub-superscripts 'org-use-sub-superscripts))
-
-
 (defcustom org-startup-with-beamer-mode nil
   "Non-nil means turn on `org-beamer-mode' on startup.
 This can also be configured on a per-file basis by adding one of
@@ -3808,11 +3799,6 @@ org-level-* faces."
   :group 'org-appearance
   :type 'boolean)
 
-(defcustom org-highlight-latex-fragments-and-specials nil
-  "Non-nil means fontify what is treated specially by the exporters."
-  :group 'org-appearance
-  :type 'boolean)
-
 (defcustom org-hide-emphasis-markers nil
   "Non-nil mean font-lock should hide the emphasis marker characters."
   :group 'org-appearance
@@ -4911,9 +4897,7 @@ but the stars and the body are.")
 	    org-all-time-keywords
 	    (mapcar (lambda (w) (substring w 0 -1))
 		    (list org-scheduled-string org-deadline-string
-			  org-clock-string org-closed-string))
-	    )
-      (org-compute-latex-and-specials-regexp)
+			  org-clock-string org-closed-string)))
       (org-set-font-lock-defaults))))
 
 (defun org-file-contents (file &optional noerror)
@@ -5279,11 +5263,8 @@ Here is what the match groups contain after a match:
 (defvar org-any-link-re nil
   "Regular expression matching any link.")
 
-(defcustom org-match-sexp-depth 3
-  "Number of stacked braces for sub/superscript matching.
-This has to be set before loading org.el to be effective."
-  :group 'org-export-translation ; ??????????????????????????/
-  :type 'integer)
+(defconst org-match-sexp-depth 3
+  "Number of stacked braces for sub/superscript matching.")
 
 (defun org-create-multibrace-regexp (left right n)
   "Create a regular expression which will match a balanced sexp.
@@ -5767,98 +5748,9 @@ by a #."
       (goto-char e)
       t)))
 
-(defvar org-latex-and-specials-regexp nil
-  "Regular expression for highlighting export special stuff.")
 (defvar org-match-substring-regexp)
 (defvar org-match-substring-with-braces-regexp)
 
-;; This should be with the exporter code, but we also use if for font-locking
-(defconst org-export-html-special-string-regexps
-  '(("\\\\-" . "&shy;")
-    ("---\\([^-]\\)" . "&mdash;\\1")
-    ("--\\([^-]\\)" . "&ndash;\\1")
-    ("\\.\\.\\." . "&hellip;"))
-  "Regular expressions for special string conversion.")
-
-
-(defun org-compute-latex-and-specials-regexp ()
-  "Compute regular expression for stuff treated specially by exporters."
-  (if (not org-highlight-latex-fragments-and-specials)
-      (org-set-local 'org-latex-and-specials-regexp nil)
-    (require 'org-exp)
-    (let*
-	((matchers (plist-get org-format-latex-options :matchers))
-	 (latexs (delq nil (mapcar (lambda (x) (if (member (car x) matchers) x))
-				   org-latex-regexps)))
-	 (org-export-allow-BIND nil)
-	 (options (org-combine-plists (org-default-export-plist)
-				      (org-infile-export-plist)))
-	 (org-export-with-sub-superscripts (plist-get options :sub-superscript))
-	 (org-export-with-LaTeX-fragments (plist-get options :LaTeX-fragments))
-	 (org-export-with-TeX-macros (plist-get options :TeX-macros))
-	 (org-export-html-expand (plist-get options :expand-quoted-html))
-	 (org-export-with-special-strings (plist-get options :special-strings))
-	 (re-sub
-	  (cond
-	   ((equal org-export-with-sub-superscripts '{})
-	    (list org-match-substring-with-braces-regexp))
-	   (org-export-with-sub-superscripts
-	    (list org-match-substring-regexp))))
-	 (re-latex
-	  (if org-export-with-LaTeX-fragments
-	      (mapcar (lambda (x) (nth 1 x)) latexs)))
-	 (re-macros
-	  (if org-export-with-TeX-macros
-	      (list (concat "\\\\"
-			    (regexp-opt
-			     (append
-
-			      (delq nil
-				    (mapcar 'car-safe
-					    (append org-entities-user
-						    org-entities)))
-			      (if (boundp 'org-latex-entities)
-				  (mapcar (lambda (x)
-					    (or (car-safe x) x))
-					  org-latex-entities)
-				nil))
-			     'words))) ; FIXME
-	    ))
-	 ;;			(list "\\\\\\(?:[a-zA-Z]+\\)")))
-	 (re-special (if org-export-with-special-strings
-			 (mapcar (lambda (x) (car x))
-				 org-export-html-special-string-regexps)))
-	 (re-rest
-	  (delq nil
-		(list
-		 (if org-export-html-expand "@<[^>\n]+>")
-		 ))))
-      (org-set-local
-       'org-latex-and-specials-regexp
-       (mapconcat 'identity (append re-latex re-sub re-macros re-special
-				    re-rest) "\\|")))))
-
-(defun org-do-latex-and-special-faces (limit)
-  "Run through the buffer and add overlays to links."
-  (when org-latex-and-specials-regexp
-    (let (rtn d)
-      (while (and (not rtn) (re-search-forward org-latex-and-specials-regexp
-					       limit t))
-	(if (not (memq (car-safe (get-text-property (1+ (match-beginning 0))
-						    'face))
-		       '(org-code org-verbatim underline)))
-	    (progn
-	      (setq rtn t
-		    d (cond ((member (char-after (1+ (match-beginning 0)))
-				     '(?_ ?^)) 1)
-			    (t 0)))
-	      (font-lock-prepend-text-property
-	       (+ d (match-beginning 0)) (match-end 0)
-	       'face 'org-latex-and-export-specials)
-	      (add-text-properties (+ d (match-beginning 0)) (match-end 0)
-				   '(font-lock-multiline t)))))
-      rtn)))
-
 (defun org-restart-font-lock ()
   "Restart `font-lock-mode', to force refontification."
   (when (and (boundp 'font-lock-mode) font-lock-mode)
@@ -6019,7 +5911,6 @@ needs to be inserted at a specific position in the font-lock sequence.")
 		  "\\(.*:" org-archive-tag ":.*\\)")
 		 '(1 'org-archived prepend))
 	   ;; Specials
-	   '(org-do-latex-and-special-faces)
 	   '(org-fontify-entities)
 	   '(org-raise-scripts)
 	   ;; Code
@@ -10211,15 +10102,7 @@ there is one, return it."
 (defun org-open-file-with-emacs (path)
   "Open file at PATH in Emacs."
   (org-open-file path 'emacs))
-(defun org-remove-file-link-modifiers ()
-  "Remove the file link modifiers in `file+sys:' and `file+emacs:' links."
-  (goto-char (point-min))
-  (while (re-search-forward "\\<file\\+\\(sys\\|emacs\\):" nil t)
-    (org-if-unprotected
-     (replace-match "file:" t t))))
-(eval-after-load "org-exp"
-  '(add-hook 'org-export-preprocess-before-normalizing-links-hook
-	     'org-remove-file-link-modifiers))
+
 
 ;;; File search
 
@@ -11532,49 +11415,29 @@ This function can be used in a hook."
 
 ;;;; Completion
 
-(defconst org-additional-option-like-keywords
-  '("BEGIN_HTML"  "END_HTML"  "HTML:" "ATTR_HTML:"
-    "BEGIN_DocBook"  "END_DocBook"  "DocBook:" "ATTR_DocBook:"
-    "BEGIN_LaTeX" "END_LaTeX" "LaTeX:" "LATEX_HEADER:"
-    "LATEX_CLASS:" "LATEX_CLASS_OPTIONS:" "ATTR_LaTeX:"
-    "BEGIN:" "END:"
-    "ORGTBL" "TBLFM:" "TBLNAME:"
-    "BEGIN_EXAMPLE" "END_EXAMPLE"
-    "BEGIN_VERBATIM" "END_VERBATIM"
-    "BEGIN_QUOTE" "END_QUOTE"
-    "BEGIN_VERSE" "END_VERSE"
-    "BEGIN_CENTER" "END_CENTER"
-    "BEGIN_SRC" "END_SRC"
-    "BEGIN_RESULT" "END_RESULT"
-    "BEGIN_lstlisting" "END_lstlisting"
-    "NAME:" "RESULTS:"
-    "HEADER:" "HEADERS:"
-    "COLUMNS:" "PROPERTY:"
-    "CAPTION:" "LABEL:"
-    "SETUPFILE:"
-    "INCLUDE:" "INDEX:"
-    "BIND:"
-    "MACRO:"))
+(defun org-get-export-keywords ()
+  "Return a list of all currently understood export keywords.
+Export keywords include options, block names, attributes and
+keywords relative to each registered export back-end."
+  (delq nil
+	(let (keywords)
+	  (mapc
+	   (lambda (back-end)
+	     (let ((props (cdr back-end)))
+	       ;; Back-end name (for keywords, like #+LATEX:)
+	       (push (upcase (symbol-name (car back-end))) keywords)
+	       ;; Back-end options.
+	       (mapc (lambda (option) (push (cadr option) keywords))
+		     (plist-get (cdr back-end) :options-alist))))
+	   (org-bound-and-true-p org-export-registered-backends))
+	  keywords)))
 
 (defconst org-options-keywords
-  '("TITLE:" "AUTHOR:" "EMAIL:" "DATE:"
-    "DESCRIPTION:" "KEYWORDS:" "LANGUAGE:" "OPTIONS:"
-    "EXPORT_SELECT_TAGS:" "EXPORT_EXCLUDE_TAGS:"
-    "LINK_UP:" "LINK_HOME:" "LINK:" "TODO:"
-    "XSLT:" "MATHJAX:" "CATEGORY:" "SEQ_TODO:" "TYP_TODO:"
-    "PRIORITIES:" "DRAWERS:" "STARTUP:" "TAGS:" "STYLE:"
-    "FILETAGS:" "ARCHIVE:" "INFOJS_OPT:"))
-
-(defconst org-additional-option-like-keywords-for-flyspell
-  (delete-dups
-   (split-string
-    (mapconcat (lambda(k)
-		 (replace-regexp-in-string
-		  "_\\|:" " "
-		  (concat k " " (downcase k) " " (upcase k))))
-	       (append org-options-keywords org-additional-option-like-keywords)
-	       " ")
-    " +" t)))
+  '("ARCHIVE:" "AUTHOR:" "BIND:" "CATEGORY:" "COLUMNS:" "CREATOR:" "DATE"
+    "DESCRIPTION:" "DRAWERS:" "EMAIL:" "EXCLUDE_TAGS:" "FILETAGS:" "INCLUDE:"
+    "INDEX:" "KEYWORDS:" "LANGUAGE:" "MACRO:" "OPTIONS:" "PROPERTY"
+    "PRIORITIES:" "SELECT_TAGS:" "SEQ_TODO:" "SETUPFILE:" "STARTUP:" "TAGS:"
+    "TITLE:" "TODO:" "TYP_TODO:"))
 
 (defcustom org-structure-template-alist
   '(("s" "#+BEGIN_SRC ?\n\n#+END_SRC"
@@ -20497,11 +20360,8 @@ Your bug report will be posted to the Org-mode mailing list.
 (defun org-require-autoloaded-modules ()
   (interactive)
   (mapc 'require
-	'(org-agenda org-archive org-ascii org-attach org-clock org-colview
-		     org-docbook org-exp org-html org-icalendar
-		     org-id org-latex
-		     org-publish org-remember org-table
-		     org-timer org-xoxo)))
+	'(org-agenda org-archive org-attach org-clock org-colview org-id
+		     org-remember org-table org-timer)))
 
 ;;;###autoload
 (defun org-reload (&optional uncompiled)
@@ -23107,6 +22967,8 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 ;;; Fixes and Hacks for problems with other packages
 
 ;; Make flyspell not check words in links, to not mess up our keymap
+(defvar org-element-affiliated-keywords) ; From org-element.el
+(defvar org-element-block-name-alist)	 ; From org-element.el
 (defun org-mode-flyspell-verify ()
   "Don't let flyspell put overlays at active buttons, or on
    {todo,all-time,additional-option-like}-keywords."
@@ -23118,7 +22980,11 @@ To get rid of the restriction, use \\[org-agenda-remove-restriction-lock]."
 	 (not (member word org-all-time-keywords))
 	 (not (member word org-options-keywords))
 	 (not (member word (mapcar 'car org-startup-options)))
-	 (not (member word org-additional-option-like-keywords-for-flyspell)))))
+	 (not (member-ignore-case word org-element-affiliated-keywords))
+	 (not (member-ignore-case word (org-get-export-keywords)))
+	 (not (member-ignore-case
+	       word (mapcar 'car org-element-block-name-alist)))
+	 (not (member-ignore-case word '("BEGIN" "END" "ATTR"))))))
 
 (defun org-remove-flyspell-overlays-in (beg end)
   "Remove flyspell overlays in region."