From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id +I2AHP14TmNsegEAbAwnHQ (envelope-from ) for ; Tue, 18 Oct 2022 11:59:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id KNiiG/14TmMPsQAAG6o9tA (envelope-from ) for ; Tue, 18 Oct 2022 11:59: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 00D5D13F22 for ; Tue, 18 Oct 2022 11:59:25 +0200 (CEST) Received: from localhost ([::1]:38254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okjNX-0006a9-JE for larch@yhetil.org; Tue, 18 Oct 2022 05:59:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okhzq-0007ss-Rb for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 04:30:59 -0400 Received: from smtpout11.r2.mail-out.ovh.net ([54.36.141.11]:49183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okhzm-0002SK-Of for emacs-orgmode@gnu.org; Tue, 18 Oct 2022 04:30:44 -0400 Received: from ex3.mail.ovh.net (unknown [10.111.172.143]) by mo512.mail-out.ovh.net (Postfix) with ESMTPS id 215C1234AE for ; Tue, 18 Oct 2022 08:30:38 +0000 (UTC) Received: from grostour (90.91.204.169) by DAG3EX2.indiv3.local (172.16.2.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 18 Oct 2022 10:28:58 +0200 References: From: drlkf To: Subject: Fwd: org-priority: allow customization of priority indicator Date: Tue, 18 Oct 2022 10:28:47 +0200 Message-ID: <2243d1d4-94f5-4d05-b655-fac44f277a48@internet> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Originating-IP: [90.91.204.169] X-ClientProxiedBy: CAS3.indiv3.local (172.16.1.3) To DAG3EX2.indiv3.local (172.16.2.6) X-Ovh-Tracer-Id: 7218988728206855323 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeluddgtdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpehfhffvufffkfggtghisehmtderredttddtnecuhfhrohhmpegurhhlkhhfuceoughrlhhkfhesughrlhhkfhdrnhgvtheqnecuggftrfgrthhtvghrnhepfffgjeduffeijeevgefgheettdfhvddtgfdvgfekheeileelffevtdefleejhfeunecukfhppeduvdejrddtrddtrddupdeltddrledurddvtdegrdduieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeoughrlhhkfhesughrlhhkfhdrnhgvtheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepvghmrggtshdqohhrghhmohguvgesghhnuhdrohhrghdpoffvtefjohhsthepmhhoheduvddpmhhouggvpehsmhhtphhouhht Received-SPF: none client-ip=54.36.141.11; envelope-from=drlkf@drlkf.net; helo=smtpout11.r2.mail-out.ovh.net X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) BAYES_00=-1.9, HK_RANDOM_ENVFROM=0.898, HK_RANDOM_FROM=0.999, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 18 Oct 2022 05:42:23 -0400 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=1666087165; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=HIJ3zxXyg46YdTjS8macczl7+UAx36C48zxqclP+j1o=; b=QV6zB4BObLZHJ7q1umu1yfi148frXUFu5X/fbSWgzmLnGyBF0mktsmzKPS57lCAAdnEx8C TeGvvwN/c2+YBOrux05Bz+dwwccUcuOhxtEkApQJyFykbAvfkFBHrSDMOgqPRO1uFjNEKp F3X/s33R9ED3YmM4+wNC83ti22J/GVhNRL6yd3qpm+0mXXrz7y2z9EfiypH6BM/d82lTZ3 dTmH2S2+mJJ/cU0u726D1Erex3hJZTrFMR8TErHc8MZZRGaIY39LXhIbMGF4sQXzQ3dZQo s0/Ds2BhAvT0sxmSA2D+alxDEFnRsbRcpCOGcZwFcPch6kxPpF2htM5lO0S/XQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666087165; a=rsa-sha256; cv=none; b=lBRfZTkd8cFL2ZJviv7tY4oKdJ0s8rZA5R1YBOzz5kFWNaUnqmvp2i98QAdqRUwP4JpGAb hUA8CzR5ZYRiPCf6bgn3MywLJYa1nnvU1imioPRR7n0qMOJlWw7vYwCOHxYIlnKcBwBfhT 37gMDrn5FXqBgNuEuFA9MC8wsfLNlT43uhkPaD2SRR4nZYiMuV4sAs7QdajpERAWKWveXd 8KmcduXipUrbnCafAy/UDIKdDmOnxCDtI8RM29XYtwLAvmEKKMRSbg6YUoxL/brZ6Vp8Gx 0NN1hN+U85uGeHOspsJ5A+ouuuqmbXVXvzvVtPIywmkwJ2wdS1WtkWm60YG3kQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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.32 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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: 00D5D13F22 X-Spam-Score: -5.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: YcbyX0HDdtgg --=-=-= Content-Type: text/plain Hello, 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. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename="org-priority.patch" >From 94117daef8fec4e214d9973a17c2ae4baba1d761 Mon Sep 17 00:00:00 2001 From: drlkf Date: Thu, 9 Jun 2022 03:19:00 +0200 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]). --- org-agenda.el | 4 ++-- org-element.el | 8 ++++++-- org.el | 40 ++++++++++++++++++++++++++++++++-------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/org-agenda.el b/org-agenda.el index 71aac271f..cbbe5e4c6 100644 --- a/org-agenda.el +++ b/org-agenda.el @@ -3431,8 +3431,8 @@ This ensures the export commands can easily use it." (setq props (plist-put props 'day tmp)) (setq props (plist-put props 'agenda-day tmp))) (when (setq tmp (plist-get props 'txt)) - (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)) (setq tmp (replace-match "" t t tmp))) (when (and (setq re (plist-get props 'org-todo-regexp)) (setq re (concat "\\`\\.*" re " ?")) diff --git a/org-element.el b/org-element.el index 9db1406b3..2047e202b 100644 --- a/org-element.el +++ b/org-element.el @@ -1009,7 +1009,9 @@ Assume point is at beginning of the headline." (match-string 1)))) (todo-type (and todo (if (member todo org-done-keywords) 'done 'todo))) - (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)))) (commentedp @@ -1158,7 +1160,9 @@ Assume point is at beginning of the inline task." (match-string 0)))) (todo-type (and todo (if (member todo org-done-keywords) 'done 'todo))) - (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)))) (title-start (point)) diff --git a/org.el b/org.el index 06af12339..648eb840a 100644 --- a/org.el +++ b/org.el @@ -4468,14 +4468,18 @@ related expressions." org-complex-heading-regexp (concat "^\\(\\*+\\)" "\\(?: +" org-todo-regexp "\\)?" - "\\(?: +\\(\\[#.\\]\\)\\)?" + (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)) "\\(?: +" ;; 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) org-comment-string) '(9 'org-special-keyword t)) ;; Blocks and meta lines @@ -7144,7 +7150,7 @@ This is a list with the following elements: (list (length (match-string 1)) (org-reduced-level (length (match-string 1))) (match-string-no-properties 2) - (and (match-end 3) (aref (match-string 3) 2)) + (and (match-end 3) (aref (match-string 3) (length org-priority-prefix))) (match-string-no-properties 4) (match-string-no-properties 5))))) @@ -11269,13 +11275,29 @@ from the `before-change-functions' in the current buffer." ;;;; 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]+\\)\\] ?\\)" "Regular expression matching the priority indicator. A priority indicator can be e.g. [#A] or [#1]. This regular expression matches these groups: 0 : the whole match, e.g. \"TODO [#A] Hack\" 1 : the priority cookie, e.g. \"[#A]\" -2 : the value of the priority cookie, e.g. \"A\".") +2 : the value of the priority cookie, e.g. \"A\". + +This regexp should match `org-priority-prefix' and +`org-priority-suffix' values in order for priorities to work both-ways +(inserting and extracting). + +See also `org-mouse-priority-regexp'.") (defun org-priority-up () "Increase the priority of the current item." @@ -11389,9 +11411,9 @@ or a character." (if (match-end 2) (progn (goto-char (match-end 2)) - (insert " [#" news "]")) + (insert " " org-priority-prefix news org-priority-suffix)) (goto-char (match-beginning 3)) - (insert "[#" news "] ")))) + (insert org-priority-prefix news org-priority-suffix " ")))) (org-align-tags)) (if remove (message "Priority removed") @@ -18800,7 +18822,9 @@ and :keyword." (push (org-point-in-group p 4 :tags) clist)) (goto-char p) (skip-chars-backward "^[\n\r \t") (or (bobp) (backward-char 1)) - (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))) (push (org-point-in-group p 0 :priority) clist))) ((org-at-item-p) -- 2.30.2 --=-=-= Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" --==-=-= Content-Type: text/plain --==-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEFTRUwa3CujBeQymdnvVC2YxLTcEFAmNOY78ACgkQnvVC2YxL TcGEzQ/7BkUFxweTlHWDizNEn2iROqpny9aumEsbxyKt3+wiB7cQf+/1lGrf+Bga fveU/f+pzbd+4CtgZb5umTrLgeGhBU9TOBIezDY1hI2Y7vDUYk4Swc/0QUvA8xvy 1lkOPJNPmWJ+4ksrdh2Zr0Cqgp4EM6OGbIXmoxd9CaGjcT6clux3OLxw2ctGFrqE nczkhdpaLFcD7cidBNTmjOC31HkmrUlLiOXsv7ObVrt4YMRcUJqfIiW/SgI7CwPH o75DNpLUESqWevGH809oGE2+iyhoFUCiw7NQtOc0kMFectzcs+ktWAghZKrA4fQr GX+TK3uXpbJfCsXaYXgjVJCWDNygWu80VTrCnXSFDoVjOOhSmweKq4/E/zqJEj30 qahvucg1sj6sSp/k4fqf9cT1dpbLSZr6NhibSTIcFtEX/juRxuizl3dsZcgVD6GL qkaZ2wbi3uzFIjCy3zQFFszvPG/pge5sXbWQNyJHLgH/WreGZ4x72BhFWQeKdvo6 lBQCmm1KCyo4I/xRJ2zOlanIxeupmTM3GoLmT+FM1xwQRhXNr4sAHitzl8dQATWz PRtJjpRWURrssIuQ82CWsnwGIspO9KneSKF8bNEv6BzbvqegG0OYcHPvSozuy2B1 RO9djc3CrCpcNckpv0cY0hR0UQCbMK+zD0r+tY748klJelZ9vxs= =IUiT -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--