ob-demarcate-block: visible region and completion during language selection

Thanks to Sébastien Vauban for the suggestion

* lisp/ob.el (org-babel-demarcate-block): visible region and
  completion during language selection
This commit is contained in:
Eric Schulte 2010-09-27 07:18:00 -06:00
parent b7e11ff608
commit eb0068e9cd
1 changed files with 4 additions and 1 deletions

View File

@ -1141,11 +1141,14 @@ region is not active then the point is demarcated."
(move-end-of-line 2))
(sort (if (region-active-p) (list (mark) (point)) (list (point))) #'>))
(let ((start (point))
(lang (org-icompleting-read "Lang: "
(mapcar (lambda (el) (symbol-name (car el)))
org-babel-load-languages)))
(body (delete-and-extract-region
(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"
"#+begin_src " lang "\n"
body
(if (or (= (length body) 0)
(string-match "[\r\n]$" body)) "" "\n")