From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CGAfMjzFKmDeKAAA0tVLHw (envelope-from ) for ; Mon, 15 Feb 2021 19:02:20 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oG0ALjzFKmBfNwAA1q6Kng (envelope-from ) for ; Mon, 15 Feb 2021 19:02:20 +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 1942D18862 for ; Mon, 15 Feb 2021 20:02:20 +0100 (CET) Received: from localhost ([::1]:52828 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lBj8T-0003U4-QO for larch@yhetil.org; Mon, 15 Feb 2021 14:02:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lBj5z-0001Q7-5I for emacs-orgmode@gnu.org; Mon, 15 Feb 2021 13:59:43 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:40311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lBj5w-0002ZD-1q for emacs-orgmode@gnu.org; Mon, 15 Feb 2021 13:59:42 -0500 Received: by mail-qt1-x835.google.com with SMTP id v10so5509331qtq.7 for ; Mon, 15 Feb 2021 10:59:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=wL+IHH3mluo+x+H2feNinq+4olLCzuVO4GAm6kqSha8=; b=OhsWfNu7CbsjJU8ZsgeFPnSpd/Ka3lKnXLSMaVBCuB8EEXMvBrMkg+V1gSKWyhGEBz lGhmemRxLkR+OjBvq1MQeIypunkPYXneu4HHmle4Ae4quYF5QiVZtLroq8hoXn0TNxC9 5OQgo8418+7m/jNBZgRGyWzqVMXdTUxjMKqbeJtmrOz1fJlGHlMPTL+J2jfin8m1HDFB XybBP/KITQN0ihZPiLBKKGcZEzQuWOWa+mAUYjytHzDT5ImhLGpnNogMetirNF7hWYKV cGz2ePTOZZn8oh0IYOKfA8/aqqwlSmEdMYvgRmxzNOzWFKYFayDMx10AEZBEq7KkfynS 9HgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=wL+IHH3mluo+x+H2feNinq+4olLCzuVO4GAm6kqSha8=; b=YBF8+6fjZAya7nD2CBRiR6J0knpiiviN+07+Ob5ji5RjBHHKdsj4HbD+6+53csbtD5 BF3BrnIMiGVy+UwanqeSGZ2TKKDXZSFiDXi7DyJL+0P3qL0K+V2eDScoLghB5rYUGZ7z qpaZX0h0NIlpYQ+eh7jXZykIt3rArGjyZDV3EcDN2HC8+qtOYhBm/vFE0qiHvAGi/w2x t844jSBxfYyltXM/wSuYeNusb+BVEcxkF9xydTjWCHxzQGO3xgzPavRWKTYAhH4Ovci3 1rFjbGSptuDCP5PU2jFW/hD4suUfLAAbhiYWdRx8RJlIyayVGMKhqI6fFhFxcmBrkzFO 1VZw== X-Gm-Message-State: AOAM531kkiXo6mkorY/OqfJXEM8Z+zxB/RrsRT2Jcc0Oh0iYtDhMFmBi dqoVsqrpPt7mWY3Pg7r0IixDNhPODbE= X-Google-Smtp-Source: ABdhPJxCfsPhn+S2nKG1RCXZXwQiywoXlF8oTlNb6zdQ971lB91VG3In2/E9YPTu+UQ7SlVaprTIKg== X-Received: by 2002:a05:622a:201:: with SMTP id b1mr15327812qtx.237.1613415577982; Mon, 15 Feb 2021 10:59:37 -0800 (PST) Received: from localhost ([190.239.232.181]) by smtp.gmail.com with ESMTPSA id 136sm12865699qko.12.2021.02.15.10.59.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Feb 2021 10:59:36 -0800 (PST) User-agent: mu4e 1.4.14; emacs 27.1 From: Rodrigo Morales To: emacs-orgmode@gnu.org Subject: How to set the name of a source code block programatically? Date: Mon, 15 Feb 2021 13:56:00 -0500 Message-ID: <871rdhcg8v.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=moralesrodrigo1100@gmail.com; helo=mail-qt1-x835.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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_ENVFROM_END_DIGIT=0.25, 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -1.06 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=OhsWfNu7; 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-Migadu-Queue-Id: 1942D18862 X-Spam-Score: -1.06 X-Migadu-Scanner: scn0.migadu.com X-TUID: nuq6CN1drMj1 --=-=-= Content-Type: text/plain At a first glance, this task seems to be easy: 1. Go to the top of the source code block 2. Insert "#+NAME: <>" or replace the current name. 3. Done. However, there are multiple scenarios. The attached file =main.org= contains the possible scenarios that the function must cover in order to be considered usable. Anyway, I could write the function but before spending time doing that I was wondering if there exist some solutions out there. The motivation for this question is to make names of code blocks include the ID of the current heading so that name clashes doesn'tf occur in Orgf mode files. Recall that =M-x org-lint= complains when there are two code blocks with the same name in the same file. This means that if you have a code block with name =generate-data=, you can't use that same name in that specific file. --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=main.org * foo Some code blocks have neither headers nor names. #+begin_src dash ls #+end_src #+begin_src dash :noweb yes :results output ls #+end_src Some code blocks only have headers. #+HEADER: :noweb yes #+begin_src dash ls #+end_src Some code blocks have multiple headers #+HEADER: :results output #+HEADER: :noweb yes #+begin_src dash ls #+end_src Some code blocks have empty names #+NAME: #+begin_src dash echo a #+end_src Some code blocks have names. #+NAME: ls #+begin_src dash ls #+end_src Some code blocks have names and headers. #+NAME: ls #+HEADER: :results output #+HEADER: :noweb yes #+begin_src dash ls #+end_src #+HEADER: :results output #+NAME: ls #+HEADER: :noweb yes #+begin_src dash ls #+end_src #+HEADER: :results output #+HEADER: :noweb yes #+NAME: ls #+begin_src dash ls #+end_src --=-=-= Content-Type: text/plain -- Greetings, Rodrigo Morales. IRC: rdrg109 (freenode) --=-=-=--