-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Offer migration paths for existing notes #11
Comments
In theory, it's possible, since In case 1., we could prepend the content of the files with the relevant file-metadata tags, checking if a title has already been defined and, if not, creating it. In case 2., however, things can get hairy quite fast. We'd have to vet every heading to make sure that it matches a BibTeX cite-key in your If we suppose that, still for case 2., every heading in the file is linked to a BibTeX cite-key, then things might be a little easier. We create a file out of each tree, adjust the headings level accordingly, add the file-metadata tags from the BibTeX cite-key, and call it a day. And obviously, we make all this non-destructive to prevent fuck-ups. How does that sound to you? |
Alterntive case 2 solution: Don't iterate over sections in org-file but iterate over entries returned by |
Then, we need to make it clear that the users should have all their I don't have much experience writing tests, let alone migration scripts. I'm going to think about it, but if anyone's feeling up to the task, feel free to let us now. |
I will look into it. Should be easy. But assuming I have an entry's note in a string and the BibTeX key, what's the easiest way to create a new note in |
You'd want to use
This should do it nicely. |
Cool, thanks. |
I have this sketch below (for just one entry). Idea is to copy the notes for the entry to the kill ring and then to have the notes automatically inserted from there by including (let ((key "Haeussler2012"))
;; First copy notes to kill ring. Then open org-roam notes file with
;; a org-roam-bibtex-template that uses to `%c` to insert notes at
;; the desired position.
(let ((org-roam-bibtex-template
'(("r" "ref" plain #'org-roam-capture--get-point ""
:file-name "${slug}"
:head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n\n%c"
:unnarrowed t))))
(bibtex-completion-edit-notes (list key))
(copy-region-as-kill
(progn (beginning-of-buffer) (point))
(progn (end-of-buffer) (point)))
(bibtex-completion-exit-notes-buffer)
(org-roam-bibtex-edit-notes key))) |
On it. |
Good news: it's just a typo! We changed the name of the variable from This should work: (let ((key "Haeussler2012"))
;; First copy notes to kill ring. Then open org-roam notes file with
;; a org-roam-bibtex-template that uses to `%c` to insert notes at
;; the desired position.
(let ((org-roam-bibtex-templates ; <---
'(("r" "ref" plain #'org-roam-capture--get-point ""
:file-name "${slug}"
:head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n\n%c"
:unnarrowed t))))
(bibtex-completion-edit-notes (list key))
(copy-region-as-kill
(progn (beginning-of-buffer) (point))
(progn (end-of-buffer) (point)))
(bibtex-completion-exit-notes-buffer)
(org-roam-bibtex-edit-notes key))) |
Just tried it but now I get a new buffer that's completely empty. Hm ... |
Can you get this to work? (let ((key "Haeussler2012"))
(let ((org-roam-bibtex-templates
'(("r" "ref" plain #'org-roam-capture--get-point ""
:file-name "${slug}"
:head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n\n%c"
:unnarrowed t))))
(kill-new "Testing 123")
(org-roam-bibtex-edit-notes key))) |
Nope, still an empty buffer (with name "haessler2020.org"). |
I installed org-roam-bibtex two hours ago from Melpa (via straight.el). Will have to test with |
Yeah, sorry, quite the annoying problem you've got there. I've run into some issues with |
I cannot even get this to work: I think the org-roam db was perhaps corrupted when I first made a notes file for this entry but then didn't save it? Reason: When I try a different key, it works. |
Raises the question: how can notes be deleted? |
You could run |
Could it be that an entry in org-roam's db is created even before the capture process is finalized? In this case an aborted capture process should trigger some clean-up. |
I'm pretty sure we're only writing to the db on filesave in Org-roam. Let me check. Edit: Yes, this is what we're running with |
Hm, but when I start |
Yes, I can reproduce it. Sadly, this is an Org-roam problem rather than an orb problem. Org-roam has addressed it by disabling nested/parallel captures, but we're not running those checks in orb. As of now, there isn't a very robust way to check if a capture buffer is already acting on the citekey, and whatever structure we could incorporate (like an alist listing the current captures), I think we're better waiting for upstream to fix it. Well, when I say 'waiting', I'm in charge of it, so I'll try to tackle it next week, cf. org-roam/org-roam#527. |
Got it. Luckily it's not a show-stopper in the current use case. Will continue to work on the migration script over the next couple of days. |
Thanks for your work, and good luck for the new semester! |
(let ((org-roam-bibtex-templates
'(("r" "ref" plain #'org-roam-capture--get-point ""
:file-name "${slug}"
:head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n\n%c"
:unnarrowed t))))
(kill-new "Testing 123")
(org-roam-bibtex-edit-notes key))) @tmalsburg @zaeph I think the problem here is that If I understood the intent of the function correctly, this may be fixed as follows, just move (let ((org-roam-bibtex-templates
'(("r" "ref" plain #'org-roam-capture--get-point "%c"
:file-name "${slug}"
:head "#+TITLE: ${title}\n#+ROAM_KEY: ${ref}\n\n"
:unnarrowed t))))
(kill-new "Testing 123")
(org-roam-bibtex-edit-notes key))) |
Below is a script that worked for me. Definitely use at your own risk :) (seq-do
(lambda (key)
;; First copy notes to kill ring. Then open org-roam notes file with
;; a org-roam-bibtex-template that uses to `%c` to insert notes at
;; the desired position.
(let ((org-roam-bibtex-templates
'(("r" "ref" plain #'org-roam-capture--get-point ""
:file-name "${citekey}"
:head "#+TITLE: ${author-abbrev}${title}\n#+ROAM_KEY: ${ref}\n\n%c"
:unnarrowed t))))
(bibtex-completion-edit-notes-default (list key))
(copy-region-as-kill
(progn (goto-char (point-min)) (point))
(progn (goto-char (point-max)) (point)))
(bibtex-completion-exit-notes-buffer)
(org-roam-bibtex-edit-notes key)
(org-capture-finalize)))
(list (car (seq-map (lambda (candidate) (cdr (assoc "=key=" candidate)))
(seq-filter
(lambda (candidate) (assoc "=has-note=" candidate))
(bibtex-completion-candidates)))))) If you want to experiment with different templates, just run the code above, check results, delete new note files in (progn
(org-roam-db--clear)
(org-roam-db-build-cache)) Rinse and repeat. |
Nice! As much as I'd love to run the risk of having things catastrophically fail on the eve of submission, I'll pass. If anyone gives it a go—and please back-up your files before—please tell us here if it worked for you! |
Good luck with your submission! And congrats in advance. Got to get back to actual work as well. :) |
Thank you, and good luck to you as well! :) |
I imagine many prospective users of this package already have notes in one of the two formats offered by helm-bibtex or some other format. Is there something that could be offered to these users to make the transition easier? Doesn't have to be a part of the package; some hints and sample code in README.org would go a long way.
The text was updated successfully, but these errors were encountered: