From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjarte Johansen Subject: Re: ob-sed Date: Thu, 28 May 2015 13:47:59 +0200 Message-ID: <751618D6-4EE2-4803-A550-EECE21006ABA@infomedia.uib.no> References: <3C35DA19-1BA3-4249-9128-99DDA0F4752D@infomedia.uib.no> <877frtd7wi.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_042F8958-4F03-40A8-AFF6-DF8F067D7A5A" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwIB-0000VO-VY for emacs-orgmode@gnu.org; Thu, 28 May 2015 07:48:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxwI7-0003z2-Vh for emacs-orgmode@gnu.org; Thu, 28 May 2015 07:48:07 -0400 Received: from alfons.uib.no ([2001:700:200:30::141]:49012) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxwI7-0003yn-L4 for emacs-orgmode@gnu.org; Thu, 28 May 2015 07:48:03 -0400 In-Reply-To: <877frtd7wi.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: emacs-orgmode --Apple-Mail=_042F8958-4F03-40A8-AFF6-DF8F067D7A5A Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii I think I have addressed all your comments in the attached patch. Regards, Bjarte --Apple-Mail=_042F8958-4F03-40A8-AFF6-DF8F067D7A5A Content-Disposition: attachment; filename=0001-Org-Babel-now-supports-sed-scripts.patch Content-Type: application/octet-stream; name="0001-Org-Babel-now-supports-sed-scripts.patch" Content-Transfer-Encoding: quoted-printable =46rom=203ffcdde852fcf968504de640f4f282d6688f9471=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Bjarte=20Johansen=20= =0ADate:=20Thu,=2028=20May=202015=2013:29:09=20= +0200=0ASubject:=20[PATCH]=20Org=20Babel=20now=20supports=20sed=20= scripts=0A=0A---=0A=20doc/org.texi=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20|=20=20=205=20+-=0A=20lisp/ob-sed.el=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20100=20= +++++++++++++++++++++++++++++++++++++++=0A=20= testing/examples/ob-sed-test.org=20|=20=2035=20++++++++++++++=0A=20= testing/lisp/test-ob-sed.el=20=20=20=20=20=20|=20=2060=20= +++++++++++++++++++++++=0A=204=20files=20changed,=20198=20insertions(+),=20= 2=20deletions(-)=0A=20create=20mode=20100644=20lisp/ob-sed.el=0A=20= create=20mode=20100644=20testing/examples/ob-sed-test.org=0A=20create=20= mode=20100644=20testing/lisp/test-ob-sed.el=0A=0Adiff=20--git=20= a/doc/org.texi=20b/doc/org.texi=0Aindex=20f10d4f5..f82566f=20100644=0A= ---=20a/doc/org.texi=0A+++=20b/doc/org.texi=0A@@=20-15056,8=20+15056,9=20= @@=20Code=20blocks=20in=20the=20following=20languages=20are=20supported.=0A= =20@item=20Processing.js=20@tab=20processing=20@tab=20Python=20@tab=20= python=20=0A=20@item=20R=20@tab=20R=20@tab=20Ruby=20@tab=20ruby=20=0A=20= @item=20Sass=20@tab=20sass=20@tab=20Scheme=20@tab=20scheme=20=0A-@item=20= GNU=20Screen=20@tab=20screen=20@tab=20shell=20@tab=20sh=20=0A-@item=20= SQL=20@tab=20sql=20@tab=20SQLite=20@tab=20sqlite=0A+@item=20GNU=20Screen=20= @tab=20screen=20Sed=20@tab=20sed=0A+@item=20@tab=20shell=20@tab=20sh=20= @item=20SQL=20@tab=20sql=0A+@item=20@tab=20SQLite=20@tab=20sqlite=20@tab=20= @tab=0A=20@end=20multitable=0A=20=0A=20Language-specific=20documentation=20= is=20available=20for=20some=20languages.=20=20If=0Adiff=20--git=20= a/lisp/ob-sed.el=20b/lisp/ob-sed.el=0Anew=20file=20mode=20100644=0Aindex=20= 0000000..ee32241=0A---=20/dev/null=0A+++=20b/lisp/ob-sed.el=0A@@=20-0,0=20= +1,100=20@@=0A+;;;=20ob-sed.el=20---=20org-babel=20functions=20for=20sed=20= scripts=0A+=0A+;;=20Copyright=20(C)=202015=20Free=20Software=20= Foundation=0A+=0A+;;=20Author:=20Bjarte=20Johansen=0A+;;=20Keywords:=20= literate=20programming,=20reproducible=20research=0A+;;=20Version:=20= 0.1.0=0A+=0A+;;=20This=20file=20is=20part=20of=20GNU=20Emacs.=0A+=0A+;;;=20= License:=0A+=0A+;;=20This=20program=20is=20free=20software;=20you=20can=20= redistribute=20it=20and/or=20modify=0A+;;=20it=20under=20the=20terms=20= of=20the=20GNU=20General=20Public=20License=20as=20published=20by=0A+;;=20= the=20Free=20Software=20Foundation;=20either=20version=203,=20or=20(at=20= your=20option)=0A+;;=20any=20later=20version.=0A+;;=0A+;;=20This=20= program=20is=20distributed=20in=20the=20hope=20that=20it=20will=20be=20= useful,=0A+;;=20but=20WITHOUT=20ANY=20WARRANTY;=20without=20even=20the=20= implied=20warranty=20of=0A+;;=20MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20= PARTICULAR=20PURPOSE.=20=20See=20the=0A+;;=20GNU=20General=20Public=20= License=20for=20more=20details.=0A+;;=0A+;;=20You=20should=20have=20= received=20a=20copy=20of=20the=20GNU=20General=20Public=20License=0A+;;=20= along=20with=20GNU=20Emacs.=20If=20not,=20see=20= .=0A+=0A+;;;=20Commentary:=0A+=0A+;;=20= Provides=20a=20way=20to=20evaluate=20sed=20scripts=20in=20Org=20mode.=0A= +=0A+;;;=20Usage:=0A+=0A+;;=20Add=20to=20your=20Emacs=20config:=0A+=0A= +;;=20(org-babel-do-load-languages=0A+;;=20=20'org-babel-load-languages=0A= +;;=20=20'((sed=20.=20t)))=0A+=0A+(require=20'ob)=0A+(require=20= 'sed-mode)=0A+=0A+(defvar=20org-babel-sed-command=20"sed"=0A+=20=20"Name=20= of=20the=20sed=20executable=20command.")=0A+=0A+(defvar=20= org-babel-tangle-lang-exts)=0A+(add-to-list=20= 'org-babel-tangle-lang-exts=20'("sed"=20.=20"sed"))=0A+=0A+(defconst=20= org-babel-header-args:sed=0A+=20=20'((:cmd-line=20:any=0A+=20=20=20=20=20= :in-file=20=20:any))=0A+=20=20"Sed=20specific=20header=20arguments.")=0A= +=0A+(defvar=20org-babel-default-header-args:sed=20'()=0A+=20=20"Default=20= arguments=20for=20evaluating=20a=20sed=20source=20block.")=0A+=0A+(defun=20= org-babel-execute:sed=20(body=20params)=0A+=20=20"Execute=20a=20block=20= of=20sed=20code=20with=20Org=20Babel.=0A+BODY=20is=20the=20source=20= inside=20a=20sed=20source=20block=20and=20PARAMS=20is=20an=0A= +association=20list=20over=20the=20source=20block=20configurations.=20= This=0A+function=20is=20called=20by=20`org-babel-execute-src-block'."=0A= +=20=20(message=20"executing=20sed=20source=20code=20block")=0A+=20=20= (let*=20((result-params=20(cdr=20(assq=20:result-params=20params)))=0A+=20= =20=20=20=20=20=20=20=20(cmd-line=20(cdr=20(assq=20:cmd-line=20params)))=0A= +=20=20=20=20=20=20=20=20=20(in-file=20(cdr=20(assq=20:in-file=20= params)))=0A+=09=20(code-file=20(let=20((file=20(org-babel-temp-file=20= "sed-")))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(with-temp-file=20file=0A+=09=09=09(insert=20body))=20file))=0A+=09= =20(stdin=20(let=20((stdin=20(cdr=20(assq=20:stdin=20params))))=0A+=09=09= =20=20=20(when=20stdin=0A+=09=09=20=20=20=20=20(let=20((tmp=20= (org-babel-temp-file=20"sed-stdin-"))=0A+=09=09=09=20=20=20(res=20= (org-babel-ref-resolve=20stdin)))=0A+=09=09=20=20=20=20=20=20=20= (with-temp-file=20tmp=0A+=09=09=09=20(insert=20res))=0A+=09=09=20=20=20=20= =20=20=20tmp))))=0A+=20=20=20=20=20=20=20=20=20(cmd=20(mapconcat=20= #'identity=0A+=09=09=09=20(remq=20nil=0A+=09=09=09=20=20=20=20=20=20=20= (list=20org-babel-sed-command=0A+=09=09=09=09=20=20=20=20=20(format=20= "--file=3D\"%s\""=20code-file)=0A+=09=09=09=09=20=20=20=20=20cmd-line=0A= +=09=09=09=09=20=20=20=20=20in-file))=0A+=09=09=09=20"=20")))=0A+=20=20=20= =20(org-babel-reassemble-table=0A+=20=20=20=20=20(let=20((results=0A+=20=20= =20=20=20=20=20=20=20=20=20=20(cond=0A+=20=20=20=20=20=20=20=20=20=20=20=20= =20(stdin=20(with-temp-buffer=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(call-process-shell-command=20cmd=20stdin=20= (current-buffer))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20(buffer-string)))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20= (t=20(org-babel-eval=20cmd=20"")))))=0A+=20=20=20=20=20=20=20(when=20= results=0A+=20=20=20=20=20=20=20=20=20(org-babel-result-cond=20= result-params=0A+=09=20=20=20results=0A+=09=20=20=20(let=20((tmp=20= (org-babel-temp-file=20"sed-results-")))=0A+=09=20=20=20=20=20= (with-temp-file=20tmp=20(insert=20results))=0A+=09=20=20=20=20=20= (org-babel-import-elisp-from-file=20tmp)))))=0A+=20=20=20=20=20= (org-babel-pick-name=0A+=20=20=20=20=20=20(cdr=20(assq=20:colname-names=20= params))=20(cdr=20(assq=20:colnames=20params)))=0A+=20=20=20=20=20= (org-babel-pick-name=0A+=20=20=20=20=20=20(cdr=20(assq=20:rowname-names=20= params))=20(cdr=20(assq=20:rownames=20params))))))=0A+=0A+(provide=20= 'ob-sed)=0A+;;;=20ob-sed.el=20ends=20here=0Adiff=20--git=20= a/testing/examples/ob-sed-test.org=20b/testing/examples/ob-sed-test.org=0A= new=20file=20mode=20100644=0Aindex=200000000..aae1323=0A---=20/dev/null=0A= +++=20b/testing/examples/ob-sed-test.org=0A@@=20-0,0=20+1,35=20@@=0A= +#+PROPERTY:=20results=20silent=20scalar=0A+#+Title:=20a=20collection=20= of=20examples=20for=20ob-sed=20tests=0A+=0A+*=20Test=20simple=20= execution=20of=20sed=20script=0A+=20=20:PROPERTIES:=0A+=20=20:ID:=20=20=20= =20=20=20=20C7E7CA6A-2601-42C9-B534-4102D62E458D=0A+=20=20:END:=0A+=0A+=20= =20#+NAME:=20ex1=0A+=20=20#+BEGIN_EXAMPLE=0A+=20=20=20=20An=20example=20= sentence.=0A+=20=20#+END_EXAMPLE=0A+=0A+=20=20#+BEGIN_SRC=20sed=20:stdin=20= ex1=0A+=20=20=20=20s/n=20example/=20processed/=0A+=20=20=20=202=20d=0A+=20= =20#+END_SRC=0A+=0A+*=20Test=20:in-file=20header=20argument=0A+=20=20= :PROPERTIES:=0A+=20=20:ID:=20=20=20=20=20=20=20= 54EC49AA-FE9F-4D58-812E-00FC87FAF562=0A+=20=20:END:=0A+=0A+=20=20= #+BEGIN_SRC=20sed=20:in-file=20test1.txt=0A+=20=20s/test/tested/=0A+=20=20= #+END_SRC=0A+=0A+*=20Test=20:cmd-line=20header=20argument=0A+=20=20= :PROPERTIES:=0A+=20=20:ID:=20=20=20=20=20=20=20= E3C6A8BA-39FF-4840-BA8E-90D5C4365AB1=0A+=20=20:END:=0A+=0A+=20=20= #+BEGIN_SRC=20sed=20:in-file=20test2.txt=20:cmd-line=20"-i"=0A+=20=20=20=20= s/test/tested=20again/=0A+=20=20#+END_SRC=0Adiff=20--git=20= a/testing/lisp/test-ob-sed.el=20b/testing/lisp/test-ob-sed.el=0Anew=20= file=20mode=20100644=0Aindex=200000000..c108240=0A---=20/dev/null=0A+++=20= b/testing/lisp/test-ob-sed.el=0A@@=20-0,0=20+1,60=20@@=0A+;;;=20= test-ob-sed.el=20---=20tests=20for=20ob-sed.el=0A+=0A+;;=20Copyright=20= (c)=202015=20Bjarte=20Johansen=0A+;;=20Authors:=20Bjarte=20Johansen=0A+=0A= +;;=20This=20file=20is=20not=20part=20of=20GNU=20Emacs.=0A+=0A+;;=20This=20= program=20is=20free=20software;=20you=20can=20redistribute=20it=20and/or=20= modify=0A+;;=20it=20under=20the=20terms=20of=20the=20GNU=20General=20= Public=20License=20as=20published=20by=0A+;;=20the=20Free=20Software=20= Foundation,=20either=20version=203=20of=20the=20License,=20or=0A+;;=20= (at=20your=20option)=20any=20later=20version.=0A+=0A+;;=20This=20program=20= is=20distributed=20in=20the=20hope=20that=20it=20will=20be=20useful,=0A= +;;=20but=20WITHOUT=20ANY=20WARRANTY;=20without=20even=20the=20implied=20= warranty=20of=0A+;;=20MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20= PARTICULAR=20PURPOSE.=20=20See=20the=0A+;;=20GNU=20General=20Public=20= License=20for=20more=20details.=0A+=0A+;;=20You=20should=20have=20= received=20a=20copy=20of=20the=20GNU=20General=20Public=20License=0A+;;=20= along=20with=20this=20program.=20=20If=20not,=20see=20= .=0A+=0A+;;;=20Code:=0A= +(org-test-for-executable=20"sed")=0A+(unless=20(featurep=20'ob-sed)=0A+=20= =20(signal=20'missing-test-dependency=20"Support=20for=20Sed=20code=20= blocks"))=0A+=0A+(ert-deftest=20ob-sed-test/simple-execution-of-script=20= ()=0A+=20=20"Test=20simple=20execution=20of=20script."=0A+=20=20= (org-test-at-id=20"C7E7CA6A-2601-42C9-B534-4102D62E458D"=0A+=20=20=20=20= (org-babel-next-src-block)=0A+=20=20=20=20(should=20(string=3D=20"A=20= processed=20sentence.\n"=0A+=09=09=20=20=20=20=20= (org-babel-execute-src-block)))))=0A+=0A+(ert-deftest=20= ob-sed-test/in-file-header-argument=20()=0A+=20=20"Test=20:in-file=20= header=20argument."=0A+=20=20(org-test-at-id=20= "54EC49AA-FE9F-4D58-812E-00FC87FAF562"=0A+=20=20=20=20(let=20= ((default-directory=20temporary-file-directory))=0A+=20=20=20=20=20=20= (with-temp-buffer=0A+=09(insert=20"A=20test=20file.")=0A+=09(write-file=20= "test1.txt"))=0A+=20=20=20=20=20=20(org-babel-next-src-block)=0A+=20=20=20= =20=20=20(should=20(string=3D=20"A=20tested=20file.\n"=0A+=09=09=20=20=20= =20=20=20=20(org-babel-execute-src-block))))))=0A+=0A+(ert-deftest=20= ob-sed-test/cmd-line-header-argument=20()=0A+=20=20"Test=20:cmd-line=20= header=20argument."=0A+=20=20(org-test-at-id=20= "E3C6A8BA-39FF-4840-BA8E-90D5C4365AB1"=0A+=20=20=20=20(let=20= ((default-directory=20temporary-file-directory))=0A+=20=20=20=20=20=20= (with-temp-buffer=0A+=09(insert=20"A=20test=20file.")=0A+=09(write-file=20= "test2.txt"))=0A+=20=20=20=20=20=20(org-babel-next-src-block)=0A+=20=20=20= =20=20=20(org-babel-execute-src-block)=0A+=20=20=20=20=20=20(should=20= (string=3D=20"A=20tested=20again=20file.\n"=0A+=09=09=20=20=20=20=20=20=20= (with-temp-buffer=0A+=09=09=09=20(insert-file-contents=20"test2.txt")=0A= +=09=09=09=20(buffer-string)))))))=0A+=0A+=0A+=0A+;;;=20test-ob-sed=20= ends=20here=0A--=20=0A2.3.2=20(Apple=20Git-55)=0A=0A= --Apple-Mail=_042F8958-4F03-40A8-AFF6-DF8F067D7A5A--