From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mCxJEOoLbmAEOgAAgWs5BA (envelope-from ) for ; Wed, 07 Apr 2021 21:45:46 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id kH8TCuoLbmAtRwAAB5/wlQ (envelope-from ) for ; Wed, 07 Apr 2021 19:45:46 +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 7671A25ADC for ; Wed, 7 Apr 2021 21:45:45 +0200 (CEST) Received: from localhost ([::1]:43358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lUE7U-0003tf-KN for larch@yhetil.org; Wed, 07 Apr 2021 15:45:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lUE6W-0003rA-LH for emacs-orgmode@gnu.org; Wed, 07 Apr 2021 15:44:44 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]:35655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lUE6U-0007Cv-It for emacs-orgmode@gnu.org; Wed, 07 Apr 2021 15:44:44 -0400 Received: by mail-wm1-x333.google.com with SMTP id b133-20020a1c678b0000b02901231346381dso1773891wmc.0 for ; Wed, 07 Apr 2021 12:44:41 -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; bh=zxdOuEzLa6IdOEnPAjkIkspvxVLWgl1AO55u51wZ8ik=; b=mtCGJbPgt5D/VA/cfEu+w39NCq3qT3wXXwk4mtrFE+ZmtvRC7SC3aoRgh/9yvpTz+t l1oUihg/Wizx6/n0HsJECqLj3x+2NMLmwqXLKOS3ldFcGdfwh9tGnFADoRU2UJpgbPPS HYL/C/rouWHxwVOJV5icT46K1Qz0AFoEkDyGUGOHutPQZa9/8v8WEWuyZod0DI5dcPCq e6S6cDzAb9gxGg50rw9TplaAZRNo4J8q1AC9x3YdJYbSXGYOP479L6kUYePc89SA+Nn8 40N9pKYNqTyLnkLO4GPsvkcBm0xmrvsMCpDX1RFTeHVOTd/0D2pKkoQzfnsjl/OyNDDR mS4A== 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; bh=zxdOuEzLa6IdOEnPAjkIkspvxVLWgl1AO55u51wZ8ik=; b=RotC5+A2ZUPOcwwBL81hNGH1bZJ0DaSQmi/D4jPMdIXc3m6LJYmqw+FavLebhqNt4O MC0suTE34eVRLaI7Evp7Aoun1/YXk4tE2l75w4kLdnkfW3SFfRQhLhP+ekKp9nhaEGXH 6WcdLUPPsKYmntXspDVZ5ai5n5Op+TVMMeDiCD7zfkK9W2ZwVRohO2mRDD2LgzhEWLgN arvElyC5/tRVt8jct1jR0n84sje2N6jfZtsaf8PcFvdjO72C/jL6eHfG9LnuYoZDaur9 xrhiRZMvaMJzWrqg4vKmMmRdI1Cks4F2P8jnY+qX7rsos4g71Ozki3L2ymzu7vqcMW5j EJ/g== X-Gm-Message-State: AOAM530saTpDrGxty8/6yYibXoD/0QuV6A07NfjuLXaZCGyaekiJ/GS4 tmdPDHchv+BXC6m4ftHU1xKudmOXf3/fFsBheic= X-Google-Smtp-Source: ABdhPJwq4wVGm72bKCRs4Z1yesOSjyuI+fu6CmUSfJTyOHHkbHeAldD84M88IU+Pb2aiVihYwOTgqVP9MWOfIm+bQ20= X-Received: by 2002:a1c:49c2:: with SMTP id w185mr4551793wma.163.1617824680325; Wed, 07 Apr 2021 12:44:40 -0700 (PDT) MIME-Version: 1.0 References: <877dlmhuu9.fsf@nicolasgoaziou.fr> <877dlhod94.fsf@nicolasgoaziou.fr> <875z0ym0x8.fsf@nicolasgoaziou.fr> In-Reply-To: <875z0ym0x8.fsf@nicolasgoaziou.fr> From: Tom Gillespie Date: Wed, 7 Apr 2021 12:44:28 -0700 Message-ID: Subject: Re: Bug: inconsistent escaping of coderef regexp To: Tom Gillespie , emacs-orgmode Content-Type: multipart/mixed; boundary="000000000000615e3a05bf67294b" Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=tgbugs@gmail.com; helo=mail-wm1-x333.google.com 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: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1617824745; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=zxdOuEzLa6IdOEnPAjkIkspvxVLWgl1AO55u51wZ8ik=; b=eLvbdMw3e0E/ABB6kcR3PjyUPZX45GXCmhc5CS6fa7/RctV6oiYGF+BIukSUSCXbLt1lCd 5R9ixKf3+3HT1Rs6glsMJHU+jDNhjEi4EfZ/pB3SoodAgw3+/Acw4mic+fAuPFISBHFKZp Zsou2Jnac1xH2rZCh+upLZE8N5lDfPKo0BwFoqVRlrPgz7nqIXGj6OYiUriXEtOAhp/Yt6 ukLroPi3GrTO/yq6toF8zAPuNip1/QZXlGYcjdM3tQx+FabK5hGcv7K3LLIH+SnGOFt7gZ mz+ILCRMZenQXmkfCOFYPj8SZSCFaNgE/pG5q+IUSnydNK0by+enF71ajAPm4g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617824745; a=rsa-sha256; cv=none; b=fXla7L4HOLFYgGecevWISC/cEOZH7vTZWu0vCKziDj/bwKnpK7KGDuuCj2VJx3i5sk5Gnm 4RzpSnZ5STIuUP2MCxSUoToz9HMu9+6up3FShzyiL4q7Nc0K4g9zB8vMbv2FDfOV7fnZUx NOacEq6WIdnJb+obb+QUfZ+5N8f+uEJglcgpB2rZR3vPyQsj639m158Nku50V9Q5zLSnxf VAVh6XOra0UH3GZS3qJoIPXtnGr62kRfr2HcI4bFLd/Y92leOIavkPKzIODv9W1ayTF7a1 d8kOyuDm9QmEsoPRjVPKqdXFiiLFMP/LVpP7xzoniKzaawfY7oOcy+CN+qr5OA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mtCGJbPg; 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-Spam-Score: -2.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=mtCGJbPg; 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: 7671A25ADC X-Spam-Score: -2.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: MFASx4PWLDsm --000000000000615e3a05bf67294b Content-Type: text/plain; charset="UTF-8" Hi Nicolas, I've included the simplest patch I could come up with for the divergence in behavior between org-babel-tangle-single-file and org-link-search. I think there are two new threads that I need to create. One is related to how to make it possible to specify what should be removed along with the coderef (i.e. coderef prefix), the other is the addition of header arguments that provide the same functionality as switches. Best, Tom > This is already conflating the two. I'd like to solve the issue at hand > without having header args interfere at all. > > This can happen later, after a discussion on the ML. Ok. I've included the simplest version of the fix, which is to use org-src-coderef-regexp in org-babel-tangle-single-file. > Would you mind answering my questions first? I still don't follow you > about the coderef prefix/regexp. https://code.orgmode.org/bzg/org-mode/src/2d78ea57cfad1ddc3e993c949daf117b76315170/lisp/org-src.el#L882 That line defines a hardcoded regular expression for matching coderefs. The codref prefix is the first =[ \t]*= and the coderef regexp is the equivalent to the fully formatted version of that format string. Neither of those can currently be specified by the user. The user should not be able to specify the coderef regexp due to the fact that it is too easy to specify a regexp that will not work correctly and because the format string is needed to make org-link-search work for named coderefs (otherwise you wind up trying to replace .+ in the coderef regexp which is a nightmare). The coderef prefix is something that should probably be configurable by the user so that empty comments are not left in the file. I also looked into detecting the comment character for the language in question, but that is significantly more difficult even using (with-temp-buffer (funcall lang-mode) comment-start) because not all languages have sane comment start values and comment-start is not complete, so we would need a way to manually specify what to exclude anyway. --000000000000615e3a05bf67294b Content-Type: text/x-patch; charset="US-ASCII"; name="0001-lisp-ob-tangle.el-Fix-coderef-removal-during-tanglin.patch" Content-Disposition: attachment; filename="0001-lisp-ob-tangle.el-Fix-coderef-removal-during-tanglin.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kn7ulkff0 RnJvbSBjMzA5MTNkYTZiMWM4ZDZiZTM2NzBhNTlhZTg2N2RmMDE5NTA1YWYzI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