yantar92 / org-capture-ref

Extract metadata/bibtex info from websites for org-capture
GNU General Public License v3.0
72 stars 4 forks source link

<org-capture-ref> Failed to get live link buffer. Got nil #7

Open cashpw opened 2 years ago

cashpw commented 2 years ago

Opening this issue to track an error I'm seeing. Hopefully my notes will be helpful to others.

#+begin_src emacs-lisp :tangle packages-personal.el
(package! org-capture-ref
  :recipe (:host github
           :repo "yantar92/org-capture-ref"))

(package! asoc
  :recipe (:host github
           :repo "troyp/asoc.el"))
#+end_src

#+begin_src emacs-lisp :tangle config-personal.el
(use-package! org-capture-ref)
(use-package! asoc)

(let ((templates (doct '( :group "Browser link"
                          :type entry
                          :file "~/proj/notes/org-capture-ref.org"
                          :fetch-bibtex (lambda () (org-capture-ref-process-capture)) ; this must run first
                          :link-type (lambda () (org-capture-ref-get-bibtex-field :type))
                          :extra (lambda () (if (org-capture-ref-get-bibtex-field :journal)
                                                (s-join "\n"
                                                        '("- [ ] download and attach pdf"
                                                          "- [ ] [[elisp:org-attach-open][read paper capturing interesting references]]"
                                                          "- [ ] [[elisp:(browse-url (url-encode-url (format \"https://www.semanticscholar.org/search?q=%s\" (org-entry-get nil \"TITLE\"))))][check citing articles]]"
                                                          "- [ ] [[elisp:(browse-url (url-encode-url (format \"https://www.connectedpapers.com/search?q=%s\" (org-entry-get nil \"TITLE\"))))][check related articles]]"
                                                          "- [ ] check if bibtex entry has missing fields"))
                                              ""))
                          :org-entry (lambda () (org-capture-ref-get-org-entry))
                          :template
                          ("%{fetch-bibtex}* TODO %?%{space}%{org-entry}"
                           "%{extra}"
                           "- Keywords: #%{link-type}")
                          :children (("Interactive link"
                                      :keys "b"
                                      :clock-in t
                                      :space " "
                                      :clock-resume t
                                      )
                                     ("Silent link"
                                      :keys "B"
                                      :space ""
                                      :immediate-finish t))))))
  (dolist (template templates)
    (asoc-put! org-capture-templates
               (car template)
               (cdr  template)
               'replace)))
#+end_src

Invoking the capture template for either "Interactive link" or "Silent link" results in " Failed to get live link buffer. Got nil" message in the minibuffer. I'm not sure how this capture template gets the URL I intend to capture.

yantar92 commented 2 years ago

These templates are supposed to work through capture protocol, not interactively. (I guess I can change this, but I usually invoke things using org-capture-ref-at-point, org-capture-ref-capture-url, and from Qutebrowser).

yantar92 commented 2 years ago

*And yes, I do need to update README

cashpw commented 2 years ago

I see. I've used the following to manually capture a few by executing code in the scratch buffer:

(org-capture-ref-capture-url "https://en.wikipedia.org/wiki/Sine_and_cosine")

These captures (below) lack bibtex entries. Is bibtex generation controlled by a variable? Or perhaps org-capture-ref-capture-url isn't sufficient to generate bibtex entries? Do you have an example org-protocol capture bookmarklet I could try?

* TODO yantar92 [Github] yantar92/org-capture-ref: Extract metadata/bibtex info from websites for org-capture :BOOKMARK:misc:
:PROPERTIES:
:TITLE:    yantar92/org-capture-ref: Extract metadata/bibtex info from websites for org-capture
:BTYPE:    misc
:ID:       Github_yantar92_yantar_org_captur_ref_extrac_9c0
:AUTHOR:   yantar92
:CREATED:  [2022-10-11 Tue 06:58]
:HOWPUBLISHED: Github
:NOTE:     Online; accessed 11 October 2022
:RSS:      https://github.com/yantar92/org-capture-ref/commits.atom
:URL:      https://github.com/yantar92/org-capture-ref
:END:
* TODO /u/ [Reddit:orgmode] r/orgmode - Guide to citations in org-mode :BOOKMARK:misc:
:PROPERTIES:
:TITLE:    r/orgmode - Guide to citations in org-mode
:BTYPE:    misc
:ID:       Reddit_orgmode_/u/_r_orgmod_guide_to_citat_456
:AUTHOR:   /u/
:CREATED:  [2022-10-11 Tue 07:00]
:HOWPUBLISHED: Reddit:orgmode
:NOTE:     Online; accessed 11 October 2022
:RSS:      https://www.reddit.com/r/orgmode/comments/vchefn/guide_to_citations_in_orgmode/.rss
:URL:      https://www.reddit.com/r/orgmode/comments/vchefn/guide_to_citations_in_orgmode/
:END:
* TODO [Wikipedia(en)] :BOOKMARK:misc:
:PROPERTIES:
:TITLE:    nil
:BTYPE:    misc
:ID:       Wikipedia(en)__975
:CREATED:  [2022-10-11 Tue 07:03]
:HOWPUBLISHED: Wikipedia(en)
:NOTE:     Online; accessed 11 October 2022
:URL:      https://en.wikipedia.org/wiki/Sine_and_cosine
:END:
yantar92 commented 2 years ago

(org-capture-ref-capture-url "https://en.wikipedia.org/wiki/Sine_and_cosine")

Ooops. Fixed. This was just a broken wikipedia page parser. It has been I while I had to capture wikipedia pages.

Or perhaps org-capture-ref-capture-url isn't sufficient to generate bibtex entries?

It is sufficient, but the default template is now putting things into property drawer rather than bibtex drawer. The templates are now stored in org-capture-ref-capture-template. The raw bibtex can be placed by calling (org-capture-ref-get-bibtex-field :bibtex-string).

Do you have an example org-protocol capture bookmarklet I could try?

Just the usual org-protocol bookmarklet that yields org-protocol://capture?template=$TEMPLATE&url=$URL.

yantar92 commented 2 years ago

Note that headlines generated using the current default template can be exported to bibtex by calling M-x org-bibtex