org-remark-file-name-function does not seem to return a valid name from a eww buffer
I use the recommended function to create a seperate notes file for each document I annotate. However when viewing an html file through eww-open-file, the notes file defaults to marginalia.org.
Using version 1.3.0 and the function
(defun my/function ()
(concat "~/Documents/org/refs/notes/"
(file-name-base (org-remark-notes-file-name-function))
".org"))
(setq org-remark-notes-file-name
#'my/function)
I use the recommended function to create a seperate notes file for each document I annotate. However when viewing an html file through eww-open-file, the notes file defaults to marginalia.org.
Yes, that's the default. See the documentation on org-remark-notes-file-name-function. As webpages in EWW do not visit a file (buffer-file-name is nil), it defaults to what you see.
If the current buffer is not visiting a file, the file name will
be marginalia.org in your `user-emacs-directory'. If this file
name is not suitable, either override the function or set the
user option to use your own custom function."
Or in the source code:
;; If buffer is not visiting a file, we use the default file name.
;; If this file name is not suitable, either override the function
;; or set the user option to a custom function.
(expand-file-name "marginalia.org" user-emacs-directory)))
Understood - I didn't expect eww to return a nil buffer when opening a file I guess. Just in-case anyone else has a similar problem I used the following workaround:
(defun my/function ()
(concat "~/Documents/org/roam/reference/"
(file-name-base (eww-current-url))
".org"))
(setq org-remark-notes-file-name
#'my/function)
It's very hacky as it will fail for anything other than eww but my elisp fu isn't good enough for anything else.