summaryrefslogtreecommitdiff
path: root/lisp/org/ob-core.el
diff options
context:
space:
mode:
authorRasmus <rasmus@gmx.us>2017-08-29 10:07:08 +0200
committerRasmus <rasmus@gmx.us>2017-08-29 10:13:31 +0200
commit3ad8ca429bac5e1354881cf4411d6f41dab36b44 (patch)
tree41d8dc789a212dc3b1e09f402714b09dc1462fc5 /lisp/org/ob-core.el
parentc1854b1d31e1b0a3a9e91ef41110a5fa77bedb31 (diff)
downloademacs-3ad8ca429bac5e1354881cf4411d6f41dab36b44.tar.gz
Update Org to v9.0.10
Please see etc/ORG-NEWS for major changes. Note, this is a bugfix release.
Diffstat (limited to 'lisp/org/ob-core.el')
-rw-r--r--lisp/org/ob-core.el53
1 files changed, 30 insertions, 23 deletions
diff --git a/lisp/org/ob-core.el b/lisp/org/ob-core.el
index c630b70f91f..527fb2204ad 100644
--- a/lisp/org/ob-core.el
+++ b/lisp/org/ob-core.el
@@ -1752,16 +1752,20 @@ NAME, or nil if no such block exists. Set match data according
to `org-babel-named-src-block-regexp'."
(save-excursion
(goto-char (point-min))
- (ignore-errors
- (org-next-block 1 nil (org-babel-named-src-block-regexp-for-name name)))))
+ (let ((regexp (org-babel-named-src-block-regexp-for-name name)))
+ (or (and (looking-at regexp)
+ (progn (goto-char (match-beginning 1))
+ (line-beginning-position)))
+ (ignore-errors (org-next-block 1 nil regexp))))))
(defun org-babel-src-block-names (&optional file)
"Returns the names of source blocks in FILE or the current buffer."
(when file (find-file file))
(save-excursion
(goto-char (point-min))
- (let ((re (org-babel-named-src-block-regexp-for-name))
- names)
+ (let* ((re (org-babel-named-src-block-regexp-for-name))
+ (names (and (looking-at re)
+ (list (match-string-no-properties 9)))))
(while (ignore-errors (org-next-block 1 nil re))
(push (match-string-no-properties 9) names))
names)))
@@ -2269,21 +2273,22 @@ INFO may provide the values of these header arguments (in the
((member "prepend" result-params))) ; already there
(setq results-switches
(if results-switches (concat " " results-switches) ""))
- (let ((wrap (lambda (start finish &optional no-escape no-newlines
- inline-start inline-finish)
- (when inline
- (setq start inline-start)
- (setq finish inline-finish)
- (setq no-newlines t))
- (goto-char end)
- (insert (concat finish (unless no-newlines "\n")))
- (goto-char beg)
- (insert (concat start (unless no-newlines "\n")))
- (unless no-escape
- (org-escape-code-in-region (min (point) end) end))
- (goto-char end)
- (unless no-newlines (goto-char (point-at-eol)))
- (setq end (point-marker))))
+ (let ((wrap
+ (lambda (start finish &optional no-escape no-newlines
+ inline-start inline-finish)
+ (when inline
+ (setq start inline-start)
+ (setq finish inline-finish)
+ (setq no-newlines t))
+ (let ((before-finish (marker-position end)))
+ (goto-char end)
+ (insert (concat finish (unless no-newlines "\n")))
+ (goto-char beg)
+ (insert (concat start (unless no-newlines "\n")))
+ (unless no-escape
+ (org-escape-code-in-region
+ (min (point) before-finish) before-finish))
+ (goto-char end))))
(tabulablep
(lambda (r)
;; Non-nil when result R can be turned into
@@ -2337,7 +2342,7 @@ INFO may provide the values of these header arguments (in the
(insert (org-macro-escape-arguments
(org-babel-chomp result "\n"))))
(t (goto-char beg) (insert result)))
- (setq end (point-marker))
+ (setq end (copy-marker (point) t))
;; possibly wrap result
(cond
((assq :wrap (nth 2 info))
@@ -2374,11 +2379,12 @@ INFO may provide the values of these header arguments (in the
((and (not (funcall tabulablep result))
(not (member "file" result-params)))
(let ((org-babel-inline-result-wrap
- ;; Hard code {{{results(...)}}} on top of customization.
+ ;; Hard code {{{results(...)}}} on top of
+ ;; customization.
(format "{{{results(%s)}}}"
org-babel-inline-result-wrap)))
- (org-babel-examplify-region beg end results-switches inline)
- (setq end (point))))))
+ (org-babel-examplify-region
+ beg end results-switches inline)))))
;; Possibly indent results in par with #+results line.
(when (and (not inline) (numberp indent) (> indent 0)
;; In this case `table-align' does the work
@@ -2391,6 +2397,7 @@ INFO may provide the values of these header arguments (in the
(message "Code block returned no value.")
(message "Code block produced no output."))
(message "Code block evaluation complete.")))
+ (set-marker end nil)
(when outside-scope (narrow-to-region visible-beg visible-end))
(set-marker visible-beg nil)
(set-marker visible-end nil)))))))