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

feat: Now cross-posting links to other page bundle subtrees works + minor performance tweaks in buffer pre processing #593

Merged
merged 29 commits into from
Mar 17, 2022

Conversation

kaushalmodi
Copy link
Owner

@kaushalmodi kaushalmodi commented Mar 16, 2022

  • Link page bundles from other subtrees in the same file.
  • Link page bundles from subtrees in a different file.

Fixes #389.

@kaushalmodi kaushalmodi reopened this Mar 16, 2022
@kaushalmodi kaushalmodi marked this pull request as draft March 16, 2022 18:10
This doesn't change anything with the tests. But it doesn't hurt to
pass the correct value.
Note: As of today, the Org stable or bugfix version's (9.5.2)
`org-element-at-point' returns the Org element at point *but* without
any of the inherited properties!!

So `org-element-map' is used where property inheritance needs to be
tested (because that does do the prop inheritance as expected!). This
issue doesn't exist in the `main' branch version of
`org-element-at-point'.
Also restore blank lines in a docstring.
Hugo `relref` does not use the `slug` front-matter. So even if a post
"abc.md" has a slug "xyz", `{{< relref "xyz" >}}` will fail.  We will
still need to use `{{< relref "abc" >}}`.
Ref: https://lists.gnu.org/r/emacs-orgmode/2021-12/msg00474.html

"It is slightly more optimal to make your lambdas in org-element-map
return nil. org-element-map allocates an extra list collecting all
non-nil return values. If your lambda always returns nil, that list
will not have to be created." - Ihor Radchenko
Ref: https://lists.gnu.org/r/emacs-orgmode/2021-12/msg00474.html

"You call org-element-map twice making Org loop over the whole AST
twice." - Ihor Radchenko
@kaushalmodi kaushalmodi marked this pull request as ready for review March 17, 2022 15:51
@kaushalmodi kaushalmodi changed the title feat: Now cross-posting links to other page bundle subtrees works feat: Now cross-posting links to other page bundle subtrees works + minor performance tweaks in buffer pre processing Mar 17, 2022
@kaushalmodi kaushalmodi reopened this Mar 17, 2022
Earlier:

- It worked i.e. searched heading strings to the correct subtree, but
  only if the searched-in Org buffer was already open.
- It failed to work if the Org file was yet to be opened.

The `(org-mode)` call in this commit sets the major mode and fixes
that issue. The other variables like `org-mode-hook`, etc. are set to
speed this up.
In Org 9.5 and older versions, `org-element-at-point` returns an Org
element *without* the properties inherited from its parent headings
e.g. EXPORT_HUGO_BUNDLE.

In Org 9.6+ (main branch as of 2022-03-17), the returned element has
the inherited properties.

In this commit a `org-hugo--search-prop-in-parents` function is added
that allows searching for the specified property in parent headings.
Also wrap the fn in org-with-wide-buffer so that the point and
narrowing are preserved.
@kaushalmodi kaushalmodi merged commit a7e7626 into main Mar 17, 2022
@kaushalmodi kaushalmodi deleted the link-bundles branch March 17, 2022 20:52
@kaushalmodi
Copy link
Owner Author

This now works!!

#+hugo_base_dir: .
#+hugo_section: /

* Articles
:PROPERTIES:
:EXPORT_HUGO_BUNDLE: articles
:EXPORT_FILE_NAME: _index
:END:
Content in a branch bundle

- Link to [[*Post 1]]
- Link to [[*Post 2]]

* Blog posts
:PROPERTIES:
:EXPORT_HUGO_SECTION: posts
:END:
** Post 1
:PROPERTIES:
:EXPORT_HUGO_BUNDLE: post-1
:EXPORT_FILE_NAME: index
:END:
Content in a "post-1" *leaf* bundle

- Link to [[*Articles]]
- Link to [[*Post 2]]

** Post 2
:PROPERTIES:
:EXPORT_HUGO_BUNDLE: post-2
:EXPORT_FILE_NAME: index
:END:
Content in a "post-2" *leaf* bundle

- Link to [[*Articles]]
- Link to [[*Post 1]]

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.

Support cross-post linking to page bundle subtrees
1 participant