On 12/07/2024 03:36, Sébastien Gendre wrote:
Max Nikulin writes:
See the "Link type, Available keywords" table in this section.
`org-capture' may be executed in various Emacs buffers and available
keywords may depend on major mode.

Is it necessary to call "org-store-link" before calling "org-capture" to
extracet the informations used by theses keywords ?
[...]
I found the documentation unclear about this.

Have a look into `org-capture' code. It calls `org-store-link'.

Is there a way to discover the keywords that a major mode provide to a
capture template ?

See specific store link functions, e.g. `org-gnus-store-link'.

%(let ((bla (plist-get (plist-get org-store-link-plist :query) :bla)))
    (or bla "No bla"))"

emacsclient
'org-protocol:/capture?template=s&title=Hello&body=World&url=http:%2F%2Fexample.com&bla=foo'

A new parameter added to the org-protocol url is only accessible through
the ":query" key ? It will not create a new "%:keywoard" automatically ?

With "capture" subprotocol it does not mapped to keywords.

What I would love to do, is creating a Firefox extension that can
extract different metadata from known well known web site and pass them
to an Org-mode capture through org-protocol.

For example, for a book, extracting author, title, year, etc.

Not all books have authors in metadata. Some have editors since every chapter has its own author. To avoid handling such logic in capture templates I decided to resort to formatting inside an extension (or formatting performed by a dedicated tool if site has API, e.g. GitHub).

And then, I could simply create a capture template that would use the
keywords "%:author", "%:title", etc.

If you are using Emacs-30 I would suggest to keep away from org-protocol hacks and to rely on `server-eval-args-left' handled by a dedicated function

    emacsclient --eval '(my-capture)' 'my-proto://something?param=value'

For older versions you may either use backslash hell like in emacsclient-mail.desktop or to define custom subprotocol for org-protocol.



Reply via email to