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 ms0.migadu.com with LMTPS id OPSCMgpGs2B35gAAgWs5BA (envelope-from ) for ; Sun, 30 May 2021 10:00:10 +0200 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 6AnlLQpGs2D3WAAA1q6Kng (envelope-from ) for ; Sun, 30 May 2021 08:00:10 +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 2910D22B09 for ; Sun, 30 May 2021 10:00:10 +0200 (CEST) Received: from localhost ([::1]:40802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lnGMj-0000hw-0T for larch@yhetil.org; Sun, 30 May 2021 04:00:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lnGMI-0000hm-7j for Emacs-orgmode@gnu.org; Sun, 30 May 2021 03:59:42 -0400 Received: from mail-lj1-x22f.google.com ([2a00:1450:4864:20::22f]:45002) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lnGMF-0000MD-IT for Emacs-orgmode@gnu.org; Sun, 30 May 2021 03:59:41 -0400 Received: by mail-lj1-x22f.google.com with SMTP id s25so10791812ljo.11 for ; Sun, 30 May 2021 00:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:in-reply-to:references:cc:date:message-id :mime-version; bh=sG9XoRLxm3PAd6zBRikDNyTgncCi3D5eZeHrpPTkKko=; b=XDFp/daz2D/BxgWdAmGIN4B0Nk4mB+/UYj60ezbOQUDHvWODUkpnsOSMzG3cVOg+ap Xl4mabbKjrGfHaprCY4WWDLqVibuBqD03ujACqCG2Q5XdlaB2lA97ZwXmki122sGRoLX 0NPVCzykfvhC8h1KXRs46N+Y5GmBcINoH8jpNQfGumE3kX/1CHfAr1j4oVM5386MAdge jvvsWk8cEmJobA/oy7lV4R3QnehZOYXP6TyqPsp8rlp4kktXOQ8FzRKG6I+3TvJutedt WxSLwgTmB4H3jB3at7/oilS6CWNbuOEnn4nCzQfIX89DW6XeKn3HX5wBB2F1Kf2D+0pv P1og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:cc:date :message-id:mime-version; bh=sG9XoRLxm3PAd6zBRikDNyTgncCi3D5eZeHrpPTkKko=; b=frN3kO2xzHbdEVpmrXnT0urrmS1aqDlphvL2WRzw6B+8K6HwPBFmwUXBGszK+e70j7 jH1DZ2mJJ0U9sBoZU68zcMY0RVt57sB3PTHFYo39XAYReJuJABx/JQKUHWiolDTGXJDm quFCdvrRufpQLBplIvOZijw9N7/hhsxyBGZD+35W+wPvrszGmTCAcaGk7lbIYnrNb7Xu xHwEJlob+ObVOGx4fC+tAKufHi5lXcgTa8ettXiBcKx60IsM9WRP3aBH8HjGI9jMMjHv 89Pl5ft0+pfqqgAXi3ogDip+Tn8n0mDuT2DyYu1Ep5O5Gel7PpOXwLDMra8Qz3UuwrEQ lHmg== X-Gm-Message-State: AOAM530mbEDWCA5QGktsKW69HDm1gpoYgCq5iMT/KO+0w651Vh8U7+Wk vuG+mv1YW3kbBd2cWC2Zouw= X-Google-Smtp-Source: ABdhPJzntvkdvC2HTqw6EcMRnQbXFta+09niVMGVynmXSrVYL322A9TALgfQidGLbXqtdWTH2qN9UQ== X-Received: by 2002:a2e:8646:: with SMTP id i6mr12341517ljj.391.1622361577802; Sun, 30 May 2021 00:59:37 -0700 (PDT) Received: from localhost ([158.255.2.9]) by smtp.gmail.com with ESMTPSA id f3sm1070128lja.107.2021.05.30.00.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 May 2021 00:59:37 -0700 (PDT) From: Ihor Radchenko To: Radon Rosborough Subject: Re: [BUG] org-compile-prefix-format regexp change breaks eval forms [9.4.6 (9.4.6-gf72a65)] In-Reply-To: References: <87fsy8yi1e.fsf@localhost> X-Woof-Patch: yes Date: Sun, 30 May 2021 16:04:20 +0800 Message-ID: <87fsy4abqz.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::22f; envelope-from=yantar92@gmail.com; helo=mail-lj1-x22f.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: , Cc: Emacs-orgmode@gnu.org 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=1622361610; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sG9XoRLxm3PAd6zBRikDNyTgncCi3D5eZeHrpPTkKko=; b=lE2Kz6lOhZdXJHUJMs7POlFkFz3P0uxd1exO+R1CmsSO3rVPVBEt1AwXrMT4b8z0WRJYcc njAfYy5udU2y3wif+c4K8Zyk83NljbNfjCRAt/XtwSIIcykBrB2hfsvW/8UKnsbnomZqmI YyMQ5+aT6A70I8D417xvoFUft0dTJsQ5G9YMnGNiaDCTsD4KIebb6NtPqf0bkiB9zkeRob bAz4oFY8KDkUnmpxnbEh67lT78B8unBbBro2AqBFhFBeMSp4NccvHgLSORguibeM2MK6WI K0VdjgTqE3BNf8QjwNMHyuC2Tv6zIguD92rhBcoF7HmQg9vh4thauNhzOoU/UQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1622361610; a=rsa-sha256; cv=none; b=Q3tDHxHtbn6qCUATD+bSCmPMF+lYlBFey5HaWIBIVnyPdk3Ci3s4ps7KlolZV4Qp5KEcBR ZYbLZzNf6ln4USK4HD1pq5j3LS53UakObrkvwK0Y9uFZ7aPRbMKPPlMuMibP3JK0suyJqe ssKBuccPeD5ntcxVYTAXEgpfbeMNJPoeHXdy6OI8IzLPE7Dl6VsB814PYvERO3dggmb6fa 1xyoQJMVRkQTjaaePjvX4f904bjO68lliFH3x0GxVzHQaqTU99J/CfFSr/2D5Sg3xaVivt QGF8a13uUlJVQ/6obFTSw2MxQL4gFDGJy+gsPGGC1w+9OlbkYRqXWIJzdXdo5w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="XDFp/daz"; 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: -1.13 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b="XDFp/daz"; 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: 2910D22B09 X-Spam-Score: -1.13 X-Migadu-Scanner: scn0.migadu.com X-TUID: wASj23B5OwBu --=-=-= Content-Type: text/plain Radon Rosborough writes: > If you insert the format string into a temporary buffer, then the `read' > function will read up to the closing parenthesis and update point > accordingly. That would be a foolproof way to handle all possible Lisp > forms: use a regexp to find the start, and then use `read' to find the end. > Then proceed with regexp matching, and repeat like that. Thanks for the suggestion! The patch is attached. Best, Ihor --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Allow-sexps-with-nested-parenthesis-in-org-agenda-pr.patch >From ffbf7fe29913e33e3f20544be49b6cc2c0ef6409 Mon Sep 17 00:00:00 2001 Message-Id: From: Ihor Radchenko Date: Sun, 30 May 2021 16:00:07 +0800 Subject: [PATCH] Allow sexps with nested parenthesis in org-agenda-prefix-format * lisp/org-agenda.el (org-compile-prefix-format): Use `read' instead of pure regexp matching to determine bounds of %(sexp) expressions in `org-agenda-prefix-format'. Fixes https://orgmode.org/list/87fsy8yi1e.fsf@localhost/ --- lisp/org-agenda.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index f49a24f88..fcfcd872e 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -6942,7 +6942,7 @@ (defun org-compile-prefix-format (key) (and (string-match "\\.[0-9]+" x) (string-to-number (substring (match-string 0 x) 1))))))) (if (eq var 'eval) - (setq varform `(format ,f (org-eval ,(read (match-string 4 s))))) + (setq varform `(format ,f (org-eval ,(read (substring s (match-beginning 4)))))) (if opt (setq varform `(if (member ,var '("" nil)) @@ -6951,7 +6951,12 @@ (defun org-compile-prefix-format (key) (setq varform `(format ,f (if (member ,var '("" nil)) "" (concat ,var ,c (get-text-property 0 'extra-space ,var))))))) - (setq s (replace-match "%s" t nil s)) + (if (eq var 'eval) + (setf (substring s (match-beginning 0) + (+ (match-beginning 4) + (length (format "%S" (read (substring s (match-beginning 4))))))) + "%s") + (setq s (replace-match "%s" t nil s))) (push varform vars)) (setq vars (nreverse vars)) (with-current-buffer (or org-agenda-buffer (current-buffer)) -- 2.26.3 --=-=-=--