From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Re: [RFC] Add commmand for wrapping sexp/region in src-blocks to Org? Date: Wed, 6 Aug 2014 15:25:49 +0300 Message-ID: References: <87k36wqirh.fsf@gmail.com> <87zjfjulf7.fsf@gmail.com> <87sil97r3n.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b5d2f888a5c5f04fff512c1 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47789) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF0Hw-0003wI-4N for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 08:25:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XF0Hu-0001BX-Pe for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 08:25:52 -0400 Received: from mail-ob0-x233.google.com ([2607:f8b0:4003:c01::233]:42168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XF0Hu-0001BQ-HK for emacs-orgmode@gnu.org; Wed, 06 Aug 2014 08:25:50 -0400 Received: by mail-ob0-f179.google.com with SMTP id wn1so1748149obc.24 for ; Wed, 06 Aug 2014 05:25:50 -0700 (PDT) In-Reply-To: <87sil97r3n.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Thorsten Jolitz Cc: org mode --047d7b5d2f888a5c5f04fff512c1 Content-Type: text/plain; charset=UTF-8 that sounds great :) looking forward to the next iterations ;-) thanks again for all your hard work Z On Wed, Aug 6, 2014 at 3:14 PM, Thorsten Jolitz wrote: > Xebar Saram writes: > > > thanks Thorsten > > > > its perfect > > well, not perfect yet since, as Nicolas mentioned, it does not cover all > possible use cases (wrap/unwrap/modify ALL kinds of Org blocks with or > without header-line params and with or without affiliated keywords or > with a combination of both). > > I got pretty far in implementing this, but spent too much time - maybe I > can deliver the general 'all-inclusive' version later, I hope so, its > useful. > > > On Tue, Aug 5, 2014 at 4:15 PM, Thorsten Jolitz > > wrote: > > > > Xebar Saram writes: > > > > Hi Xebar, > > > > > small question. > > > > sorry for the late answer > > > > > > > i wonder if i could request a tiny related feature (this may be > > very > > > easy to do already). > > > i would like to assign hotkeys for 2 scenarios: > > > > > > 1) pre selected language for 1 line > > > 2) pre selected language prompting for number of lines to wrap > > > > > > so IE id assign F9-b to auto wrap current line with bash syntax > > while > > > F9-l would wrap in lisp > > > also F10-b would prompt me how man lines to wrap in bash etc > > > > > > is that possible? > > > > > > I think so, I have some predefined calls to that function with > > global > > keybindings in my init file (right now I call it > > `tj/wrap-in-src-block', > > you might have to adapt this): > > > > (global-set-key (kbd "C-c w l") > > (lambda () > > (interactive) > > (let ((current-prefix-arg '(4))) > > (call-interactively > > 'tj/wrap-in-src-block)))) > > > > (global-set-key (kbd "C-c w n") > > (lambda () > > (interactive) > > (let ((current-prefix-arg '(16))) > > (call-interactively > > 'tj/wrap-in-src-block)))) > > > > (global-set-key (kbd "C-c w w") 'tj/wrap-in-src-block) > > > > > > > > > 1) pre selected language for 1 line > > > > > > e.g. > > (global-set-key (kbd "C-c w y") > > (lambda () > > (interactive) > > (tj/wrap-in-src-block "shell" 1))) > > > > > > > > > 2) pre selected language prompting for number of lines to wrap > > > > > > emacs-lisp is kind of preselected, but you could add this after > > the > > ((equal current-prefix-arg '(16)) ...) part > > > > > > ((equal current-prefix-arg '(64)) > > (list > > "shell" > > > > (read-number "Number of lines to wrap: " 1))) > > > > > > and then > > > > (global-set-key (kbd "C-c w z") > > (lambda () > > (interactive) > > (let ((current-prefix-arg '(64))) > > (call-interactively > > 'tj/wrap-in-src-block)))) > > > > everything untested, unfortunately ... > > -- > > cheers, > > Thorsten > > > -- > cheers, > Thorsten > > > --047d7b5d2f888a5c5f04fff512c1 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
that sounds great :)

looking forward to= the next iterations ;-)

thanks again for all your= hard work

Z


On Wed, Aug 6, 2014 at 3:14 PM, Thorsten= Jolitz <tjolitz@gmail.com> wrote:
Xebar Saram <zeltakc@gmail.com&= gt; writes:

> thanks Thorsten
>
> its perfect

well, not perfect yet since, as Nicolas mentioned, it does not cover all possible use cases (wrap/unwrap/modify ALL kinds of Org blocks with or
without header-line params and with or without affiliated keywords or
with a combination of both).

I got pretty far in implementing this, but spent too much time - maybe I can deliver the general 'all-inclusive' version later, I hope so, i= ts
useful.

> On Tue, Aug 5, 2014 at 4:15 PM, Thorsten Jolitz <tjolitz@gmail.com>
> wrote:
>
> =C2=A0 =C2=A0 Xebar Saram <zel= takc@gmail.com> writes:
>
> =C2=A0 =C2=A0 Hi Xebar,
>
> =C2=A0 =C2=A0 > small question.
>
> =C2=A0 =C2=A0 sorry for the late answer
>
>
> =C2=A0 =C2=A0 > i wonder if i could request a tiny related feature = (this may be
> =C2=A0 =C2=A0 very
> =C2=A0 =C2=A0 > easy to do already).
> =C2=A0 =C2=A0 > i would like to assign hotkeys for 2 scenarios:
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > 1) pre selected language for 1 line
> =C2=A0 =C2=A0 > 2) pre selected language prompting for number of li= nes to wrap
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > so IE id assign F9-b to auto wrap current line with= bash syntax
> =C2=A0 =C2=A0 while
> =C2=A0 =C2=A0 > F9-l would wrap in lisp
> =C2=A0 =C2=A0 > also F10-b would prompt me how man lines to wrap in= bash etc
> =C2=A0 =C2=A0 >
> =C2=A0 =C2=A0 > is that possible?
>
>
> =C2=A0 =C2=A0 I think so, I have some predefined calls to that functio= n with
> =C2=A0 =C2=A0 global
> =C2=A0 =C2=A0 keybindings in my init file (right now I call it
> =C2=A0 =C2=A0 `tj/wrap-in-src-block',
> =C2=A0 =C2=A0 you might have to adapt this):
>
> =C2=A0 =C2=A0 (global-set-key (kbd "C-c w l")
> =C2=A0 =C2=A0 (lambda ()
> =C2=A0 =C2=A0 (interactive)
> =C2=A0 =C2=A0 (let ((current-prefix-arg '(4)))
> =C2=A0 =C2=A0 (call-interactively
> =C2=A0 =C2=A0 'tj/wrap-in-src-block))))
>
> =C2=A0 =C2=A0 (global-set-key (kbd "C-c w n")
> =C2=A0 =C2=A0 (lambda ()
> =C2=A0 =C2=A0 (interactive)
> =C2=A0 =C2=A0 (let ((current-prefix-arg '(16)))
> =C2=A0 =C2=A0 (call-interactively
> =C2=A0 =C2=A0 'tj/wrap-in-src-block))))
>
> =C2=A0 =C2=A0 (global-set-key (kbd "C-c w w") 'tj/wrap-i= n-src-block)
>
>
>
> =C2=A0 =C2=A0 > 1) pre selected language for 1 line
>
>
> =C2=A0 =C2=A0 e.g.
> =C2=A0 =C2=A0 (global-set-key (kbd "C-c w y")
> =C2=A0 =C2=A0 (lambda ()
> =C2=A0 =C2=A0 (interactive)
> =C2=A0 =C2=A0 (tj/wrap-in-src-block "shell" 1)))
>
>
>
> =C2=A0 =C2=A0 > 2) pre selected language prompting for number of li= nes to wrap
>
>
> =C2=A0 =C2=A0 emacs-lisp is kind of preselected, but you could add thi= s after
> =C2=A0 =C2=A0 the
> =C2=A0 =C2=A0 ((equal current-prefix-arg '(16)) ...) part
>
>
> =C2=A0 =C2=A0 ((equal current-prefix-arg '(64))
> =C2=A0 =C2=A0 (list
> =C2=A0 =C2=A0 "shell"
>
> =C2=A0 =C2=A0 (read-number "Number of lines to wrap: " 1)))<= br> >
>
> =C2=A0 =C2=A0 and then
>
> =C2=A0 =C2=A0 (global-set-key (kbd "C-c w z")
> =C2=A0 =C2=A0 (lambda ()
> =C2=A0 =C2=A0 (interactive)
> =C2=A0 =C2=A0 (let ((current-prefix-arg '(64)))
> =C2=A0 =C2=A0 (call-interactively
> =C2=A0 =C2=A0 'tj/wrap-in-src-block))))
>
> =C2=A0 =C2=A0 everything untested, unfortunately ...
> =C2=A0 =C2=A0 --
> =C2=A0 =C2=A0 cheers,
> =C2=A0 =C2=A0 Thorsten


--
cheers,
Thorsten



--047d7b5d2f888a5c5f04fff512c1--