org-remark icon indicating copy to clipboard operation
org-remark copied to clipboard

org-remark-file-name-function does not seem to return a valid name from a eww buffer

Open rrottier opened this issue 10 months ago • 2 comments

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)

rrottier avatar Feb 10 '25 01:02 rrottier

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)))

nobiot avatar Feb 10 '25 17:02 nobiot

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.

rrottier avatar Feb 12 '25 06:02 rrottier