Charles Choi <[email protected]> writes:

> Trying to figure out how to use Org Protocol to capture a web page link
> as a BibTeX entry. I've created a capture template as so:
>
> ("bib"
>   "BibTex Entry"
>   ;; ... <snip -- cm> 
>   :jump-to-captured t)

> [snip]

> When I try to finalize this capture I get this warning/error message:
>
> ⛔ Warning (org-element): ‘org-element-at-point’ cannot be used in non-Org 
> buffer #<buffer references.bib> (bibtex-mode)
> ⛔ Warning (org-element): org-element--cache: Org parser error in 
> references.bib::2. Resetting.
> The error was: (error "rx ‘**’ range error")
> Backtrace:
> "  backtrace-to-string(nil)
>   org-element-at-point()
>   org-up-heading-safe()
>   org-fold-show-set-visibility(ancestors)
>   org-fold-show-context(org-goto)
>   org-goto-marker-or-bmk(#<marker at 2 in references.bib> 
> \"org-capture-last-stored\")
>   org-capture-goto-last-stored()
>   org-capture-finalize(nil)
>   funcall-interactively(org-capture-finalize nil)
>   command-execute(org-capture-finalize)
> "

Reproduced. But the captured entry does get inserted in references.bib,
doesn't it? It does for me.

>From the backtrace, it seems the error arises only when you try to jump
to the captured entry. In an Org file it might be folded/hidden, so
=org-goto-marker-or-bmk= tries to make sure it's unfolded enough that
you see the context. I think that's an internal helper function that
isn't expected to be invoked on locations outside Org files, but maybe
it would be a good idea to change it to test if we're in an Org buffer
before trying any unfolding.

Meanwhile, you can at least avoid the error message by setting
=:jump-to-capture nil= in the template. Though not quite the workflow
you wanted, it should work to get web pages into the bibtex file.

> Does Org capture only work with Org files?

That seems a reasonable expectation, at least, since Org doesn't know
how to insert captured items into particular locations in arbitrary
formats, or how to jump to a stored item that opens in an arbitrary mode
where it might be hidden by an overlay. So I don't think it's a bug if
doing so causes errors. Though your example shows that Org capture *can*
partly be made to work with other formats.

Yours,
Christian

Reply via email to