emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [BUG] org-habit does not respect STYLE property inheritance
@ 2023-05-03 13:03 Дмитрий Логвиненко
  2023-05-04  9:53 ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Дмитрий Логвиненко @ 2023-05-03 13:03 UTC (permalink / raw)
  To: emacs-orgmode

Hi there,

I've noticed that org-habits does not take an inherited STYLE property
when it searches entries. Let me illustrate it:

    (setq org-use-property-inheritance t)

    (defun run-example ()
      (with-temp-buffer
        (insert "\
    * Habit group
    :PROPERTIES:
    :STYLE: habit
    :END:
    ** DONE Contribute to org
    SCHEDULED <2023-05-01 Mon +1w/2w>
    :PROPERTIES:
    :ID: deadbeef
    :END:")
        (delay-mode-hooks (org-mode))
        (let ((entry (org-find-entry-with-id 'deadbeef)))
          `(,(org-entry-get entry "ITEM")
            ,(org-entry-get entry "TODO")
            ,(org-is-habit-p entry)))))

    ;; Original
    (defun org-is-habit-p (&optional pom)
      "Is the task at POM or point a habit?"
      (string= "habit" (org-entry-get (or pom (point)) "STYLE")))

    (run-example)
    ;; => ("Contribute to org" "DONE" nil)

    ;; Proposed
    (defun org-is-habit-p (&optional pom)
      "Is the task at POM or point a habit?"
      (string= "habit" (org-entry-get (or pom (point)) "STYLE" 'selective)))

    (run-example)
    ;; => ("Contribute to org" "DONE" t)


A little patch:

    diff --git a/lisp/org-habit.el b/lisp/org-habit.el
    index ea935fe..b7ba6e3 100644
    --- a/lisp/org-habit.el
    +++ b/lisp/org-habit.el
    @@ -170,7 +170,7 @@ means of creating calendar-based reminders."

     (defun org-is-habit-p (&optional pom)
       "Is the task at POM or point a habit?"
    -  (string= "habit" (org-entry-get (or pom (point)) "STYLE")))
    +  (string= "habit" (org-entry-get (or pom (point)) "STYLE" 'selective)))

     (defun org-habit-parse-todo (&optional pom)
       "Parse the TODO surrounding point for its habit-related data.


Emacs  : GNU Emacs 28.2 (build 1, x86_64-apple-darwin22.1.0, Carbon
Version 169 AppKit 2299)
 of 2022-12-05
Package: Org mode version 9.7 (9.7-??-5ec364a @
/Users/d.logvinenko/.emacs.d/.local/straight/build-28.2/org/)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-05-03 13:03 [BUG] org-habit does not respect STYLE property inheritance Дмитрий Логвиненко
@ 2023-05-04  9:53 ` Ihor Radchenko
  2023-05-18 10:38   ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-05-04  9:53 UTC (permalink / raw)
  To: Дмитрий Логвиненко
  Cc: emacs-orgmode

Дмитрий Логвиненко <dmlogv@gmail.com> writes:

> I've noticed that org-habits does not take an inherited STYLE property
> when it searches entries.
> ....
>     ;; Proposed
>     (defun org-is-habit-p (&optional pom)
>       "Is the task at POM or point a habit?"
>       (string= "habit" (org-entry-get (or pom (point)) "STYLE" 'selective)))

I am not sure if it should be considered a bug.
Currently, sub-tasks under habits are not considered habits.

With your patch, they might be, if a user have customized
`org-use-property-inheritance' to t. (Of course, if user added "STYLE"
there, it is on purpose, and there is no problem).

I am generally in favour of allowing STYLE to be inherited, but it is
technically a breaking change, as I described.

Let's see if anyone voices against this change.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-05-04  9:53 ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Ihor Radchenko
@ 2023-05-18 10:38   ` Ihor Radchenko
  2023-05-18 16:10     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) Colin Baxter
  2023-06-15 17:11     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Dmitry Logvinenko
  0 siblings, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2023-05-18 10:38 UTC (permalink / raw)
  To: Дмитрий Логвиненко
  Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> I am generally in favour of allowing STYLE to be inherited, but it is
> technically a breaking change, as I described.
>
> Let's see if anyone voices against this change.

No objections have been raised.

Dmitry, could you please create a proper patch, adding etc/ORG-NEWS
entry that describes the change (under " ... breaking changes" section),
and a proper commit message? See
https://orgmode.org/worg/org-contribute.html#first-patch

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally)
  2023-05-18 10:38   ` Ihor Radchenko
@ 2023-05-18 16:10     ` Colin Baxter
  2023-05-18 16:25       ` Ihor Radchenko
  2023-06-15 17:11     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Dmitry Logvinenko
  1 sibling, 1 reply; 10+ messages in thread
From: Colin Baxter @ 2023-05-18 16:10 UTC (permalink / raw)
  To: Ihor Radchenko
  Cc: Дмитрий Логвиненко,
	emacs-orgmode

>>>>> Ihor Radchenko <yantar92@posteo.net> writes:

    > Ihor Radchenko <yantar92@posteo.net> writes:
    >> I am generally in favour of allowing STYLE to be inherited, but
    >> it is technically a breaking change, as I described.
    >> 
    >> Let's see if anyone voices against this change.

    > No objections have been raised.

Well, you have not really given much time to respond.

Does this mean that all sub-heading with their TODOs will now become
habits? I would like much more information on the effects of this
proposal.

We have had `habits' for zillions of years which have worked well. So
why the change?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally)
  2023-05-18 16:10     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) Colin Baxter
@ 2023-05-18 16:25       ` Ihor Radchenko
  2023-05-18 16:32         ` Colin Baxter
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-05-18 16:25 UTC (permalink / raw)
  To: m43cap
  Cc: Дмитрий Логвиненко,
	emacs-orgmode

Colin Baxter <m43cap@yandex.com> writes:

>     > No objections have been raised.
>
> Well, you have not really given much time to respond.

2 weeks. I could have waited one month, but this is relatively safe
breaking change.

> Does this mean that all sub-heading with their TODOs will now become
> habits? I would like much more information on the effects of this
> proposal.

Sorry if I was not clear in my original message.

1. STYLE will _not_ be inherited by default after the proposed change.
2. HABIT will be inherited if user customized
   `org-use-property-inheritance' to value of t (aka inherit all properties)
3. STYLE will be inherited if user explicitly added "STYLE" to
   `org-use-property-inheritance' when it is a list.

Only (2) can be breaking.

> We have had `habits' for zillions of years which have worked well. So
> why the change?

To be able to dedicate a separate subtree or file to habits,
automatically making all the sub-tasks habits without spamming property
drawers setting :STYLE: habit.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally)
  2023-05-18 16:25       ` Ihor Radchenko
@ 2023-05-18 16:32         ` Colin Baxter
  0 siblings, 0 replies; 10+ messages in thread
From: Colin Baxter @ 2023-05-18 16:32 UTC (permalink / raw)
  To: Ihor Radchenko
  Cc: Дмитрий Логвиненко,
	emacs-orgmode

>>>>> Ihor Radchenko <yantar92@posteo.net> writes:

    > Colin Baxter <m43cap@yandex.com> writes:
    >> > No objections have been raised.
    >> 
    >> Well, you have not really given much time to respond.

    > 2 weeks. I could have waited one month, but this is relatively
    > safe breaking change.

    >> Does this mean that all sub-heading with their TODOs will now
    >> become habits? I would like much more information on the effects
    >> of this proposal.

    > Sorry if I was not clear in my original message.

    > 1. STYLE will _not_ be inherited by default after the proposed
    > change.  2. HABIT will be inherited if user customized
    > `org-use-property-inheritance' to value of t (aka inherit all
    > properties) 3. STYLE will be inherited if user explicitly added
    > "STYLE" to `org-use-property-inheritance' when it is a list.

    > Only (2) can be breaking.

Ok, that's good.

    >> We have had `habits' for zillions of years which have worked
    >> well. So why the change?

    > To be able to dedicate a separate subtree or file to habits,
    > automatically making all the sub-tasks habits without spamming
    > property drawers setting :STYLE: habit.

Thank you very much. I understand.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-05-18 10:38   ` Ihor Radchenko
  2023-05-18 16:10     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) Colin Baxter
@ 2023-06-15 17:11     ` Dmitry Logvinenko
  2023-06-16  9:45       ` Ihor Radchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Dmitry Logvinenko @ 2023-06-15 17:11 UTC (permalink / raw)
  To: Ihor Radchenko, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 31 bytes --]

--
Dmitry Logvinenko // dmlogv

[-- Attachment #2: 0001-lisp-org-habit.el-Inherit-habit-style-property.patch --]
[-- Type: application/octet-stream, Size: 1774 bytes --]

From 12ef3a940f0c7d4abf3129011440684f18686951 Mon Sep 17 00:00:00 2001
From: Dmitry Logvinenko <dmlogv@gmail.com>
Date: Thu, 15 Jun 2023 19:47:51 +0300
Subject: [PATCH] lisp/org-habit.el: Inherit habit style property

* lisp/org-habit.el (org-is-habit-p):  Use `org-entry-get' with
'selective option to optionally find habit subheadings.
* etc/ORG-NEWS: Describe a breaking change.
---
 etc/ORG-NEWS      | 12 ++++++++++++
 lisp/org-habit.el |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 7e7015064..ad7436c33 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -478,6 +478,18 @@ After:
 : ("simple" "list")
 #+end_src
 
+
+*** =org-habit.el= now optionally inherits ~:STYLE: habit~ properties
+
+Currently, the ~STYLE~ property of habits is not inherited when searching
+for entries.
+
+This change allows the property to be inherited optionally by customizing
+the ~org-use-property-inheritance~ variable.
+
+This change aims to provide more flexibility in managing habits, allowing
+users to dedicate separate subtrees or files to habits without manually
+setting the ~STYLE~ property for each sub-task.
 ** New features
 *** Clock table can now produce quarterly reports
 
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index ea935fe7c..b7ba6e349 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -170,7 +170,7 @@ means of creating calendar-based reminders."
 
 (defun org-is-habit-p (&optional pom)
   "Is the task at POM or point a habit?"
-  (string= "habit" (org-entry-get (or pom (point)) "STYLE")))
+  (string= "habit" (org-entry-get (or pom (point)) "STYLE" 'selective)))
 
 (defun org-habit-parse-todo (&optional pom)
   "Parse the TODO surrounding point for its habit-related data.
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-06-15 17:11     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Dmitry Logvinenko
@ 2023-06-16  9:45       ` Ihor Radchenko
  2023-06-22 17:08         ` Dmitry Logvinenko
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2023-06-16  9:45 UTC (permalink / raw)
  To: Dmitry Logvinenko; +Cc: emacs-orgmode

Dmitry Logvinenko <dmlogv@gmail.com> writes:

> Subject: [PATCH] lisp/org-habit.el: Inherit habit style property
>
> * lisp/org-habit.el (org-is-habit-p):  Use `org-entry-get' with
> 'selective option to optionally find habit subheadings.
> * etc/ORG-NEWS: Describe a breaking change.

Thanks for the patch!
May I know if you have FSF copyright assignment?
If not, you need to add TINYCHANGE cookie to the commit message.
See https://orgmode.org/worg/org-contribute.html#first-patch

> --- a/etc/ORG-NEWS
> +++ b/etc/ORG-NEWS
> @@ -478,6 +478,18 @@ After:
>  : ("simple" "list")
>  #+end_src
>  
> +
> +*** =org-habit.el= now optionally inherits ~:STYLE: habit~ properties
> +
> +Currently, the ~STYLE~ property of habits is not inherited when searching
> +for entries.
> +
> +This change allows the property to be inherited optionally by customizing
> +the ~org-use-property-inheritance~ variable.
> +
> +This change aims to provide more flexibility in managing habits, allowing
> +users to dedicate separate subtrees or files to habits without manually
> +setting the ~STYLE~ property for each sub-task.

Please add this under Org 9.7. It is for main branch - next release.
Also, please mention that the change is breaking when
`org-use-property-inheritance' is set to t. This is important
information - we need to explain how the change can break existing configs.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-06-16  9:45       ` Ihor Radchenko
@ 2023-06-22 17:08         ` Dmitry Logvinenko
  2023-06-23 10:51           ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Logvinenko @ 2023-06-22 17:08 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Dmitry Logvinenko, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 36 bytes --]

Thank you for your comments, fixed.

[-- Attachment #2: 0001-lisp-org-habit.el-Inherit-habit-style-property.patch --]
[-- Type: application/octet-stream, Size: 2143 bytes --]

From 6a1814a8b0d7189b397790b90fb5a6979a6b66cb Mon Sep 17 00:00:00 2001
From: Dmitry Logvinenko <dmlogv@gmail.com>
Date: Thu, 15 Jun 2023 19:47:51 +0300
Subject: [PATCH] lisp/org-habit.el: Inherit habit style property

* lisp/org-habit.el (org-is-habit-p):  Use `org-entry-get' with
'selective option to optionally find habit subheadings.
* etc/ORG-NEWS: Describe a breaking change.

TINYCHANGE
---
 etc/ORG-NEWS      | 15 +++++++++++++++
 lisp/org-habit.el |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 01d2975d3..cb4bc632b 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -74,6 +74,20 @@ the iCalendar spec demands a start date, and
 To revert to the old behavior, set
 ~org-icalendar-todo-unscheduled-start~ to ~current-datetime~.
 
+*** =org-habit.el= now optionally inherits ~:STYLE: habit~ properties
+
+Currently, the ~STYLE~ property of habits is not inherited when searching
+for entries.
+
+This change allows the property to be inherited optionally by customizing
+the ~org-use-property-inheritance~ variable.
+
+This change aims to provide more flexibility in managing habits, allowing
+users to dedicate separate subtrees or files to habits without manually
+setting the ~STYLE~ property for each sub-task.
+
+The change is breaking when ~org-use-property-inheritance~ is set to ~t~.
+
 ** New and changed options
 *** Commands affected by ~org-fold-catch-invisible-edits~ can now be customized
 
@@ -556,6 +570,7 @@ After:
 : ("simple" "list")
 #+end_src
 
+
 ** New features
 *** Clock table can now produce quarterly reports
 
diff --git a/lisp/org-habit.el b/lisp/org-habit.el
index ea935fe7c..b7ba6e349 100644
--- a/lisp/org-habit.el
+++ b/lisp/org-habit.el
@@ -170,7 +170,7 @@ means of creating calendar-based reminders."
 
 (defun org-is-habit-p (&optional pom)
   "Is the task at POM or point a habit?"
-  (string= "habit" (org-entry-get (or pom (point)) "STYLE")))
+  (string= "habit" (org-entry-get (or pom (point)) "STYLE" 'selective)))
 
 (defun org-habit-parse-todo (&optional pom)
   "Parse the TODO surrounding point for its habit-related data.
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance)
  2023-06-22 17:08         ` Dmitry Logvinenko
@ 2023-06-23 10:51           ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2023-06-23 10:51 UTC (permalink / raw)
  To: Dmitry Logvinenko; +Cc: emacs-orgmode

Dmitry Logvinenko <dmlogv@gmail.com> writes:

> Thank you for your comments, fixed.

Thanks!
Applied, onto main.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=5b3a1a634

I also added you to the contributor list.
https://git.sr.ht/~bzg/worg/commit/d9174193

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-06-23 10:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-03 13:03 [BUG] org-habit does not respect STYLE property inheritance Дмитрий Логвиненко
2023-05-04  9:53 ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Ihor Radchenko
2023-05-18 10:38   ` Ihor Radchenko
2023-05-18 16:10     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) Colin Baxter
2023-05-18 16:25       ` Ihor Radchenko
2023-05-18 16:32         ` Colin Baxter
2023-06-15 17:11     ` [POLL] Will it be ok to allow HABIT property inheritance? (optionally) (was: [BUG] org-habit does not respect STYLE property inheritance) Dmitry Logvinenko
2023-06-16  9:45       ` Ihor Radchenko
2023-06-22 17:08         ` Dmitry Logvinenko
2023-06-23 10:51           ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).