Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on org-habit-stats-view-habit-at-point after recent org-mode update #10

Open
thomaslaich opened this issue Jun 9, 2024 · 0 comments

Comments

@thomaslaich
Copy link

When invoking org-habit-stats-view-habit-at-point, I get the following error:

Debugger entered--Lisp error: (wrong-type-argument stringp [org-element-deferred org-element--headline-raw-value (3 69) nil])
  string-width([org-element-deferred org-element--headline-raw-value (3 69) nil])
  truncate-string-to-width([org-element-deferred org-element--headline-raw-value (3 69) nil] 25 nil nil t)
  org-habit-stats-create-habit-buffer((739044 1 nil nil (738849 738850 738851 738852 738853 738854 738855 738857 738858 738860 738861 738862 738863 738864 738865 738866 738867 738868 738868 738871 738872 738876 738878 738879 738880 738881 738882 738883 738885 738887 738897 738898 738899 738900 738901 738902 738906 738907 738908 738909 738920 738921 738926 738970 739017 739020 739026 739027 739030 739031 ...) ".+") [org-element-deferred org-element--headline-raw-value (3 69) nil] nil file)
  org-habit-stats-view-habit-at-point()
  funcall-interactively(org-habit-stats-view-habit-at-point)
  command-execute(org-habit-stats-view-habit-at-point)

it seems like org-mode made changes to the org-element-property function after 9.7 releases, so the following code does not work anymore:

(defun org-habit-stats-view-habit-at-point ()
  "Open an org-habit-stats buffer for the habit at point in a file."
  (interactive)
  (let ((habit-name (org-element-property :raw-value
                                          (save-excursion
                                            (when (not (eq (car (org-element-at-point)) 'headline))
                                              (outline-previous-heading))
                                            (org-element-at-point))))
        (habit-data (org-habit-stats-parse-todo (point)))
        (habit-description (org-entry-get (point) "DESCRIPTION")))
    (org-habit-stats-create-habit-buffer habit-data habit-name habit-description 'file)))

Without having spent a ton of time investigating it, it seems to be a similar underlying issue as this:
alphapapa/org-ql#364 (comment)

Here are the org-mode changes:
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n40

I hope I'm not completely off in this analysis.

My systems (happens on both my machines):

MacOS

OS: MacOS Sonoma 14.5
Emacs: 29.3 (PGTK version) (also tried 30.0.50)
org-version: 9.7.3

NixOS

OS: NixOS 24.11 (Vicuña)
Emacs: 29.3 (PGTK version) (also tried 30.0.50)
org-version: 9.7.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant