From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: inherit priority Date: Sun, 31 Dec 2017 10:14:22 -0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------8A5777233F2EA2595E4777EE" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eVi7x-0004h4-M1 for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 13:14:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eVi7t-0000rB-K1 for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 13:14:29 -0500 Received: from mail-pl0-x22a.google.com ([2607:f8b0:400e:c01::22a]:41878) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eVi7t-0000qQ-D4 for emacs-orgmode@gnu.org; Sun, 31 Dec 2017 13:14:25 -0500 Received: by mail-pl0-x22a.google.com with SMTP id g2so25924797pli.8 for ; Sun, 31 Dec 2017 10:14:25 -0800 (PST) Received: from [192.168.1.200] ([23.252.58.98]) by smtp.gmail.com with ESMTPSA id b63sm39337386pga.24.2017.12.31.10.14.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 31 Dec 2017 10:14:22 -0800 (PST) Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org This is a multi-part message in MIME format. --------------8A5777233F2EA2595E4777EE Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi all, I want child org items to inherit priority from their parent. I tried setting |org-use-property-inheritance '("PRIORITY")|, but it did not have any apparent effect. Use case: I often have high priority projects whose tasks are mostly equally important. I don't want to waste time setting priorities for each individual child task unless it differs from the parent (e.g., an optional subtask may have lower priority). I realize this has been brought up a few times over the years, but I couldn't find any recent info on how this is doable with stock org. Gracias, Jesse --------------8A5777233F2EA2595E4777EE Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

Hi all,

I want child org items to inherit priority from their parent.

I tried setting org-use-property-inheritance '("PRIORITY"), but it did not have any apparent effect.

Use case: I often have high priority projects whose tasks are mostly equally important. I don't want to waste time setting priorities for each individual child task unless it differs from the parent (e.g., an optional subtask may have lower priority).

I realize this has been brought up a few times over the years, but I couldn't find any recent info on how this is doable with stock org.

Gracias,

Jesse

