summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-09-21 09:34:50 -0600
committerEric Schulte <schulte.eric@gmail.com>2010-09-21 09:34:50 -0600
commit0ec264ddf7f3f684fa4c13ecc91ea7aca035a350 (patch)
tree61e0fd6fc144f45512386b3f2e4a3181fe9416d9
parent26b9263926b9bbf3b6ab1a31ead096793b12cab1 (diff)
downloadorg-mode-0ec264ddf7f3f684fa4c13ecc91ea7aca035a350.tar.gz
org-babel-demarcate-block now works before first headline
fix suggested by Dan Davison * lisp/ob.el (org-babel-demarcate-block): better initialization of stars
-rw-r--r--lisp/ob.el9
1 files changed, 4 insertions, 5 deletions
diff --git a/lisp/ob.el b/lisp/ob.el
index a087092..bcdcc72 100644
--- a/lisp/ob.el
+++ b/lisp/ob.el
@@ -1138,15 +1138,15 @@ split. When called from outside of a code block a new code block
is created. In both cases if the region is demarcated and if the
region is not active then the point is demarcated."
(interactive "P")
- (let ((info (org-babel-get-src-block-info)))
+ (let ((info (org-babel-get-src-block-info))
+ (stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
(if info
(mapc
(lambda (place)
(save-excursion
(goto-char place)
(let ((lang (nth 0 info))
- (indent (make-string (nth 6 info) ? ))
- (stars (concat (make-string (org-current-level) ?*) " ")))
+ (indent (make-string (nth 6 info) ? )))
(when (string-match "^[[:space:]]*$"
(buffer-substring (point-at-bol)
(point-at-eol)))
@@ -1160,8 +1160,7 @@ region is not active then the point is demarcated."
(sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
(let ((start (point))
(body (delete-and-extract-region
- (if (region-active-p) (mark) (point)) (point)))
- (stars (concat (make-string (org-current-level) ?*) " ")))
+ (if (region-active-p) (mark) (point)) (point))))
(insert (concat (if (looking-at "^") "" "\n")
(if arg (concat stars "\n") "")
"#+begin_src " (read-from-minibuffer "Lang: ") "\n"