Skip to content

Latest commit

 

History

History
71 lines (53 loc) · 2.81 KB

org-capture-settings.org

File metadata and controls

71 lines (53 loc) · 2.81 KB

Settings for Org Capture

Preface

The document describes the settings to use org-protocol and is based on this article. The settings were tested on Emacs 25.1 on ArchLinux and Windows with Firefox 47.

Common

  • Create bookmark with the following as location:
javascript:(function()%20{location.href='org-protocol://capture://w/'+encodeURIComponent(location.href)+'/'+encodeURIComponent(document.title)+'/'+encodeURIComponent(window.getSelection());})()
  • Add the following code to init.el:
(use-package org-protocol
  :defer t
  :config
  (setq org-capture-templates
	(quote (("w" "Weblink" entry (file (expand-file-name "bookmarks.org" "~/org/"))
		 "* %c\n  :PROPERTIES:\n  :CREATED: %U\n  :END:\n  - Quote:\n    %i" :unnarrowed)))))

Notes:

  1. If you don’t have use-package, just copy the setq part
  2. Both org and org-protocol have deferred loading, hence we’ll add require for the latter in next sections, when the former will be loaded by the protocol itself
  3. The letter “w” both in the bookmark and in the template may be changed, but it should be the same for both cases
  4. After completing the instructions, restart Firefox, click on the bookmark once & approve the usage of the handler. Later you may check that org-protocol has an associated handler in about:preferences#applications

Linux

  • Create ~/.local/share/applications/org-protocol.desktop with the following content:
[Desktop Entry]
Name=org-protocol
Exec=sh -c "emacsclient -e \"(require 'org-protocol)\" && emacsclient -c %u"
Type=Application
Terminal=false
Categories=System;
MimeType=x-scheme-handler/org-protocol;
  • Run in the terminal
update-desktop-database ~/.local/share/applications/

Windows

  • If needed, download nircmd utility from NirSoft to run batch files without visible console window; otherwise, change the configuration accordingly
  • Create runOrgProtocol.bat in some directory, remove or replace -f %HOME%\.emacs.d\volatile\server:
@echo off
emacsclientw.exe -a "" -f "%HOME%\.emacs.d\volatile\server" -e "(require 'org-protocol)"
emacsclientw.exe -a "" -f "%HOME%\.emacs.d\volatile\server" %*
  • Create file with bat extension, run it as administrator, replacing %HOME%\Scripts\runOrgProtocol.bat accordingly:
@echo off
reg add "HKEY_CLASSES_ROOT\org-protocol" /t REG_SZ /d "URL:Org Protocol" /f
reg add "HKEY_CLASSES_ROOT\org-protocol" /t REG_SZ /v "URL Protocol" /d "" /f
reg add "HKEY_CLASSES_ROOT\org-protocol\shell\open\command" /t REG_EXPAND_SZ /d "c:\progs\nirsoft\nircmd.exe execmd %HOME%\Scripts\runOrgProtocol.bat \"%%1\"" /f