From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id aJ4eMMWhTmOElgAAbAwnHQ (envelope-from ) for ; Tue, 18 Oct 2022 14:53:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id KF5iMMWhTmMKWQEA9RJhRA (envelope-from ) for ; Tue, 18 Oct 2022 14:53:25 +0200 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 24ACC2CBDC for ; Tue, 18 Oct 2022 14:53:25 +0200 (CEST) Received: from localhost ([::1]:46850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okm5z-00078i-RM for larch@yhetil.org; Tue, 18 Oct 2022 08:53:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oklo4-0004mt-P7 for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 08:35:07 -0400 Received: from mout02.posteo.de ([185.67.36.66]:33527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oklo1-00023P-NI for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 08:34:52 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2896A240106 for ; Tue, 18 Oct 2022 14:34:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666096486; bh=EjaOTeBrFm8zlpSl0WC3iS7PmVFwGJJhoFBtnSICmkw=; h=From:To:Cc:Subject:Date:From; b=nh61+CmLi5fELmQExJlCGVTN6eDnOe219ZB9oPldgdm4sKWMCAkfNOepj+kO40dMF Tl1rTuELFE2u+ye/n8Bw0khardBWs5rePEWlhyC37OTKSwsaCeS476MVVX9aDzKzBm O3KLKQDH4VLTP5Be8EbBuNPG4XSTpNLT/eqIvIRVVbuoPNBn+h3/oNIdk4Mn9YdfTA +jM4eJI18jCpfQQMdTg+yWS5aLLg9Bc+wLLK5ih8kLO5qKkmXR5Axhnx/De3KPqi0v 9GFSrSl/nL6YIBPcLUUqHd72zsJjxqzu/wPtddrLqI4mTZPEyTw9EXi2MsSfcHYWYN cQiB6VAmMJpBg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MsCx106DHz9rxL; Tue, 18 Oct 2022 14:34:44 +0200 (CEST) From: Ihor Radchenko To: drlkf Cc: emacs-orgmode@gnu.org Subject: Re: Fwd: org-priority: allow customization of priority indicator In-Reply-To: <2243d1d4-94f5-4d05-b655-fac44f277a48@internet> References: <2243d1d4-94f5-4d05-b655-fac44f277a48@internet> Date: Tue, 18 Oct 2022 12:35:31 +0000 Message-ID: <87edv5e2cs.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H2=-0.001, 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.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" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666097605; 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=4dmjvxurMpzbQunfJei3InodQdug0EIe0GPboanr/Kk=; b=J+Dm+YSoaxQm8hhkrtHgVF9zQt5/UGKkjZXdvijwdIcX4YUix+bbvpSY7rs9Sz5DLxDLeT ZAJUN39dDWWf7E2CBHiQedbmqstgTOlnNZQXHLaWXHINbNfcniHVj21EAD/jWyWytXBOSg Xw0VQpF7CW+8/IVQl8ZQWFGhZ789gXbVjCzPJX9rTZ1FQgIeJE7wnFKZi3LR6/xzPXRWgW id/yylWCYEqC6NFnIjjzRRqpTOpA6GUITd6lvcsJGtj3/efK/8fjTxvK98+yaj/edvv3Op bTFySSRj+Oo+/Stk5fZbOUkKsqhx/MBs/4vR2GDZI7esHRITsqrw5ZKTnQdFfQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666097605; a=rsa-sha256; cv=none; b=iJ/4gUCE94JK2XzgPdUlP2gBXlF4uwgkM/3O4wx+uYDc7ey7krxpEnbzE0ygHkvkgRIH9/ 6mWGCZ46tkjbeYYbNbRO/mbptd5iSmwmJ8ubheo/C5OSRxZq2hKBDk6UBkYFq8nNQvSJU4 8gXQG/YSkuzYyQcKsW3w8ZNGN/wpCX8KiY+buZL8+7PuzAhPP2/fEMO5y5k8r5AiVl6TqH OLPeFj2PJrGrD8cZ9qr2IchhZAaGDinzNPL7par1Ykj9S/5l8eoCxq3iiTC+cqj4Vx9sak 31jc0VIo5IB7ZKQ74WAg/voXSRyWuDx6RFI4AQL0+C4uzmIY8nS2lBetw11jZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=nh61+CmL; dmarc=pass (policy=none) header.from=posteo.net; 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" X-Migadu-Spam-Score: -5.02 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=nh61+CmL; dmarc=pass (policy=none) header.from=posteo.net; 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" X-Migadu-Queue-Id: 24ACC2CBDC X-Spam-Score: -5.02 X-Migadu-Scanner: scn0.migadu.com X-TUID: +JvzrIv709wi drlkf writes: > I would like to submit a patch to allow users to change the priority > tag's form entirely. While it has been working for my use-case i.e > basic operations inside org buffers and org-agenda, it is not perfect > and there are some bugs that remain when using more advanced features > with different tag forms (mine is `_p' where `p' is `[1-9]'), that I am > not competent enough to solve. However I believe there are no breaking > changes if the user does not modify said tag form. If there's any > precision I can add, please let me know. Thanks for the patch! In general, we do not intend to support changing basic elements of Org syntax. So, things like your _p may remain buggy because they clash with underscore emphasis. However, your patch is anyway useful because it makes the Org code cleaner and more modular. A side effect that users will be able to change the syntax at their own risk can also be considered as somewhat odd feature (apparently useful for you at least). As a general feedback to the patch, I suggest moving the old and new priority variables into org-element.el and change them to defconst (Elisp still allows altering defconsts). When moving, rename them to use org-element-* prefix, but keep old existing variables under defvaralias. More comments below. > Subject: [PATCH] org-priority: allow customization of priority indicator > > * org.el (org-priority): Allow the user to set the prefix and suffix > of the priority indicator so that it have a completely different form > for them (e.g _A instead of [#A]). Please word the patch more along the lines of "Refactor priority syntax". Org maintainers are not going to take an extra burden of resolving bugs coming from arbitrary changes in property syntax. > - (when (string-match "\\[#\\([A-Z0-9]\\)\\] ?" tmp) > - (plist-put props 'priority-letter (match-string 1 tmp)) > + (when (string-match org-priority-regexp tmp) > + (plist-put props 'priority-letter (match-string 3 tmp)) Do note that org-priority-regexp is not the same with the old regexp. Maybe we can introduce something like org-element-priority-regexp that does not do match groups. Just "[\\[#[A-Z0-9]+\\][ \t]*". Then, you can use it here instead of employing costly lazy matching in analytic org-priority-regexp. > - (priority (and (looking-at "\\[#.\\][ \t]*") > + (priority (and (looking-at (format "%s.%s[ \t]*" > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-prefix))) Better use org-element-priority-regexp as above. > - (priority (and (looking-at "\\[#.\\][ \t]*") > + (priority (and (looking-at (format "%s.%s[ \t]*" > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-prefix))) > (progn (goto-char (match-end 0)) > (aref (match-string 0) 2)))) same > - "\\(?: +\\(\\[#.\\]\\)\\)?" > + (format "\\(?: +\\(%s.%s\\)\\)?" > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-suffix)) > "\\(?: +\\(.*?\\)\\)??" > "\\(?:[ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)?" > "[ \t]*$") > org-complex-heading-regexp-format > (concat "^\\(\\*+\\)" > "\\(?: +" org-todo-regexp "\\)?" > - "\\(?: +\\(\\[#.\\]\\)\\)?" > + (format "\\(?: +\\(%s.%s\\)\\)?" > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-suffix)) same > "\\(?: +" > ;; Stats cookies can be stuck to body. > "\\(?:\\[[0-9%%/]+\\] *\\)*" > @@ -5764,8 +5768,10 @@ needs to be inserted at a specific position in the font-lock sequence.") > '(org-activate-code (1 'org-code t)) > ;; COMMENT > (list (format > - "^\\*+\\(?: +%s\\)?\\(?: +\\[#[A-Z0-9]\\]\\)? +\\(?9:%s\\)\\(?: \\|$\\)" > + "^\\*+\\(?: +%s\\)?\\(?: +%s[A-Z0-9]%s\\)? +\\(?9:%s\\)\\(?: \\|$\\)" > org-todo-regexp > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-suffix) same > ;;;; Priorities > > +(defvar org-priority-prefix "[#" > + "Prefix to insert before a priority value to form the priority indicator. > +It should be matched in accordance by `org-priority-regexp' in order > +for priorities to work both-ways (inserting and extracting).") > + > +(defvar org-priority-suffix "]" > + "Suffix to insert after a priority value to end the priority indicator. > +It should be matched in accordance by `org-priority-regexp' in order > +for priorities to work both-ways (inserting and extracting).") > + > (defvar org-priority-regexp ".*?\\(\\[#\\([A-Z0-9]+\\)\\] ?\\)" You can use org-priority-prefix and org-priority-suffix values here. > - (when (looking-at "\\[#[A-Z0-9]\\]") > + (when (looking-at (format "%s[A-Z0-9]%s" > + (regexp-quote org-priority-prefix) > + (regexp-quote org-priority-suffix))) org-element-priority-regexp -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at