From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bjarte Johansen Subject: Re: Make ob-shell conform to the org-babel interface Date: Wed, 3 Jun 2015 12:58:55 +0200 Message-ID: References: <3651FC40-E9B3-4027-91D7-DD03147591C4@infomedia.uib.no> <877frntkj2.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2098\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_A0CC247A-2182-4B0E-8D58-408F39290134" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z06Nz-0005Jr-U6 for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 06:59:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z06Nw-0007iQ-Ll for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 06:59:03 -0400 Received: from alfons.uib.no ([2001:700:200:30::141]:35682) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z06Nw-0007ZG-Ae for emacs-orgmode@gnu.org; Wed, 03 Jun 2015 06:59:00 -0400 In-Reply-To: <877frntkj2.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=_A0CC247A-2182-4B0E-8D58-408F39290134 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Sorry for the delay. Is this better? --Apple-Mail=_A0CC247A-2182-4B0E-8D58-408F39290134 Content-Disposition: attachment; filename=0001-ob-shell-Conform-to-variable-assignment-interface.patch Content-Type: application/octet-stream; name="0001-ob-shell-Conform-to-variable-assignment-interface.patch" Content-Transfer-Encoding: quoted-printable =46rom=202c68fce2a2f340740cc3dded2c8c04841742d21a=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Bjarte=20Johansen=20= =0ADate:=20Wed,=203=20Jun=202015=2012:46:32=20= +0200=0ASubject:=20[PATCH]=20ob-shell:=20Conform=20to=20variable=20= assignment=20interface=0A=0A*=20lisp/ob-shell.el=20= (org-babel-shell-names):=0A=20=20Initialize=20= org-babel-variable-assignments:*=20for=20each=20shell.=0A=0A*=20= (org-babel-variable-assignments-bash):=0A=20=20Renamed=20from=20= `org-babel-variable-assignments:bash'.=0A=0A*=20= (org-babel-variable-assignments:sh):=0A=20=20Apply=20renaming.=0A=0A*=20= testing/lisp/test-ob-shell.el=0A=20=20= (test-ob-shell/should-respect-ob-interface-naming-convention):=0A=20=20= New=20test.=0A=0AChange=20org-babel-variable-assignments=20functions=20= in=20ob-shell=20to=20use=20the=0Asame=20function=20so=20it=20conforms=20= to=20the=20interface=20used=20for=20variable=0Aassignment=20in=20Org=20= Babel.=0A---=0A=20lisp/ob-shell.el=20=20=20=20=20=20=20=20=20=20=20=20=20= =20|=2016=20++++++++++------=0A=20testing/lisp/test-ob-shell.el=20|=2011=20= +++++++++++=0A=202=20files=20changed,=2021=20insertions(+),=206=20= deletions(-)=0A=0Adiff=20--git=20a/lisp/ob-shell.el=20b/lisp/ob-shell.el=0A= index=205b74821..c90ba04=20100644=0A---=20a/lisp/ob-shell.el=0A+++=20= b/lisp/ob-shell.el=0A@@=20-48,10=20+48,14=20@@=0A=20=20=20=20=20= (set-default=20symbol=20(second=20value))=0A=20=20=20=20=20(mapc=0A=20=20= =20=20=20=20(lambda=20(name)=0A-=20=20=20=20=20=20=20(eval=20`(defun=20= ,(intern=20(concat=20"org-babel-execute:"=20name))=20(body=20params)=0A-=09= =09,(format=20"Execute=20a=20block=20of=20%s=20commands=20with=20Babel."=20= name)=0A-=09=09(let=20((shell-file-name=20,name))=0A-=09=09=20=20= (org-babel-execute:shell=20body=20params)))))=0A+=20=20=20=20=20=20=20= (eval=0A+=09`(progn=0A+=09=20=20=20(defun=20,(intern=20(concat=20= "org-babel-execute:"=20name))=20(body=20params)=0A+=09=20=20=20=20=20= ,(format=20"Execute=20a=20block=20of=20%s=20commands=20with=20Babel."=20= name)=0A+=09=20=20=20=20=20(let=20((shell-file-name=20,name))=0A+=09=20=20= =20=20=20=20=20(org-babel-execute:shell=20body=20params)))=0A+=09=20=20=20= (defvar=20,(intern=20(concat=20"org-babel-variable-assignments:"=20= name))=0A+=09=20=20=20=20=20'org-babel-variable-assignments:sh))))=0A=20=20= =20=20=20=20(second=20value))))=0A=20=0A=20(defun=20= org-babel-execute:shell=20(body=20params)=0A@@=20-121,7=20+125,7=20@@=20= This=20function=20is=20called=20by=20`org-babel-execute-src-block'."=0A=20= =20=20=20=20=20values=0A=20=20=20=20=20=20"\n")))=0A=20=0A-(defun=20= org-babel-variable-assignments:bash=20(varname=20values=20&optional=20= sep=20hline)=0A+(defun=20org-babel-variable-assignments-bash=20(varname=20= values=20&optional=20sep=20hline)=0A=20=20=20"Represents=20the=20= parameters=20as=20useful=20Bash=20shell=20variables."=0A=20=20=20(if=20= (listp=20values)=0A=20=20=20=20=20=20=20(if=20(and=20(listp=20(car=20= values))=20(=3D=201=20(length=20(car=20values))))=0A@@=20-138,7=20+142,7=20= @@=20This=20function=20is=20called=20by=20= `org-babel-execute-src-block'."=0A=20=20=20=20=20(mapcar=0A=20=20=20=20=20= =20(lambda=20(pair)=0A=20=20=20=20=20=20=20=20(if=20(string-match=20= "bash$"=20shell-file-name)=0A-=09=20=20=20= (org-babel-variable-assignments:bash=0A+=09=20=20=20= (org-babel-variable-assignments-bash=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20(car=20pair)=20(cdr=20pair)=20sep=20hline)=0A=20=20=20=20=20=20=20=20=20= =20(org-babel-variable-assignments:sh-generic=0A=20=09=20=20(car=20pair)=20= (cdr=20pair)=20sep=20hline)))=0Adiff=20--git=20= a/testing/lisp/test-ob-shell.el=20b/testing/lisp/test-ob-shell.el=0A= index=2058a7859..36f0fc1=20100644=0A---=20= a/testing/lisp/test-ob-shell.el=0A+++=20b/testing/lisp/test-ob-shell.el=0A= @@=20-27,6=20+27,17=20@@=0A=20(unless=20(featurep=20'ob-shell)=0A=20=20=20= (signal=20'missing-test-dependency=20"Support=20for=20Shell=20code=20= blocks"))=0A=20=0A+(ert-deftest=20= test-ob-shell/should-respect-ob-interface-naming-convention=20()=0A+=20=20= "Functions=20used=20to=20interface=20with=20the=20different=20Org=20= Babel=0A+should=20have=20the=20correct=20signature."=0A+=20=20(dolist=20= (shell=20org-babel-shell-names)=0A+=20=20=20=20(org-test-with-temp-text=0A= +=09(format=20"#+BEGIN_SRC=20%s=20:cache=20yes=0A+=20=20echo=20= test=0A+#+END_SRC"=20shell)=0A+=20=20=20=20=20=20(let=20((info=20= (org-babel-get-src-block-info)))=0A+=09(should=20(org-babel-sha1-hash=20= info))))))=0A+=0A=20(ert-deftest=20= test-ob-shell/dont-insert-spaces-on-expanded-bodies=20()=0A=20=20=20= "Expanded=20shell=20bodies=20should=20not=20start=20with=20a=20blank=20= line=0A=20unless=20the=20body=20of=20the=20tangled=20block=20does."=0A--=20= =0A2.3.2=20(Apple=20Git-55)=0A=0A= --Apple-Mail=_A0CC247A-2182-4B0E-8D58-408F39290134 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 01 Jun 2015, at 19:18, Nicolas Goaziou = wrote: >=20 > Hello, >=20 > Bjarte Johansen writes: >=20 >> I found that ob-shell=E2=80=99s org-babel-variable-assignments:bash = function >> does not respect the interface for org-babel. It takes multiple >> arguments when it should only take 1. This is a problem when f.ex. >> org-babel-sha1-hash tries to expand the body of a bash source block >> and tries to call that function with only 1 argument. >>=20 >> I am not sure if the following patch follows best practices in the >> project, but it solves the problem for me. >=20 > Thank you for the patch. Some comments follow. >=20 >> =46rom 04f00e4f69c5352d51b7de1ba8783ddd96124c1f Mon Sep 17 00:00:00 = 2001 >> From: Bjarte Johansen >> Date: Wed, 27 May 2015 17:20:41 +0200 >> Subject: [PATCH] ob-shell: Conform to variable assignment interface >=20 > You need to list modified functions in commit message. >=20 >=20 >> Change org-babel-variable-assignments functions in ob-shell to use = the >> same function so conform to the interface used for variable = assignment >> in org-babel. >=20 > "Org Babel" >=20 >> +(ert-deftest = test-ob-shell/should-respect-ob-interface-naming-convention () >> + "Functions used to interface with the different org-babel >> + should have the correct signature." >=20 > "Org Babel". >=20 > Also, do not indent second line, and please make first sentence fit on > a single line. >=20 >> + (dolist (shell org-babel-shell-names) >> + (org-test-with-temp-text >> + (format "#+BEGIN_SRC %s :cache yes >> + echo test >> +#+END_SRC" shell) >> + (let ((info (org-babel-get-src-block-info))) >> + (org-babel-sha1-hash info))))) >=20 > You need to wrap this within a `should' in order to define a proper > test. >=20 >=20 > Regards, >=20 > --=20 > Nicolas Goaziou --Apple-Mail=_A0CC247A-2182-4B0E-8D58-408F39290134--