emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] org-habit does not respect STYLE property inheritance


From: Дмитрий Логвиненко
Subject: [BUG] org-habit does not respect STYLE property inheritance
Date: Wed, 3 May 2023 16:03:33 +0300

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]