Explorar el Código

when present resolve orig-buffer headlines w/IDs

* lisp/ob-exp.el (org-babel-exp-in-export-file): Instead of using the
  headline text use the headline ID when one is present.  This fixes a
  bug in the resolution of code block headers in properties during
  export when multiple headlines with the same name are present.
Eric Schulte hace 12 años
padre
commit
266233164f
Se han modificado 1 ficheros con 10 adiciones y 5 borrados
  1. 10 5
      lisp/ob-exp.el

+ 10 - 5
lisp/ob-exp.el

@@ -66,7 +66,12 @@ be executed."
 (defmacro org-babel-exp-in-export-file (lang &rest body)
   (declare (indent 1))
   `(let* ((lang-headers (intern (concat "org-babel-default-header-args:" ,lang)))
-	  (heading (nth 4 (ignore-errors (org-heading-components))))
+	  (heading-query (or (org-id-get)
+			     ;; CUSTOM_IDs don't work, maybe they are
+			     ;; stripped, or maybe they resolve too
+			     ;; late in `org-link-search'.
+			     ;; (org-entry-get nil "CUSTOM_ID")
+			     (nth 4 (ignore-errors (org-heading-components)))))
 	  (export-buffer (current-buffer))
 	  results)
      (when org-babel-exp-reference-buffer
@@ -75,17 +80,17 @@ be executed."
        ;; heading in the original file
        (set-buffer org-babel-exp-reference-buffer)
        (save-restriction
-	 (when heading
+	 (when heading-query
 	   (condition-case nil
 	       (let ((org-link-search-inhibit-query t))
 		 ;; TODO: When multiple headings have the same title,
 		 ;;       this returns the first, which is not always
 		 ;;       the right heading.  Consider a better way to
 		 ;;       find the proper heading.
-		 (org-link-search heading))
-	     (error (when heading
+		 (org-link-search heading-query))
+	     (error (when heading-query
 		      (goto-char (point-min))
-		      (re-search-forward (regexp-quote heading) nil t)))))
+		      (re-search-forward (regexp-quote heading-query) nil t)))))
 	 (setq results ,@body))
        (set-buffer export-buffer)
        results)))