mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-08-22 00:48:37 +00:00
ob-core.el (org-babel-demarcate-block): Fix case
* ob-core.el (org-babel-demarcate-block): Upcase or downcase the inserted #+begin_src and #+end_src depending on the current case of #+begin_src and #+end_src. Thanks to Alexander Baier for reporting this.
This commit is contained in:
parent
7ac468ff55
commit
cb8366cd21
|
@ -1858,10 +1858,13 @@ 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
|
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)
|
(block (progn (org-babel-where-is-src-block-head) (match-string 0)))
|
||||||
(match-string 4)))
|
(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) ?*) " "))
|
||||||
|
lower-case-p)
|
||||||
|
(if (let (case-fold-search) (string-match "#\\+begin_src" block))
|
||||||
|
(setq lower-case-p t))
|
||||||
(if info
|
(if info
|
||||||
(mapc
|
(mapc
|
||||||
(lambda (place)
|
(lambda (place)
|
||||||
|
@ -1875,9 +1878,10 @@ region is not active then the point is demarcated."
|
||||||
(delete-region (point-at-bol) (point-at-eol)))
|
(delete-region (point-at-bol) (point-at-eol)))
|
||||||
(insert (concat
|
(insert (concat
|
||||||
(if (looking-at "^") "" "\n")
|
(if (looking-at "^") "" "\n")
|
||||||
indent "#+end_src\n"
|
indent (funcall (if lower-case-p 'downcase 'upcase) "#+end_src\n")
|
||||||
(if arg stars indent) "\n"
|
(if arg stars indent) "\n"
|
||||||
indent "#+begin_src " lang
|
indent (funcall (if lower-case-p 'downcase 'upcase) "#+begin_src ")
|
||||||
|
lang
|
||||||
(if (> (length headers) 1)
|
(if (> (length headers) 1)
|
||||||
(concat " " headers) headers)
|
(concat " " headers) headers)
|
||||||
(if (looking-at "[\n\r]")
|
(if (looking-at "[\n\r]")
|
||||||
|
@ -1897,11 +1901,12 @@ region is not active then the point is demarcated."
|
||||||
(if (org-region-active-p) (mark) (point)) (point))))
|
(if (org-region-active-p) (mark) (point)) (point))))
|
||||||
(insert (concat (if (looking-at "^") "" "\n")
|
(insert (concat (if (looking-at "^") "" "\n")
|
||||||
(if arg (concat stars "\n") "")
|
(if arg (concat stars "\n") "")
|
||||||
"#+begin_src " lang "\n"
|
(funcall (if lower-case-p 'downcase 'upcase) "#+begin_src ")
|
||||||
|
lang "\n"
|
||||||
body
|
body
|
||||||
(if (or (= (length body) 0)
|
(if (or (= (length body) 0)
|
||||||
(string-match "[\r\n]$" body)) "" "\n")
|
(string-match "[\r\n]$" body)) "" "\n")
|
||||||
"#+end_src\n"))
|
(funcall (if lower-case-p 'downcase 'upcase) "#+end_src\n")))
|
||||||
(goto-char start) (move-end-of-line 1)))))
|
(goto-char start) (move-end-of-line 1)))))
|
||||||
|
|
||||||
(defvar org-babel-lob-one-liner-regexp)
|
(defvar org-babel-lob-one-liner-regexp)
|
||||||
|
|
Loading…
Reference in a new issue