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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions hywiki.el
Original file line number Diff line number Diff line change
Expand Up @@ -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.

(funcall hywiki-display-page-function referent)
(let ((referent (hywiki-get-file wikiword))
(section (when (string-match "#[^#]+$" wikiword)
(substring wikiword (match-beginning 0)))))
(funcall hywiki-display-page-function (concat referent section))
;; Set 'referent attribute of current implicit button
(hattr:set 'hbut:current 'referent referent)
referent)))
Expand All @@ -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.

(setq wikiword (substring wikiword 0 (match-beginning 0))))
(let* ((section (when (string-match "#[^#]+$" wikiword)
(substring wikiword (match-beginning 0))))
(wikiword (if (string-match "#[^#]+$" wikiword)
(substring wikiword 0 (match-beginning 0))
wikiword))
(referent (cond (prompt-flag
(hywiki-add-prompted-referent wikiword))
((hywiki-get-referent wikiword))
Expand Down
Loading