Skip to content

Commit

Permalink
fix: error "rx ‘**’ range error" (#80,#81)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
nobiot committed Jan 13, 2024
1 parent be9ae73 commit d05d867
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion md-roam.el
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,27 @@ Requied for wiki link capture."
(emacsql-with-transaction (org-roam-db)
(save-excursion
(org-roam-db-clear-file)
(org-roam-db-insert-file)
(md-roam-db-insert-file)
(md-roam-db-insert-file-node)
(md-roam-db-insert-wiki-links)
(md-roam-db-insert-citations)
(md-roam-db-insert-links))))

(defun md-roam-db-insert-file (&optional hash)
"Update the files table for the current buffer.
If UPDATE-P is non-nil, first remove the file in the database.
If HASH is non-nil, use that as the file's hash without recalculating it."
(let* ((file (buffer-file-name))
(file-title (or (md-roam-get-title) (file-name-base file)))
(attr (file-attributes file))
(atime (file-attribute-access-time attr))
(mtime (file-attribute-modification-time attr))
(hash (or hash (org-roam-db--file-hash file))))
(org-roam-db-query
[:insert :into files
:values $v1]
(list (vector file file-title hash atime mtime)))))

(defun md-roam-db-insert-file-node ()
"Insert the file-level node into the Org-roam cache."
;; `org-roam-db-update-file' turns the mode to org-mode (in `org-roam-with-file' macro)
Expand Down

0 comments on commit d05d867

Please sign in to comment.