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

Showing problems with handling sections. #628

Closed
wants to merge 1 commit into from

Conversation

matsl
Copy link
Collaborator

@matsl matsl commented Dec 26, 2024

What

Showing problems with handling of sections.

Why

I have started to look at writing tests for WikiWords with sections
and found that the movement to sections is broken. So before writing
tests I tried to understand what was the issue.

Two problematic parts were found and they are described in this PR. I
want to share it with you before hacking away on the tests.

Note

Observations:

  • Maybe the code can be refactored so that there is less need to string-match possible section part. Like early noticing this and pass the wikiword and section as a tuple?
  • The parameter name wikiword is less ideal when it also can contain sections. Maybe another parameter name can be used for those functions?

@@ -639,10 +641,11 @@ After successfully finding a page and reading it into a buffer, run
(unless buffer-file-name
(error "(hywiki-display-referent): No `wikiword' given; buffer must have an attached file"))
(setq wikiword (file-name-sans-extension (file-name-nondirectory buffer-file-name))))
(when (string-match "#[^#]+$" wikiword)
Copy link
Collaborator Author

@matsl matsl Dec 26, 2024

Choose a reason for hiding this comment

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

Here wikiword is set with the section removed so the following let* will never see a section. I moved it into the let* in a pragmatic way. Can probably be improved.

@@ -614,8 +614,10 @@ an existing or new HyWikiWord."
(call-interactively hywiki-display-page-function)
(when (null wikiword)
(setq wikiword (hywiki-word-read-new "Find HyWiki page: ")))
(let ((referent (hywiki-get-file wikiword)))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here hywiki-get-file drops the section info from wikiword. So I added getting the section back to it can be appended to the file name so that hpath:find can do its job.

Copy link
Owner

Choose a reason for hiding this comment

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

Why don't you just catch these with tests and then I will update to ensure the tests work right? But I see your point here. But now I'm rebasing on all my prior changes, so it is less work if you just send tests that fail. My two cents.

@matsl matsl requested a review from rswgnu December 26, 2024 22:57
@matsl matsl closed this Dec 27, 2024
@matsl matsl deleted the discussion-of-problems-with-sections branch December 27, 2024 14:09
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