emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Xebar Saram <zeltakc@gmail.com>
To: Thorsten Jolitz <tjolitz@gmail.com>
Cc: org mode <emacs-orgmode@gnu.org>
Subject: Re: Elisp function for wrapping sexp or region in src-block (was Re: some lisp help)
Date: Tue, 29 Jul 2014 19:23:21 +0300	[thread overview]
Message-ID: <CAOQHXPpEXPP-0DkXQvZ_82K3Xvw_TUg-Z5nwy6DBQ8CB9BgW0A@mail.gmail.com> (raw)
In-Reply-To: <CAOQHXPoBOKPVdbA6GJcx4F6uZ9X0sfQ_GbD7kBDVmCE_EJm0AA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3050 bytes --]

ok ignore above email, i just saw the previous email..damm gmail..grrr

z


On Tue, Jul 29, 2014 at 7:21 PM, Xebar Saram <zeltakc@gmail.com> wrote:

> 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 <zeltakc@gmail.com> 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 <tjolitz@gmail.com>
>> wrote:
>>
>>> Thorsten Jolitz <tjolitz@gmail.com> writes:
>>>
>>> > Xebar Saram <zeltakc@gmail.com> 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
>>>
>>>
>>>
>>
>

[-- Attachment #2: Type: text/html, Size: 4722 bytes --]

  reply	other threads:[~2014-07-29 16:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-29 11:02 some lisp help (for complete 0-knowledge lisp emacs user :)) Xebar Saram
2014-07-29 12:21 ` Thorsten Jolitz
     [not found]   ` <CAOQHXPoJT4gGTJfOrHAtOfuS53GmPFgSwBqr4OA0ECpE28K1wg@mail.gmail.com>
     [not found]     ` <8761igs5e8.fsf@gmail.com>
2014-07-29 12:48       ` Xebar Saram
2014-07-29 13:30         ` Elisp function for wrapping sexp or region in src-block (was Re: some lisp help) Thorsten Jolitz
2014-07-29 13:52           ` Thorsten Jolitz
2014-07-29 14:48             ` Xebar Saram
2014-07-29 15:42               ` Thorsten Jolitz
2014-07-29 16:21               ` Xebar Saram
2014-07-29 16:23                 ` Xebar Saram [this message]
2014-07-29 16:27                   ` Xebar Saram
2014-07-29 16:36                   ` Thorsten Jolitz
2014-08-04 14:45 ` some lisp help (for complete 0-knowledge lisp emacs user :)) Sebastien Vauban

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOQHXPpEXPP-0DkXQvZ_82K3Xvw_TUg-Z5nwy6DBQ8CB9BgW0A@mail.gmail.com \
    --to=zeltakc@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=tjolitz@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).