From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 3qxgJfF2MmGoMAAAgWs5BA (envelope-from ) for ; Fri, 03 Sep 2021 21:26:41 +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 yDI6IPF2MmE2fQAAB5/wlQ (envelope-from ) for ; Fri, 03 Sep 2021 19:26:41 +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 BEFDB2F0E for ; Fri, 3 Sep 2021 21:26:40 +0200 (CEST) Received: from localhost ([::1]:50006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMEpi-00026t-S9 for larch@yhetil.org; Fri, 03 Sep 2021 15:26:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMEjC-0007AI-MS for emacs-orgmode@gnu.org; Fri, 03 Sep 2021 15:19:56 -0400 Received: from mail-qt1-x82a.google.com ([2607:f8b0:4864:20::82a]:40450) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMEjA-0001un-Ls for emacs-orgmode@gnu.org; Fri, 03 Sep 2021 15:19:54 -0400 Received: by mail-qt1-x82a.google.com with SMTP id c19so107541qte.7 for ; Fri, 03 Sep 2021 12:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version; bh=5vvevIKZu3sVPmvxVBnbLx3Zhl+d8VUK0/xOqdSN7+4=; b=ZJslJxb7DTJdKzVAu1uBdHbBc6/7TpvfxddYlfEeYN/NanlVyP3CT1nXcs07TsPqe/ BGmCmDxqJv+omgf8M+9k12LmblcOg4rjUY2rYCTTueZFpvXQPr0m2H/gDjyhGpAgtvCo p3Hb5v8Hjsuwzq90lc0/Abd0hjV5HyftYsrB2HWaBIdS3uHxoNvzXlM2VoPpc1I982h9 7b07ChQPXmViN4zPyLfTzgOCv2smAVXFELViHXknHpbZDpUnWyKFFCAsPxnS9blm0Qo3 0jwFJEsUW0mIHqXhkyWSxbh++Xq8+rNbGcRFX9xLmL8Z1RWzIw+P65iNzv1xeIkUnqqD ucUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version; bh=5vvevIKZu3sVPmvxVBnbLx3Zhl+d8VUK0/xOqdSN7+4=; b=sUl3y6PAsWoV8w04VFkTGyBKZuhUZY5uF+efA2t8HoHd6tVM5Fzx9yKKVF1/Bp0r9r 1+y7tJOYQTpvG3q1evEa4FbCd+tlwOqfWrr9Rr05AZ9jJLiqOt3lLEf6POsidLqCZWAd Cl50dOPFrZRac7oE0yi5kr80gxdoYY88KZ+WDLGaGf1mrdE1S8790Yj07dNkOlpNrkMo A41JKW+4s8HaKclIwG4yR926XHENlHrCOjWtnk7w3xUvzS7rfOg43laelYEr46DgUZmv raYqP7nYqYl5I5PWl8ZV94hW5gFF/l8tckosijthl4QdkTUJiFZSbV1oTSIWNb698xAg vkQQ== X-Gm-Message-State: AOAM533nUrObQHBvhOpoDSJjq20wtTAmRCCZonv+HoIQqN4BPtZVFY6Z hSC3KoAqB0Gsvoqic2khPlT8Mo9V3ZI= X-Google-Smtp-Source: ABdhPJxHr3NpdC7NdzJULVoyaUlqi8lhY/0hwYC5lx+i2ywWyFckL8e2ye63Er1CX2km8cQTv3NUZQ== X-Received: by 2002:ac8:7f15:: with SMTP id f21mr452446qtk.413.1630696791353; Fri, 03 Sep 2021 12:19:51 -0700 (PDT) Received: from nbook ([2601:82:c200:166d:2866:4a5e:aa1f:64c5]) by smtp.gmail.com with ESMTPSA id p187sm55728qkd.101.2021.09.03.12.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 12:19:50 -0700 (PDT) References: <87a6l4b0bx.fsf@gmail.com> <80pmtqp2wx.fsf@felesatra.moe> User-agent: mu4e 1.6.4; emacs 28.0.50 From: No Wayman To: Allen Li Subject: Re: [BUG] [BUG] inconsistent behavior when reading multiple tags [9.4.6 (9.4.6-g366444 @ /home/n/.emacs.d/straight/build/org/)] Date: Fri, 03 Sep 2021 13:13:45 -0400 In-reply-to: <80pmtqp2wx.fsf@felesatra.moe> Message-ID: <87ilzhjwkk.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2607:f8b0:4864:20::82a; envelope-from=iarchivedmywholelife@gmail.com; helo=mail-qt1-x82a.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: , 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=1630697200; 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=5vvevIKZu3sVPmvxVBnbLx3Zhl+d8VUK0/xOqdSN7+4=; b=acRQe2rN5Lqv226irT7qFOhkAHZfzBn1AH9Ohw83YIvCzZO9yqoFXkVyLa4X9PC0C87vzY s9PSppwpYYdMQ9IG5JNTq+A313ty3s9AkZPMexBNXzcYBKbeoOoM/07L8irrQ6RimeuW8o FNMpB3fVPAN9CzxI6f429p/jKVnuA1M26ZfNEe88npKS+AHk66NrwOli+85hzTmRIYBtu8 90vyUyxS6Y5z2M2+xfO7yHewjdcG562bXHug0EaR9B6GpBlo2ilAhCURHxKKA6tSc3Kbtm RTpHuBKl6mf1Thx6zyvSh4xmqroahLXOMvd6QowO8cnd1of13xgUA9zcyNANYw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630697200; a=rsa-sha256; cv=none; b=ZUUXSZjBeowRziGQCqumOQOHudSTt7kECmgmhzMac2f1XC9CipZzVZAbgy/Zimjau6yPym 1us0UjUiOT2K0X9seaxgAD4Nd7cdkqEioplnNSQ6mTpP6ZxY7ockhS/H0r9rEkUzs+1c4T hBNDvCw+dTeN3oqVHIpnrrlRLRpY1pk6wb32oazLabeI4UbvYGDraFCrHxKn1+NGz6sfmC vROKqMS0N2o2mFm420BGgx9U7+/A+BXBtcNtOccf/hVDOCkgeDnJ03E/KGP4/S76MUNIfJ 3JILnPBjTx3ai2CpRZ1tqoqEBYE2KTBefRum9iXoO+jrQ6hm0UTiI6Om2/jTHQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ZJslJxb7; 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: -3.12 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=ZJslJxb7; 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: BEFDB2F0E X-Spam-Score: -3.12 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9Phfbur9GNvw --=-=-= Content-Type: text/plain; format=flowed Allen Li writes: > Sorry about that (I wrote the crm patch). I did not consider > people > deliberately using invalid tag characters to separate tags. > It's an > (un?)happy coincidence that org-set-tags-commands retains this > behavior, > because the fast tags selection logic gets in the way. > > The inconsistency in behavior can be easily fixed by deleting > the code > in org-set-tags-commands that replaces invalid tag characters > with ":". > > 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. > There's also the option to only allow ":" and "," as separators. > Whichever behavior we choose, I don't think it's worth making it > customizable. I would rather not have to type ":" to separate Org tags when CRM allows me to use "," (or another character of my choice) everywhere else. This violates the principle of least surprise. An even simpler solution than my original patch is to have a defcustom which allows the user to customize the CRM separator character(s) Org uses to read tags. See the attached patch for a first draft implementation. 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-org-tags-crm-separators.patch Content-Description: org-tags-crm-separators-defcustom >From 34d292a60bc45923589646499b6e06c5cb3ca036 Mon Sep 17 00:00:00 2001 From: Nicholas Vollmer Date: Fri, 3 Sep 2021 14:50:48 -0400 Subject: [PATCH] Add org-tags-crm-separators commit message/formatting pending discussion of solution. --- lisp/org-capture.el | 7 +++++-- lisp/org.el | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lisp/org-capture.el b/lisp/org-capture.el index c51744680..e9cd8f490 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): " + (string-join (mapcar #'char-to-string separators) " "))) org-last-tags-completion-table nil nil nil 'org-tags-history)) ":"))) diff --git a/lisp/org.el b/lisp/org.el index ce68f4692..d6739f7ed 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 characters used to separate tags during Org commands which read mutiple tags." + :type 'list + :group 'org-tags) + (defvar org-tags-history nil "History of minibuffer reads for tags.") (defvar org-last-tags-completion-table nil @@ -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): " + (string-join (mapcar #'char-to-string separators) " ")) org-last-tags-completion-table nil nil (org-make-tag-string current-tags) 'org-tags-history) -- 2.33.0 --=-=-=--