Skip to content
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

Citar-org-roam is not filling the capture fields #47

Closed
ieremies opened this issue Jun 3, 2023 · 14 comments
Closed

Citar-org-roam is not filling the capture fields #47

ieremies opened this issue Jun 3, 2023 · 14 comments

Comments

@ieremies
Copy link

ieremies commented Jun 3, 2023

Hi (and thanks for the wonderful package).

I'm having a little problem: when using the capture template, even with the exact same config as your README, the citar-fields are not filled and instead asked to me.

I'm using doom emacs, with vertico module and citar / citar-org-roam. Everything else seems fine, citar-org-roam-mode and 2 other functions shows up when M-x. The thing is: when I "click" the citation and choose the "Create Org-Roam Notes", it asks me to fill the fields like citar-citekey etc... Even stranger is the fact there is no defined variable citar-org-roam-template-fields when I try to describe-variable.

Here is my config (doom emacs):

;; Aldready in doom
(use-package citar-org-roam
  :after (citar org-roam)
  :config (citar-org-roam-mode))
;; My config
(setq citar-org-roam-note-title-template "${author} - ${title}")
(setq org-roam-capture-templates
      '(("d" "default" plain
         "%?"
         :target
         (file+head
          "%<%Y%m%d%H%M%S>-${slug}.org"
          "#+title: ${note-title}\n")
         :unnarrowed t)
        ("n" "literature note" plain
         "%?"
         :target
         (file+head
          "%(expand-file-name (or citar-org-roam-subdir \"\") org-roam-directory)/${citar-citekey}.org"
          "#+title: ${citar-citekey} (${citar-date}). ${note-title}.\n#+created: %U\n#+last_modified: %U\n\n")
         :unnarrowed t)))
(setq citar-org-roam-capture-template-key "n")

No other errors, even with debug mode.

Thanks for any help in advance!

@bdarcus
Copy link
Contributor

bdarcus commented Jun 3, 2023 via email

@ieremies
Copy link
Author

ieremies commented Jun 4, 2023

Hun, did not think of that possibility.

For future reference: doing unpin! citar-org-roam in packages.el did solve the issue. Keep in mind, you need to doom upgrade after.

Thanks, @bdarcus, for the insight, and sorry for opening a doom specific issue here.

@ieremies ieremies closed this as completed Jun 4, 2023
@bdarcus
Copy link
Contributor

bdarcus commented Aug 6, 2023

FYI, that PR has since been merged.

@deen1
Copy link

deen1 commented Aug 14, 2023

I've been getting what I think is the same issue on vanilla Emacs 28.2.
I just upgraded to MELPA version 20230404.1225 to check. To be clear, when I run M-x citar, select a reference from the list provided that has no notes and hit RET, then choose Create Notes, I get prompted in the minibuffer for citar-citekey, citar-date etc.

My config is as follows:

