Taking notes on webpages using org-protocol

Hi folks,

I’ve been trying to implement the solution described in the org-roam manual here. The manual doesn’t reference the need to get the server running with M-x server-start but that is a minor problem. If you don’t, you get all sorts of problems as follows:

user@client:~$ xdg-open org-protocol://roam-ref?template=d&ref=test&title=this
/usr/bin/emacsclient: can’t find socket; have you started the server?
/usr/bin/emacsclient: To start the server in Emacs, type “M-x server-start”.
/usr/bin/emacsclient: No socket or alternate editor. Please use:

      --server-file      (or environment variable EMACS_SERVER_FILE)
      --alternate-editor (or environment variable ALTERNATE_EDITOR)

kf.kio.gui: Failed to register new cgroup: “app-org\x2dprotocol-333f50bc3cc24058840ba0640cb73632.scope” “org.freedesktop.DBus.Error.UnixProcessIdUnknown” “Process with ID 6648 does not exist.”

However, that is not the end of the story. Even with the server running after I do M-x server-start I still get the following:

user@client:~$ xdg-open org-protocol://roam-ref?template=d&ref=test&title=this
Waiting for Emacs…
ERROR: No capture template referred to by “d” keys
user@client:~$ emacsclient org-protocol://roam-ref?template=d&ref=test&title=this
Waiting for Emacs…
ERROR: No capture template referred to by “d” keys

Running Emacs 27.1 on Debian stable with latest version of org-roam. It seems to be something associated with the inability to find the “d” template but the snippet from my init.el file below has the following for the templates which works correctly when running C-c n f. Any thoughts?

(setq org-roam-capture-templates
'((“d” “default” plain
:if-new (file+head “%<%Y%m%d%H%M%S>-${slug}.org” “#+title: ${title}\n#+date: %u\n#+lastmod: \n\n”)
:unnarrowed t)
(“p” “program documentation” plain
“* Introduction\n\n- Version: %?\n- Dependencies: \n\n* Requirements\n\n* Installation\n\n* Testing\n\n”
:if-new (file+head “%<%Y%m%d%H%M%S>-${slug}.org” “#+title: ${title}\n#+date: %u\n#+lastmod: \n\n”)
:unnarrowed t)
(“b” “book” plain
“* Summary\n\n- Book Title: %?\n- Number of pages: \n- Cost: \n\n* Quotes\n\n* Bibliographical information\n\n* Topic notes\n\n”
:if-new (file+head “%<%Y%m%d%H%M%S>-${slug}.org” “#+title: ${title}\n#+date: %u\n#+lastmod: \n\n”)
:unnarrowed t)
(“l” “programming language” plain
“* Characteristics\n\n- Family: %?\n- Inspired by: \n\n* Reference:\n\n”
:if-new (file+head “%<%Y%m%d%H%M%S>-${slug}.org” “#+title: ${title}\n#+date: %u\n#+lastmod: \n\n”)
:unnarrowed t)))

So you have specifically chosen ?template=d.
Perhaps you might like to check org-roam-capture-ref-templates; the default has only r, and has no d.

The manual has the following too:

where template is the template key for a template in org-roam-capture-ref-templates (see The Templating System).

You could create a PR to propose this to be added; this might help others.

Org mode’s manual [1] has the following part; I believe Org-roam assumes this, because org-roam-protocol is an extension to org-protocol:

In order to use Org protocol from an application, you need to
register ‘org-protocol://’ as a valid scheme-handler. External calls
are passed to Emacs through the ‘emacsclient’ command, so you also need
to ensure an Emacs server is running.

  1. you can evaluate this: (info "(org) Protocols") ↩︎

Alright @nobiot , credit to you. I glanced over that because my brain didn’t spot that org-roam-capture-ref-templates is different to org-roam-capture-templates. Forgive me. I feel like a little kid (even though almost 50 …) that getting this org-roam system slowly pieced together. So yes, now it does work. I have even created the bookmarklet and it rocks (just need to get Firefox to stop asking me too many questions … I’ll have to explore whether the Chrome workarounds in the manual apply to Firefox).

I understand the frustration of many that adventure to org-roam and abandon the effort after a few weeks. You need patience and resilience if you want to build your Zittelkasten environment in Emacs. But I think with time, these efforts are rewarded.

Just remind me what PR stands for (clearly not Public Relations …) . I may add another one too, which is to add a sentence after this one where template is the template key for a template in org-roam-capture-ref-templates (see The Templating System) on the lines of Ensure you do not confuse org-roam-capture-ref-templateswithorg-roam-capture-templates`.

Alright, so I think the way to fix this is to have Emacs running in daemon mode as described here.

Being on Debian, my solution was to create ~/.config/autostart/emacs_daemon.desktop with the following content:

[Desktop Entry]
Exec=emacs --daemon

Sorry, it stands for a pull request. It’s a way to send a patch to a project on GitHub and some similar source code collaboration tools. Org-roam’s documentation is also part of the source code hosted on GitHub, so you can send your edit proposal to improve the quality of documentation.

Ok, has a go at submitting my first PR on Github ever :slight_smile:
Forgive me if not meeting expectations.

I had pretty much the same problems when I tried to get org-protocol to work. At some point it worked fine on my Linux PC but when I tried to get it to work on Windows (with WSL2) I gave up…

My “solution” was (and still is) to use ORG-grasp , which is a browser extension that communicates with a small Python server application. This works well for me, and it does not require a running emacs-server (but a running Python server…) . I know, this does not actually answer your question, but I thought I post it here in case there are other people that have problems with org-protocol and want a quick working solution…