Ver Fonte

ob-ref: Small refactoring

* lisp/ob-ref.el (org-babel-ref-goto-headline-id):
(org-babel-ref-headline-body): Small refactoring.
Nicolas Goaziou há 10 anos atrás
pai
commit
b3e3f901b1
1 ficheiros alterados com 14 adições e 17 exclusões
  1. 14 17
      lisp/ob-ref.el

+ 14 - 17
lisp/ob-ref.el

@@ -53,6 +53,8 @@
 (eval-when-compile
   (require 'cl))
 
+(declare-function org-end-of-meta-data "org" (&optional full))
+(declare-function org-find-property "org" (property &optional value))
 (declare-function org-remove-if-not "org" (predicate seq))
 (declare-function org-at-table-p "org" (&optional table-type))
 (declare-function org-count "org" (CL-ITEM CL-SEQ))
@@ -98,29 +100,24 @@ the variable."
 		out))))))
 
 (defun org-babel-ref-goto-headline-id (id)
-  (goto-char (point-min))
-  (let ((rx (regexp-quote id)))
-    (or (re-search-forward
-	 (concat "^[ \t]*:CUSTOM_ID:[ \t]+" rx "[ \t]*$") nil t)
-	(let* ((file (org-id-find-id-file id))
-	       (m (when file (org-id-find-id-in-file id file 'marker))))
-	  (when (and file m)
-	    (message "file:%S" file)
-	    (org-pop-to-buffer-same-window (marker-buffer m))
-	    (goto-char m)
-	    (move-marker m nil)
-	    (org-show-context)
-	    t)))))
+  (or (let ((h (org-find-property "CUSTOM_ID" id)))
+	(when h (goto-char h)))
+      (let* ((file (org-id-find-id-file id))
+	     (m (when file (org-id-find-id-in-file id file 'marker))))
+	(when (and file m)
+	  (message "file:%S" file)
+	  (org-pop-to-buffer-same-window (marker-buffer m))
+	  (goto-char m)
+	  (move-marker m nil)
+	  (org-show-context)
+	  t))))
 
 (defun org-babel-ref-headline-body ()
   (save-restriction
     (org-narrow-to-subtree)
     (buffer-substring
      (save-excursion (goto-char (point-min))
-		     (forward-line 1)
-		     (when (looking-at "[ \t]*:PROPERTIES:")
-		       (re-search-forward ":END:" nil)
-		       (forward-char))
+		     (org-end-of-meta-data)
 		     (point))
      (point-max))))