(use-package citar-org-roam
  :ensure t

  :after (:any citar org-roam)
  :init
  (citar-org-roam-mode)
  (citar-register-notes-source
   'orb-citar-source
   (list :items #'citar-org-roam--get-candidates
	 :hasitems #'citar-org-roam-has-notes
	 :open #'citar-org-roam-open-note
	 :create #'orb-citar-edit-note
	 :annotate #'citar-org-roam--annotate))
  (setq citar-notes-source 'orb-citar-source)
  :no-require
  :custom
  (citar-org-roam-subdir nil)
  :diminish citar-org-roam-mode
  )

I'm trying to use citar specific variables, so this is my capture template:

(add-to-list 'org-roam-capture-templates
	     '("c" "citar bibliography reference" plain
	       (file "~/org-roam/org-notes/citar_template.org")
               :if-new
               (file+head  "~/org-roam/org-notes/${citar-citekey}.org"
		"#+title: ${citar-citekey} (${citar-date}). ${note-title}.\n#+created: %U\n#+last_modified: %U\n\n")
               ))

(setq citar-org-roam-capture-template-key "c")

where citar_template.org looks like this:

* %^{title}
:PROPERTIES:
:Custom_ID: %^{citar-citekey}
:URL: %^{url}
:AUTHOR: %^{citar-author}
:NOTER_DOCUMENT: %^{file}  
:END:

- tags ::
- keywords :: %^{keywords}

@bdarcus
Copy link
Contributor

bdarcus commented Aug 14, 2023

What happens if you do describe-variable for citar-org-roam-template-fields?

The value cars should be the same as whatever template names you're using in the templates.

Mine shows this, for example:

((:citar-title "title")
 (:citar-author "author" "editor")
 (:citar-date "date" "year" "issued")
 (:citar-pages "pages")
 (:citar-type "=type="))

@deen1
Copy link

deen1 commented Aug 15, 2023

I see. I get

Its value is
((:citar-title "title")
 (:citar-author "author" "editor")
 (:citar-date "date" "year" "issued")
 (:citar-pages "pages")
 (:citar-type "=type="))

I don't have e.g. citar-citekey in there, which is in my citar-template.org file. But when prompted for it in the minibuffer, (it's the first thing I'm prompted for), and after manually filling it with the correct key, I am them prompted for citar-author as well, which is in citar-org-roam-template-fields.

For example, at one point the capture buffer for an example looks like this, with the minibuffer-prompt citar-author (emphasis on cursor position mine):

* Assigning Probabilities To Non-Lipschitz Mechanical Systems
:PROPERTIES:
:Custom_ID: vanpoucke21_assig_probab_to_non_lipsc_mechan_system
:URL: http://dx.doi.org/10.1063/5.0063388
:AUTHOR:   <------------ Here
:NOTER_DOCUMENT: ~/org-roam-files/vanpoucke21_assig_probab_to_non_lipsc_mechan_system.pdf  
:END:

I then changed citar-org-roam-template-fields to include (:citar-citekey "cite-key") or (:citar-citekey "key"), but neither
made a difference -- I was still asked for citar-citekey at the beginning of the capture and so on.

Of course, I have a working version of this capture-template system without citar-org-roam variables. It's just that it was suggested elsewhere (perhaps by you?) that we could change to ensure everything remained within the citar ecosystem.

@bdarcus
Copy link
Contributor

bdarcus commented Aug 15, 2023

This seems wrong:

  (setq citar-notes-source 'orb-citar-source)

Try removing the notes-source lines?

Here's my vanilla config:

https://gitlab.com/bdarcus/emacs-elp/-/blob/main/lisp/init-notes.el?ref_type=heads

@deen1
Copy link

deen1 commented Aug 15, 2023

Thanks! Unfortunately setting citar-notes-source to the default value of citar-file leads to the capture template being ignored completely, giving me a capture buffer that looks like this (compare with the above):

:PROPERTIES:
:ID:       18cdd9cd-baf2-497b-8125-fcde0c177be1
:ROAM_REFS: @vanpoucke21_assig_probab_to_non_lipsc_mechan_system
:END:
#+title: Notes on Danny E. P. Vanpoucke & Sylvia Wenmackers, Assigning Probabilities To Non-Lipschitz Mechanical Systems

#+print_bibliography:

I think this is very similar to your vanilla capture-template, which I also tried, with a similar result.

I then tried using your literature-note template using a minimal-ish config using emacs -Q -l, and running Create Notes on a reference again completely avoids the capture template settings -- i.e. the newly created notes buffer does not follow the literature-note format when citar-org-roam-capture-template-key is set, and doesn't even show the capture-template menu buffer (with the template keys as options, that the mini-buffer prompts for) when citar-org-roam-capture-template-key is not set.

@bdarcus
Copy link
Contributor

bdarcus commented Aug 15, 2023

I'll double check later, but pretty sure there's something wrong with your config.

@bdarcus
Copy link
Contributor

bdarcus commented Aug 15, 2023

I'll double check later, but pretty sure there's something wrong with your config.

Yeah, so I just quickly tested with the config I linked to above, and it works as expected; if I create a new note from citar-open, it creates a new note, using the template, with the correct data, and no prompts.

You may, in your config, want to ensure that citar-org-roam-mode is activated (which sets the notes source), though you could of course do that manually.

Otherwise, paste your equivalent to what I share above, and I'll see if I can see anything.

@deen1
Copy link

deen1 commented Aug 15, 2023

I'll double check later, but pretty sure there's something wrong with your config.

That's probably the case, I do have a lot of other stuff including org-roam-bibtex and org-noter hanging around too.

I do have citar-org-roam-mode activated (see above ), and double-checked just now to see that it hasn't been disabled.

Thanks for checking this out, but I wonder if you could just check the following so I can be sure where I'm going wrong:

  1. Your config linked above doesn't use e.g. citar-author, citar-date -- does it work for you if you include these in the capture template?

  2. Similarly, does my citar-template.org format work for you (modulo a few minor tweaks)?

  3. What's the value of citar-org-roam--orig-source for you? By default it seems to take the value at load-time of citar-notes-source, so after your suggestion above I had to manually reset it to citar-file.

  4. How does this capture template setup work for you overall? Do you just do Create Notes and get a capture buffer/org file, or do you get a buffer with a list of org-roam-capture-template options first?

@bdarcus
Copy link
Contributor

bdarcus commented Aug 15, 2023

  1. yes
  2. not convenient for me to test this ATM
  3. citar-file
  4. the former

@deen1
Copy link

deen1 commented Aug 15, 2023

Thanks, I'll try and bisect my config when I can find some more time.

@deen1
Copy link

deen1 commented Sep 11, 2023

Have a reasonably working fix for my issue here: emacs-citar/citar#756 (comment)

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

No branches or pull requests

3 participants