hi i fell like an idiot but what is RFC, is that a repo of some sorts, would you mind pasting a link? sorry about that Z On Tue, Jul 29, 2014 at 5:48 PM, Xebar Saram wrote: > Hi again > > looks great but i think there may be a bug. if there is 1 line then issues > the function works perfect (although no prompt, which for 1 line is ideal). > but using C-u before the M-x dosent seem to do anything at all, it just > wraps the current line. do i need any dependencies or doing something wrong? > > thx alot again, i hope other people will find it as useful as i do (i > literally use it 20-30 times a day....) > > > On Tue, Jul 29, 2014 at 4:52 PM, Thorsten Jolitz > wrote: > >> Thorsten Jolitz writes: >> >> > Xebar Saram writes: >> >> This is what I got in my init.el now (improved version with global >> keybindings). And I like, will probably become one of those commands I >> use all the time. >> >> I already used it to wrap the following code in 3 src-blocks: >> >> #+begin_src emacs-lisp >> (defun tj/wrap-sexp-or-reg-in-src-block (&optional lang lines) >> "Wrap sexp at point or region (point +-lines) in src block" >> (interactive >> (when current-prefix-arg >> (list >> (ido-completing-read "Org-Babel language: " >> (mapcar >> (lambda (--lang) >> (symbol-name (car --lang))) >> org-babel-load-languages) >> nil nil nil nil "emacs-lisp") >> (read-number "Number of lines to wrap: " 1)))) >> (let* ((language (or lang "emacs-lisp")) >> (marker (point-marker)) >> (beg (point)) >> (bol (bolp)) >> (end (if lines >> (save-excursion >> (forward-line lines) (point)) >> (save-excursion >> (forward-sexp) (point)))) >> (cut-strg (buffer-substring beg end))) >> (delete-region beg end) >> (goto-char (marker-position marker)) >> (insert >> (format >> "%s#+begin_src %s\n%s%s#+end_src\n" >> (if bol "" "\n") >> language >> cut-strg >> (if lines "" "\n"))) >> (set-marker marker nil))) >> #+end_src >> >> #+begin_src emacs-lisp >> (global-set-key (kbd "C-c w l") >> (lambda () >> (interactive) >> (let ((current-prefix-arg '(4))) >> (call-interactively >> 'tj/wrap-sexp-or-reg-in-src-block)))) >> #+end_src >> >> >> #+begin_src emacs-lisp >> (global-set-key (kbd "C-c w w") >> 'tj/wrap-sexp-or-reg-in-src-block) >> #+end_src >> >> -- >> cheers, >> Thorsten >> >> >> >