Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dmitrym0
Copy link
Member

@dmitrym0 dmitrym0 commented Jun 7, 2023

Problem

org-noter is very opinionated about where notes are to be stored. This makes using org-roam a bit of a challenge with org-noter. org-roam favours many small notes files over the combined file that org-noter prefers.

See #2 as well.

Solution

In #32, I introduced a hook that allows the file opening process to be overriden. By default, the hook is set to org-noter--create-session-from-document-file-default which implements the standard org-noter opening process (mostly Notes.org file).

In this PR, I add org-noter-org-roam module. This module has org-noter--create-session-from-document-file-supporting-org-roam which supports the alternative org-roam workflow.

This functionality has to be enabled by the user by setting the file opening hook like so:

(setq org-noter-create-session-from-document-hook '(org-noter--create-session-from-document-file-supporting-org-roam))

Checklist

  • I checked the code to make sure that it works on my machine.
  • I checked that the code works without my custom emacs config.
  • I added unit tests.
  • add docs

Steps to Test

  1. (setq org-noter-create-session-from-document-hook '(org-noter--create-session-from-document-file-supporting-org-roam))
  2. open a pdf document
  3. invoke org noter: M-x org-noter
  4. standard org-roam node-find completion will be invoked, user specifies a new or an existing node
  5. Notes heading is generated in the specified node (text-file). If a heading was previously created the user is brought to it.

[Optional] Screenshots

@petermao
Copy link
Member

petermao commented Jun 17, 2023

I pushed a dedicated branch to test this feature to our org-noter-with-emacs-basic-test repo. Not sure if I got it right as I get this error (copied from *Messages*):

Wrote <path-to>/org-roam/20230617151846-md0.org
org-noter--get-filename-for-org-roam-node: Wrong type argument: org-roam-node, nil

Step 1 is implemented in install-straight.el
Step 2 is opening our test copy of "Moby Dick"
Step 3 is as prescribed
Step 4: the Node: prompt appears, I give it some text: MD0

The file ...-md0.org, gets written, but there is nothing recognizable as org-noter after the error message.

@dmitrym0
Copy link
Member Author

Thanks for creating the branch. I traced it to this point here: https://github.com/org-noter/org-noter/blob/feature%2Forg-roam-integration/modules/org-noter-org-roam.el#L37

I create an org-roam node/file and then try to resolve the actual file path based on the ID that was created. But org-roam is returning nil. I suspect that this is a configuration problem. I'll dig into it tonight.

@dmitrym0
Copy link
Member Author

I updated the test branch, @petermao. I had to specify explicit paths for org-roam properties to make sure it doesn't conflict with my existing org-roam installation.

(org-roam-db-autosync-mode) has to be enabled. Without it, org-roam is not immediately aware of new nodes and that breaks my code.

@dmitrym0
Copy link
Member Author

@petermao, I updated the branch as well as the org-noter-with-emacs-basic-test test branch.

I pinned org-mode to built in emacs version, which happens to be 9.5 in Emacs 28.2

To test full end to end flow:

  1. In vanilla emacs. open install-straight.el and eval-buffer it. This should install everything.
  2. Open up a pdf file and M-x org-noter.
  3. You should get an org-roam prompt asking you what node the notes should go into.
  4. Specify a node, org-noter should open.

@bdarcus
Copy link

bdarcus commented Aug 24, 2023

Hey @dmitrym0 - @petermao pointed me to your work on org-roam integration, so thought I'd link this issue on the citar repo for reference.

emacs-citar/citar#756

In particular, see Roshan's comment here:

emacs-citar/citar#756 (comment)

I am not currently using org-noter, so will have to find time when I can to wrap my head around the details, but hopefully what we're wanting to do makes sense.

But, a high-level observation on this:

org-roam favours many small notes files over the combined file that org-noter prefers.

It's more complicated though. It's not just org-roam that has this preference. Denote does as well (and likely other org-based note packages), as does the default note "source" in citar:

https://github.com/emacs-citar/citar#notes

Also, org-roam v2 is more general, and does allow more than one note per file.

It might suggest it's worth generalizing this more, and not tying it explicitly to org-roam?

Our note API in citar seems to do a good job balancing generality and simplicity; citar-org-roam is a ~200 LOC implementation of it.

https://github.com/emacs-citar/citar-org-roam/blob/main/citar-org-roam.el

And here's the "source" plist.

https://github.com/emacs-citar/citar-org-roam/blob/761eed66782fdbb6d65749098caa42ba43e8441d/citar-org-roam.el#L75-L81

@dmitrym0
Copy link
Member Author

@bdarcus I'm not familiar with citar (yet?). I skimmed the issue you linked to. It seems to be about being able to find the notes file based on the original pdf document?

It might suggest it's worth generalizing this more, and not tying it explicitly to org-roam?

That is the goal here, with org-roam being the first implementation.

In #32 I made it possible to hook into org-noter's file opening process. The next step is to create org-noter skeleton if needed (top level heading for the document, :PROPERTIES, etc). Only then is the buffer passed to org-roam.

To summarize, there is very little org-roam specific here, the goal is to make it compatible with any note taking system.

@dmitrym0 dmitrym0 merged commit 9d7d488 into master Dec 5, 2023
@dmitrym0 dmitrym0 deleted the feature/org-roam-integration branch December 14, 2023 16:40
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

Successfully merging this pull request may close these issues.

4 participants