Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2018-02-01 15:51:28 +01:00
commit e490d2766f
1 changed files with 15 additions and 4 deletions

View File

@ -980,13 +980,24 @@ with a prefix argument then this is passed on to
(defmacro org-babel-do-in-edit-buffer (&rest body) (defmacro org-babel-do-in-edit-buffer (&rest body)
"Evaluate BODY in edit buffer if there is a code block at point. "Evaluate BODY in edit buffer if there is a code block at point.
Return t if a code block was found at point, nil otherwise." Return t if a code block was found at point, nil otherwise."
`(let ((org-src-window-setup 'switch-invisibly)) (declare (debug (body)))
(when (and (org-babel-where-is-src-block-head) `(let* ((element (org-element-at-point))
;; This function is not supposed to move point. However,
;; `org-edit-src-code' always moves point back into the
;; source block. It is problematic if the point was before
;; the code, e.g., on block's opening line. In this case,
;; we want to restore this location after executing BODY.
(outside-position
(and (<= (line-beginning-position)
(org-element-property :post-affiliated element))
(point-marker)))
(org-src-window-setup 'switch-invisibly))
(when (and (org-babel-where-is-src-block-head element)
(org-edit-src-code)) (org-edit-src-code))
(unwind-protect (progn ,@body) (unwind-protect (progn ,@body)
(org-edit-src-exit)) (org-edit-src-exit)
(when outside-position (goto-char outside-position)))
t))) t)))
(def-edebug-spec org-babel-do-in-edit-buffer (body))
(defun org-babel-do-key-sequence-in-edit-buffer (key) (defun org-babel-do-key-sequence-in-edit-buffer (key)
"Read key sequence and execute the command in edit buffer. "Read key sequence and execute the command in edit buffer.