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

zotxt needs examples and a tutorial. #59

Open
EmmanuelCharpentier opened this issue Jun 22, 2021 · 9 comments
Open

zotxt needs examples and a tutorial. #59

EmmanuelCharpentier opened this issue Jun 22, 2021 · 9 comments

Comments

@EmmanuelCharpentier
Copy link

I have used used bibtex for 34 years (and counting...). I recently started to use org-mode, where I use org-ref with .bib files, and dabbled lightly with markdown (via pandoc), again using .bib files.

I have, however, a strong incentive to use Zotero with as little interim steps as possible : Zotero is the base bibliographic tool of by workplace, where most of the work is done with Word, and none of my coworker is a LaTeX, org-mode or markdown user.

I tried, again, to figure out how to use zotxt : installation is easy, and I am able to use org-zotxt-insert-reference-link (C-c " i) to search for a publication and insert a "zotero link" in the buffer (a reference to the Zotero database and the (simplified) text of a citation).

But I am unable to figure out how to use this link :

  • specifying a bibliography style ;
  • citing in the text (with automatic key generation) ;
  • inserting the (formatted) reference at (or near to) the end of the text.

I am probably erring by drifting too close to the LaTeX/org-mode/pandoc model. A tutorial explaining the use of these links would be useful (notwithstanding the fact that the only commands bound to keys are org-zotxt-insert-reference-link and zotxt-citekey-insert) ; an example file, quicker to create, could be sufficient.

@ChauhanT
Copy link

I am on doom emacs. I just want to see my list of zotero refs and create links to the underlying PDF files :D Can't figure out how to do this! But the fact that he software exists and is maintained is amazing <3 I think Emacs has a package for almost everything!

@egh
Copy link
Owner

egh commented Aug 3, 2021

Hi @EmmanuelCharpentier

Yes, I agree 😄 and I'm sorry, as you can see by my late response I can't promise anything - I've been busy with other things.

In general, if you use org-mode, you probably can't (at the moment) end up with a proper paper with references and a bibliography - but you can insert links. If you use markdown + pandoc, you should be able to insert references.

However, with the merge of the org-cite stuff, it should be possible to make the interaction work better.

@titaniumbones
Copy link

@egh I'd love to see this move forward. Is there anythhing I can do to make it easier to use zotero directly in my org cites?

@egh
Copy link
Owner

egh commented Feb 10, 2022

Hi @titaniumbones ! Sorry for the delay.

Yes, my top priority is making zotxt work properly with org cite. I think it will be pretty easy to do.

If you set

 (setq org-zotxt-link-description-style :citation)

You should be able to insert org-cite citations with C-" k (if you enabled zotxt-citekey-mode) You'll need to manually add [cite:...]

You'll still need to export a JSON or BibTeX file manually for use in your org document, but I'm hoping it will be pretty easy to to hook it up so you don't have to do this.

@Awannaphasch2016
Copy link

I do agree that popular packages should always have strong example, tutorial, and documentation.

But the nature of open source doesn't take developer time and populatiry projection into account.

It is best to have ability to read and figure out code your self. I wouldn't say that this is a hard constraint, but if you going to go emacs route. 95 percent of the time you can blaze through the problem, but the last 5 percent will fall into similar problem you are having now.

I am excited for a great documentation, nontheless.

Good luck!.

@Stwerp
Copy link

Stwerp commented Feb 5, 2024

If you set

 (setq org-zotxt-link-description-style :citation)

You should be able to insert org-cite citations with C-" k (if you enabled zotxt-citekey-mode) You'll need to manually add [cite:...]

This does seem to be working. In the line at

(format "@%s" (plist-get item :citekey)))

if that is changed to

(format "cite:&%s" (plist-get item :citekey)))

then things seem to work well for me with org-ref.

My steps were:

  1. Install orgtxt Zotero plugin, and the orgtxt package from melpa for emacs
  2. Download a betterbibtex export from Zotero and place it in my current directory
  3. Point to the csl style with #+csl-style: ieee.csl
  4. Make the bibliography with bibliography:refs.bib at the end of the org file.
  5. Insert references with the citekey mode you described.
  6. When I export with org-ref, things seem to be working well!

