Issue with new action function
Closed this issue · 5 comments
Hi Titus,
I am trying to add the following function for a new action, in particular to add a heading to my notes.org file:
(defun bibtex-completion-insert-notes (keys)
"Insert note heading at point."
(insert
(concat "** READ cite:" keys " "
(bibtex-completion-get-value "title" (bibtex-completion-get-entry keys)) "\n"
":PROPERTIES:\n"
":Custom_ID: " keys "\n"
":PDF: /home/julian/Documents/Refs/" keys ".pdf\n"
":END:\n")
)
)
If I evaluate it in a lisp-interaction buffer it seems to do what I want:
(bibtex-completion-insert-notes "Aalto2013")
** READ cite:Aalto2013 Spatial Interpolation of Monthly Climate Data for Finland: Comparing the Performance of Kriging and Generalized Additive Models
:PROPERTIES:
:Custom_ID: Aalto2013
:PDF: /home/julian/Documents/Refs/Aalto2013.pdf
:END:
Then, to add the function to ivy-bibtex, I added this to my .init file:
(ivy-bibtex-ivify-action bibtex-completion-insert-notes ivy-bibtex-insert-notes)
(ivy-add-actions
'ivy-bibtex
'(("n" ivy-bibtex-insert-notes "Create note heading")))
The problem is when I try to use it from ivy-bibtex, I get the following error:
bibtex-completion-get-entry1: Wrong type argument: stringp, ("Aalto2013")
I cannot figure out what is the problem... do you have any ideas?
Many thanks!
Julian
Thanks, but I am not sure if I understand you. Where do I need to do this replacement?
I think you have to write
(bibtex-completion-get-entry (car keys))
Because keys
is a list but bibtex-completion-get-entry
expects a string (i.e., the key).
Yes, that was the issue. Thank you for the help!