summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-27 23:56:30 +0100
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-01-27 23:56:30 +0100
commitebb9da0d037eea1968efd6612f00dec1819cb866 (patch)
treec8e45107a4cd4c601a51ab1329eccddf2d176e9c
parentd715cc42fa0a08f4d1fa77b35119fa8b7af59a16 (diff)
downloadorg-mode-ebb9da0d037eea1968efd6612f00dec1819cb866.tar.gz
Allow C-c C-c on blank lines within src blocks
* lisp/org.el (org-ctrl-c-ctrl-c): Act on blank lines if they are located within a src block. Reported-by: John Hendy <jw.hendy@gmail.com> <http://permalink.gmane.org/gmane.emacs.orgmode/111720>
-rw-r--r--lisp/org.el24
1 files changed, 14 insertions, 10 deletions
diff --git a/lisp/org.el b/lisp/org.el
index b5f88be..7f68dcb 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -21117,11 +21117,6 @@ This command does many different things, depending on context:
(funcall org-finish-function))
((org-babel-hash-at-point))
((run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-hook))
- ((save-excursion (beginning-of-line) (looking-at-p "[ \t]*$"))
- (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
- (user-error
- (substitute-command-keys
- "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))
(t
(let* ((context
(org-element-lineage
@@ -21145,7 +21140,21 @@ This command does many different things, depending on context:
(setq context parent)
(setq type 'item))))
;; Act according to type of element or object at point.
+ ;;
+ ;; Do nothing on a blank line, except if it is contained in
+ ;; a src block. Hence, we first check if point is in such
+ ;; a block and then if it is at a blank line.
(pcase type
+ ((or `inline-src-block `src-block)
+ (unless org-babel-no-eval-on-ctrl-c-ctrl-c
+ (org-babel-eval-wipe-error-buffer)
+ (org-babel-execute-src-block
+ current-prefix-arg (org-babel-get-src-block-info nil context))))
+ ((guard (org-match-line "[ \t]*$"))
+ (or (run-hook-with-args-until-success 'org-ctrl-c-ctrl-c-final-hook)
+ (user-error
+ (substitute-command-keys
+ "`\\[org-ctrl-c-ctrl-c]' can do nothing useful here"))))
((or `babel-call `inline-babel-call)
(let ((info (org-babel-lob-get-info context)))
(when info (org-babel-execute-src-block nil info))))
@@ -21161,11 +21170,6 @@ This command does many different things, depending on context:
((or `headline `inlinetask)
(save-excursion (goto-char (org-element-property :begin context))
(call-interactively #'org-set-tags)))
- ((or `inline-src-block `src-block)
- (unless org-babel-no-eval-on-ctrl-c-ctrl-c
- (org-babel-eval-wipe-error-buffer)
- (org-babel-execute-src-block
- current-prefix-arg (org-babel-get-src-block-info nil context))))
(`item
;; At an item: `C-u C-u' sets checkbox to "[-]"
;; unconditionally, whereas `C-u' will toggle its presence.