emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* looking for examples of `org-capture-templates` working with `org-protocol://capture`
@ 2022-01-31  2:30 chris
  2022-01-31  3:07 ` chris
  0 siblings, 1 reply; 4+ messages in thread
From: chris @ 2022-01-31  2:30 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 895 bytes --]

Hi,
When you do 
`emacsclient "org-protocol://capture?
template=X&url=URL&title=TITLE&body=BODY"`
I don't understand at all how you make use of `url` `title` and `body` in `org-
capture-template`.
I understand there is some sort of "encoding" that doesn't make use of the keywords 
`url` `title` or `body`, but it's dense.
There are no indications of how to do that here:
https://orgmode.org/manual/The-capture-protocol.html[1]
I haven't found any example that I've been able to reproduce in the whole web.
I've spent hours on the documentation and the source code of
https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el[2]
And I have absolutely no idea of how to use `url` `title` and `body` in `org-capture-
template`.
Chris

--------
[1] https://orgmode.org/manual/The-capture-protocol.html
[2] https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el

[-- Attachment #2: Type: text/html, Size: 1972 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: looking for examples of `org-capture-templates` working with `org-protocol://capture`
  2022-01-31  2:30 looking for examples of `org-capture-templates` working with `org-protocol://capture` chris
@ 2022-01-31  3:07 ` chris
  2022-01-31  4:23   ` chris
  0 siblings, 1 reply; 4+ messages in thread
From: chris @ 2022-01-31  3:07 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1983 bytes --]

On Monday, 31 January 2022 03:30:41 CET chris wrote:
> Hi,
> When you do
> `emacsclient "org-protocol://capture?
> template=X&url=URL&title=TITLE&body=BODY"`
> I don't understand at all how you make use of `url` `title` and `body` in
> `org- capture-template`.
> I understand there is some sort of "encoding" that doesn't make use of the
> keywords `url` `title` or `body`, but it's dense.
> There are no indications of how to do that here:
> https://orgmode.org/manual/The-capture-protocol.html[1]
> I haven't found any example that I've been able to reproduce in the whole
> web. I've spent hours on the documentation and the source code of
> https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el[2
> ] And I have absolutely no idea of how to use `url` `title` and `body` in
> `org-capture- template`.


The last example in https://blog.jethro.dev/posts/capturing_inbox/[1], namely:
```emacs-lisp
(setq org-capture-templates
      `(("l" "org-protocol-capture" entry
         (file "~/path/inbox.org")
        "* TODO [[%:link][%:description]]\n\n %i"
        :immediate-finish t)))
```
Seems to work consistently with:
`xdg-open "org-protocol://capture?template=l&url=URL$(date --iso-8601=s)&title=TITLE$
(date --iso-86
01=s)&body=BODY$(date --iso-8601=s)"`


Provided I have opened at least one org buffer before hand, otherwise it opens a buffer 
named `"org-protocol://capture?template=l&url=URL&title=TITLE&body=BODY"
` at what point it can get messy. Probably I have to "start" somehow "org-mode" first, and 
it doesn't get enough started from my `init.el`.


Goal is to have the capturing work in the background, with emacs started as a daemon, 
but with no opened emacsclient frame:
capture, simply, silently, unobtrusively.


> Chris
> 
> --------
> [1] https://orgmode.org/manual/The-capture-protocol.html
> [2]
> https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el

--------
[1] https://blog.jethro.dev/posts/capturing_inbox/

[-- Attachment #2: Type: text/html, Size: 5400 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: looking for examples of `org-capture-templates` working with `org-protocol://capture`
  2022-01-31  3:07 ` chris
@ 2022-01-31  4:23   ` chris
  2022-02-03 12:57     ` Max Nikulin
  0 siblings, 1 reply; 4+ messages in thread
From: chris @ 2022-01-31  4:23 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3043 bytes --]

On Monday, 31 January 2022 04:07:01 CET chris wrote:
> On Monday, 31 January 2022 03:30:41 CET chris wrote:
> > Hi,
> > When you do
> > `emacsclient "org-protocol://capture?
> > template=X&url=URL&title=TITLE&body=BODY"`
> > I don't understand at all how you make use of `url` `title` and `body` in
> > `org- capture-template`.
> > I understand there is some sort of "encoding" that doesn't make use of the
> > keywords `url` `title` or `body`, but it's dense.
> > There are no indications of how to do that here:
> > https://orgmode.org/manual/The-capture-protocol.html[1]
> > I haven't found any example that I've been able to reproduce in the whole
> > web. I've spent hours on the documentation and the source code of
> > https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el
> > [2 ] And I have absolutely no idea of how to use `url` `title` and `body`
> > in `org-capture- template`.
> 
> The last example in https://blog.jethro.dev/posts/capturing_inbox/[1],
> namely: ```emacs-lisp
> (setq org-capture-templates
>       `(("l" "org-protocol-capture" entry
>          (file "~/path/inbox.org")
>         "* TODO [[%:link][%:description]]\n\n %i"
> 
>         :immediate-finish t)))
> 
> ```
> Seems to work consistently with:
> `xdg-open "org-protocol://capture?template=l&url=URL$(date
> --iso-8601=s)&title=TITLE$ (date --iso-86
> 01=s)&body=BODY$(date --iso-8601=s)"`
> 
> 
> Provided I have opened at least one org buffer before hand, otherwise it
> opens a buffer named
> `"org-protocol://capture?template=l&url=URL&title=TITLE&body=BODY" ` at
> what point it can get messy. Probably I have to "start" somehow "org-mode"
> first, and it doesn't get enough started from my `init.el`.
> 

