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

Run into "range error" while opening a .md file #80

Closed
hy-zhao23 opened this issue Aug 9, 2023 · 10 comments
Closed

Run into "range error" while opening a .md file #80

hy-zhao23 opened this issue Aug 9, 2023 · 10 comments

Comments

@hy-zhao23
Copy link

Hi, Here is what I get in my emacs when I open and click a .md file in a md roam project.

 The error was: (error "rx ‘**’ range error")
 Backtrace:
"  backtrace-to-string(nil)
  org-element-at-point()
  org-back-to-heading(t)
  org-back-to-heading-or-point-min(t)
  org-roam-id-at-point()
  org-roam-ui--update-current-node()
"
 Please report this to Org mode mailing list (M-x org-submit-bug-report). 

I have reported this to org-mode contributors. And they think it might because md-roam package modified `org-roam-buffer-p' and caused the breakage.

Hope this could help you to fix the issue.

@nobiot
Copy link
Owner

nobiot commented Aug 9, 2023

Does this happen any md file?

@hy-zhao23
Copy link
Author

hy-zhao23 commented Aug 9, 2023

It happens when I open a new md-roam project, then open a file in it and click inside inside that file for the first time. I have been managed several roam projects with .dir-locals.el files. I don't know if this approach would cause the problem.

@nobiot
Copy link
Owner

nobiot commented Aug 9, 2023

Does it happen when you open a md file in a directory without .dir-local.el?

Does it happen when you open every md file? (I am suspecting that the content of the file may influence the behavior).

@nobiot
Copy link
Owner

nobiot commented Aug 9, 2023

Also, whats your org version and Emacs version?

@nobiot
Copy link
Owner

nobiot commented Aug 9, 2023

Additionally, you seem to be opening a md file from org-roam-ui. Does the problem happen if you open the same file from within Emacs via find-file?

@hy-zhao23
Copy link
Author

hy-zhao23 commented Aug 9, 2023

Org: 9.7
Emacs: 28.2

It only happens for the first file visiting with SPC-p-p. And I can't trigger it now after I redefined org-roam-directory, which is useless for my workflow.

But once I redefined org-roam-directory, I can't use multiple roam projects anymore under md-roam. For example, when I try to find a node under a project with SPC-n-r-f, the pop-up window is blank. And it works pretty well under org-roam no matter that directory is defined or not.

Plus, I started run into errors as the following when I disabled the directory definition
Error caused by user's config or system: /Users/melody/.doom.d/config.el, (file-missing Opening directory No such file or directory /Users/melody/Documents/emacs/org/roam)

I guess it might come from a recent update, because it works fine before that when I can both define the directory and use .dir-locals.el to manage multiple projects.

@hy-zhao23
Copy link
Author

It is resolved after I disable org-roam-db-autosync-mode, which caused the conflicts I guess. Thanks for your help!

@hy-zhao23 hy-zhao23 reopened this Aug 10, 2023
@hy-zhao23
Copy link
Author

After I disabled definition of directory, turn off org-roam-db-autosync-mode and tried to use dir-locals.el to enable multiple projects. The problem appears again when I tried to open another file with SPC-n-r-f.
Please check the error message below:

Warning (org-element-cache): org-element--cache: Org parser error in 23-08-10-explanation.md::215. Resetting.
 The error was: (error "rx ‘**’ range error")
 Backtrace:
nil

@dltacube
Copy link

This might be unrelated but I ran into the same error when adding a markdown file containing a #+title: 1 inside of a codeblock. Removing the line or even adding ;; for comments resolved the issue.

nobiot added a commit that referenced this issue Jan 13, 2024
The error occurs when the markdown file contains a code blog with an org
syntax such as this below:

   ```org
   #+title: Org title
   ```

Before this change, md-roam used function `org-roam-db-insert-file' to
insert a new markdown file. This function tries to get the title of the
file with function `org-roam-db--file-title' and it calls
`org-collect-keywords'. Somewhere down this chain, the error gets raised
because the buffer is not a org buffer (and rest of the buffer is
written in the markdown syntax).
@nobiot
Copy link
Owner

nobiot commented Jan 13, 2024

Hopefully d05d867 fixes the issue. Let me know how you go. Closing for now.

@nobiot nobiot closed this as completed Jan 13, 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
Development

No branches or pull requests

3 participants