emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Possible bug in org-agenda not showing habits properly
@ 2024-03-18 11:26 Rens Oliemans
  2024-03-19 14:56 ` Ihor Radchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Rens Oliemans @ 2024-03-18 11:26 UTC (permalink / raw)
  To: emacs-orgmode

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

When I open an org file before opening the agenda, my habits show up as regular tasks,
rather than with the consistency graph. Additionally, many CANCELed tasks still show up in
the agenda. When I open the agenda first however, everything goes fine.

Interestingly, this only happens when I bind 'org-agenda' to a key. To show this, I have
attached bad.el and good.el which reproduce the issue on current main (Org mode version
9.7-pre (release_9.6.21-1295-g46909a @ /opt/org-mode/lisp/)).

Note that they set

    (setq org-directory "/tmp/tmp.emacs/notes")

and they expect '/tmp/tmp.emacs/notes/file.org' to exist, see attachment.

Reproduce with:

  emacs -Q -l bad.el /tmp/tmp.emacs/notes/file.org

so that it definitely opens an org-file before the org-agenda. After opening the agenda,
my habits do not show up as habits. My habits do show up with:

  emacs -Q -l bad.el --eval="(org-agenda-list)"

and with they also show up:

  emacs -Q -l good.el /tmp/tmp.emacs/notes/file.org

I am running Emacs 29.2. Am I doing something wrong here?


[-- Attachment #2: bad.el --]
[-- Type: text/plain, Size: 306 bytes --]

(use-package org
  :load-path "/opt/org-mode/lisp"
  :init
  (setq org-directory "/tmp/tmp.emacs/notes"))

(use-package org-agenda
  :ensure nil
  :load-path "/opt/org-mode/lisp"
  :config
  (add-to-list 'org-modules 'org-habit t)
  (setq org-agenda-files '("file.org"))

  :bind (("C-c a" . org-agenda)))

[-- Attachment #3: good.el --]
[-- Type: text/plain, Size: 272 bytes --]

(use-package org
  :load-path "/opt/org-mode/lisp"
  :init
  (setq org-directory "/tmp/tmp.emacs/notes"))

(use-package org-agenda
  :ensure nil
  :load-path "/opt/org-mode/lisp"
  :config
  (add-to-list 'org-modules 'org-habit t)
  (setq org-agenda-files '("file.org")))

[-- Attachment #4: file.org --]
[-- Type: application/vnd.lotus-organizer, Size: 185 bytes --]

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

* Re: Possible bug in org-agenda not showing habits properly
  2024-03-18 11:26 Possible bug in org-agenda not showing habits properly Rens Oliemans
@ 2024-03-19 14:56 ` Ihor Radchenko
  2024-03-20 11:20   ` Rens Oliemans
  0 siblings, 1 reply; 3+ messages in thread
From: Ihor Radchenko @ 2024-03-19 14:56 UTC (permalink / raw)
  To: Rens Oliemans; +Cc: emacs-orgmode

Rens Oliemans <hallo@rensoliemans.nl> writes:

> When I open an org file before opening the agenda, my habits show up as regular tasks,
> rather than with the consistency graph. Additionally, many CANCELed tasks still show up in
> the agenda. When I open the agenda first however, everything goes fine.
>
> Interestingly, this only happens when I bind 'org-agenda' to a key. To show this, I have
> attached bad.el and good.el which reproduce the issue on current main (Org mode version
> 9.7-pre (release_9.6.21-1295-g46909a @ /opt/org-mode/lisp/)).
> ...
> (use-package org-agenda
>   :ensure nil
>   :load-path "/opt/org-mode/lisp"
>   :config
>   (add-to-list 'org-modules 'org-habit t)
>   (setq org-agenda-files '("file.org"))
>
>   :bind (("C-c a" . org-agenda)))

:bind keyword in use-package defers execution of the config snippet. So,
with :bind, you first have the (use-package org ...) executed, loading
org.el, and only later, after you press C-c a, :config block in
(use-package org-agenda ...) is executed and `org-modules' is changed.

If you check the docstring for `org-modules', you will see "Modules that
should always be loaded together with org.el." However, your config
block is executed _after_ org.el is loaded. So, changes to that variable
have 0 effect and org-habit.el is not loaded.

You should set `org-modules' _before_ loading Org. Or you can load
org-habit in more traditional way, via (require 'org-habit) or
(use-package org-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] 3+ messages in thread

* Re: Possible bug in org-agenda not showing habits properly
  2024-03-19 14:56 ` Ihor Radchenko
@ 2024-03-20 11:20   ` Rens Oliemans
  0 siblings, 0 replies; 3+ messages in thread
From: Rens Oliemans @ 2024-03-20 11:20 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> You should set `org-modules' _before_ loading Org. Or you can load
> org-habit in more traditional way, via (require 'org-habit) or
> (use-package org-habit).

Thanks, this works! I misunderstood the way the different use-package blocks got executed.


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

end of thread, other threads:[~2024-03-20 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18 11:26 Possible bug in org-agenda not showing habits properly Rens Oliemans
2024-03-19 14:56 ` Ihor Radchenko
2024-03-20 11:20   ` Rens Oliemans

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