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

fix: undefer org headline nodes for org 9.7 #75

Merged
merged 1 commit into from
Jul 4, 2024

Conversation

nanzhong
Copy link
Collaborator

@nanzhong nanzhong commented Dec 28, 2023

The unreleased 9.7 version of org-mode introduced a change that breaks the current weblorg-slugify implementation. The change results in some org nodes being deferred and requiring the org buffer to be live when lazily evaluated. (See https://git.savannah.gnu.org/cgit/emacs/org-mode.git/tree/etc/ORG-NEWS#n148).

This change in behaviour results in errors such as:

Error: wrong-type-argument (stringp [org-element-deferred org-element--headline-raw-value (4 29) nil])
  mapbacktrace(#f(compiled-function (evald func args flags) #<bytecode -0x1dd916894512f81>))
  debug-early-backtrace()
  debug-early(error (wrong-type-argument stringp [org-element-deferred org-element--headline-raw-value (4 29) nil]))
  replace-regexp-in-string("[^[:alnum:]]" "-" [org-element-deferred org-element--headline-raw-value (4 29) nil])
  #f(compiled-function (accum item) #<bytecode -0x14baae06cc0870c3>)([org-element-deferred org-element--headline-raw-value (4 29) nil] ("[^[:alnum:]]" . "-"))
  #f(compiled-function (elt) #<bytecode 0x190baab04a068801>)(("[^[:alnum:]]" . "-"))
  mapc(#f(compiled-function (elt) #<bytecode 0x190baab04a068801>) (("[^[:alnum:]]" . "-") ("--+" . "-") ("^-" . "") ("-$" . "")))
  seq-do(#f(compiled-function (elt) #<bytecode 0x190baab04a068801>) (("[^[:alnum:]]" . "-") ("--+" . "-") ("^-" . "") ("-$" . "")))
  seq-reduce(#f(compiled-function (accum item) #<bytecode -0x14baae06cc0870c3>) (("[^[:alnum:]]" . "-") ("--+" . "-") ("^-" . "") ("-$" . "")) [org-element-deferred org-element--headline-raw-value (4 29) nil])
  weblorg--slugify([org-element-deferred org-element--headline-raw-value (4 29) nil])

This PR makes use of the updated support in org-element-property to forced undeferring. Once 9.7 is released, this would be good to revisit (whether that means bumping the required org version or keeping this conditional).

@nanzhong nanzhong force-pushed the org-element-undefer branch 2 times, most recently from 90222c1 to f46f2bb Compare December 28, 2023 21:26
@nanzhong
Copy link
Collaborator Author

nanzhong commented Dec 28, 2023

Mhmm, not quite sure why the version detection is not working in CI. It seems to be working as expected locally.

It looks like the version of emacs being used in CI makes use of org 9.6 even in the snapshot version as it's building from the github emacs mirror. So I would expect both the 26.3 and snapshot tests to be calling the old branch, which it doesn't seem to be doing 🤔.

@nanzhong nanzhong force-pushed the org-element-undefer branch 2 times, most recently from 1dfdf82 to 6a134f8 Compare December 29, 2023 01:26
@nanzhong
Copy link
Collaborator Author

Ah, I think the reason it's failing is because org-element-property is defined using defsubst in 9.6 and define-inline in 9.7. The inlining that happens during byte compilation seems to be what's tripping this up since in 9.6, org-element-property only allows for 2 arguments.

I'm not that familiar with emacs lisp, so I don't have a clear idea of how to fix this, but I'll dig a little deeper and see.

@nanzhong nanzhong force-pushed the org-element-undefer branch 9 times, most recently from cf9cf6e to 7c06fb4 Compare December 29, 2023 04:54
@nanzhong
Copy link
Collaborator Author

I've reworked this to make use of org-element-propertise-resolve to conditionally resolve deferred element properties on org 9.7+ sidestepping changing inlined function.

@nanzhong nanzhong force-pushed the org-element-undefer branch from 7c06fb4 to efebd6b Compare December 29, 2023 05:21
@nanzhong nanzhong force-pushed the org-element-undefer branch from efebd6b to 8a6c9cb Compare December 29, 2023 05:29
@markokocic
Copy link
Collaborator

Now that org-mode 9.7.2 is the actual release, we need this to address #78

@nanzhong nanzhong merged commit 217bdac into emacs-love:main Jul 4, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

2 participants