From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>
Received: from mp12.migadu.com ([2001:41d0:2:bcc0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms5.migadu.com with LMTPS
	id sP0pBakxsGOYRwEAbAwnHQ
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sat, 31 Dec 2022 13:57:13 +0100
Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp12.migadu.com with LMTPS
	id qLRmBakxsGMiQwEAauVa8A
	(envelope-from <emacs-orgmode-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sat, 31 Dec 2022 13:57:13 +0100
Received: from lists.gnu.org (lists.gnu.org [209.51.188.17])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by aspmx1.migadu.com (Postfix) with ESMTPS id AC80A17177
	for <larch@yhetil.org>; Sat, 31 Dec 2022 13:57:12 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <emacs-orgmode-bounces@gnu.org>)
	id 1pBbPK-0002Nw-Eq; Sat, 31 Dec 2022 07:56:14 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1pBbPI-0002Kj-1E
 for emacs-orgmode@gnu.org; Sat, 31 Dec 2022 07:56:12 -0500
Received: from mout02.posteo.de ([185.67.36.66])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@posteo.net>)
 id 1pBbPF-0004hX-O2
 for emacs-orgmode@gnu.org; Sat, 31 Dec 2022 07:56:11 -0500
Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 4DF23240194
 for <emacs-orgmode@gnu.org>; Sat, 31 Dec 2022 13:56:07 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1672491367; bh=YEGXlQt3p/zI6+ZyRGkWBLbUzMS2wj5LtQpfg7a4aaY=;
 h=From:To:Cc:Subject:Date:From;
 b=VhhpnKuqsmJAg78BZ2vJIqn4domBSDo2X3GVuwZoRjfa/TkQGfRbkpBUv0h4KgvRh
 VM1CuU4Od/CX0VNGV5upCJ9Uvst87eJK0jhoW90t5gmu8stqrR81OqyIX+H+mOwj1h
 3MDTCjx7cYHEi/M8Ztlsvg6zhgHWaKD3i8RciBuLB0qyrKXElgsZ26ktA4sNSQOPui
 C6Ckphmxdf5f2v0GVEWLLA9YO0NzgmESJJfeXUVxywpXOHW+lHn+rBCsgGb0pVZX38
 K7G7vuqRTN9zJrFBa9pcMOaYMy5HGUUK71P8i0X5ha1FibjPJsd49y0N6pKVV8LZXO
 ov5wyM2xISUAA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4NkhvV32gPz9rxK;
 Sat, 31 Dec 2022 13:56:06 +0100 (CET)
From: Ihor Radchenko <yantar92@posteo.net>
To: Matt <matt@excalamus.com>
Cc: bastien <bzg@gnu.org>, emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: ob-shell intentions and paperwork (was Bash results broken?)
In-Reply-To: <18561866f8c.f22a62b3866025.8634474263936272339@excalamus.com>
References: <m2tu1v8gj8.fsf@me.com> <878rj7s0ti.fsf@localhost>
 <1853354beb4.fce54d8d902653.6359367327256505471@excalamus.com>
 <18555580d75.d7b471f9370716.1497263973038999899@excalamus.com>
 <87edsiv54k.fsf@localhost>
 <18561866f8c.f22a62b3866025.8634474263936272339@excalamus.com>
Date: Sat, 31 Dec 2022 12:56:37 +0000
Message-ID: <87r0wfafzu.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net;
 helo=mout02.posteo.de
X-Spam_score_int: -43
X-Spam_score: -4.4
X-Spam_bar: ----
X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: emacs-orgmode@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: "General discussions about Org-mode." <emacs-orgmode.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/emacs-orgmode>
List-Post: <mailto:emacs-orgmode@gnu.org>
List-Help: <mailto:emacs-orgmode-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/emacs-orgmode>,
 <mailto:emacs-orgmode-request@gnu.org?subject=subscribe>
Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org
X-Migadu-Country: US
X-Migadu-Flow: FLOW_IN
ARC-Seal: i=1; s=key1; d=yhetil.org; t=1672491432; a=rsa-sha256; cv=none;
	b=V7UYowQaVmn+txxCVVADmC1tc9wIJB86vbEjPEsRYkqzaViomXCQPzmsi6Y+Ee7SpLreGu
	zIaDPwZnjQdN9oMG94krpgmiL8fe3rFkm3ZeoHfPwWNLXa0oF0BmpijLvYUuIq8jo8wQgN
	yRaO2707IwNtOuyfEPJWAq2Rvpll/rbhya3Q6Ly7At9+n77gTdLf7nqocPgrMG2egOXOnF
	o3WxEkBEWC5sgVZGcb1/S0g+Wz/ZFx1AsHiRaEr9wfzbE/2EnuM+N+u+DZIxfqZEI42hlV
	+v3NxLCPHNjrhFfETXVlk0N3hXb7cawyclg+ycF+B32KBoj86tPUdbt6WsJNgA==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=VhhpnKuq;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org;
	s=key1; t=1672491432;
	h=from:from:sender:sender:reply-to:subject:subject:date:date:
	 message-id:message-id:to:to:cc:cc:mime-version:mime-version:
	 content-type:content-type:
	 content-transfer-encoding:content-transfer-encoding:
	 in-reply-to:in-reply-to:references:references:list-id:list-help:
	 list-unsubscribe:list-subscribe:list-post:dkim-signature;
	bh=VYoFI7pvTM6hjOe/JwA0Y22bIeZpI1IPA0UH9ZgKZ2g=;
	b=dONfRaIvd43s2gUqstt7sdfKTqL3SHa4ZGoNi4TMIKm9dhyj7KG4ibIb1CsqpU8/iSeLMM
	utqm9nQX5mLHRdClxrIxHNbP3CB40BRmFN17G7wwMm/0al20pbc11V38NWAhwA8IjwBJ/e
	tTaTe+a3BVaYj1aEM1i8idSykU2uWfhJCabjOzQKjv66cHh8wOOCDHuqzgRdSvKZY6CcU3
	EXEjbWKT6ODTyKwMVpLghbv7HwaLPKMPeQ+irlIMG9V3Hn4Z3mxqx0JOw2Og9JbWSrcueJ
	HfF3bh/EYZRNhpC6Qb+Tlz0JBonTSop8t0ZVdY81xaAdpiHr1fSrafgfnqsbLw==
X-Spam-Score: -5.77
X-Migadu-Queue-Id: AC80A17177
Authentication-Results: aspmx1.migadu.com;
	dkim=pass header.d=posteo.net header.s=2017 header.b=VhhpnKuq;
	spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org";
	dmarc=pass (policy=none) header.from=posteo.net
X-Migadu-Scanner: scn0.migadu.com
X-Migadu-Spam-Score: -5.77
X-TUID: sTz86Fu+lS4t

Matt <matt@excalamus.com> writes:

>  > > +;; TODO refactor into macro.  Currently violates (elisp) Coding
>  > > +;; Conventions and is hard to debug.
>  > >  (defun org-babel-shell-initialize ()
>  > >    "Define execution functions associated to shell names.
>  >=20
>  > Could you please elaborate? Which particular convention does it violat=
e?
>  > What is hard to debug?
>
> (elisp) Coding Conventions says,
>
> "=E2=80=A2 Constructs that define a function or variable should be macros=
, not
>      functions, and their names should start with =E2=80=98define-=E2=80=
=99.  The macro
>      should receive the name to be defined as the first argument.  That
>      will help various tools find the definition automatically.  Avoid
>      constructing the names in the macro itself, since that would
>      confuse these tools."
>
> The `org-babel-shell-initialize' function defines *all* the `org-babel-ex=
ecute:XXX' functions given by `org-babel-shell-names' (sh, bash, zsh, etc.).

I agree that `org-babel-shell-initialize' could use a better name.

As for being a macro, there will be not much gain - the convention is
mostly designed for things like `cl-defun' aimed to be used in the code.
`org-babel-shell-initialize' is only used by `org-babel-shell-names'.

I do not have objections if it were a macro though. (But I do not see
how it would help debugging).

> Because `org-babel-shell-initialize' is a function factory, you can't eas=
ily examine or modify their definitions.  `C-h f org-babel-execute:sh' jump=
s to the top of lisp/ob-shell.el.  Changing the definition requires reevalu=
ating the definition for all the execute functions (or first changing `org-=
babel-shell-names').

This is indeed a downside. Any better ideas?
ob-core dictates that we must have org-babel-execute:lang functions to
make things work.

> This was a problem for me when I wanted to make the session name string f=
or `test-ob-shell/session' the test name (mentioned above).  In the test, w=
hen I replaced the session name string with a variable containing the strin=
g, `org-babel-execute:sh' failed with a type error.  I couldn't get the var=
iable to evaluate (with backquote and comma or otherwise).  Without an expl=
icit function definition or a macro to expand, I found it hard to debug/exp=
eriment with (and so left the test name as a hard coded string).

Could you please explain a bit more about the problem? I do not see how
macro would help in this situation.

> I probably don't need it and am happy to remove it.    An older version o=
f the function was more complex and made sense as a separate function (or s=
o I thought).  My aim was to make the test strings easy to read so that it'=
s clearer what's being tested (i.e. not write multi-line strings on a singl=
e line).  I could use concat and add "\n" to the end of each line.  Or, sim=
ply write out the string-join.  Maybe there's another way to write multi-li=
ne strings that I'm not aware of in Elisp, maybe something like Python's tr=
iple-quote?

We write multi-line docstrings all the time without extra macros. I
recommend using paredit or similar packages to auto-escape things that
need to be escaped.

--=20
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>