--------------8A5777233F2EA2595E4777EE-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Wed, 03 Jan 2018 22:41:33 +0100 Message-ID: <87wp0ymxgy.fsf@nicolasgoaziou.fr> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWqn5-00085e-Aw for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 16:41:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWqn2-0005uV-1f for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 16:41:39 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:42468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eWqn1-0005tt-RM for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 16:41:35 -0500 In-Reply-To: (Jesse Johnson's message of "Sun, 31 Dec 2017 10:14:22 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > I want child org items to inherit priority from their parent. > > I tried setting |org-use-property-inheritance '("PRIORITY")|, but it > did not have any apparent effect. What did you try exactly, i.e., how could you show an ECM demonstrating the issue? Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Wed, 3 Jan 2018 20:04:56 -0800 Message-ID: <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55182) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eWwm6-0007NK-9h for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 23:05:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eWwm3-0001jl-5X for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 23:05:02 -0500 Received: from mail-pl0-x229.google.com ([2607:f8b0:400e:c01::229]:43907) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eWwm2-0001jF-UI for emacs-orgmode@gnu.org; Wed, 03 Jan 2018 23:04:59 -0500 Received: by mail-pl0-x229.google.com with SMTP id z5so367886plo.10 for ; Wed, 03 Jan 2018 20:04:58 -0800 (PST) In-Reply-To: <87wp0ymxgy.fsf@nicolasgoaziou.fr> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Hi! I don't know what an ECM is in this context, but I assume you mean a minimal reproducible case. 1. Set |org-use-property-inheritance '("PRIORITY")| 2. Create a new org file with this content: * [#A] parent ** child A ** child B 3. View org-columns (C-c C-x C-c in my setup) 4. Note that the children have priority B, while parent has priority A. For my use case I want org agenda to recognize that priority is being inherited for purpose of filtering and sorting. On 01/03/2018 01:41 PM, Nicolas Goaziou wrote: > Hello, > > Jesse Johnson writes: > >> I want child org items to inherit priority from their parent. >> >> I tried setting |org-use-property-inheritance '("PRIORITY")|, but it >> did not have any apparent effect. > What did you try exactly, i.e., how could you show an ECM demonstrating > the issue? > > Regards, > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Thu, 04 Jan 2018 09:15:58 +0100 Message-ID: <87o9mam43l.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eX0h4-0005cF-1O for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 03:16:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eX0h0-0001pB-2E for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 03:16:06 -0500 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:51030) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eX0gz-0001oe-S8 for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 03:16:01 -0500 In-Reply-To: <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> (Jesse Johnson's message of "Wed, 3 Jan 2018 20:04:56 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > 1. Set |org-use-property-inheritance '("PRIORITY")| > > 2. Create a new org file with this content: > > * [#A] parent > ** child A > ** child B > > 3. View org-columns (C-c C-x C-c in my setup) > > 4. Note that the children have priority B, while parent has priority > A. Oh yes, I realize now. PRIORITY is a special property: (info "(org) Special properties") They follow their own inheritance rules -- in this case, none. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Thu, 4 Jan 2018 20:00:27 -0800 Message-ID: References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45152) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXJB8-0000NE-U3 for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 23:00:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXJB4-0003ZQ-QW for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 23:00:22 -0500 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]:35742) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eXJB3-0003Y2-Rt for emacs-orgmode@gnu.org; Thu, 04 Jan 2018 23:00:18 -0500 Received: by mail-pf0-x22f.google.com with SMTP id j124so1719625pfc.2 for ; Thu, 04 Jan 2018 20:00:17 -0800 (PST) In-Reply-To: <87o9mam43l.fsf@nicolasgoaziou.fr> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org There have been several requests for priority inheritance over the years. If it can't currently be done, I am willing to take a look at implementing it. On 01/04/2018 12:15 AM, Nicolas Goaziou wrote: > Hello, > > Jesse Johnson writes: > >> 1. Set |org-use-property-inheritance '("PRIORITY")| >> >> 2. Create a new org file with this content: >> >> * [#A] parent >> ** child A >> ** child B >> >> 3. View org-columns (C-c C-x C-c in my setup) >> >> 4. Note that the children have priority B, while parent has priority >> A. > Oh yes, I realize now. PRIORITY is a special property: > > (info "(org) Special properties") > > They follow their own inheritance rules -- in this case, none. > > Regards, > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Fri, 05 Jan 2018 08:24:27 +0100 Message-ID: <87tvw0g444.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXMMm-0008SJ-11 for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 02:24:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXMMh-0005Dm-0f for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 02:24:35 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:51836) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXMMg-0005Cb-Jz for emacs-orgmode@gnu.org; Fri, 05 Jan 2018 02:24:30 -0500 In-Reply-To: (Jesse Johnson's message of "Thu, 4 Jan 2018 20:00:27 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > There have been several requests for priority inheritance over the > years. That doesn't ring a bell. > If it can't currently be done, I don't think it can, atm. > I am willing to take a look at implementing it. OK! IMO, there should be a global variable to allow priority inheritance (default off). Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Sun, 7 Jan 2018 14:47:20 -0800 Message-ID: References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87tvw0g444.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58604) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYJix-0003A2-DE for emacs-orgmode@gnu.org; Sun, 07 Jan 2018 17:47:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYJit-0008QM-CV for emacs-orgmode@gnu.org; Sun, 07 Jan 2018 17:47:27 -0500 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:35789) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eYJit-0008PS-6H for emacs-orgmode@gnu.org; Sun, 07 Jan 2018 17:47:23 -0500 Received: by mail-pg0-x234.google.com with SMTP id d6so3275397pgv.2 for ; Sun, 07 Jan 2018 14:47:22 -0800 (PST) In-Reply-To: <87tvw0g444.fsf@nicolasgoaziou.fr> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: emacs-orgmode@gnu.org Hi, I am trying to determine the functions I need to add / update to respect priority inheritance. I see that org-show-priority would need to be updated, and likely a new function, say org-get-priority-with-inheritance, should supplement org-get-priority. However, I can't figure out where org-colview is getting the priority from. It seems to be parsing and validating the priority prior to display since it regresses to org-default-priority if I input [#NONSENSE] priorities. I also don't know where sorting is considering priority. Help with pointing me in the right direction for either of those would be much appreciated! Also let me know if other things touching priority need updating for inheritance. Jesse On 01/04/2018 11:24 PM, Nicolas Goaziou wrote: > Hello, > > Jesse Johnson writes: > >> There have been several requests for priority inheritance over the >> years. > That doesn't ring a bell. > >> If it can't currently be done, > I don't think it can, atm. > >> I am willing to take a look at implementing it. > OK! > > IMO, there should be a global variable to allow priority inheritance > (default off). > > Regards, > From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Mon, 08 Jan 2018 14:16:45 +0100 Message-ID: <87r2r05w3m.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87tvw0g444.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34719) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYXIJ-0006br-Ui for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 08:16:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYXIJ-0007wK-3C for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 08:16:51 -0500 Received: from relay3-d.mail.gandi.net ([2001:4b98:c:538::195]:39085) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eYXII-0007tE-Sj for emacs-orgmode@gnu.org; Mon, 08 Jan 2018 08:16:51 -0500 In-Reply-To: (Jesse Johnson's message of "Sun, 7 Jan 2018 14:47:20 -0800") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > I am trying to determine the functions I need to add / update to > respect priority inheritance. > > I see that org-show-priority would need to be updated, Correct, but that would be a minor change. > and likely > a new function, say org-get-priority-with-inheritance, should > supplement org-get-priority. I think you need to change `org-get-priority' signature. You can remove the string argument and possibly add an optional argument: a buffer position. It should handle inheritance without any additional function, if a global variable, e.g., `org-priority-use-inheritance' is non-nil. Note that you can already achieve inheritance by setting `org-get-priority-function' to a function that searches priority cookies among ancestors of the current headline. > However, I can't figure out where org-colview is getting the priority > from. >From `org-entry-get' -> `org-entry-properties'. I don't think there's any change involved in "org-colview.el". > I also don't know where sorting is considering priority. > > Help with pointing me in the right direction for either of those would > be much appreciated! Also let me know if other things touching > priority need updating for inheritance. You should start with `org-get-priority'. Most things are going to work once it is updated. Regards, -- Nicolas Goaziou From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: inherit priority Date: Fri, 27 Apr 2018 01:34:44 +0200 Message-ID: <87bme5pmnf.fsf@bzg.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:41644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBqPc-00086i-5Y for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 19:34:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBqPX-0001RM-W0 for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 19:34:52 -0400 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org, Nicolas Goaziou Hi Jesse, Jesse Johnson writes: > There have been several requests for priority inheritance over the > years. If it can't currently be done, I am willing to take a look at > implementing it. Did you make progress on this? FWIW I'm not convinced it is worth implementing priority inheritance, and like Nicolas, I don't remember any request for this (but my memory can be wrong here). Best, -- Bastien From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Thu, 26 Apr 2018 18:34:18 -0700 Message-ID: <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBsHI-0007yR-JO for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 21:34:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBsHE-0000kc-Lh for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 21:34:24 -0400 In-Reply-To: <87bme5pmnf.fsf@bzg.fr> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Bastien Cc: emacs-orgmode@gnu.org, Nicolas Goaziou On 04/26/2018 04:34 PM, Bastien wrote: >> There have been several requests for priority inheritance over the >> years. If it can't currently be done, I am willing to take a look at >> implementing it. > Did you make progress on this? Crazy timing! I've been testing my implementation for a few months, made some big adjustments a couple weeks ago and plan to submit a patch this weekend. > FWIW I'm not convinced it is worth implementing priority inheritance, > and like Nicolas, I don't remember any request for this (but my memory > can be wrong here). Well, I asked for it, so there's at least one person asked for it! Very tedious busy-body work setting priority on dozens of subtasks when they all share the same priority as their parent task. Will save me hours of effort over the course of a year. I'm surprised it wasn't already implemented. FWIW, I found a few requests for this feature while searching for a solution. However I implemented it because it's useful to me, not because anyone asked me to. Jesse From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: inherit priority Date: Fri, 27 Apr 2018 03:59:42 +0200 Message-ID: <87tvrxz9wx.fsf@gnu.org> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:37809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBsfu-0004Z3-Ne for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 21:59:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBsfu-0007OJ-0G for emacs-orgmode@gnu.org; Thu, 26 Apr 2018 21:59:50 -0400 In-Reply-To: <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> (Jesse Johnson's message of "Thu, 26 Apr 2018 18:34:18 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: emacs-orgmode@gnu.org, Nicolas Goaziou Hi Jesse, Jesse Johnson writes: > Crazy timing! I've been testing my implementation for a few months, > made some big adjustments a couple weeks ago and plan to submit a > patch this weekend. Nice, thanks in advance - also, when it comes to inheritance, we can hit performance issues. Let's make sure a new feature in this area has no impact on the speed of, e.g., the agenda generation. M-x profiler-start RET M-x elp-instrument-function RET are your friends! -- Bastien From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Sat, 7 Jul 2018 18:55:36 -0700 Message-ID: <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> <87tvrxz9wx.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fbyvQ-0000Cy-GM for emacs-orgmode@gnu.org; Sat, 07 Jul 2018 21:55:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fbyvL-0004yD-MN for emacs-orgmode@gnu.org; Sat, 07 Jul 2018 21:55:44 -0400 In-Reply-To: <87tvrxz9wx.fsf@gnu.org> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Bastien Cc: emacs-orgmode@gnu.org, Nicolas Goaziou Hi all, Here is my branch adding priority inheritance. remote: https://code.orgmode.org/holocronweaver/org-mode.git branch: inherit-priority-squashed I rebased upon the latest master, everything still seems to work. Sorry for the long delay in release. Please test and critique. Thanks! Jesse From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Mon, 09 Jul 2018 10:22:30 +0200 Message-ID: <87a7r0ked5.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> <87tvrxz9wx.fsf@gnu.org> <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcRRO-00059J-TQ for emacs-orgmode@gnu.org; Mon, 09 Jul 2018 04:22:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcRRO-0004re-0b for emacs-orgmode@gnu.org; Mon, 09 Jul 2018 04:22:38 -0400 In-Reply-To: <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> (Jesse Johnson's message of "Sat, 7 Jul 2018 18:55:36 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: Bastien , emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > Here is my branch adding priority inheritance. > > remote: https://code.orgmode.org/holocronweaver/org-mode.git It looks good. Could you send it on this ML as a patch so I can comment it more conveniently? Thank you. Regards, -- Nicolas Goaziou 0x80A93738 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jesse Johnson Subject: Re: inherit priority Date: Mon, 9 Jul 2018 22:03:12 -0700 Message-ID: <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> <87tvrxz9wx.fsf@gnu.org> <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> <87a7r0ked5.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52670) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcko6-0003Hl-OL for emacs-orgmode@gnu.org; Tue, 10 Jul 2018 01:03:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcko3-0003eg-PV for emacs-orgmode@gnu.org; Tue, 10 Jul 2018 01:03:22 -0400 In-Reply-To: <87a7r0ked5.fsf@nicolasgoaziou.fr> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: Bastien , emacs-orgmode@gnu.org Hi Nicolas, On 07/09/2018 01:22 AM, Nicolas Goaziou wrote: > It looks good. Could you send it on this ML as a patch so I can comment > it more conveniently? Since you want to comment I guess you want the patch in the e-mail body rather than attached. Here goes nothing. From bb02cd6c00b32155c0a25f409f1bfa4160b2ddcd Mon Sep 17 00:00:00 2001 From: Jesse Johnson Date: Sun, 22 Apr 2018 18:12:54 -0700 Subject: [PATCH] Add priority inheritance * New org-use-priority-inheritance defcustom to toggle inheritance. * org-get-priority now takes a pos and implements inheritance. * org-get-priority-function can make use of inheritance by returning t. * org-agenda-fix-displayed-priority ensures inherited priority is   visible. * Updates where priority is used so that inheritance is respected.  As   a side effect, org-get-priority-function is now more widely   respected. ---  lisp/org-agenda.el | 117 +++++++++++++++++++++++++++++++++--------------------  lisp/org-habit.el  |  16 ++++----  lisp/org.el        | 102 ++++++++++++++++++++++++++++++++++------------  3 files changed, 157 insertions(+), 78 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index eaeddb6..e18e73d 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4581,6 +4581,7 @@ is active."              (setq marker (org-agenda-new-marker (point))                    category (org-get-category)                    level (make-string (org-reduced-level (org-outline-level)) ? ) +                              priority (org-get-priority)                    inherited-tags                    (or (eq org-agenda-show-inherited-tags 'always)                    (and (listp org-agenda-show-inherited-tags) @@ -4593,13 +4594,13 @@ is active."                     ""                     (buffer-substring-no-properties                      beg1 (point-at-eol)) -                   level category tags t)) +                   level category priority tags t))              (org-add-props txt props                'org-marker marker 'org-hd-marker marker                'org-todo-regexp org-todo-regexp                'level level                'org-complex-heading-regexp org-complex-heading-regexp -              'priority 1000 +              'priority priority                'type "search")              (push txt ee)              (goto-char (1- end)))))))))) @@ -5078,7 +5079,7 @@ of what a project is and how to check if it stuck, customize the variable        (setq entries          (mapcar           (lambda (x) -           (setq x (org-agenda-format-item "" x nil "Diary" nil 'time)) +           (setq x (org-agenda-format-item "" x nil "Diary" nil nil 'time))             ;; Extend the text properties to the beginning of the line             (org-add-props x (text-properties-at (1- (length x)) x)           'type "diary" 'date date 'face 'org-agenda-diary)) @@ -5361,6 +5362,7 @@ and the timestamp type relevant for the sorting strategy in            ts-date (car ts-date-pair)            ts-date-type (cdr ts-date-pair)            txt (org-trim (buffer-substring (match-beginning 2) (match-end 0))) +              priority (1+ (org-get-priority))            inherited-tags            (or (eq org-agenda-show-inherited-tags 'always)            (and (listp org-agenda-show-inherited-tags) @@ -5370,8 +5372,7 @@ and the timestamp type relevant for the sorting strategy in                 (memq 'todo org-agenda-use-tag-inheritance))))            tags (org-get-tags nil (not inherited-tags))            level (make-string (org-reduced-level (org-outline-level)) ? ) -          txt (org-agenda-format-item "" txt level category tags t) -          priority (1+ (org-get-priority txt))) +          txt (org-agenda-format-item "" txt level category priority tags t))      (org-add-props txt props        'org-marker marker 'org-hd-marker marker        'priority priority @@ -5570,6 +5571,9 @@ displayed in agenda view."                 (assq (point) deadline-position-alist))            (throw :skip nil))          (let* ((category (org-get-category pos)) +                   (priority (if habit? +                                 (org-habit-get-priority (org-habit-parse-todo)) +                               (org-get-priority item)))             (inherited-tags              (or (eq org-agenda-show-inherited-tags 'always)              (and (consp org-agenda-show-inherited-tags) @@ -5588,11 +5592,10 @@ displayed in agenda view."             (item              (org-agenda-format-item               (and inactive? org-agenda-inactive-leader) -             head level category tags time-stamp org-ts-regexp habit?))) +             head level category priority tags +                     time-stamp org-ts-regexp habit?)))            (org-add-props item props -        'priority (if habit? -                  (org-habit-get-priority (org-habit-parse-todo)) -                (org-get-priority item)) +        'priority priority          'org-marker (org-agenda-new-marker pos)          'org-hd-marker (org-agenda-new-marker)          'date date @@ -5635,6 +5638,7 @@ displayed in agenda view."        (setq marker (org-agenda-new-marker beg)          level (make-string (org-reduced-level (org-outline-level)) ? )          category (org-get-category beg) +                priority (org-get-priority)          inherited-tags          (or (eq org-agenda-show-inherited-tags 'always)              (and (listp org-agenda-show-inherited-tags) @@ -5657,7 +5661,7 @@ displayed in agenda view."          (if (string-match "\\S-" r)          (setq txt r)            (setq txt "SEXP entry returned empty string")) -        (setq txt (org-agenda-format-item extra txt level category tags 'time)) +        (setq txt (org-agenda-format-item extra txt level category priority tags 'time))          (org-add-props txt props 'org-marker marker                 'date date 'todo-state todo-state                 'level level 'type "sexp" 'warntime warntime) @@ -5785,6 +5789,7 @@ then those holidays will be skipped."            (throw :skip nil)          (goto-char (match-beginning 0))          (setq hdmarker (org-agenda-new-marker) +                  priority (org-get-priority)            inherited-tags            (or (eq org-agenda-show-inherited-tags 'always)                (and (listp org-agenda-show-inherited-tags) @@ -5806,8 +5811,7 @@ then those holidays will be skipped."              (closedp "Closed:    ")              (statep (concat "State:     (" state ")"))              (t (concat "Clocked:   (" clocked  ")"))) -               txt level category tags timestr))) -      (setq priority 100000) +               txt level category priority tags timestr)))        (org-add-props txt props          'org-marker marker 'org-hd-marker hdmarker 'face 'org-agenda-done          'priority priority 'level level @@ -6032,6 +6036,13 @@ specification like [h]h:mm."             (level (make-string (org-reduced-level (org-outline-level))                         ?\s))             (head (buffer-substring (point) (line-end-position))) +                   (priority +                    ;; Adjust priority to today reminders about deadlines. +                    ;; Overdue deadlines get the highest priority +                    ;; increase, then imminent deadlines and eventually +                    ;; more distant deadlines. +                    (let ((adjust (if today? (- diff) 0))) +                      (+ adjust (org-get-priority))))             (inherited-tags              (or (eq org-agenda-show-inherited-tags 'always)              (and (listp org-agenda-show-inherited-tags) @@ -6059,7 +6070,7 @@ specification like [h]h:mm."              ((and today? (< deadline today)) (format past (- diff)))              ((and today? (> deadline today)) (format future diff))              (t now))) -             head level category tags time)) +             head level category priority tags time))             (face (org-agenda-deadline-face                (- 1 (/ (float diff) (max wdays 1)))))             (upcoming? (and today? (> deadline today))) @@ -6070,13 +6081,7 @@ specification like [h]h:mm."          'warntime warntime          'level level          'ts-date deadline -        'priority -        ;; Adjust priority to today reminders about deadlines. -        ;; Overdue deadlines get the highest priority -        ;; increase, then imminent deadlines and eventually -        ;; more distant deadlines. -        (let ((adjust (if today? (- diff) 0))) -          (+ adjust (org-get-priority item))) +        'priority priority          'todo-state todo-state          'type (if upcoming? "upcoming-deadline" "deadline")          'date (if upcoming? date deadline) @@ -6222,16 +6227,19 @@ scheduled items with an hour specification like [h]h:mm."        ;; Skip habits if `org-habit-show-habits' is nil, or if we        ;; only show them for today.  Also skip done habits.        (when (and habitp -             (or donep -             (not (bound-and-true-p org-habit-show-habits)) -             (and (not todayp) -                  (bound-and-true-p -                   org-habit-show-habits-only-for-today)))) +                     (or donep +                         (not (bound-and-true-p org-habit-show-habits)) +                         (and (not todayp) +                              (bound-and-true-p + org-habit-show-habits-only-for-today))))          (throw :skip nil))        (save-excursion          (re-search-backward "^\\*+[ \t]+" nil t)          (goto-char (match-end 0))          (let* ((category (org-get-category)) +                   (habit (and habitp (org-habit-parse-todo))) +                   (priority (if habit (org-habit-get-priority habit) +                               (+ 99 diff (org-get-priority))))             (inherited-tags              (or (eq org-agenda-show-inherited-tags 'always)              (and (listp org-agenda-show-inherited-tags) @@ -6259,12 +6267,11 @@ scheduled items with an hour specification like [h]h:mm."                 (if (and todayp pastschedp)                 (format past diff)               first)) -             head level category tags time nil habitp)) +             head level category priority tags time nil habitp))             (face (cond ((and (not habitp) pastschedp)                  'org-scheduled-previously)                     (todayp 'org-scheduled-today) -                   (t 'org-scheduled))) -           (habitp (and habitp (org-habit-parse-todo)))) +                   (t 'org-scheduled))))            (org-add-props item props          'undone-face face          'face (if donep 'org-agenda-done face) @@ -6275,9 +6282,8 @@ scheduled items with an hour specification like [h]h:mm."          'ts-date schedule          'warntime warntime          'level level -        'priority (if habitp (org-habit-get-priority habitp) -                (+ 99 diff (org-get-priority item))) -        'org-habit-p habitp +        'priority priority +        'org-habit-p habit          'todo-state todo-state)            (push item scheduled-items))))))      (nreverse scheduled-items))) @@ -6295,7 +6301,7 @@ scheduled items with an hour specification like [h]h:mm."       (regexp org-tr-regexp)       (d0 (calendar-absolute-from-gregorian date))       marker hdmarker ee txt d1 d2 s1 s2 category -     level todo-state tags pos head donep inherited-tags) +     level priority todo-state tags pos head donep inherited-tags)      (goto-char (point-min))      (while (re-search-forward regexp nil t)        (catch :skip @@ -6346,7 +6352,7 @@ scheduled items with an hour specification like [h]h:mm."                (and (eq org-agenda-show-inherited-tags t)                     (or (eq org-agenda-use-tag-inheritance t)                     (memq 'agenda org-agenda-use-tag-inheritance)))) - +              priority (org-get-priority)                tags (org-get-tags nil (not inherited-tags)))          (setq level (make-string (org-reduced-level (org-outline-level)) ? ))          (looking-at "\\*+[ \t]+\\(.*\\)") @@ -6363,7 +6369,7 @@ scheduled items with an hour specification like [h]h:mm."                    (nth (if (= d1 d2) 0 1)                     org-agenda-timerange-leaders)                    (1+ (- d0 d1)) (1+ (- d2 d1))) -                 head level category tags +                 head level category priority tags                   (cond ((and (= d1 d0) (= d2 d0))                      (concat "<" start-time ">--<" end-time ">"))                                     ((= d1 d0) @@ -6376,11 +6382,11 @@ scheduled items with an hour specification like [h]h:mm."          'type "block" 'date date          'level level          'todo-state todo-state -        'priority (org-get-priority txt)) +        'priority priority)            (push txt ee)))) -    (goto-char pos))) -    ;; Sort the entries by expiration date. -    (nreverse ee))) +      (goto-char pos))) +  ;; Sort the entries by expiration date. +  (nreverse ee)))  ;;; Agenda presentation and sorting @@ -6409,8 +6415,9 @@ The flag is set if the currently compiled format contains a `%b'.")        (cl-return (cadr entry))      (cl-return (apply #'create-image (cdr entry))))))) -(defun org-agenda-format-item (extra txt &optional level category tags dotime -                     remove-re habitp) +(defun org-agenda-format-item (extra txt +                                     &optional level category priority tags +                                     dotime remove-re habitp)    "Format TXT to be inserted into the agenda buffer.  In particular, add the prefix and corresponding text properties. @@ -6419,10 +6426,11 @@ LEVEL may be a string to replace the `%l' specifier.  CATEGORY (a string, a symbol or nil) may be used to overrule the default  category taken from local variable or file name.  It will replace the `%c'  specifier in the format. +PRIORITY can be the integer priority of the headline. +TAGS can be the tags of the headline.  DOTIME, when non-nil, indicates that a time-of-day should be extracted from  TXT for sorting of this entry, and for the `%t' specifier in the format.  When DOTIME is a string, this string is searched for a time before TXT is. -TAGS can be the tags of the headline.  Any match of REMOVE-RE will be removed from TXT."    ;; We keep the org-prefix-* variable values along with a compiled    ;; formatter, so that multiple agendas existing at the same time do @@ -6440,6 +6448,9 @@ Any match of REMOVE-RE will be removed from TXT."        ;; Diary entries sometimes have extra whitespace at the beginning        (setq txt (org-trim txt)) +      ;; Fix the priority part in txt +      (setq txt (org-agenda-fix-displayed-priority txt priority)) +        ;; Fix the tags part in txt        (setq txt (org-agenda-fix-displayed-tags           txt tags @@ -6611,6 +6622,20 @@ The modified list may contain inherited tags, and tags matched by                (if have-i "::" ":"))))))    txt) +(defun org-agenda-fix-displayed-priority (txt priority) +  "Modifies TXT to show correct PRIORITY. +Respects `org-use-priority-inheritance' by adding PRIORITY if not +already present. No change is made if `org-get-priority-function' +is non-nil since TXT may be using non-standard priority cookies." +  (when (and priority +             org-use-priority-inheritance +             (not (functionp org-get-priority-function)) +             (not (string-match org-priority-regexp txt))) +    (let ((priority-str +           (char-to-string (org-priority-integer-to-char priority)))) +      (setq txt (concat "[#" priority-str "] " txt)))) +  txt) +  (defun org-downcase-keep-props (s)    (let ((props (text-properties-at 0 s)))      (setq s (downcase s)) @@ -6646,14 +6671,14 @@ TODAYP is t when the current agenda view is on today."      (unless (and remove (member time have))        (setq time (replace-regexp-in-string " " "0" (format "%04s" time)))        (push (org-agenda-format-item -         nil string nil "" nil +         nil string nil "" nil nil nil           (concat (substring time 0 -2) ":" (substring time -2)))          new)        (put-text-property         2 (length (car new)) 'face 'org-time-grid (car new))))        (when (and todayp org-agenda-show-current-time-in-grid)      (push (org-agenda-format-item -           nil org-agenda-current-time-string nil "" nil +           nil org-agenda-current-time-string nil "" nil nil nil             (format-time-string "%H:%M "))            new)      (put-text-property @@ -8932,6 +8957,10 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."    (let* ((inhibit-read-only t)       (line (org-current-line))       (org-agenda-buffer (current-buffer)) +         (priority (with-current-buffer (marker-buffer hdmarker) +                     (org-with-wide-buffer +                      (goto-char hdmarker) +                      (org-get-priority))))       (thetags (with-current-buffer (marker-buffer hdmarker)              (org-get-tags hdmarker)))       props m pl undone-face done-face finish new dotime level cat tags) @@ -8955,7 +8984,7 @@ If FORCE-TAGS is non nil, the car of it returns the new tags."                (extra (org-get-at-bol 'extra)))            (with-current-buffer (marker-buffer hdmarker)              (org-with-wide-buffer -             (org-agenda-format-item extra newhead level cat tags dotime)))) +             (org-agenda-format-item extra newhead level cat priority tags dotime))))          pl (text-property-any (point-at-bol) (point-at-eol) 'org-heading t)          undone-face (org-get-at-bol 'undone-face)          done-face (org-get-at-bol 'done-face)) diff --git a/lisp/org-habit.el b/lisp/org-habit.el index 375714e..2d5d0d8 100644 --- a/lisp/org-habit.el +++ b/lisp/org-habit.el @@ -248,23 +248,23 @@ This list represents a \"habit\" for the rest of this module."  (defsubst org-habit-get-priority (habit &optional moment)    "Determine the relative priority of a habit.  This must take into account not just urgency, but consistency as well." -  (let ((pri 1000) -    (now (if moment (time-to-days moment) (org-today))) -    (scheduled (org-habit-scheduled habit)) -    (deadline (org-habit-deadline habit))) +  (let ((pri (org-get-priority)) +        (now (if moment (time-to-days moment) (org-today))) +        (scheduled (org-habit-scheduled habit)) +        (deadline (org-habit-deadline habit)))      ;; add 10 for every day past the scheduled date, and subtract for every      ;; day before it      (setq pri (+ pri (* (- now scheduled) 10)))      ;; add 50 if the deadline is today      (if (and (/= scheduled deadline) -         (= now deadline)) -    (setq pri (+ pri 50))) +             (= now deadline)) +        (setq pri (+ pri 50)))      ;; add 100 for every day beyond the deadline date, and subtract 10 for      ;; every day before it      (let ((slip (- now (1- deadline))))        (if (> slip 0) -      (setq pri (+ pri (* slip 100))) -    (setq pri (+ pri (* slip 10))))) +          (setq pri (+ pri (* slip 100))) +        (setq pri (+ pri (* slip 10)))))      pri))  (defun org-habit-get-faces (habit &optional now-days scheduled-days donep) diff --git a/lisp/org.el b/lisp/org.el index 66eb2f3..768b84a 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -3175,18 +3175,46 @@ See also `org-default-priority'."    :type 'boolean)  (defcustom org-get-priority-function nil -  "Function to extract the priority from a string. -The string is normally the headline.  If this is nil Org computes the -priority from the priority cookie like [#A] in the headline.  It returns -an integer, increasing by 1000 for each priority level. -The user can set a different function here, which should take a string -as an argument and return the numeric priority." +  "Function to extract the priority from current line. +The line is always a headline. + +If this is nil Org computes the priority of the headline from a +priority cookie like [#A]. It returns an integer, increasing by +1000 for each priority level (see +`org-priority-char-to-integer'). + +The user can set a different function here, which should process +the current line and return one of: + +- an integer priority +- nil if current line is not a header or otherwise has no +associated priority +- t if the `org-default-priority' should be used or the priority can be +inherited from its parent + +Priority can only be inherited if `org-use-priority-inheritance' is +non-nil."    :group 'org-priorities    :version "24.1"    :type '(choice        (const nil)        (function))) +(defcustom org-use-priority-inheritance nil +  "Whether headline priority is inherited from its parents. + +If non-nil then the first explicit priority found when searching +up the headline tree applies.  Thus a child headline can override +its parent's priority. + +When nil, explicit priorities only apply to the headline they are +given on. + +Regardless of setting, if no explicit priority is found then the +default priority is used." +  :group 'org-priorities +  :type 'boolean) +  (defgroup org-time nil    "Options concerning time stamps and deadlines in Org mode."    :tag "Org Time" @@ -13633,22 +13661,43 @@ and by additional input from the age of a schedules or deadline entry."    (interactive)    (let ((pri (if (eq major-mode 'org-agenda-mode)           (org-get-at-bol 'priority) -           (save-excursion -         (save-match-data -           (beginning-of-line) -           (and (looking-at org-heading-regexp) -            (org-get-priority (match-string 0)))))))) +           (org-get-priority))))      (message "Priority is %d" (if pri pri -1000)))) -(defun org-get-priority (s) -  "Find priority cookie and return priority." -  (save-match-data -    (if (functionp org-get-priority-function) -    (funcall org-get-priority-function) -      (if (not (string-match org-priority-regexp s)) -      (* 1000 (- org-lowest-priority org-default-priority)) -    (* 1000 (- org-lowest-priority -           (string-to-char (match-string 2 s)))))))) +(defun org-priority-char-to-integer (character) +  "Convert priority CHARACTER to an integer priority." +  (* 1000 (- org-lowest-priority character))) + +(defun org-priority-integer-to-char (integer) +  "Convert priority INTEGER to a character priority." +  (- org-lowest-priority (/ integer 1000))) + +(defun org-get-priority (&optional pos local) +  "Get integer priority at POS. +POS defaults to point.  If LOCAL is non-nil priority inheritance +is ignored regardless of the value of +`org-use-priority-inheritance'.  Returns nil if no priority can be +determined at POS." +  (save-excursion +    (save-restriction +      (widen) +      (goto-char (or pos (point))) +      (beginning-of-line) +      (if (not (looking-at org-heading-regexp)) +      (return nil) +    (save-match-data +      (cl-loop +       (if (functionp org-get-priority-function) +           (let ((priority (funcall org-get-priority-function))) +         (unless (eq priority t) +           (return priority))) +         (when (looking-at org-priority-regexp) +           (return (org-priority-char-to-integer +            (string-to-char (match-string-no-properties 2)))))) +       (unless (and (not local) +            org-use-priority-inheritance +            (org-up-heading-safe)) +         (return (org-priority-char-to-integer org-default-priority)))))))))  ;;;; Tags @@ -13713,6 +13762,7 @@ headlines matching this string."                     (or (buffer-file-name (buffer-base-buffer))                     (buffer-name (buffer-base-buffer)))))))       (org-map-continue-from nil) +         priority           lspos tags tags-list       (tags-alist (list (cons 0 org-file-tags)))       (llast 0) rtn rtn1 level category i txt @@ -13800,7 +13850,8 @@ headlines matching this string."              (match-beginning 1) (match-end 1)))            (org-show-context 'tags-tree))           ((eq action 'agenda) -          (setq txt (org-agenda-format-item +          (setq priority (org-get-priority) +            txt (org-agenda-format-item               ""               (concat                (if (eq org-tags-match-list-sublevels 'indented) @@ -13808,8 +13859,8 @@ headlines matching this string."                (org-get-heading))               (make-string level ?\s)               category -             tags-list) -            priority (org-get-priority txt)) +                         priority +             tags-list))            (goto-char lspos)            (setq marker (org-agenda-new-marker))            (org-add-props txt props @@ -15066,9 +15117,8 @@ strings."            (when specific (throw 'exit props)))          (when (or (not specific) (string= specific "PRIORITY"))            (push (cons "PRIORITY" -              (if (looking-at org-priority-regexp) -                  (match-string-no-properties 2) -                (char-to-string org-default-priority))) +                          (char-to-string +                           (org-priority-integer-to-char (org-get-priority))))              props)            (when specific (throw 'exit props)))          (when (or (not specific) (string= specific "FILE")) -- 2.7.4 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: inherit priority Date: Wed, 18 Jul 2018 14:54:34 +0200 Message-ID: <87efg5vkj1.fsf@nicolasgoaziou.fr> References: <87wp0ymxgy.fsf@nicolasgoaziou.fr> <92a7a7a4-a992-86f5-eb8f-2381213ad32f@gmail.com> <87o9mam43l.fsf@nicolasgoaziou.fr> <87bme5pmnf.fsf@bzg.fr> <7e082452-7450-c2fa-ac53-40d75b348b3c@gmail.com> <87tvrxz9wx.fsf@gnu.org> <3e785a53-293d-0faf-d3b0-86036ebd1747@gmail.com> <87a7r0ked5.fsf@nicolasgoaziou.fr> <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:32853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fflyl-0005ml-H2 for emacs-orgmode@gnu.org; Wed, 18 Jul 2018 08:54:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fflyk-00069I-DW for emacs-orgmode@gnu.org; Wed, 18 Jul 2018 08:54:51 -0400 In-Reply-To: <01c7db31-72eb-be93-c772-e93b0327a906@gmail.com> (Jesse Johnson's message of "Mon, 9 Jul 2018 22:03:12 -0700") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jesse Johnson Cc: Bastien , emacs-orgmode@gnu.org Hello, Jesse Johnson writes: > Since you want to comment I guess you want the patch in the e-mail > body rather than attached. Here goes nothing. Thank you! It looks good. Some minor comments follow. > From bb02cd6c00b32155c0a25f409f1bfa4160b2ddcd Mon Sep 17 00:00:00 2001 > From: Jesse Johnson > Date: Sun, 22 Apr 2018 18:12:54 -0700 > Subject: [PATCH] Add priority inheritance You need to describe here what functions or variables changed here, e.g., * lisp/org-agenda (org-search-view): ... > =C2=A0(defcustom org-get-priority-function nil > -=C2=A0 "Function to extract the priority from a string. > -The string is normally the headline.=C2=A0 If this is nil Org computes t= he > -priority from the priority cookie like [#A] in the headline.=C2=A0 It re= turns > -an integer, increasing by 1000 for each priority level. > -The user can set a different function here, which should take a string > -as an argument and return the numeric priority." > +=C2=A0 "Function to extract the priority from current line. > +The line is always a headline. > + > +If this is nil Org computes the priority of the headline from a > +priority cookie like [#A]. It returns an integer, increasing by You need to add two spaces after a full stop. > +1000 for each priority level (see > +`org-priority-char-to-integer'). > +(defcustom org-use-priority-inheritance nil > +=C2=A0 "Whether headline priority is inherited from its parents. "Non-nil means headline priority is..." > +If non-nil then the first explicit priority found when searching > +up the headline tree applies.=C2=A0 Thus a child headline can override > +its parent's priority. > + > +When nil, explicit priorities only apply to the headline they are > +given on. > + > +Regardless of setting, if no explicit priority is found then the > +default priority is used." > +=C2=A0 :group 'org-priorities > +=C2=A0 :type 'boolean) You need to add the following keywords:=20 :package-version '(Org . "9.3") and possibly=20 :safe t > +(defun org-priority-char-to-integer (character) > +=C2=A0 "Convert priority CHARACTER to an integer priority." > +=C2=A0 (* 1000 (- org-lowest-priority character))) > + > +(defun org-priority-integer-to-char (integer) > +=C2=A0 "Convert priority INTEGER to a character priority." > +=C2=A0 (- org-lowest-priority (/ integer 1000))) I think those can be internal functions, so they should be renamed `org--priority-char-to-integer' and `org--priority-integer-to-char'. > +(defun org-get-priority (&optional pos local) > +=C2=A0 "Get integer priority at POS. > +POS defaults to point.=C2=A0 If LOCAL is non-nil priority inheritance > +is ignored regardless of the value of > +`org-use-priority-inheritance'.=C2=A0 Returns nil if no priority can be Return nil if... > +determined at POS." > +=C2=A0 (save-excursion > +=C2=A0=C2=A0=C2=A0 (save-restriction > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (widen) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (goto-char (or pos (point))) `save-excursion' + `save-restriction' + `widen' + `goto-char' =3D `org-with= -point-at' So the above would be: (org-with-point-at pos ...) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (beginning-of-line) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (if (not (looking-at org-heading-regexp)) > +=C2=A0=C2=A0=C2=A0 =C2=A0 (return nil) Indentation looks wrong, but it should be: (unless (looking-at org-heading-regexp) ...) > +=C2=A0=C2=A0=C2=A0 (save-match-data > +=C2=A0=C2=A0=C2=A0 =C2=A0 (cl-loop > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (if (functionp org-get-priority-function) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (let ((priority = (funcall org-get-priority-function))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0(unless (eq priority t) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (return priority))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (when (looking-at org-priori= ty-regexp) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (return (org-pri= ority-char-to-integer > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (string-to-char= (match-string-no-properties 2)))))) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 (unless (and (not local) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 org-use-priorit= y-inheritance > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (org-up-heading= -safe)) > +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 (return (org-priority-char-t= o-integer > org-default-priority))))))))) You can write a simpler function. Please have a look at `org-get-tags' and use `org-complex-heading-regexp' to get priority cookie. Also could you throw in a bunch of tests in "contrib/lisp/test-org.el" and update the manual accordingly? Regards, --=20 Nicolas Goaziou