From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: some lisp help (for complete 0-knowledge lisp emacs user :)) Date: Tue, 29 Jul 2014 14:02:20 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c21b0635fc0c04ff52f993 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC5Ak-00042r-Cv for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 07:02:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC5Aj-0005p9-5L for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 07:02:22 -0400 Received: from mail-oa0-x22e.google.com ([2607:f8b0:4003:c02::22e]:60295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC5Ai-0005ns-WF for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 07:02:21 -0400 Received: by mail-oa0-f46.google.com with SMTP id m1so10127715oag.33 for ; Tue, 29 Jul 2014 04:02:20 -0700 (PDT) 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: org mode --001a11c21b0635fc0c04ff52f993 Content-Type: text/plain; charset=UTF-8 Hi list so i know i should start to really learn lisp but real life (uni work, family etc) doesn't really allow me so im marking my 1st year anniversary of using emacs without grasping lisp (plus i am in generally coding inept :)) in any case.... :) i have this handy lisp snippet that i find very useful and maybe some others in the list will find as well. it allows to quick convert lines of text into org src/example blocks: (defun z-wrap-cblock-lisp () "Wrap region in quote block" (interactive) (save-excursion (save-restriction (and (region-active-p) (use-region-p) (narrow-to-region (region-beginning) (region-end))) (goto-char (point-min)) (insert "#+BEGIN_SRC emacs-lisp :results none\n") (goto-char (point-max)) (insert "#+END_SRC\n") (deactivate-mark)))) this works well but has some annoying flaws like you have to first manually mark the region you want to convert etc i was wondering: a)can some lisp coding master show me how to make this function auto select the line//X user defined lines/smart paragraph selection before it wraps it in the org block b)any improvement ideas from the community? thx alot in advance Z --001a11c21b0635fc0c04ff52f993 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi list

so i know i should start to rea= lly learn lisp but real life (uni work, family etc) doesn't really allo= w me so im marking my= 1st year anniversary of using emacs without grasping lisp (plus i am in generally coding inept = :))

in any case.... :) i have this handy lisp snippet that = i find very useful and maybe some others in the list will find as well. it = allows to quick convert lines of text into org src/example blocks:

(de= fun z-wrap-cblock-lisp ()
=C2=A0 =C2=A0"Wrap region in quote block"
=C2=A0 =C2=A0(interactive)
=C2=A0 =C2=A0(save-excursion
=C2=A0 =C2=A0 =C2=A0(save-restr= iction
=C2=A0 =C2=A0 =C2=A0 =C2=A0(and
=C2=A0 =C2=A0 = =C2=A0 =C2=A0 (region-active-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (use-= region-p)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (narrow-to-region (region-b= eginning) (region-end)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (point-min))
=C2=A0 =C2=A0 =C2=A0 =C2=A0= (insert "#+BEGIN_SRC<= /span> emacs-lisp :r= esults none\n")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (goto-char (point-max))
=C2=A0 =C2=A0 =C2=A0 =C2=A0= (insert "#+END_SRC\n")
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (de= activate-mark))))


this works well but has some annoying flaws like you have to first manually= mark the region you want to convert etc

i was won= dering:

a)can some lisp coding master show me how = to make this function auto select the line//X user defined lines/smart para= graph selection before it wraps it in the org block
b)any improvement ideas from the community?

<= span class=3D"" id=3D":284.15" tabindex=3D"-1">thx alot in advance

<= div>Z
--001a11c21b0635fc0c04ff52f993--