better code block demarcation
* lisp/ob.el (org-babel-demarcate-block): Copy headers and indent to column of point when a block is split.
This commit is contained in:
parent
0b6de9a026
commit
0d580520cc
11
lisp/ob.el
11
lisp/ob.el
|
@ -1334,6 +1334,8 @@ is created. In both cases if the region is demarcated and if the
|
||||||
region is not active then the point is demarcated."
|
region is not active then the point is demarcated."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let ((info (org-babel-get-src-block-info 'light))
|
(let ((info (org-babel-get-src-block-info 'light))
|
||||||
|
(headers (progn (org-babel-where-is-src-block-head)
|
||||||
|
(match-string 4)))
|
||||||
(stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
|
(stars (concat (make-string (or (org-current-level) 1) ?*) " ")))
|
||||||
(if info
|
(if info
|
||||||
(mapc
|
(mapc
|
||||||
|
@ -1346,11 +1348,16 @@ region is not active then the point is demarcated."
|
||||||
(buffer-substring (point-at-bol)
|
(buffer-substring (point-at-bol)
|
||||||
(point-at-eol)))
|
(point-at-eol)))
|
||||||
(delete-region (point-at-bol) (point-at-eol)))
|
(delete-region (point-at-bol) (point-at-eol)))
|
||||||
(insert (concat (if (looking-at "^") "" "\n")
|
(insert (concat
|
||||||
|
(if (looking-at "^") "" "\n")
|
||||||
indent "#+end_src\n"
|
indent "#+end_src\n"
|
||||||
(if arg stars indent) "\n"
|
(if arg stars indent) "\n"
|
||||||
indent "#+begin_src " lang
|
indent "#+begin_src " lang
|
||||||
(if (looking-at "[\n\r]") "" "\n")))))
|
(if (> (length headers) 1)
|
||||||
|
(concat " " headers) headers)
|
||||||
|
(if (looking-at "[\n\r]")
|
||||||
|
""
|
||||||
|
(concat "\n" (make-string (current-column) ? )))))))
|
||||||
(move-end-of-line 2))
|
(move-end-of-line 2))
|
||||||
(sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
|
(sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
|
||||||
(let ((start (point))
|
(let ((start (point))
|
||||||
|
|
Loading…
Reference in New Issue