Pages

Saturday, September 18, 2010

Mark region as src code. If prefix used then create new org entry with the region marked as src.

(define-key org-mode-map (kbd "C-c C-b") '
(lambda()(interactive)
(let ((stars (make-string (org-current-level) ?*)))
(insert
(format
"%s%s \n#+begin_src emacs-lisp\n%s#+end_src\n%s"
(if current-prefix-arg "#+end_src\n\n") stars (delete-and-extract-region (region-beginning) (region-end)) (if current-prefix-arg (concat "\n" stars " \n#+begin_src emacs-lisp")))))))





--
My Emacs Files At GitHub

No comments:

Post a Comment