There was a weird thing about needing to set the default library to ":all" to work with shared libraries, but that seemed to just need to be a custom variable to set, and it seems to be smooth sailing.

Maybe breaking off the link formatting in the line linked to above so that we could write a custom function, or making a custom variable would help. It sounds like the one as-is is built around markdown formatting? I'm not sure what makes since here, besides just re-defining the whole function for now in my config files.

@Stwerp
Copy link

Stwerp commented Feb 6, 2024

And replying to my last message here in case anyone else runs into this. There's an issue with the deferred package related to scope of variables in the the let statement (see kiwanami/emacs-deferred#54 ). It doesn't seem to be affecting zotxt for now, but when I redefined my zotxt-citekey-insert function to change the citation format, it worked when evaluated from the scratch buffer, it worked when I modified the function in the zotxt.el directly, but would return a void-variable error in when I defined the function in my config files. The solution is to quote the deferred chain lambda. Here's my redefine. I put this in the :config section of my (use-package zotxt) statement:

(defun zotxt-citekey-insert (arg)
    "Insert a citekey.

Prompts for search to choose item.  If prefix argument ARG is used,
will insert the currently selected item from Zotero.  If double
prefix argument is used the search method will have to be
selected even if `zotxt-default-search-method' is non-nil"
    (interactive "p")
    (let ((mk (point-marker)))
      (deferred:$
       (zotxt-choose-deferred arg)
       (deferred:nextc it
                       (lambda (items)
                         (zotxt-mapcar-deferred (lambda (item)
                                                  (zotxt-get-item-deferred item :citekey))
                                                items)))
       (deferred:nextc it
                       `(lambda (items)
                          (let ((current-buffer (current-buffer)))
                            (with-current-buffer current-buffer

                              (goto-char (marker-position ,mk))
                              (insert (mapconcat
                                       (lambda (item)
                                         (format "cite:&%s" (plist-get item :citekey)))
                                       items " "))))))
       (deferred:error it #'zotxt--deferred-handle-error)
       (if zotxt--debug-sync (deferred:sync! it)))))

Key being the backtick for the lambda, and then the comma before mk.

@jacobkasper
Copy link

And replying to my last message here in case anyone else runs into this. There's an issue with the deferred package related to scope of variables in the the let statement (see kiwanami/emacs-deferred#54 ). It doesn't seem to be affecting zotxt for now, but when I redefined my zotxt-citekey-insert function to change the citation format, it worked when evaluated from the scratch buffer, it worked when I modified the function in the zotxt.el directly, but would return a void-variable error in when I defined the function in my config files. The solution is to quote the deferred chain lambda. Here's my redefine. I put this in the :config section of my (use-package zotxt) statement:

(defun zotxt-citekey-insert (arg)
    "Insert a citekey.

Prompts for search to choose item.  If prefix argument ARG is used,
will insert the currently selected item from Zotero.  If double
prefix argument is used the search method will have to be
selected even if `zotxt-default-search-method' is non-nil"
    (interactive "p")
    (let ((mk (point-marker)))
      (deferred:$
       (zotxt-choose-deferred arg)
       (deferred:nextc it
                       (lambda (items)
                         (zotxt-mapcar-deferred (lambda (item)
                                                  (zotxt-get-item-deferred item :citekey))
                                                items)))
       (deferred:nextc it
                       `(lambda (items)
                          (let ((current-buffer (current-buffer)))
                            (with-current-buffer current-buffer

                              (goto-char (marker-position ,mk))
                              (insert (mapconcat
                                       (lambda (item)
                                         (format "cite:&%s" (plist-get item :citekey)))
                                       items " "))))))
       (deferred:error it #'zotxt--deferred-handle-error)
       (if zotxt--debug-sync (deferred:sync! it)))))

Key being the backtick for the lambda, and then the comma before mk.

Thanks, this is great! How do you handle citing multiple citations simultaneously? Mine show up as (Smith, 2020) (Rabbit, 2021).

@Stwerp
Copy link

Stwerp commented Feb 15, 2024

I ended up manually editing the links with multiple citations. So the zotxt commands would insert cite:&key1cite:&key2 and I would edit it to cite:&key1;&key2 by hand. It's a little clunky, but at that point the org-ref engine could take over and put it correctly per the CSL file's specifications.

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

7 participants