From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6GemJ3xlNWEUoAAAgWs5BA (envelope-from ) for ; Mon, 06 Sep 2021 02:49:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uKYjI3xlNWFZMAAAbx9fmQ (envelope-from ) for ; Mon, 06 Sep 2021 00:49:00 +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 F21A92DEA for ; Mon, 6 Sep 2021 02:48:58 +0200 (CEST) Received: from localhost ([::1]:35990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mN2oi-00048z-KZ for larch@yhetil.org; Sun, 05 Sep 2021 20:48:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mN2o7-00048h-Ov for emacs-orgmode@gnu.org; Sun, 05 Sep 2021 20:48:19 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:39718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mN2o5-0001LP-C2 for emacs-orgmode@gnu.org; Sun, 05 Sep 2021 20:48:19 -0400 Received: by mail-pf1-x433.google.com with SMTP id e16so4339356pfc.6 for ; Sun, 05 Sep 2021 17:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=felesatra-moe.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=d+7Kk6urJTIZETT32/NTrvaRFKUB+mxWa/uz4jit6ls=; b=Xj/a3fsVpyt5OlXM4xx0j5jOjjks1o2Ps7V3lzGhnBBr6/xFblMpNVzC+rZR680DR0 hvyj5H6c3+IdM4IMEyerDxUtoeiQI6P7h2L93q18OI1VU4W9cbzM2SaI26wakjq16jcT EmpY/Whgu+Oa5iwuf4lNdqqvo3cnqJ93/rOHJhohNV0r7JqgKl0g+WUNzbIweAeE62PI PhDVD+FGv2wdvvu3FDBM6VZdrwLTZPHGkUYTwIIgu5+uRsHSUMg96R/83foT0n3qKnDD uVNqdVZlcUfg8wA26RylrLVMCx18FEBGFP6QGn1uk5ZFoOBFCGeBUhANY8Kl5nec6Nqf Hsdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=d+7Kk6urJTIZETT32/NTrvaRFKUB+mxWa/uz4jit6ls=; b=Aw3YHAZ4M5JyhWmRbxZPtelAijaj/z0OorBfOI9a4v5W/Vv5iosjmRUph/00mVURKF 8mcVONgUGUrO/vrotkOKuu6mrK/6XAN3WW+RseIQtvzdLSIYXPV8jE6WZOivhQhT1jzz WeRZn2A2AK4TGb/3sqMTrQrzxYGPsvaZIrifLoX1egZt+NJXCoEC9ZhKn+3qF/Du17QZ 2mIe8SxXEulOy0amn5dkLDfEVrU7RVpFYNltdveM0nFZkfxJcS2k9qaYyV2vwJYY185V yNh10gFh+7/sw4NdUt7DRcMaOyDcsiO3XBwDPGvzXTeVU1uA/t+o82qtIGsMfvBuSQHQ 8Kbg== X-Gm-Message-State: AOAM531kqLagkVeyh5D9zqPTRsb0yhPQ62IJH4jo4hfqfQuCHTe0VlQ+ bMGI5OitRHRsEoDZ1/XRlg1U/w== X-Google-Smtp-Source: ABdhPJw8vwIA704RFShRL0xQ26msI6s2FgKtPEcDuqf6wLU7u7jx89ThHbB46anHJU8JlaQZMC5lvQ== X-Received: by 2002:a63:1717:: with SMTP id x23mr9691154pgl.182.1630889295338; Sun, 05 Sep 2021 17:48:15 -0700 (PDT) Received: from localhost ([2600:1700:7270:7d1f:fa59:71ff:fe00:10cc]) by smtp.gmail.com with ESMTPSA id q7sm5404528pja.11.2021.09.05.17.48.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Sep 2021 17:48:14 -0700 (PDT) From: Allen Li To: No Wayman Subject: Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)] References: <87a6l4b0bx.fsf@gmail.com> <80pmtqp2wx.fsf@felesatra.moe> <87ilzhjwkk.fsf@gmail.com> Date: Sun, 05 Sep 2021 17:48:13 -0700 In-Reply-To: <87ilzhjwkk.fsf@gmail.com> (No Wayman's message of "Fri, 03 Sep 2021 13:13:45 -0400") Message-ID: <80mtoqttpu.fsf@felesatra.moe> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=darkfeline@felesatra.moe; helo=mail-pf1-x433.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, 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=1630889339; 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=d+7Kk6urJTIZETT32/NTrvaRFKUB+mxWa/uz4jit6ls=; b=KCpud7nLGL5G8NuLNn+hzVmUJPXOM3T2Hzic7D+feL/sH3Dj7OuctSDN8HlitjgqSBnXmc Xt8vmL3TN3y8E0tCU621jnh6f1Lf05yzpNQOx7jItk2qV/2aLEpyGgGAzC+ZbvzOpZSKqT eo9ZTC0r7e7TZkTmId8Od2xZVKWmP7MV/oZHLiCvy5l595IyBiN2pMlG2aMsns1TH52COG tbbw/2Y6iGCTvc0R30vmsloDOHmFX9J7FalyuZlI8iJDrDtKAzYd+RUznoC1Afr42BaELn kIkpQfrDfGm2yWCi9pTXPCFhBy6MbmX4lycgB25EOsj28s4F472hw5U/PRsySg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630889339; a=rsa-sha256; cv=none; b=LEoUPlxNVIRzy8CKVu8DGNvuz/TM91Fiew4VtzF9BtDGbeYc5nrfR7fWIvh/JcNQ2EUG7m PjqaHp4Xl3PBMtQIW3HbCxlhC30XWj1qzo/y2yS+NWgoenwzFY7PMyX4Y6ee841hgrgTMg VQGv51Ua3s2lEzQU606869+9Y4SWAcuo1lsoZfehR+udilKoeKY52KyNTXA0VW2dlHtXYy WK9/BRuBOyvrKVuFv/0BA8+iD0WQ21Sx1PK74gXtd74hAEwEB2mmevVgPdO3PEVSz8yFk8 HMQksufRjh3oIiPSQsCT3mFCad5OAGt1qOLVQkto/YKnhcw95MfGPiYNvL/ppg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=felesatra-moe.20150623.gappssmtp.com header.s=20150623 header.b="Xj/a3fsV"; dmarc=none; 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.61 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=felesatra-moe.20150623.gappssmtp.com header.s=20150623 header.b="Xj/a3fsV"; dmarc=none; 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: F21A92DEA X-Spam-Score: -2.61 X-Migadu-Scanner: scn0.migadu.com X-TUID: BwSUs8pSdnSu No Wayman writes: > Allen Li writes: >> The question here is, which behavior do we want? My philosphy >> is that >> programs shouldn't try to silently re-interpret the user's >> intentions. >> For example, if I accidentally mistyped the tag "green_blue" as >> "green-blue", I don't want Org to "helpfully" split one tag into >> two >> tags "green:blue". I may not realize the data corruption until >> too >> late. > > Consider the current behavior of `org-capture-fill-template': > > If you were to mistype your tag as "green-blue" it would be > captured as part of the headline string instead of a set of tags. > Future tag completions would not include any reference to it, and > so you likely wouldn't notice until long after the fact > (especially in the case of a template with a non-nil > :immediate-finish). > So the risk of data corruption exists now by allowing the function > to return an invalid tag string. green-blue is recoverable, and green:blue is not. Consider a file where some headings are tagged :green:blue: and some are tagged :green_blue:. If green-blue gets changed into :green:blue:, then it is no longer possible to tell which :green:blue: headings are supposed to be :green_blue:. If they were left as green-blue, it is trivial to fix them with a search-replace. It is also easy to notice that they were typed incorrectly because the tags would be highlighted differently (as they are invalid). > It defaults to what you've proposed (allowing ":" and "," to > delimit tags). > It avoids introducing a new regexp variable which needs to be > maintained in lockstep with `org-tag-re'. > It's customizable. > It informs the user about the tag delimiting characters in the > prompt. Yes, I think using only ":" and "," is the best default option. I still don't think there is a need to make it customizable (I doubt anyone is typing tags separated with ! or @ or #), but I suppose there's minimal harm from doing so. diff --git a/lisp/org-capture.el b/lisp/org-capture.el index c51744680..e51d039d5 100644 --- a/lisp/org-capture.el +++ b/lisp/org-capture.el @@ -1740,9 +1740,12 @@ The template may still contain \"%?\" for cursor positioning." (org-add-colon-after-tag-completion t) (ins (mapconcat #'identity - (let ((crm-separator "[ \t]*:[ \t]*")) + (let* ((separators (or org-tags-crm-separators '(?: ?,))) + (crm-separator (org-tags-crm-regexp separators))) (completing-read-multiple - (if prompt (concat prompt ": ") "Tags: ") + (if prompt (concat prompt ": ") + (format "Tags (%s to delimit): " + (mapconcat #'char-to-string separators " "))) org-last-tags-completion-table nil nil nil 'org-tags-history)) ":"))) I am -0.5 on showing the delimiters since this is not conventional for completing-read-multiple, especially after we add support for "," like most other uses of completing-read-multiple. It needlessly inflates the length of the prompt. I suggest adding a helper function for the: (separators (or org-tags-crm-separators '(?: ?,))) (crm-separator (org-tags-crm-regexp separators)) so you can call it like: (crm-separator (org-tags--crm-separator-regexp)) since you repeat this verbatim below. diff --git a/lisp/org.el b/lisp/org.el index ce68f4692..4cd173c99 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -2980,6 +2980,11 @@ is better to limit inheritance to certain tags using the variables (const :tag "Reverse alphabetical" org-string-collate-greaterp) (function :tag "Custom function" nil))) +(defcustom org-tags-crm-separators '(?: ?,) + "List of tag delimiting characters used when reading multiple tags." + :type 'list + :group 'org-tags) + (defvar org-tags-history nil "History of minibuffer reads for tags.") (defvar org-last-tags-completion-table nil You should make the :type a list of characters so the widget is more user friendly. @@ -12007,6 +12012,10 @@ tags." ;; it now points to BLANK-START. Use COLUMN instead. (if in-blank? (org-move-to-column column) (goto-char origin)))))) +(defun org-tags-crm-regexp (chars) + "Return `crm-separator' regexp using CHARS as separators." + (format "[ \t]*%s[ \t]*" (regexp-opt (mapcar #'char-to-string chars)))) + (defun org-set-tags-command (&optional arg) "Set the tags for the current visible entry. @@ -12065,11 +12074,13 @@ in Lisp code use `org-set-tags' instead." inherited-tags table (and org-fast-tag-selection-include-todo org-todo-key-alist)) - (let ((org-add-colon-after-tag-completion (< 1 (length table))) - (crm-separator "[ \t]*:[ \t]*")) + (let* ((org-add-colon-after-tag-completion (< 1 (length table))) + (separators (or org-tags-crm-separators '(?: ?,))) + (crm-separator (org-tags-crm-regexp separators))) (mapconcat #'identity (completing-read-multiple - "Tags: " + (format "Tags (%s to delimit): " + (mapconcat #'char-to-string separators " ")) org-last-tags-completion-table nil nil (org-make-tag-string current-tags) 'org-tags-history) -- 2.33.0