So, reverse-engineering the example I've eventually found the relevant points of the 
documentation:

https://orgmode.org/worg/org-contrib/org-protocol.html[1]
%i'
    will be replaced by the selected text in your browser window if any.
In addition, you may use the following placeholders in your template:
Placeholders     Replacement
%:link     URL of the web-page
%:description     The title of the web-page
%:initial     Selected text.


https://orgmode.org/manual/Template-expansion.html[2]

So, not so many examples, that's all.

So I've rewritten Jethro's example using `%:initial` because it's easier to read:


```emacs-lisp
(setq org-capture-templates
      `(("l" "org-protocol-capture" entry
         (file "~/path/inbox.org")
        "* TODO [[%:link][%:description]]\n\n %:initial"
        :immediate-finish t)))
```

> 
> Goal is to have the capturing work in the background, with emacs started as
> a daemon, but with no opened emacsclient frame:
> capture, simply, silently, unobtrusively.
> 
> > Chris
> > 
> > --------
> > [1] https://orgmode.org/manual/The-capture-protocol.html
> > [2]
> > https://github.com/emacs-mirror/emacs/blob/master/lisp/org/org-protocol.el
> 
> --------
> [1] https://blog.jethro.dev/posts/capturing_inbox/



--------
[1] https://orgmode.org/worg/org-contrib/org-protocol.html

[-- Attachment #2: Type: text/html, Size: 9295 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: looking for examples of `org-capture-templates` working with `org-protocol://capture`
  2022-01-31  4:23   ` chris
@ 2022-02-03 12:57     ` Max Nikulin
  0 siblings, 0 replies; 4+ messages in thread
From: Max Nikulin @ 2022-02-03 12:57 UTC (permalink / raw)
  To: emacs-orgmode

Chris, could you, please, be more specific with your complains? 
Templates are described in the manual in the sections you cited.

Notice that manual may be accessed from emacs
    M-x info RET org RET
or
    M-: (info "(org) The capture protocol")
or using [[info:org#The capture protocol]] links in org files or as a 
single long HTML page https://orgmode.org/org.html

On 31/01/2022 11:23, chris wrote:
> 
>  > Provided I have opened at least one org buffer before hand, otherwise it
>  > opens a buffer named
>  > `"org-protocol://capture?template=l&url=URL&title=TITLE&body=BODY" ` at
>  > what point it can get messy. Probably I have to "start" somehow 
> "org-mode"
>  > first, and it doesn't get enough started from my `init.el`.

You need something like
   (require 'org-protocol)
in your emacs init file to setup handlers for specific "file names". 
Org-protocol URIs are just relative paths to files from standpoint of 
emcasclient. Certainly this line should be executed when directory with 
org package is already known. The pitfall of such line is that it makes 
impossible to temporary try another org version using just
     emacs -L ~/src/org-mode/lisp test.org
it must be combined with -q or -Q.

> So, reverse-engineering the example I've eventually found the relevant 
> points of the documentation:

What do you mean by "reverse-engineering"? %:link, %:description, %i are 
described in "The capture protocol" 
https://orgmode.org/manual/The-capture-protocol.html known to you. Upper 
"Protocols for External Access" section contains link to "Capture" 
section where a couple of examples (unrelated to org-protocol however) 
may be found. "Template elements" and (known to you) "Template 
expansion" sections have detailed reference of template constituents.

> https://orgmode.org/worg/org-contrib/org-protocol.html

Notice that some information on this page is outdated.

> (setq org-capture-templates
> 
>        `(("l" "org-protocol-capture" entry
>           (file "~/path/inbox.org")
>          "* TODO [[%:link][%:description]]\n\n %:initial"
>          :immediate-finish t)))

:immediate-finish should be added when everything already works.



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-03 13:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-31  2:30 looking for examples of `org-capture-templates` working with `org-protocol://capture` chris
2022-01-31  3:07 ` chris
2022-01-31  4:23   ` chris
2022-02-03 12:57     ` Max Nikulin

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).