emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Дмитрий Логвиненко" <dmlogv@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [BUG] org-habit does not respect STYLE property inheritance
Date: Wed, 3 May 2023 16:03:33 +0300	[thread overview]
Message-ID: <CAB+pTYkWaKXDa24-PCdJfSeXYm2=uBNk8uwWkELoSBmgQe6o7g@mail.gmail.com> (raw)

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	other threads:[~2023-05-03 14:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-03 13:03 Дмитрий Логвиненко [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB+pTYkWaKXDa24-PCdJfSeXYm2=uBNk8uwWkELoSBmgQe6o7g@mail.gmail.com' \
    --to=dmlogv@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).