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

Empty links warn #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Empty links warn #28

wants to merge 2 commits into from

Conversation

psionic-k
Copy link

@psionic-k psionic-k commented Nov 18, 2022

Normalizing away nils in the 4th header component results in org warning the user that they have an empty link. The TOC does not finish generation in this case.

At first I just fixed the string-match-p call, but this will complete without generating user feedback about the empty title.

fixes #27
fixes #13

Signed-off-by: Psionik K 73710933+psionic-k@users.noreply.github.com

@alphapapa
Copy link
Owner

I appreciate the PR, but with regard to #27, it would be helpful if we decided what to do in plain English before deciding how to change the code. If you'd like, please discuss some ideas there first.

@psionic-k psionic-k force-pushed the master branch 3 times, most recently from ea31461 to 334aa14 Compare November 28, 2022 09:08
This commit makes the string comparison avoid failure when the title component
is nil, (it's not an empty string).

This occurs for example when a headline is just a TODO cookie with no later
headline text.

The two blocks for generating the link properly attempt to skip headlines where
there is no 4th title component, so later generation correctly handles the case
where an empty link generation would be attempted in the TOC.

Note, empty links would not render or behave, so forcing their generation would
be incorrect anyway.

Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
This change correctly reports the line where a headline returned nul from the
call to `org-heading-components'.  Warnings are delayed and displayed after the
command to generate the TOC completes.

Signed-off-by: Psionik K <73710933+psionic-k@users.noreply.github.com>
(string-match-p (rx bos "COMMENT" (or blank eos)) headline-text)))
(if-let ((headline-text (nth 4 (org-heading-components))))
(string-match-p (rx bos "COMMENT" (or blank eos)) headline-text)
(delay-warning 'org-make-toc
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't understand the manual or docstring's explanation of the TYPE argument to delay-warning, but use-package macros expand such that they use the package name symbol when calling display-warning. As far as I can tell, any symbol is accepted, and the output to the user looks informative when done this way.

@alphapapa alphapapa added this to the v0.7 milestone Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants