Browse Source

org-element: Introduce a new accessor: `org-element-type'

* EXPERIMENTAL/org-e-ascii.el (org-e-ascii--current-text-width,
  org-e-ascii--build-caption, org-e-ascii--build-title,
  org-e-ascii--describe-links, org-e-ascii-template,
  org-e-ascii-paragraph): Use new accessor
* EXPERIMENTAL/org-e-latex.el (org-e-latex--guess-inputenc): Small
  refactoring.
  (org-e-latex-footnote-reference, org-e-latex-link):  Use new
  accessor.
* contrib/lisp/org-element.el (org-element-type): New function.
  (org-element-map, org-element-parse-elements,
  org-element-interpret-data, org-element-normalize-contents,
  org-element-forward, org-element-unindent-buffer): Use new
  accessor.
* contrib/lisp/org-export.el (org-export-get-inbuffer-options,
  org-export-get-min-level, org-export-data, org-export-skip-p,
  org-export-interpret-p, org-export-expand,
  org-export-expand-include-keyword,
  org-export-prepare-file-contents, org-export-first-sibling-p,
  org-export-resolve-fuzzy-link, org-export-get-ordinal,
  org-export-get-loc, org-export-get-genealogy,
  org-export-get-parent-headline): Use new accessor.
Nicolas Goaziou 13 years ago
parent
commit
0ff3d47d13
4 changed files with 174 additions and 158 deletions
  1. 73 73
      EXPERIMENTAL/org-e-ascii.el
  2. 3 4
      EXPERIMENTAL/org-e-latex.el
  3. 29 17
      contrib/lisp/org-element.el
  4. 69 64
      contrib/lisp/org-export.el

+ 73 - 73
EXPERIMENTAL/org-e-ascii.el

@@ -504,69 +504,69 @@ INFO is a plist used as a communicaton channel."
 (defun org-e-ascii--current-text-width (element info)
   "Return maximum text width for ELEMENT's contents.
 INFO is a plist used as a communication channel."
-  (cond
-   ;; Elements with an absolute width: `headline' and `inlinetask'.
-   ((eq (car element) 'inlinetask) org-e-ascii-inlinetask-width)
-   ((eq (car element) 'headline)
-    (- org-e-ascii-text-width
-       (let ((low-level-rank (org-export-low-level-p element info)))
-	 (if low-level-rank (* low-level-rank 2) org-e-ascii-global-margin))))
-   ;; Elements with a relative width: store maximum text width in
-   ;; TOTAL-WIDTH.
-   (t
-    (let* ((genealogy (cons element (plist-get info :genealogy)))
-	   ;; Total width is determined by the presence, or not, of an
-	   ;; inline task among ELEMENT parents.
-	   (total-width
-	    (if (loop for parent in genealogy
-		      thereis (eq (car parent) 'inlinetask))
-		org-e-ascii-inlinetask-width
-	      ;; No inlinetask: Remove global margin from text width.
-	      (- org-e-ascii-text-width
-		 org-e-ascii-global-margin
-		 (let ((parent (org-export-get-parent-headline element info)))
-		   ;; Inner margin doesn't apply to text before first
-		   ;; headline.
-		   (if (not parent) 0
-		     (let ((low-level-rank
-			    (org-export-low-level-p parent info)))
-		       ;; Inner margin doesn't apply to contents of
-		       ;; low level headlines, since they've got their
-		       ;; own indentation mechanism.
-		       (if low-level-rank (* low-level-rank 2)
-			 org-e-ascii-inner-margin))))))))
-      (- total-width
-	 ;; Each `quote-block', `quote-section' and `verse-block' above
-	 ;; narrows text width by twice the standard margin size.
-	 (+ (* (loop for parent in genealogy
-		     when (memq (car parent)
-				'(quote-block quote-section verse-block))
-		     count parent)
-	       2 org-e-ascii-quote-margin)
-	    ;; Text width within a plain-list is restricted by
-	    ;; indentation of current item.  If that's the case,
-	    ;; compute it with the help of `:structure' property from
-	    ;; parent item, if any.
-	    (let ((parent-item
-		   (if (eq (car element) 'item) element
-		     (loop for parent in genealogy
-			   when (eq (car parent) 'item)
-			   return parent))))
-	      (if (not parent-item) 0
-		;; Compute indentation offset of the current item,
-		;; that is the sum of the difference between its
-		;; indentation and the indentation of the top item in
-		;; the list and current item bullet's length.  Also
-		;; remove tag length (for description lists) or bullet
-		;; length.
-		(let ((struct (org-element-get-property :structure parent-item))
-		      (beg-item (org-element-get-property :begin parent-item)))
-		  (+ (- (org-list-get-ind beg-item struct)
-			(org-list-get-ind
-			 (org-list-get-top-point struct) struct))
-		     (length
-		      (or (org-list-get-tag beg-item struct)
-			  (org-list-get-bullet beg-item struct)))))))))))))
+  (case (org-element-type element)
+    ;; Elements with an absolute width: `headline' and `inlinetask'.
+    (inlinetask org-e-ascii-inlinetask-width)
+    ('headline
+     (- org-e-ascii-text-width
+	(let ((low-level-rank (org-export-low-level-p element info)))
+	  (if low-level-rank (* low-level-rank 2) org-e-ascii-global-margin))))
+    ;; Elements with a relative width: store maximum text width in
+    ;; TOTAL-WIDTH.
+    (otherwise
+     (let* ((genealogy (cons element (plist-get info :genealogy)))
+	    ;; Total width is determined by the presence, or not, of an
+	    ;; inline task among ELEMENT parents.
+	    (total-width
+	     (if (loop for parent in genealogy
+		       thereis (eq (org-element-type parent) 'inlinetask))
+		 org-e-ascii-inlinetask-width
+	       ;; No inlinetask: Remove global margin from text width.
+	       (- org-e-ascii-text-width
+		  org-e-ascii-global-margin
+		  (let ((parent (org-export-get-parent-headline element info)))
+		    ;; Inner margin doesn't apply to text before first
+		    ;; headline.
+		    (if (not parent) 0
+		      (let ((low-level-rank
+			     (org-export-low-level-p parent info)))
+			;; Inner margin doesn't apply to contents of
+			;; low level headlines, since they've got their
+			;; own indentation mechanism.
+			(if low-level-rank (* low-level-rank 2)
+			  org-e-ascii-inner-margin))))))))
+       (- total-width
+	  ;; Each `quote-block', `quote-section' and `verse-block' above
+	  ;; narrows text width by twice the standard margin size.
+	  (+ (* (loop for parent in genealogy
+		      when (memq (org-element-type parent)
+				 '(quote-block quote-section verse-block))
+		      count parent)
+		2 org-e-ascii-quote-margin)
+	     ;; Text width within a plain-list is restricted by
+	     ;; indentation of current item.  If that's the case,
+	     ;; compute it with the help of `:structure' property from
+	     ;; parent item, if any.
+	     (let ((parent-item
+		    (if (eq (org-element-type element) 'item) element
+		      (loop for parent in genealogy
+			    when (eq (org-element-type parent) 'item)
+			    return parent))))
+	       (if (not parent-item) 0
+		 ;; Compute indentation offset of the current item,
+		 ;; that is the sum of the difference between its
+		 ;; indentation and the indentation of the top item in
+		 ;; the list and current item bullet's length.  Also
+		 ;; remove tag length (for description lists) or bullet
+		 ;; length.
+		 (let ((struct (org-element-get-property :structure parent-item))
+		       (beg-item (org-element-get-property :begin parent-item)))
+		   (+ (- (org-list-get-ind beg-item struct)
+			 (org-list-get-ind
+			  (org-list-get-top-point struct) struct))
+		      (length
+		       (or (org-list-get-tag beg-item struct)
+			   (org-list-get-bullet beg-item struct)))))))))))))
 
 (defun org-e-ascii--build-title
   (element info text-width &optional underline notags)
@@ -582,7 +582,7 @@ specifications.
 
 if optional argument NOTAGS is nil, no tags will be added to the
 title."
-  (let* ((headlinep (eq (car element) 'headline))
+  (let* ((headlinep (eq (org-element-type element) 'headline))
 	 (numbers
 	  ;; Numbering is specific to headlines.
 	  (and headlinep
@@ -651,7 +651,7 @@ keyword."
 	      (lambda (el) (or (org-element-get-property :caption el)
 			  (org-element-get-property :name el)))))
 	    (title-fmt (org-e-ascii--translate
-			(case (car element)
+			(case (org-element-type element)
 			  (table "Table %d: %s")
 			  (src-block "Listing %d: %s")) info)))
 	(org-e-ascii--fill-string
@@ -795,14 +795,14 @@ the following section and in any inlinetask's title there."
 	   (lambda (element)
 	     (let (acc)
 	       (dolist (obj (org-element-get-property :title element) acc)
-		 (when (and (listp obj) (eq (car obj) 'link))
+		 (when (eq (org-element-type obj) 'link)
 		   (let ((link (funcall unique-link-p obj)))
 		     (and link (push link acc)))))))))
 	 ;; Retrieve HEADLINE's section, if it exists.
-	 (section (if (eq (car element) 'section) element
+	 (section (if (eq (org-element-type element) 'section) element
 		    (let ((sec (car (org-element-get-contents element))))
-		      (and (eq (car sec) 'section) sec))))
-	 (headline (if (eq (car element) 'headline) element
+		      (and (eq (org-element-type sec) 'section) sec))))
+	 (headline (if (eq (org-element-type element) 'headline) element
 		     (org-export-get-parent-headline element info))))
     (append
      ;; Links that may be in HEADLINE's title.
@@ -834,7 +834,7 @@ channel."
 	 (let ((destination (if (string= type "fuzzy")
 				(org-export-resolve-fuzzy-link link info)
 			      (org-export-resolve-id-link link info))))
-	   (unless (eq (car destination) 'target)
+	   (unless (eq (org-element-type destination) 'target)
 	     (concat
 	      (org-e-ascii--fill-string
 	       (format
@@ -974,13 +974,13 @@ holding export options."
 		 ;; full-fledged definitions.
 		 (org-trim
 		  (let ((def (nth 2 ref)))
-		    (if (eq (car def) 'org-data)
+		    (if (eq (org-element-type def) 'org-data)
 			;; Full-fledged definition: footnote ID is
 			;; inserted inside the first parsed paragraph
 			;; (FIRST), if any, to be sure filling will
 			;; take it into consideration.
 			(let ((first (car (org-element-get-contents def))))
-			  (if (not (eq (car first) 'paragraph))
+			  (if (not (eq (org-element-type first) 'paragraph))
 			      (concat id "\n" (org-export-data def 'e-ascii info))
 			    (push id (nthcdr 2 first))
 			    (org-export-data def 'e-ascii info)))
@@ -1437,7 +1437,7 @@ the plist used as a communication channel."
      ;; If PARAGRAPH is the first one in a list element, be sure to
      ;; add the check-box in front of it, before any filling.  Later,
      ;; it would interfere with line width.
-     (if (and (eq (car parent) 'item)
+     (if (and (eq (org-element-type parent) 'item)
 	      (equal (car (org-element-get-contents parent)) paragraph))
 	 (let ((utf8p (eq (plist-get info :ascii-charset) 'utf-8)))
 	   (concat (case (org-element-get-property :checkbox parent)

+ 3 - 4
EXPERIMENTAL/org-e-latex.el

@@ -745,8 +745,7 @@ Return the new header."
 		   (latexenc-coding-system-to-inputenc
 		    buffer-file-coding-system))
 		 "utf8")))
-    (if (not cs)
-	header
+    (if (not cs) header
       ;; First translate if that is requested.
       (setq cs (or (cdr (assoc cs org-e-latex-inputenc-alist)) cs))
       ;; Then find the \usepackage statement and replace the option.
@@ -1013,7 +1012,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   (concat
    ;; Insert separator between two footnotes in a row.
    (let ((prev (org-export-get-previous-element footnote-reference info)))
-     (when (and (listp prev) (eq (car prev) 'footnote-reference))
+     (when (eq (org-element-type prev) 'footnote-reference)
        org-e-latex-footnote-separator))
    ;; Use \footnotemark if the footnote has already been defined.
    ;; Otherwise, define it with \footnote command.
@@ -1439,7 +1438,7 @@ INFO is a plist holding contextual information.  See
 			     (org-export-resolve-fuzzy-link link info)
 			   (org-export-resolve-id-link link info))))
 	;; Fuzzy link points to a target.  Do as above.
-	(case (car destination)
+	(case (org-element-type destination)
 	  (target
 	   (format "\\hyperref[%s]{%s}"
 		   (org-export-solidify-link-text

+ 29 - 17
contrib/lisp/org-element.el

@@ -79,10 +79,10 @@
 ;; The first part of this file implements a parser and an interpreter
 ;; for each type of Org syntax.
 
-;; The next two parts introduce two accessors and a function
+;; The next two parts introduce three accessors and a function
 ;; retrieving the smallest element containing point (respectively
-;; `org-element-get-property', `org-element-get-contents' and
-;; `org-element-at-point').
+;; `org-element-type', `org-element-get-property',
+;; `org-element-get-contents' and `org-element-at-point').
 
 ;; The following part creates a fully recursive buffer parser.  It
 ;; also provides a tool to map a function to elements or objects
@@ -2593,8 +2593,20 @@ its type is listed here.")
 
 ;;; Accessors
 ;;
-;; Provide two accessors: `org-element-get-property' and
-;; `org-element-get-contents'.
+;; Provide three accessors: `org-element-type',
+;; `org-element-get-property' and `org-element-get-contents'.
+
+(defun org-element-type (element)
+  "Return type of element ELEMENT.
+
+The function returns the type of the element or object provided.
+It can also return the following special value:
+  `plain-text'       for a string
+  `org-data'         for a complete document
+  nil                in any other case."
+  (cond
+   ((not (consp element)) (and (stringp element) 'plain-text))
+   ((symbolp (car element)) (car element))))
 
 (defun org-element-get-property (property element)
   "Extract the value from the PROPERTY of an ELEMENT."
@@ -3056,7 +3068,7 @@ Nil values returned from FUN are ignored in the result."
 	     ;; a plist holding contextual information.
 	     (mapc
 	      (lambda (--blob)
-		(let ((--type (if (stringp --blob) 'plain-text (car --blob))))
+		(let ((--type (org-element-type --blob)))
 		  ;; Determine if a recursion into --BLOB is
 		  ;; possible and allowed.
 		  (cond
@@ -3170,7 +3182,7 @@ Elements are accumulated into ACC."
 	   (cond
 	    ;; Case 1.  ELEMENT is a paragraph.  Parse objects inside,
 	    ;; if GRANULARITY allows it.
-	    ((and (eq (car element) 'paragraph)
+	    ((and (eq (org-element-type element) 'paragraph)
 		  (or (not granularity) (eq granularity 'object)))
 	     (org-element-parse-objects
 	      (org-element-get-property :contents-begin element)
@@ -3182,10 +3194,10 @@ Elements are accumulated into ACC."
 	    ;; headline, in which case going inside is mandatory, in
 	    ;; order to get sub-level headings.  If VISIBLE-ONLY is
 	    ;; true and element is hidden, do not recurse into it.
-	    ((and (memq (car element) org-element-greater-elements)
+	    ((and (memq (org-element-type element) org-element-greater-elements)
 		  (or (not granularity)
 		      (memq granularity '(element object))
-		      (eq (car element) 'headline))
+		      (eq (org-element-type element) 'headline))
 		  (not (and visible-only
 			    (org-element-get-property :hiddenp element))))
 	     (org-element-parse-elements
@@ -3194,7 +3206,7 @@ Elements are accumulated into ACC."
 	      ;; At a plain list, switch to item mode.  At an
 	      ;; headline, switch to section mode.  Any other
 	      ;; element turns off special modes.
-	      (case (car element)
+	      (case (org-element-type element)
 		(plain-list 'item)
 		(headline (if (org-element-get-property :quotedp element)
 			      'quote-section
@@ -3475,7 +3487,7 @@ Return Org syntax as a string."
       ((equal blob "") nil)
       ((stringp blob) blob)
       (t
-       (let* ((type (car blob))
+       (let* ((type (org-element-type blob))
 	      (interpreter
 	       (if (eq type 'org-data) 'identity
 		 (intern (format "org-element-%s-interpreter" type))))
@@ -3627,7 +3639,7 @@ indentation is not done with TAB characters."
                    (while (string-match "\n\\( *\\)" object start)
                      (setq start (match-end 0))
                      (push (length (match-string 1 object)) ind-list))))
-                ((memq (car object) org-element-recursive-objects)
+                ((memq (org-element-type object) org-element-recursive-objects)
                  (funcall collect-inds object first-flag))))
              (org-element-get-contents blob))))))
     ;; Collect indentation list in ELEMENT.  Possibly remove first
@@ -3644,7 +3656,7 @@ indentation is not done with TAB characters."
 		;; non-nil when the first string hasn't been seen
 		;; yet.
 		(nconc
-		 (list (car blob) (nth 1 blob))
+		 (list (org-element-type blob) (nth 1 blob))
 		 (mapcar
 		  (lambda (object)
 		    (when (and first-flag (stringp object))
@@ -3656,7 +3668,7 @@ indentation is not done with TAB characters."
 		     ((stringp object)
 		      (replace-regexp-in-string
 		       (format "\n \\{%d\\}" mci) "\n" object))
-		     ((memq (car object) org-element-recursive-objects)
+		     ((memq (org-element-type object) org-element-recursive-objects)
 		      (funcall build object mci first-flag))
 		     (t object)))
 		  (org-element-get-contents blob)))))))
@@ -3833,7 +3845,7 @@ Assume ELEM-A is before ELEM-B and that they are not nested."
 	   (cond
 	    ;; At an item: Either move to the next element inside, or
 	    ;; to its end if it's hidden.
-	    ((eq (car element) 'item)
+	    ((eq (org-element-type element) 'item)
 	     (if (org-element-get-property :hiddenp element)
 		 (goto-char (org-element-get-property :end element))
 	       (end-of-line)
@@ -3842,7 +3854,7 @@ Assume ELEM-A is before ELEM-B and that they are not nested."
 	       (beginning-of-line)))
 	    ;; At a recursive element: Either move inside, or if it's
 	    ;; hidden, move to its end.
-	    ((memq (car element) org-element-greater-elements)
+	    ((memq (org-element-type element) org-element-greater-elements)
 	     (let ((cbeg (org-element-get-property :contents-begin element)))
 	       (goto-char
 		(if (or (org-element-get-property :hiddenp element)
@@ -3922,7 +3934,7 @@ modified."
 	  (function
 	   (lambda (contents)
 	     (mapc (lambda (element)
-		     (if (eq (car element) 'headline)
+		     (if (eq (org-element-type element) 'headline)
 			 (funcall unindent-tree
 				  (org-element-get-contents element))
 		       (save-excursion

+ 69 - 64
contrib/lisp/org-export.el

@@ -1018,7 +1018,7 @@ Assume buffer is in Org mode.  Narrowing, if any, is ignored."
      (let ((special-re (org-make-options-regexp org-export-special-keywords)))
        (while (re-search-forward special-re nil t)
 	 (let ((element (org-element-at-point)))
-	   (when (eq (car element) 'keyword)
+	   (when (eq (org-element-type element) 'keyword)
 	     (let* ((key (upcase (org-element-get-property :key element)))
 		    (val (org-element-get-property :value element))
 		    (prop
@@ -1095,7 +1095,7 @@ Assume buffer is in Org mode.  Narrowing, if any, is ignored."
        (goto-char (point-min))
        (while (re-search-forward opt-re nil t)
 	 (let ((element (org-element-at-point)))
-	   (when (eq (car element) 'keyword)
+	   (when (eq (org-element-type element) 'keyword)
 	     (let* ((key (upcase (org-element-get-property :key element)))
 		    (val (org-element-get-property :value element))
 		    (prop (cdr (assoc key alist)))
@@ -1304,7 +1304,7 @@ OPTIONS is a plist holding export options."
   (catch 'exit
     (let ((min-level 10000))
       (mapc (lambda (blob)
-	      (when (and (eq (car blob) 'headline)
+	      (when (and (eq (org-element-type blob) 'headline)
 			 (not (org-export-skip-p blob options)))
 		(setq min-level
 		      (min (org-element-get-property :level blob) min-level)))
@@ -1389,7 +1389,7 @@ Return transcoded string."
 	  backend info)))
       ;; BLOB is an element or an object.
       (t
-       (let* ((type (if (stringp blob) 'plain-text (car blob)))
+       (let* ((type (org-element-type blob))
 	      ;; 1. Determine the appropriate TRANSCODER.
 	      (transcoder
 	       (cond
@@ -1491,59 +1491,60 @@ Return transcoded string."
 (defun org-export-skip-p (blob info)
   "Non-nil when element or object BLOB should be skipped during export.
 INFO is the plist holding export options."
-  ;; Check headline.
-  (unless (stringp blob)
-    (case (car blob)
-      ('headline
-       (let ((with-tasks (plist-get info :with-tasks))
-	     (todo (org-element-get-property :todo-keyword blob))
-	     (todo-type (org-element-get-property :todo-type blob))
-	     (archived (plist-get info :with-archived-trees))
-	     (tag-list (let ((tags (org-element-get-property :tags blob)))
-			 (and tags (org-split-string tags ":")))))
-	 (or
-	  ;; Ignore subtrees with an exclude tag.
-	  (loop for k in (plist-get info :exclude-tags)
-		thereis (member k tag-list))
-	  ;; Ignore subtrees without a select tag, when such tag is found
-	  ;; in the buffer.
-	  (and (plist-get info :use-select-tags)
-	       (loop for k in (plist-get info :select-tags)
-		     never (member k tag-list)))
-	  ;; Ignore commented sub-trees.
-	  (org-element-get-property :commentedp blob)
-	  ;; Ignore archived subtrees if `:with-archived-trees' is nil.
-	  (and (not archived) (org-element-get-property :archivedp blob))
-	  ;; Ignore tasks, if specified by `:with-tasks' property.
-	  (and todo (not with-tasks))
-	  (and todo
-	       (memq with-tasks '(todo done))
-	       (not (eq todo-type with-tasks)))
-	  (and todo
-	       (consp with-tasks)
-	       (not (member todo with-tasks))))))
-      ;; Check time-stamp.
-      ('time-stamp (not (plist-get info :with-timestamps)))
-      ;; Check drawer.
-      ('drawer
-       (or (not (plist-get info :with-drawers))
-	   (and (consp (plist-get info :with-drawers))
-		(not (member (org-element-get-property :drawer-name blob)
-			     (plist-get info :with-drawers))))))
-      ;; Check export snippet.
-      ('export-snippet
-       (let* ((raw-back-end (org-element-get-property :back-end blob))
-	      (true-back-end
-	       (or (cdr (assoc raw-back-end org-export-snippet-translation-alist))
-		   raw-back-end)))
-	 (not (string= (symbol-name (plist-get info :back-end))
-		       true-back-end)))))))
+  (case (org-element-type blob)
+    ;; Plain text is never skipped.
+    (plain-text nil)
+    ;; Check headline.
+    (headline
+     (let ((with-tasks (plist-get info :with-tasks))
+	   (todo (org-element-get-property :todo-keyword blob))
+	   (todo-type (org-element-get-property :todo-type blob))
+	   (archived (plist-get info :with-archived-trees))
+	   (tag-list (let ((tags (org-element-get-property :tags blob)))
+		       (and tags (org-split-string tags ":")))))
+       (or
+	;; Ignore subtrees with an exclude tag.
+	(loop for k in (plist-get info :exclude-tags)
+	      thereis (member k tag-list))
+	;; Ignore subtrees without a select tag, when such tag is found
+	;; in the buffer.
+	(and (plist-get info :use-select-tags)
+	     (loop for k in (plist-get info :select-tags)
+		   never (member k tag-list)))
+	;; Ignore commented sub-trees.
+	(org-element-get-property :commentedp blob)
+	;; Ignore archived subtrees if `:with-archived-trees' is nil.
+	(and (not archived) (org-element-get-property :archivedp blob))
+	;; Ignore tasks, if specified by `:with-tasks' property.
+	(and todo (not with-tasks))
+	(and todo
+	     (memq with-tasks '(todo done))
+	     (not (eq todo-type with-tasks)))
+	(and todo
+	     (consp with-tasks)
+	     (not (member todo with-tasks))))))
+    ;; Check time-stamp.
+    (time-stamp (not (plist-get info :with-timestamps)))
+    ;; Check drawer.
+    (drawer
+     (or (not (plist-get info :with-drawers))
+	 (and (consp (plist-get info :with-drawers))
+	      (not (member (org-element-get-property :drawer-name blob)
+			   (plist-get info :with-drawers))))))
+    ;; Check export snippet.
+    (export-snippet
+     (let* ((raw-back-end (org-element-get-property :back-end blob))
+	    (true-back-end
+	     (or (cdr (assoc raw-back-end org-export-snippet-translation-alist))
+		 raw-back-end)))
+       (not (string= (symbol-name (plist-get info :back-end))
+		     true-back-end))))))
 
 (defun org-export-interpret-p (blob info)
   "Non-nil if element or object BLOB should be interpreted as Org syntax.
 Check is done according to export options INFO, stored as
 a plist."
-  (case (car blob)
+  (case (org-element-type blob)
     ;; ... entities...
     (entity (plist-get info :with-entities))
     ;; ... emphasis...
@@ -1567,8 +1568,8 @@ a plist."
   "Expand a parsed element or object to its original state.
 BLOB is either an element or an object.  CONTENTS is its
 contents, as a string or nil."
-  (funcall
-   (intern (format "org-element-%s-interpreter" (car blob))) blob contents))
+  (funcall (intern (format "org-element-%s-interpreter" (org-element-type blob)))
+	   blob contents))
 
 
 
@@ -2207,7 +2208,8 @@ recursion."
   (let ((case-fold-search nil))
     (goto-char (point-min))
     (while (re-search-forward "^[ \t]*#\\+include: \\(.*\\)" nil t)
-      (when (eq (car (save-match-data (org-element-at-point))) 'keyword)
+      (when (eq (org-element-type (save-match-data (org-element-at-point)))
+		'keyword)
 	(beginning-of-line)
 	;; Extract arguments from keyword's value.
 	(let* ((value (match-string 1))
@@ -2328,7 +2330,8 @@ file should have."
 	(while (not (or (eobp) (looking-at org-outline-regexp-bol)))
 	  ;; Do not move footnote definitions out of column 0.
 	  (unless (and (looking-at org-footnote-definition-re)
-		       (eq (car (org-element-at-point)) 'footnote-definition))
+		       (eq (org-element-type (org-element-at-point))
+			   'footnote-definition))
 	    (insert ind-str))
 	  (forward-line))))
     ;; When MINLEVEL is specified, compute minimal level for headlines
@@ -2501,7 +2504,8 @@ INFO is a plist holding contextual information."
 (defun org-export-first-sibling-p (headline info)
   "Non-nil when HEADLINE is the first sibling in its sub-tree.
 INFO is the plist used as a communication channel."
-  (not (eq (car (org-export-get-previous-element headline info)) 'headline)))
+  (not (eq (org-element-type (org-export-get-previous-element headline info))
+	   'headline)))
 
 (defun org-export-last-sibling-p (headline info)
   "Non-nil when HEADLINE is the last sibling in its sub-tree.
@@ -2618,7 +2622,7 @@ Assume LINK type is \"fuzzy\"."
 	  (or (catch 'exit
 		(mapc
 		 (lambda (parent)
-		   (when (eq (car parent) 'headline)
+		   (when (eq (org-element-type parent) 'headline)
 		     (let ((foundp (funcall find-headline path parent)))
 		       (when foundp (throw 'exit foundp)))))
 		 (plist-get info :genealogy)) nil)
@@ -2759,7 +2763,7 @@ like inline images, which are a subset of links \(in that case,
 	       (plist-get info :parse-tree)))))
     ;; Increment counter until ELEMENT is found again.
     (org-element-map
-     data (or types (car element))
+     data (or types (org-element-type element))
      (lambda (el local)
        (cond
         ((equal element el) (1+ counter))
@@ -2785,14 +2789,15 @@ INFO is the plist used as a communication channel.
 ELEMENT is excluded from count."
   (let ((loc 0))
     (org-element-map
-     (plist-get info :parse-tree) `(src-block example-block ,(car element))
+     (plist-get info :parse-tree)
+     `(src-block example-block ,(org-element-type element))
      (lambda (el local)
        (cond
         ;; ELEMENT is reached: Quit the loop.
         ((equal el element) t)
         ;; Only count lines from src-block and example-block elements
         ;; with a "+n" or "-n" switch.  A "-n" switch resets counter.
-        ((not (memq (car el) '(src-block example-block))) nil)
+        ((not (memq (org-element-type el) '(src-block example-block))) nil)
         ((let ((switches (org-element-get-property :switches el)))
            (when (and switches (string-match "\\([-+]\\)n\\>" switches))
 	     ;; Accumulate locs or reset them.
@@ -3113,7 +3118,7 @@ used as a communication channel."
     (if localp (plist-get info :genealogy)
       (catch 'exit
 	(org-element-map
-	 (plist-get info :parse-tree) (car blob)
+	 (plist-get info :parse-tree) (org-element-type blob)
 	 (lambda (el local)
 	   (when (equal el blob)
 	     (throw 'exit (plist-get local :genealogy))))
@@ -3126,7 +3131,7 @@ BLOB is the element or object being considered.  INFO is a plist
 used as a communication channel."
   (catch 'exit
     (mapc
-     (lambda (el) (when (eq (car el) 'headline) (throw 'exit el)))
+     (lambda (el) (when (eq (org-element-type el) 'headline) (throw 'exit el)))
      (org-export-get-genealogy blob info))
     nil))
 
@@ -3142,7 +3147,7 @@ This is useful for objects, which share attributes with the
 paragraph containing them."
   (catch 'exit
     (mapc
-     (lambda (el) (when (eq (car el) 'paragraph) (throw 'exit el)))
+     (lambda (el) (when (eq (org-element-type el) 'paragraph) (throw 'exit el)))
      (org-export-get-genealogy object info))
     nil))