emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Capture, template expansion and keyword for link type
Date: Fri, 12 Jul 2024 19:00:45 +0700	[thread overview]
Message-ID: <v6r5td$rqr$1@ciao.gmane.io> (raw)
In-Reply-To: <87ikxbwtru.fsf@k-7.ch>

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	other threads:[~2024-07-12 12:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87sewga4ni.fsf@k-7.ch>
2024-07-11  6:59 ` Capture, template expansion and keyword for link type Sébastien Gendre
2024-07-11 13:56   ` Ihor Radchenko
2024-07-11 20:47     ` Sébastien Gendre
2024-07-11 14:05   ` Max Nikulin
2024-07-11 20:36     ` Sébastien Gendre
2024-07-12 12:00       ` Max Nikulin [this message]
2024-07-12 16:34         ` Sébastien Gendre
2024-07-14  8:22           ` Max Nikulin
2024-07-11  3:42 Sébastien Gendre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='v6r5td$rqr$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).