From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id SAy4NA8ry2ZJNAAAqHPOHw:P1 (envelope-from ) for ; Sun, 25 Aug 2024 13:01:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id SAy4NA8ry2ZJNAAAqHPOHw (envelope-from ) for ; Sun, 25 Aug 2024 15:01:04 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hMbhEnPk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1724590863; 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=XhQOWIJvSFu/iMBIn6iPniYyjwa5XNZe22jmmNJMFJk=; b=GZmw3XSGij5t7zybheszNoipEnQWywqihkBODUz1BfRnN8ZC2I4nhXaMZotrkIXVGIS3RB tcC/34LGy8cZ5DcA9YMKWvXu6KCbGXajvkjjdN+nLGDGqjwUmwmjQCYfowrdJ4AqJ79mX/ F+qRHD6nzD9iRyJVZrFJx6WVKzdeuI4HaDH4T/XUmiHRADm5Yv8YFqlqWQXczPzPSSuW5n cMXkLdFK5XfnDNRQV1bSMavCrPEt+SVzZS1X63p2G0g1FSMYuhLuCuSBcfg1YK4wZUw4qC S8G5ONNyb0Uyd5DcKPUqENxhfcupfl70xaIOyOopkGmZVZ1SepgHoHwMQsvyoQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1724590863; a=rsa-sha256; cv=none; b=u/48n4ktfqXvbXF+yVITbDzdVhwGMB77meux3P2Fp9SKTqegIONQ4K8yPmqmoRSqFwPdeu 0iX5RP5smG/BaDQFrIWzwMpxrSP8amT4corPD7i98uutOhD5s0EmJTi1SOpZtEa9MEAG7R DFoeO3LFBTigBNqNFvS/77lHo2Pw8Q9Mpd/0swbYDH+Le05Om/nf5RBUW6vmKq/kXksapX vY2tbEbSKC9EfkdgCYhA/5NKn/nZqhclXalIIzWBWPmGujSeY1Gw8SYvK50ycmIOKX8Er3 udSH+kAzzRFTfL2SBCgtMMXVcq5Hj25P4N0SmDEqZYABwT1R1yUkBKHVgiRoPQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hMbhEnPk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" 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 86CBA6E79F for ; Sun, 25 Aug 2024 15:01:03 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1siCqc-00052c-Il; Sun, 25 Aug 2024 08:59:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1siCqa-00052Q-F6 for emacs-orgmode@gnu.org; Sun, 25 Aug 2024 08:59:56 -0400 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1siCqY-000808-GI for emacs-orgmode@gnu.org; Sun, 25 Aug 2024 08:59:56 -0400 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5334c4d6829so4710336e87.2 for ; Sun, 25 Aug 2024 05:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724590792; x=1725195592; darn=gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=XhQOWIJvSFu/iMBIn6iPniYyjwa5XNZe22jmmNJMFJk=; b=hMbhEnPkyKc2gB6Hrxifc3LxhDxts4Ue/NUjinTexWO67VzNonZShHR5W5xjT7fp8u S9NHx0154h73S6NvHPbn8loXLutY801fO7jLr5EZFZDPIQ8DUE8dYuIkodcm+RqFkAbf mQvpGzy+NgWAI0DB9u2K/Q8gBcZRRXD2zNJDqRjM6P6l95+mSaa8B2woTkek8JZPg/bJ z+V5HGDgu4LpUlz0ljJNVGsvheN9lubKhAqk9r3sA1iqoNAKBlYkYviRrhVL7RGwbvtI 7tohaR+VNhSLuT9owbSHAjWNKYKfoLhxXfuyiwJY6pZSmvF3+O9lKLjBUr82tqtYMJet Cjqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724590792; x=1725195592; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XhQOWIJvSFu/iMBIn6iPniYyjwa5XNZe22jmmNJMFJk=; b=q1LynD0MoWGbptDo2zTU6Ca1UJBVat5nX4lzTLnOAv37dSKfCG6E7FRnGXNEaI2uHA XTAaYBej49pxJEbwiqL1lSRCRK5HVjVD8rAfFf/aeulhAi+t5Qi4wBOqrAgjupf7n6kU n/YVPJpzxpvPiqLv6GnzbvNGP6BGAsVjywuoYnP0AShIMS+in1BC0uCoxz4zqflAa6E7 HeGyLgMcT4ejmmQD2Zd34QJ5gkcVbDKy7p1vXKmx7ugXgTHyBhJehQGTnnQHemutrR+r HQjSwuhbSCwitxsH058yc9qVXhGgqdLwqlzelBGjHAe+bEMe31HlQTujB2uCNlPG75NL 8gYw== X-Gm-Message-State: AOJu0YzpkLkPYPFJi0H2pOP1EJSSVM2pQeXZSolUHOVh9uwavqX5dJxu X0lG9F5MlOfB4uhbNswomBwh9p4QfqCKthgeBaoCDYaziEJkpqGRg6MpJQ== X-Google-Smtp-Source: AGHT+IFYEMl9xTVwwAyfdimecPdpF/NeQze+equIo76k/t7aW28D1z+bXBYuI70qFIwgkcaPDCuwGg== X-Received: by 2002:a05:6512:318a:b0:533:46cc:a71e with SMTP id 2adb3069b0e04-534387c4a82mr4255767e87.54.1724590791618; Sun, 25 Aug 2024 05:59:51 -0700 (PDT) Received: from windows (83.24.136.39.ipv4.supernova.orange.pl. [83.24.136.39]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5334ea29782sm1157758e87.48.2024.08.25.05.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 05:59:50 -0700 (PDT) From: =?utf-8?Q?S=C5=82awomir?= Grochowski To: Ihor Radchenko Cc: emacs-orgmode@gnu.org Subject: Re: [BUG] colview.el regexp - capture operator when title is empty In-Reply-To: <8734ms6ake.fsf@localhost> References: <877ccczt83.fsf@gmail.com> <87o75nawdk.fsf@localhost> <87zfp6cmbh.fsf@gmail.com> <875xrobx13.fsf@gmail.com> <8734ms6ake.fsf@localhost> Date: Sun, 25 Aug 2024 14:59:50 +0200 Message-ID: <8734msbvw9.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::129; envelope-from=slawomir.grochowski@gmail.com; helo=mail-lf1-x129.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 86CBA6E79F X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -9.79 X-Spam-Score: -9.79 X-TUID: 44Ri8I16WPFY --=-=-= Content-Type: text/plain Ihor Radchenko writes: > There is no patch attached. --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-lisp-org-colview.el-org-columns-compile-format-regex.patch Content-Transfer-Encoding: quoted-printable >From 987f66774db4ad1e515cac4b9fc5ba46bd627c27 Mon Sep 17 00:00:00 2001 From: Slawomir Grochowski Date: Sat, 24 Aug 2024 18:47:09 +0200 Subject: [PATCH] lisp/org-colview.el: org-columns-compile-format regexp bug= fix MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/org-colview.el (org-columns-compile-format): Refactor string-based regexp to `rx' form. Fix regexp: When an empty parentheses `()` is in the column format string then the regexp can't capture the operator which is in curly brackets `{}`. (org-columns-new): prevent adding empty parantheses '()' to 'column format string' when 'column title' is empty. * testing/lisp.test-org-colview.el (test-org-colview/compile-format): add new case to test: check if operator will be captured when there is empty parantheses '()' in 'column format string'. Reported-by: S=C5=82awomir Grochowski Link: https://list.orgmode.org/orgmode/877ccczt83.fsf@gmail.com/ --- lisp/org-colview.el | 19 ++++++++++++------- testing/lisp/test-org-colview.el | 7 ++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/org-colview.el b/lisp/org-colview.el index bc93941e4..b111c1676 100644 --- a/lisp/org-colview.el +++ b/lisp/org-colview.el @@ -935,8 +935,9 @@ details." (mapcar #'list (org-buffer-property-keys t nil t)) nil nil (nth 0 spec)))) (list prop - (read-string (format "Column title [%s]: " prop) - (nth 1 spec)) + (org-string-nw-p + (read-string (format "Column title [%s]: " prop) + (nth 1 spec))) ;; Use `read-string' instead of `read-number' ;; to allow empty width. (let ((w (read-string @@ -1183,14 +1184,18 @@ This function updates `org-columns-current-fmt-comp= iled'." (setq org-columns-current-fmt-compiled nil) (let ((start 0)) (while (string-match - "%\\([0-9]+\\)?\\([[:alnum:]_-]+\\)\\(?:(\\([^)]+\\))\\)?\ -\\(?:{\\([^}]+\\)}\\)?\\s-*" - fmt start) + (rx "%" + (optional (group (+ digit))) + (group (one-or-more (in alnum "_-"))) + (optional "(" (group (zero-or-more (not (any ")")))) ")") + (optional "{" (group (zero-or-more (not (any "}")))) "}") + (zero-or-more space)) + fmt start) (setq start (match-end 0)) (let* ((width (and (match-end 1) (string-to-number (match-string 1 f= mt)))) (prop (match-string-no-properties 2 fmt)) - (title (or (match-string-no-properties 3 fmt) prop)) - (operator (match-string-no-properties 4 fmt))) + (title (or (org-string-nw-p (match-string-no-properties 3 fmt)) prop= )) + (operator (org-string-nw-p (match-string-no-properties 4 fmt)))) (push (if (not operator) (list (upcase prop) title width nil nil) (let (printf) (when (string-match ";" operator) diff --git a/testing/lisp/test-org-colview.el b/testing/lisp/test-org-colvi= ew.el index 6b603c31b..623ee6283 100644 --- a/testing/lisp/test-org-colview.el +++ b/testing/lisp/test-org-colview.el @@ -90,7 +90,12 @@ (should (equal `(("ITEM" "ITEM" nil "+" "%.1f")) (org-columns-compile-format - "%ITEM{+;%.1f}")))) + "%ITEM{+;%.1f}"))) + (should + ;; Bug https://list.orgmode.org/orgmode/877ccczt83.fsf@gmail.com/ + (equal '(("ITEM" "ITEM" nil "X" nil)) + (org-columns-compile-format + "%ITEM(){X}")))) =20 (ert-deftest test-org-colview/substring-below-width () "Test `org-columns--truncate-below-width'." --=20 2.30.2 --=-=-= Content-Type: text/plain -- Slawomir Grochowski --=-=-=--