From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xebar Saram Subject: Cool trick on how to eval bash/zsh babel blocks in emacs Date: Mon, 21 Apr 2014 21:40:14 +0300 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e013cba627fd89804f791d472 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcJ8b-0008MA-6t for emacs-orgmode@gnu.org; Mon, 21 Apr 2014 14:40:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WcJ8a-0000wf-3a for emacs-orgmode@gnu.org; Mon, 21 Apr 2014 14:40:17 -0400 Received: from mail-oa0-x232.google.com ([2607:f8b0:4003:c02::232]:60288) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WcJ8Z-0000wX-Ur for emacs-orgmode@gnu.org; Mon, 21 Apr 2014 14:40:16 -0400 Received: by mail-oa0-f50.google.com with SMTP id i11so2690576oag.9 for ; Mon, 21 Apr 2014 11:40:14 -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 --089e013cba627fd89804f791d472 Content-Type: text/plain; charset=UTF-8 Hi all Thanks to the always amazing sacha chua here is a neat way to evaluate/run bash/zsh command line commands inside the emacs term. i find this very useful for collecting multiple bash snippets and quickly running them here is the code #+begin_src emacs-lisp (defadvice org-babel-execute:sh (around sacha activate) (if (assoc-default :term (ad-get-arg 1) nil) (let ((buffer (make-term "babel" "/bin/zsh"))) (with-current-buffer buffer (insert (org-babel-expand-body:generic body params (org-babel-variable-assignments:sh params))) (term-send-input)) (pop-to-buffer buffer)) ad-do-it)) #+end_src i wonder if this would be of interest to other people and perhaps could be incorporated into org mode and babel note of warning: sacha says its very hackish..since i have zero coding knowledge i ill take her word for it even thought it works perfectly here ;-) would love to know if anyone else has interest in this and if people have improvements on this best Z --089e013cba627fd89804f791d472 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all

Thanks to the always amazing sac= ha chua here is a neat way to evaluate/run bash/zsh command line commands i= nside the emacs term. i find this very useful for collecting multiple bash = snippets and quickly running them

here is the code

#+begin_= src emacs-lisp
(defadvice org-babel-execute:sh (around sacha acti= vate)
=C2=A0 (if (assoc-default :term (ad-get-arg 1) nil)
=C2=A0 =C2=A0 (let ((buffer (make-term "babel" "/bin/zsh&quo= t;)))
=C2=A0 =C2=A0 =C2=A0 (with-current-buffer buffer
= =C2=A0 =C2=A0 =C2=A0 =C2=A0 (insert (org-babel-expand-body:generic
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0body params (org-babel-va= riable-assignments:sh params)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (term-send-input))
(pop-to-buffe= r buffer))
=C2=A0 =C2=A0 ad-do-it))
#+end_src


i wonder if this would be of interest = to other people and perhaps could be incorporated into org mode and babel

note of warning: sacha says its very hackish..since i h= ave zero coding knowledge i ill take her word for it even thought it works = perfectly here ;-)

would love to know if anyone el= se has interest in this and if people have improvements on this=C2=A0

best Z
--089e013cba627fd89804f791d472--