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

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).