diff options
author | Kyle Meyer <kyle@kyleam.com> | 2022-11-29 23:05:53 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2022-11-29 23:05:53 -0500 |
commit | 0625651e8a61c9effc31ff771f15885a3a37c6e6 (patch) | |
tree | db4c09e8ef119ad4a9a4028c5e615fd58d2dee69 /lisp/org/ob-ref.el | |
parent | edd64e64a389e0f0e6ce670846d4fae79a9d8b35 (diff) | |
download | emacs-0625651e8a61c9effc31ff771f15885a3a37c6e6.tar.gz emacs-0625651e8a61c9effc31ff771f15885a3a37c6e6.tar.bz2 emacs-0625651e8a61c9effc31ff771f15885a3a37c6e6.zip |
Update to Org 9.6-3-ga4d38e
Diffstat (limited to 'lisp/org/ob-ref.el')
-rw-r--r-- | lisp/org/ob-ref.el | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lisp/org/ob-ref.el b/lisp/org/ob-ref.el index 21076b67b24..2bba2071ee3 100644 --- a/lisp/org/ob-ref.el +++ b/lisp/org/ob-ref.el @@ -5,7 +5,7 @@ ;; Authors: Eric Schulte ;; Dan Davison ;; Keywords: literate programming, reproducible research -;; Homepage: https://orgmode.org +;; URL: https://orgmode.org ;; This file is part of GNU Emacs. @@ -49,12 +49,16 @@ ;; #+end_src ;;; Code: + +(require 'org-macs) +(org-assert-version) + (require 'ob-core) (require 'org-macs) (require 'cl-lib) -(declare-function org-babel-lob-get-info "ob-lob" (&optional datum)) -(declare-function org-element-at-point "org-element" ()) +(declare-function org-babel-lob-get-info "ob-lob" (&optional datum no-eval)) +(declare-function org-element-at-point "org-element" (&optional pom cached-only)) (declare-function org-element-property "org-element" (property element)) (declare-function org-element-type "org-element" (element)) (declare-function org-end-of-meta-data "org" (&optional full)) @@ -62,8 +66,8 @@ (declare-function org-id-find-id-file "org-id" (id)) (declare-function org-id-find-id-in-file "org-id" (id file &optional markerp)) (declare-function org-in-commented-heading-p "org" (&optional no-inheritance)) -(declare-function org-narrow-to-subtree "org" ()) -(declare-function org-show-context "org" (&optional key)) +(declare-function org-narrow-to-subtree "org" (&optional element)) +(declare-function org-fold-show-context "org-fold" (&optional key)) (defvar org-babel-update-intermediate nil "Update the in-buffer results of code blocks executed to resolve references.") @@ -104,7 +108,7 @@ Emacs Lisp representation of the value of the variable." (pop-to-buffer-same-window (marker-buffer m)) (goto-char m) (move-marker m nil) - (org-show-context) + (org-fold-show-context) t)))) (defun org-babel-ref-headline-body () @@ -124,12 +128,14 @@ Emacs Lisp representation of the value of the variable." (save-excursion (let ((case-fold-search t) args new-refere new-header-args new-referent split-file split-ref - index) + index contents) ;; if ref is indexed grab the indices -- beware nested indices - (when (and (string-match "\\[\\([^\\[]+\\)\\]$" ref) + (when (and (string-match "\\[\\([^\\[]*\\)\\]$" ref) (let ((str (substring ref 0 (match-beginning 0)))) (= (cl-count ?\( str) (cl-count ?\) str)))) - (setq index (match-string 1 ref)) + (if (> (length (match-string 1 ref)) 0) + (setq index (match-string 1 ref)) + (setq contents t)) (setq ref (substring ref 0 (match-beginning 0)))) ;; assign any arguments to pass to source block (when (string-match @@ -153,7 +159,7 @@ Emacs Lisp representation of the value of the variable." (setq ref split-ref)) (org-with-wide-buffer (goto-char (point-min)) - (let* ((params (append args '((:results . "silent")))) + (let* ((params (append args '((:results . "none")))) (regexp (org-babel-named-data-regexp-for-name ref)) (result (catch :found @@ -171,7 +177,7 @@ Emacs Lisp representation of the value of the variable." (throw :found (org-babel-execute-src-block nil (org-babel-lob-get-info e) params))) - (`src-block + ((and `src-block (guard (not contents))) (throw :found (org-babel-execute-src-block nil nil @@ -193,7 +199,7 @@ Emacs Lisp representation of the value of the variable." (org-babel-execute-src-block nil info params)))) (error "Reference `%s' not found in this buffer" ref)))) (cond - ((symbolp result) (format "%S" result)) + ((and result (symbolp result)) (format "%S" result)) ((and index (listp result)) (org-babel-ref-index-list index result)) (t result))))))))) |