mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-29 19:07:52 +00:00
ob-ref: Small refactoring
* lisp/ob-ref.el (org-babel-ref-goto-headline-id): (org-babel-ref-headline-body): Small refactoring.
This commit is contained in:
parent
33e2e375df
commit
b3e3f901b1
|
@ -53,6 +53,8 @@
|
||||||
(eval-when-compile
|
(eval-when-compile
|
||||||
(require 'cl))
|
(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-remove-if-not "org" (predicate seq))
|
||||||
(declare-function org-at-table-p "org" (&optional table-type))
|
(declare-function org-at-table-p "org" (&optional table-type))
|
||||||
(declare-function org-count "org" (CL-ITEM CL-SEQ))
|
(declare-function org-count "org" (CL-ITEM CL-SEQ))
|
||||||
|
@ -98,10 +100,8 @@ the variable."
|
||||||
out))))))
|
out))))))
|
||||||
|
|
||||||
(defun org-babel-ref-goto-headline-id (id)
|
(defun org-babel-ref-goto-headline-id (id)
|
||||||
(goto-char (point-min))
|
(or (let ((h (org-find-property "CUSTOM_ID" id)))
|
||||||
(let ((rx (regexp-quote id)))
|
(when h (goto-char h)))
|
||||||
(or (re-search-forward
|
|
||||||
(concat "^[ \t]*:CUSTOM_ID:[ \t]+" rx "[ \t]*$") nil t)
|
|
||||||
(let* ((file (org-id-find-id-file id))
|
(let* ((file (org-id-find-id-file id))
|
||||||
(m (when file (org-id-find-id-in-file id file 'marker))))
|
(m (when file (org-id-find-id-in-file id file 'marker))))
|
||||||
(when (and file m)
|
(when (and file m)
|
||||||
|
@ -110,17 +110,14 @@ the variable."
|
||||||
(goto-char m)
|
(goto-char m)
|
||||||
(move-marker m nil)
|
(move-marker m nil)
|
||||||
(org-show-context)
|
(org-show-context)
|
||||||
t)))))
|
t))))
|
||||||
|
|
||||||
(defun org-babel-ref-headline-body ()
|
(defun org-babel-ref-headline-body ()
|
||||||
(save-restriction
|
(save-restriction
|
||||||
(org-narrow-to-subtree)
|
(org-narrow-to-subtree)
|
||||||
(buffer-substring
|
(buffer-substring
|
||||||
(save-excursion (goto-char (point-min))
|
(save-excursion (goto-char (point-min))
|
||||||
(forward-line 1)
|
(org-end-of-meta-data)
|
||||||
(when (looking-at "[ \t]*:PROPERTIES:")
|
|
||||||
(re-search-forward ":END:" nil)
|
|
||||||
(forward-char))
|
|
||||||
(point))
|
(point))
|
||||||
(point-max))))
|
(point-max))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue