utils: descendant-of-p: Defend against nils#2319
Merged
jethrokuan merged 1 commit intoorg-roam:mainfrom Feb 23, 2023
Merged
Conversation
This has an effect on find-file-hook for totally unrelated files,
through the callchain of `org-roam-db-autosync--setup-file-h ->
org-roam-file-p -> org-roam-descendant-of-p'.
From an org file, inside a project-el project, (find-file
"some/other/file") will intermittently reproduce this error:
org-roam-descendant-of-p: Wrong type argument: arrayp, nil
If this fix seems inappropriate -- it could amount to surppressing a
valid error in routine calls -- then I would advise throwing an
explicit signal here, or finding a safer way to get the `path` inside
`org-roam-file-p'; the current means:
(or file (buffer-file-name (buffer-base-buffer)))
.. can result in nil, which then bleeds errors into use elsewhere.
for posterity, here is the full calling context I'm referring to, from
`org-roam-file-p'.
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
(ext (when path (org-roam--file-name-extension path)))
(ext (if (string= ext "gpg")
(org-roam--file-name-extension (file-name-sans-extension path))
ext))
(org-roam-dir-p (org-roam-descendant-of-p path
org-roam-directory))
...
Member
|
thanks! the lint error was on main so i fixed it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This has an effect on find-file-hook for totally unrelated files, through the callchain of `org-roam-db-autosync--setup-file-h -> org-roam-file-p -> org-roam-descendant-of-p'.
From an org file, inside a project-el project, (find-file "some/other/file") will intermittently reproduce this error:
org-roam-descendant-of-p: Wrong type argument: arrayp, nil
If this fix seems inappropriate -- it could amount to surppressing a valid error in routine calls -- then I would advise throwing an explicit signal here, or finding a safer way to get the
pathinside `org-roam-file-p'; the current means:.. can result in nil, which then bleeds errors into use elsewhere.
for posterity, here is the full calling context I'm referring to, from `org-roam-file-p'.
(let* ((path (or file (buffer-file-name (buffer-base-buffer))))
(ext (when path (org-roam--file-name-extension path)))
(ext (if (string= ext "gpg")
(org-roam--file-name-extension (file-name-sans-extension path))
ext))
(org-roam-dir-p (org-roam-descendant-of-p path
org-roam-directory))
...
Motivation for this change
I should be able to find-file to any file, outside of org-roam, without error bleed from this package's hook functions.