From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id iGZ+AavRWV/sMwAA0tVLHw (envelope-from ) for ; Thu, 10 Sep 2020 07:11:39 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id qArxOKrRWV8BagAA1q6Kng (envelope-from ) for ; Thu, 10 Sep 2020 07:11:38 +0000 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 A0E2094036A for ; Thu, 10 Sep 2020 07:11:38 +0000 (UTC) Received: from localhost ([::1]:47284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kGGk5-0000Rp-Iy for larch@yhetil.org; Thu, 10 Sep 2020 03:11:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kGGjc-0000Qb-G2 for emacs-orgmode@gnu.org; Thu, 10 Sep 2020 03:11:09 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:41430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kGGja-0002qe-G4; Thu, 10 Sep 2020 03:11:08 -0400 Received: by mail-wr1-x434.google.com with SMTP id w5so5445043wrp.8; Thu, 10 Sep 2020 00:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pHf4okG7za4nRRKKPl33EQwtlm1Dyzve5+pi45bb06c=; b=qtXA3RdNVCekkUvaNTBggYrbDHEB7iMqsyRVTCjkeOCBocEySRM8Qh7fCnxbEALfjV JjskLGb64vn1IhLnvHET+/MfvbfvaGht/f6PmWGzpGaRA3MatgOCMAP0q2NjK7uXShsA 4fYh95XrS0rcmMTqLTNgk89EeuiNeoV2Yi8PxkFb2X9G5sbIe0x1yZP+TH16PGty4dKF jRdalbTatpDRoBgc6EgNLdnkCm+eYojAaWfUwDkrIcoU2dde8iC8ZtJvyxKib892VCJ0 UcLtzPU7w7GPJtVw8wI34Y5IsMQeDNkhx0keZiRMpUzpPqpAU86Lnlt8dLMhIK4OE5nS kS0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pHf4okG7za4nRRKKPl33EQwtlm1Dyzve5+pi45bb06c=; b=OgR0vl+eoixhZfivPRjKonf9fqlTM8/TVKFwzkGqrLrDGGSbeJqhIvEU6hyrmJ2BR5 PaLLTY39VdC/cFrecLK2AC6KpULIU3T2KkutJLGYxOxNxu9EKHasVgCkaVok3eq5cOLY btsGPpulCn7O5hgydGq9AMKRcEXOZtJNADw0SQJER3bcCWDnnP/43nZx0MdP+Ii6CtlB IJpJqydTOEHuBMfJOhLMcPSuViyEl6lYM4dywvrlqz60BJsaPVd5vYhFSQq57XfbAe6D I3HwEqP6Q46/oNRPdta52nLlOmwW++zY07iO4996PIwpyUN1k9oePMVUTmmVQuRxzaAG uXZA== X-Gm-Message-State: AOAM533PeeilPg6b+40lXi05D48tSgXvVkTeJOJ0Z9ZwAlJF8zUsB59+ W8XRNynr7Gu8XMnGIodCOBXe6k15q2xe37G4qm4= X-Google-Smtp-Source: ABdhPJzYGTAvh0kF+4rcFSCR0XYZXIoZA09bE5UUIeBBIi31OOZOvO5uE1wsXtWLI/cOF3G+oaZ0ywYKo2pOhEGjp/Q= X-Received: by 2002:adf:912b:: with SMTP id j40mr7531497wrj.42.1599721862691; Thu, 10 Sep 2020 00:11:02 -0700 (PDT) MIME-Version: 1.0 References: <87y2loakcw.fsf@gnu.org> <87d030ae7g.fsf@bzg.fr> In-Reply-To: From: Tom Gillespie Date: Thu, 10 Sep 2020 00:10:51 -0700 Message-ID: Subject: Re: Shouldn't ob-shell's org-babel-expand-src-block prepend the :shebang value? To: Vladimir Nikishkin Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=tgbugs@gmail.com; helo=mail-wr1-x434.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bastien , emacs-orgmode Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=qtXA3RdN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.71 X-TUID: 0DE+6D+zHzm/ Hi Vladimir, I have encountered similar issues with wanting to have a racket #lang line included in a tangled block while also allowing org to know exactly which #lang it is working with. I haven't found a good solution. One issue with embedding the shebang when editing a buffer is that it is very likely to cause confusion because the shebang line will not actually be included when executing the code, or if it was included then there is a reasonable possibility that in some cases it would not be included as the first line due to the addition of a prologue section. It also becomes necessary to remove the shebang line from the edit buffer, which means you have to know which shebang lines were added automatically and which were not. Further, the need to keep what will be run by org babel in line with what is shown via these various views makes it seem unlikely that this should be implemented as default behavior. I have a long email that touches on these issues in the works for after the 9.4 release, so thank you for providing an excellent example. It seems like one possible solution for your workflow would be to advise org-babel-expand-src-block to insert the shebang. Best, Tom On Wed, Sep 9, 2020 at 11:53 PM Vladimir Nikishkin wrote: > > So, my point is the following. A shebang is an almost universally > accepted way to specify which interpreter should be used for code > evaluation. > > In the ob-core.el, at line 787, the function called > org-babel-expand-src-block makes a buffer out of the noweb-expanded > code. > (I am working with org 20200907) > > The sexp is looking like this: > > (org-edit-src-code > expanded (concat "*Org-Babel Preview " (buffer-name) "[ " lang " ]*")) > > I suggest replacing this sexp with > > (org-edit-src-code > (seq-concatenate 'string (or (alist-get :shebang params) "") "\n" > expanded) (concat "*Org-Babel Preview " (buffer-name) "[ " lang " > ]*")) > > This way the expanded buffer would respect the shebang, and the > resulting buffer would be saveable as a runnable file. > > I suspect that the second branch of the (if) should be left as it is, > because non-interactive usage probably means that the code will be > used later as a part of something, and therefore does not need a > shebang. > > Vlad > > On Sat, 5 Sep 2020 at 15:13, Bastien wrote: > > > > Vladimir Nikishkin writes: > > > > > I'll try to do one this week, but I can't submit a patch officially > > > because of my employer being staunchly against signing the copyright > > > disclaimer. > > > > :/ > > > > So please just give directions on what to modify and how, and that'd > > be enough for someone (probably me) to get started. > > > > Thanks! > > > > -- > > Bastien > > > > -- > Yours sincerely, Vladimir Nikishkin >