From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id +F5oCXU3amDpuAAAgWs5BA (envelope-from ) for ; Mon, 05 Apr 2021 00:02:29 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UHBkA3U3amAhCgAAB5/wlQ (envelope-from ) for ; Sun, 04 Apr 2021 22:02:29 +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 8FD85A1E4 for ; Mon, 5 Apr 2021 00:02:27 +0200 (CEST) Received: from localhost ([::1]:44120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTAp8-00023s-I3 for larch@yhetil.org; Sun, 04 Apr 2021 18:02:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTAof-00023h-KN for emacs-orgmode@gnu.org; Sun, 04 Apr 2021 18:01:57 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]:39537) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTAod-0002Q3-LA for emacs-orgmode@gnu.org; Sun, 04 Apr 2021 18:01:57 -0400 Received: by mail-wm1-x32f.google.com with SMTP id g18-20020a7bc4d20000b0290116042cfdd8so1630262wmk.4 for ; Sun, 04 Apr 2021 15:01:55 -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=jknHNFa8jy4ODQUNstk7Yr3r35aKNPv2zFuSJau7fAo=; b=nJ+/1Wq5PcxwvcGu1LNjIR4vE8PhhHU/TVLIsAlh7n9yVhtgUPESHT3AVlqafZ85Da CUjfcpY9By5i4BHhELPp6o5nczHaxrGbataIW6xmfNGWFvexyygqWGAhzTYUvunSvDym H8UXOVowrnFLWw+Drcp2QWHcatEUKiadOwaYYFsLpu9GvMdXlLzK6l9LFE8fKyy7Qxo+ L9Cbb5hRE2EKaoEN6L+bJJw39Y0k6tqZOP8wjcoBxY+WL5NkvWOek0CK88ZBIMlQyFUj bSv4IvHk/j7Lelr09wm2Mpk4Jkhg0wkoYJ+z6QL+Gnb2Bph7SZsnPSSxlEUTi4yPgq4Y SD5Q== 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=jknHNFa8jy4ODQUNstk7Yr3r35aKNPv2zFuSJau7fAo=; b=I+Hxl+rDAsg7M+TWF9RBkyDd9gZ24scUrxvE6uymQPIsN1Ve+nQn/tHvUT1mAAfqQ2 h3g2Hix0oeHBGfOyl1+/GuMoh6u8/KY7CeQX9DqDtdoJOO4nUP20B9OolZeRyzf3sVK4 6Cqzo/8A9KAu1yiSHYien2jb7VmHE3J1mKnm0z7TfQWT1XYgdI3IhVMM4k4+wwV0nqws SfeeXILUGo+NEIsvikv5UqtZp1CFS5bKhNxPGU/ey9aHNmBGCP57ih7l6R7RKEZ11mBb sJCqkaPplfj8Xz/XqVsKMKkO8dvZziWJeTrVcheTH5+2W1M6JPO6fWHAb2EBnhW4PyNS p+pg== X-Gm-Message-State: AOAM530CHFCyrFqTp4zpztJ4ietaWgUsIvhCqYUMgxPmVZmlRao3kTMx wG9i/x4QlBQfqJ4dyfqdtjTLyiiAV+LgULXI2/c= X-Google-Smtp-Source: ABdhPJy4TDebSsn2pCZ0OSQBXJXncJjmy7QtRPYRKf4D+OjlC3q15nQuWiaAQzNrw62I2qPuhpd57nIVDgfclBG9du0= X-Received: by 2002:a05:600c:3514:: with SMTP id h20mr22803905wmq.45.1617573713872; Sun, 04 Apr 2021 15:01:53 -0700 (PDT) MIME-Version: 1.0 References: <877dlmhuu9.fsf@nicolasgoaziou.fr> In-Reply-To: <877dlmhuu9.fsf@nicolasgoaziou.fr> From: Tom Gillespie Date: Sun, 4 Apr 2021 15:01:42 -0700 Message-ID: Subject: Re: Bug: inconsistent escaping of coderef regexp To: Nicolas Goaziou , emacs-orgmode Content-Type: multipart/mixed; boundary="0000000000009d38eb05bf2cbace" Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=tgbugs@gmail.com; helo=mail-wm1-x32f.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=1617573748; 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=jknHNFa8jy4ODQUNstk7Yr3r35aKNPv2zFuSJau7fAo=; b=cpUsZ4LQL++rqDUeAQo+hRbjklJsr3rTjoID9FtvKUb69+V/w8CVyil6+1OSQ+P8X4+P0K S5RJIQtE90M0kTfQVx0xfXDM8BwL8FUBrBUydKSi7FXS8eQ6AWdJ8rF16s5ZXOgZqmBwQs 4p8fO5+Ktbrq7LNWXejf9W/lvUI/sclHBH3pwfpavXY+/GQbaqpOD551Fr2iQR8cBar0nF 1E4GHKYS/Dst5OS+aCZnyhSxs8pp0onvxXGsUvYWi9xuAaY6k9b8MlXymqbdXho7yRkINY 7OmhaSKcbKEGwXg5bDpM0Nvcl6I7nMVENiNEWIc6OtvkvrEiLPG8UyHb0tb5ZA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1617573748; a=rsa-sha256; cv=none; b=OpSRY0+4uwWPBzF3Sxha29OTnRvwUJmKv1Rnxxw5nZrNKfO6S50ui9Uzeop/Xz7U4Rrhtt wEPvuHLxm+Asu7zQESB2lzp4f49YoN/grPRb1slOInQrFl1DzntgFF8gZA5NIzSDS6l8Yu 5LSFuclBSmhjKGNqPmCcG2vgf3To7EgencXIXQA3kBE4ni8SGGtEUQqY/31i+ckrTLjVTm dV3rDMnJIYdf8NDgZcLVvm82sI9eqa+4MGlkWuFKVjXFtbehKyhdpvhFfilvE0gWHBZWN/ qFwuuQMiJNMxez0WCXB/f/S3NmyzcZjv+BYG3qgGYGibmS8zuSDukIX/EtOXyg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="nJ+/1Wq5"; 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-Spam-Score: -0.54 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="nJ+/1Wq5"; 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: 8FD85A1E4 X-Spam-Score: -0.54 X-Migadu-Scanner: scn0.migadu.com X-TUID: eCACDU51jvSE --0000000000009d38eb05bf2cbace Content-Type: text/plain; charset="UTF-8" Hi Nicolas, After a bit of investigation I understand the issue better now. There are two problems here. One is an easy single line change, the other is a deeper issue, which is that it is impossible for the user to specify their own coderef regexp that can be used in both cases. No matter what change we make we are likely to break existing org files if users relied on one behavior and not the other. Given this, I would say that it is worse to break tangling behavior than it is to break coderef search because it is obvious to the user when coderef search breaks, whereas a change in tanging behavior is a silent change that users will not be aware of. If we want a temporary fix, a patch is attached, but I would suggest against changing the behavior right now and instead work toward a new, more consistent system using header args. I think that moving to use header args to control these is an opportunity to resolve both issues, and to make a start toward eventually deprecating the switches. The only question that I have right now regarding that implementation is whether we provide header args for just the coderef regexp or also for the coderef format, with the coderef regexp taking precedence. The deeper issue is that the format string that appears in the org-src snippit below is hard coded, and if we allow users to set the coderef format, then it may make sense to let them set that format string. However, this would duplicate the simpler functionality of simply allowing the user to provide their own coderef regexp. At the moment I have two proposed header args which are :coderef-regexp with default matching the current output of the org-src snippit below, and :coderef-tangle which defaults to yes matching the behavior of the existing =-r= switch. There is an option for a 3rd header arg that would directly replaced the =-l= switch :coderef-format, however as mentioned above it adds significant complexity and requires a fourth argument :coderef-surround or something like that which is the hard coded format string in the org-src snippit. I'm working on a basic implementation and will respond in this thread again when I have something worth looking at. Best! Tom For the record there are at least 3 different inconsistent regex that are used to detect coderefs. org-element: (string-match "-l +\"\\([^\"\n]+\\)\"" switches) is duplicated between org-element-src-block-parser and org-element-example-block-parser org-src: (format "\\([ \t]*\\(%s\\)[ \t]*\\)$" (replace-regexp-in-string "%s" (if label (regexp-quote label) "\\([-a-zA-Z0-9_][-a-zA-Z0-9_ ]*\\)") (regexp-quote fmt) nil t)) ob-tangle: (re-search-forward (replace-regexp-in-string "%s" ".+" cref-fmt) nil t) --0000000000009d38eb05bf2cbace Content-Type: text/x-patch; charset="US-ASCII"; name="cref-fmt.patch" Content-Disposition: attachment; filename="cref-fmt.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kn3pj83h0 ZGlmZiAtLWdpdCBhL2xpc3Avb2ItdGFuZ2xlLmVsIGIvbGlzcC9vYi10YW5nbGUuZWwKaW5kZXgg YWEwMzczYWI4Li42NzdkOWQ4YmEgMTAwNjQ0Ci0tLSBhL2xpc3Avb2ItdGFuZ2xlLmVsCisrKyBi L2xpc3Avb2ItdGFuZ2xlLmVsCkBAIC00NDYsNyArNDQ2LDcgQEAgbm9uLW5pbCwgcmV0dXJuIHRo ZSBmdWxsIGFzc29jaWF0aW9uIGxpc3QgdG8gYmUgdXNlZCBieQogCSAgICAgICh3aGVuIChzdHJp bmctbWF0Y2ggIi1yIiBleHRyYSkKIAkJKGdvdG8tY2hhciAocG9pbnQtbWluKSkKIAkJKHdoaWxl IChyZS1zZWFyY2gtZm9yd2FyZAotCQkJKHJlcGxhY2UtcmVnZXhwLWluLXN0cmluZyAiJXMiICIu KyIgY3JlZi1mbXQpIG5pbCB0KQorCQkJKHJlcGxhY2UtcmVnZXhwLWluLXN0cmluZyAiJXMiICIu KyIgKG9yZy1zcmMtY29kZXJlZi1yZWdleHAgY3JlZi1mbXQpKSBuaWwgdCkKIAkJICAocmVwbGFj ZS1tYXRjaCAiIikpKQogCSAgICAgIChydW4taG9va3MgJ29yZy1iYWJlbC10YW5nbGUtYm9keS1o b29rKQogCSAgICAgIChidWZmZXItc3RyaW5nKSkpKQo= --0000000000009d38eb05bf2cbace--