From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: drlkf Newsgroups: gmane.emacs.devel Subject: org-priority: allow customization of priority indicator Date: Mon, 17 Oct 2022 22:46:28 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30161"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Oct 18 04:28:16 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okcL1-0007bs-S0 for ged-emacs-devel@m.gmane-mx.org; Tue, 18 Oct 2022 04:28:16 +0200 Original-Received: from localhost ([::1]:50142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okcL0-0005Bn-4Z for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Oct 2022 22:28:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okX0g-0004Fn-7l for emacs-devel@gnu.org; Mon, 17 Oct 2022 16:46:54 -0400 Original-Received: from 8.mo546.mail-out.ovh.net ([46.105.61.39]:51423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okX0e-0007FJ-2r for emacs-devel@gnu.org; Mon, 17 Oct 2022 16:46:53 -0400 Original-Received: from ex3.mail.ovh.net (unknown [10.111.172.114]) by mo546.mail-out.ovh.net (Postfix) with ESMTPS id 2A81423AEF for ; Mon, 17 Oct 2022 20:46:40 +0000 (UTC) Original-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; Mon, 17 Oct 2022 22:46:39 +0200 X-Originating-IP: [90.91.204.169] X-ClientProxiedBy: CAS6.indiv3.local (172.16.1.6) To DAG3EX2.indiv3.local (172.16.2.6) X-Ovh-Tracer-Id: 13776511262000254117 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeekledgudehfecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvufffkfggtghisehmtderredttddtnecuhfhrohhmpegurhhlkhhfuceoughrlhhkfhesughrlhhkfhdrnhgvtheqnecuggftrfgrthhtvghrnhepffetveffvdehheejffekgfetieejfeelgeeiieffkeduueelleegheehgfdvtddunecukfhppeduvdejrddtrddtrddupdeltddrledurddvtdegrdduieelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeoughrlhhkfhesughrlhhkfhdrnhgvtheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepvghmrggtshdquggvvhgvlhesghhnuhdrohhrghdpoffvtefjohhsthepmhhoheegiedpmhhouggvpehsmhhtphhouhht Received-SPF: none client-ip=46.105.61.39; envelope-from=drlkf@drlkf.net; helo=8.mo546.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, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Oct 2022 22:25:03 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:298004 Archived-At: --=-=-= 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----- iQIzBAEBCgAdFiEEFTRUwa3CujBeQymdnvVC2YxLTcEFAmNNvyQACgkQnvVC2YxL TcFjShAAxiqVT5dFPYq9uRgSmoT4xRUcc/1lNN7UYy7TMLoLqxvbwrJMBficquok TMOClM3wVFT0wwh25BiSO8jcuzuBZlVhxaaRcfKoWZ17D9zUGPAQD4hzgRfMFS9x rizQ30efLpu57wKo8UJh4zUDa6Zxrs1Efyzr4nDGHJzf2IUZWi+Nr7x7HOg/2DSy uYLhgexQ+vnO4Mf4Em6xgy5ECEZcCxk4b6GerewDakNJ6BmOyYs1ze5utVWA8kWk mT1SqC6vnHfP3h0TDNfdDrI+iQ302uzo66myS20j5eIoGHv2MdbjcXNmK53Y/9X4 YisbROCefbnR9c8+Kcy9sUDke65mV992jhIEtNxkjNh0GMa9FaeDAczveC0bmku6 elmU9HaecOTBbPENhlWpQYdf5T6NDV4J+Wr2TyQGyNSvHTrMCIFqg446gCzWCWT4 baYiWoWAywyUN59POvxrxwQEe/DmMHTRzp7osuviMvJqCAYrNg09rx7lzbAo9p4P MJTa58H7ngkQfXO8VkDn0MA9URzJHOeSarMOuvfTgGiP/Vdzp1VGandB7b6LGO8f qeoF9G8vSCl0XMop6DBe67bwfi2jejTKLZVsog9NmZaJnNnBEOqSvN2HSwaDMDnx FjswUR0I5wIZHsYi7z5Q2s1ALWNwE/RpE8sGUiY58lSKegSMKSg= =PqW5 -----END PGP SIGNATURE----- --==-=-=-- --=-=-=--