{"id":14008659,"url":"https://github.com/sprig/org-capture-extension","last_synced_at":"2026-01-19T02:37:08.605Z","repository":{"id":34716285,"uuid":"38693335","full_name":"sprig/org-capture-extension","owner":"sprig","description":"A Chrome and firefox extension facilitating org-capture in emacs","archived":false,"fork":false,"pushed_at":"2025-07-31T23:52:41.000Z","size":9317,"stargazers_count":548,"open_issues_count":29,"forks_count":59,"subscribers_count":22,"default_branch":"master","last_synced_at":"2025-08-01T01:38:20.798Z","etag":null,"topics":["chrome","emacs","firefox"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sprig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-07T14:33:29.000Z","updated_at":"2025-07-12T00:55:24.000Z","dependencies_parsed_at":"2024-08-10T11:13:40.767Z","dependency_job_id":null,"html_url":"https://github.com/sprig/org-capture-extension","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sprig/org-capture-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprig%2Forg-capture-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprig%2Forg-capture-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprig%2Forg-capture-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprig%2Forg-capture-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sprig","download_url":"https://codeload.github.com/sprig/org-capture-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sprig%2Forg-capture-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28558279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-19T00:46:33.223Z","status":"online","status_checked_at":"2026-01-19T02:00:08.049Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chrome","emacs","firefox"],"created_at":"2024-08-10T11:01:58.235Z","updated_at":"2026-01-19T02:37:08.590Z","avatar_url":"https://github.com/sprig.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# Org Capture Extension\n\nThis is an extension for Google Chrome (tm) and Firefox (tm) which adds a \"Capture\" button, sending the site address, title, and selected text (if any) to emacs via org-protocol, see the [Org-Mode site] for instructions for setting that up org-protocol. The extentsion itself is available at the [Chrome App Store].\n\n# Improvements\n\n- Adding options for selecting the exact structure of the links that are constructed (e.g. for the benefit of people with '///' problems).\n- There is always room to improve. Open a ticket with your ideas.\n\n# Example Usage\n[![Example Usage Video](https://img.youtube.com/vi/zKDHto-4wsU/0.jpg)](https://www.youtube.com/watch?v=zKDHto-4wsU)\n![Example Usage Screenshot](https://dl.dropboxusercontent.com/s/x2xjgg7bnwuj6uv/Screenshot.png)\n\n# Problems? Please [click here](#troubleshooting) or scroll to the bottom.\n\n# Detailed setup instructions\n\n## Install the extension\n\nEither via the [Chrome App Store] or by dragging the extension folder to the \"Extensions\" tab in Chrome. If the latter is the chosen procedure then one needs to enable developer mode first, if I'm not mistaken. Note that if you choose to have a local-install, then you need to choose some icon and name it org-mode-unicorn.png, placing it in the extension's folder. Or, you can name it anything you want, but then you need to update manifest.json.\n\n_Note_: The first time you use the extension, Chrome will ask you allow it to run ```open ....``` (on OSX) or ```xdg-open ...``` (on Linux), or ??? (On Windows). Those are the standard system mechanisms for dispatching a file/URL to the appropriate handler, so you should accept the request.\n\n## Set up org-protocol\n\nDetailed instructions available at [Org-Mode site].\n\nThe gist of it is to make your system recognize emacsclient as the handler of ```org-protocol://``` links. In addition, one needs to set up emacs to load org-protocol and to set up capture templates.\n\n### Register emacsclient as the ```org-protocol``` handler\n\n#### Under Linux\n\n``` bash\ncat \u003e \"${HOME}/.local/share/applications/org-protocol.desktop\" \u003c\u003c EOF\n[Desktop Entry]\nName=org-protocol\nExec=emacsclient %u\nType=Application\nTerminal=false\nCategories=System;\nMimeType=x-scheme-handler/org-protocol;\nEOF\n```\n\nAnd then, for GTK-based DE:\n``` bash\nupdate-desktop-database ~/.local/share/applications/\n```\n\nFor KDE5:\n``` bash\nkbuildsycoca5\nxdg-mime default org-protocol.desktop x-scheme-handler/org-protocol\n```\n##### For KDE4\n###### Note: This is a workaround to issue #16 - See comment [here](https://github.com/sprig/org-capture-extension/issues/16#issuecomment-305050310)\n\nCreate the file\n*/usr/local/bin/emacs-capture*\n```sh\n#!/bin/bash\n\n# HACK: workaround for a kde-open bug (feature?) that might have\n#       eaten a colon from our argument, om nom nom\nargv=()\nfor arg in \"$@\"; do\n    re='s_^org-protocol:/+capture:?/+_org-protocol://capture://_'\n    argv+=(\"$(echo -n \"$arg\" | sed -Ez \"$re\")\")\ndone\n\n# Note: feel free to add any other arguments you want,\n#  e.g. emacsclient --alternate-editor= -c \"${argv[@]}\"\nemacsclient \"${argv[@]}\"\n```\nAnd the file\n\n*$HOME/.local/share/applications/emacs-capture.desktop*\n```desktop\n#!/usr/bin/env xdg-open\n[Desktop Entry]\nName=Emacs Client\nExec=emacs-capture \"%u\"\nIcon=emacs-icon\nType=Application\nTerminal=false\nMimeType=x-scheme-handler/org-protocol;\n```\n\nFinally, run\n\n``` bash\nkbuildsycoca4\nsudo update-desktop-database\n```\n\n#### Under OSX\n\nStart Applescript Editor. Paste the following snippet:\n\n``` applescript\non emacsclient(input)\n\tdo shell script \"/Applications/Emacs.app/Contents/MacOS/bin-x86_64-10_9/emacsclient -n -c -a \\\"/Applications/Emacs.app/Contents/MacOS/Emacs\\\" '\" \u0026 input \u0026 \"'\"\nend emacsclient\n\non open location input\n\temacsclient(input)\nend open location\n\non open inputs\n\trepeat with raw_input in inputs\n\t\tset input to POSIX path of raw_input\n\t\temacsclient(input)\n\tend repeat\nend open\n\non run\n\tdo shell script emacsclient(\"\")\nend run\n```\n\nAdjust the paths and save it (with 'type' as Application) under ```/Applications/EmacsClient.app``` (or whatever else you choose).\nEdit (with Xcode) the file ```/Applications/Emacsclient.app/Contents/Info.plist```\n\nAnd add there the following:\n``` plist\n\u003ckey\u003eCFBundleURLTypes\u003c/key\u003e\n\u003carray\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eCFBundleURLName\u003c/key\u003e\n\t\t\u003cstring\u003eorg-protocol\u003c/string\u003e\n\t\t\u003ckey\u003eCFBundleURLSchemes\u003c/key\u003e\n\t\t\u003carray\u003e\n\t\t\t\u003cstring\u003eorg-protocol\u003c/string\u003e\n\t\t\u003c/array\u003e\n\t\u003c/dict\u003e\n\u003c/array\u003e\n```\n\nand\n``` plist\n\u003ckey\u003eCFBundleDocumentTypes\u003c/key\u003e\n\u003carray\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eCFBundleTypeExtensions\u003c/key\u003e\n\t\t\u003carray\u003e\n\t\t\t\u003cstring\u003e*\u003c/string\u003e\n\t\t\u003c/array\u003e\n\t\t\u003ckey\u003eCFBundleTypeName\u003c/key\u003e\n\t\t\u003cstring\u003eAll\u003c/string\u003e\n\t\t\u003ckey\u003eCFBundleTypeOSTypes\u003c/key\u003e\n\t\t\u003carray\u003e\n\t\t\t\u003cstring\u003e****\u003c/string\u003e\n\t\t\u003c/array\u003e\n\t\t\u003ckey\u003eCFBundleTypeRole\u003c/key\u003e\n\t\t\u003cstring\u003eViewer\u003c/string\u003e\n\t\u003c/dict\u003e\n\u003c/array\u003e\n```\n\nand restart the desktop. You can also download [EmacsClient.app.zip], which I prepared in advance, if you are lazy.\n\n##### Install EmacsClient.app with homebrew cask\n\nIf you have Homebrew and [Homebrew-Cask](https://caskroom.github.io/) installed, you can also install [EmacsClient.app.zip] with `brew cask install emacsclient`\n\n##### Frame Visibility\n\nUnder some setups the emacs frame does not appear on top. @dangom [proposes a workaround using hammerspoon](https://github.com/sprig/org-capture-extension/issues/46#issuecomment-379498419):\n\nAdd the following to your init.lua:\n\n```lua\nfunction emacsclientWatcher(appName, eventType, appObject)\n  if (eventType == hs.application.watcher.activated) then\n    if (appName == \"Emacsclient\") then\n      -- Bring Emacs to Front\n      hs.osascript.applescript('tell application \"Emacs\" to activate')\n    end\n  end\nend\nappWatcher = hs.application.watcher.new(emacsclientWatcher)\nappWatcher:start()\n```\n\n#### Under Windows\n\nOpen the Registry Editor (Win-R, then type `regedit`). Within `HKEY_CLASSES_ROOT`, add a key called `org-protocol`. Within `org-protocol`, set the data for the string value with the name `(Default)`  to be `URL:org-protocol`, add another string value with name `URL Protocol` and no data, and add a key called `shell`.\n\nWithin `shell`, create a key called `open`.\n\nWithin `open`, create a key called `command`.\n\nWithin `command`, set the data for the string value with the name `(Default)` to `\"C:\\the\\path\\to\\your\\emacsclientw.exe\" \"%1\"`, updating the path to point to your Emacs installation.\n\nIf you get stuck, see [this guide to registering a protocol handler](https://msdn.microsoft.com/en-us/library/aa767914\\(v=vs.85\\).aspx) and look at how registries are set up for other protocol handlers (`skype`, `ftp`, etc.). Most of your pre-existing protocol handlers have more config than you need.\n\n### Set up handlers in emacs\n\nIf some text is selected before the button is clicked, then the following is sent to emacs:\n```\norg-protocol://capture:/p/\u003curl\u003e/\u003ctitle\u003e/selection\u003e\n```\n\nIf nothing is selected, then instead the following is sent:\n```\norg-protocol://capture:/L/\u003curl\u003e/\u003ctitle\u003e\n```\n\nThis means that you need to have appropriate capture templates for \"L\" and for \"p\". Example templates below:\n\n```lisp\n(setq org-capture-templates `(\n\t(\"p\" \"Protocol\" entry (file+headline ,(concat org-directory \"notes.org\") \"Inbox\")\n        \"* %^{Title}\\nSource: %u, %c\\n #+BEGIN_QUOTE\\n%i\\n#+END_QUOTE\\n\\n\\n%?\")\n\t(\"L\" \"Protocol Link\" entry (file+headline ,(concat org-directory \"notes.org\") \"Inbox\")\n        \"* %? [[%:link][%:description]] \\nCaptured On: %U\")\n))\n```\n\n\n_Hint:_ You can put code in capture handlers via %() blocks. I use this mechanism to automatically close the newly crated frame in the L template. If anyone cares to know, I'll add the details. Another example use is below.\n\n[*Note*](https://github.com/sprig/org-capture-extension/issues/37): The `L` template above would break for links to pages having `[` and `]` characters in their page titles - notably ArXiv. To mitigae this, you can use the improved template, contributed by [Vincent Picaud](https://www.github.com/vincent-picaud):\n\n```lisp\n(defun transform-square-brackets-to-round-ones(string-to-transform)\n  \"Transforms [ into ( and ] into ), other chars left unchanged.\"\n  (concat \n  (mapcar #'(lambda (c) (if (equal c ?[) ?\\( (if (equal c ?]) ?\\) c))) string-to-transform))\n  )\n\n(setq org-capture-templates `(\n\t(\"p\" \"Protocol\" entry (file+headline ,(concat org-directory \"notes.org\") \"Inbox\")\n        \"* %^{Title}\\nSource: %u, %c\\n #+BEGIN_QUOTE\\n%i\\n#+END_QUOTE\\n\\n\\n%?\")\t\n\t(\"L\" \"Protocol Link\" entry (file+headline ,(concat org-directory \"notes.org\") \"Inbox\")\n        \"* %? [[%:link][%(transform-square-brackets-to-round-ones \\\"%:description\\\")]]\\n\")\n))\n```\n\n#### Example: closins the frame after a capture\n\nIf you wish to automatically close the emacs frame after a capture, add the following template:\n\n```lisp\n(\"L\" \"Protocol Link\" entry (file+headline ,(concat org-directory \"notes.org\") \"Inbox\")\n \"* %? [[%:link][%:description]] %(progn (setq kk/delete-frame-after-capture 2) \\\"\\\")\\nCaptured On: %U\"\n :empty-lines 1)\n```\n\nand in the initialization of org-mode put:\n\n```lisp\n  ;; Kill the frame if one was created for the capture\n  (defvar kk/delete-frame-after-capture 0 \"Whether to delete the last frame after the current capture\")\n\n  (defun kk/delete-frame-if-neccessary (\u0026rest r)\n    (cond\n     ((= kk/delete-frame-after-capture 0) nil)\n     ((\u003e kk/delete-frame-after-capture 1)\n      (setq kk/delete-frame-after-capture (- kk/delete-frame-after-capture 1)))\n     (t\n      (setq kk/delete-frame-after-capture 0)\n      (delete-frame))))\n\n  (advice-add 'org-capture-finalize :after 'kk/delete-frame-if-neccessary)\n  (advice-add 'org-capture-kill :after 'kk/delete-frame-if-neccessary)\n  (advice-add 'org-capture-refile :after 'kk/delete-frame-if-neccessary)\n```\n\n# Troubleshooting\n\nIs the extension not working as you expect? i.e., is it \"broken\"? You need to do some investigative\nlegwork. And if you open a ticket, provide enough information to help solve the problem!\n\nPlease describe your setup. Linux? Version. OSX? Version. Emacs? Version. org-mode? Version. Chrome? Version. How did\nyou get your system to send org-protocol links to emacs? Please provide the relevant capture templates.\n\nPlease find the simplest URL for which it fails (does it work on a simple address that contain only\nalphanumeric characters and periods? and backslashes? and query parameters? and escaped characters?\netc.). Then open the developer console and look for the debug message that the extension gives and\nadd it to the ticket.\n\nOpen a terminal and run $open \"COPIED-URL\" (do not skip the quotes, unless what you are pasting\nalready has quotes around it). $open is simply open if you are on OSX and xdg-open if on\nlinux. COPIED-URL is obviously the url you pasted here in step 1. Does it work? Congrats, you found\nwhere the problem is not (i.e. inside chrome). No? Does $open org-\"protocol://capture:/p/a/b\" work?\nNo? Again you found where the problem lies not. Otherwise proceed to step 3.\n\nCall up the line you ran in the terminal with the non-working url. it will be of the form open\n\"org-protocol://capture:/\u003cletter\u003e/PIECE1/PIECE2/ with PIECE2 usually being longer and more complex\nif you selected any text, and PIECE1 otherwise. Please edit the url until it is as short as possible\nwhile still breaking (Note, % should always be proceeded by two digits/letters in the ranges 0-9 and\nA-F so do not leave a percent sign with a single symbol following). You can probably trim one of the\npieces to be just one character. Add to the ticket the smallest breaking URL.\n\nTry sending said URL directly to emacsclient, for good measure. Does it work? Again, congrats. If\nyou are using OSX, make sure that the emacsclient which you call is the correct one!\n\n### P.S.\nIt is of course fine to ask for help with problems in your config as well.\n\n# License\nThis repository is licensed as MIT license, see the LICENSE file for details.\n\n[Org-Mode site]: http://orgmode.org/worg/org-contrib/org-protocol.html\n[Chrome App Store]: https://chrome.google.com/webstore/detail/org-capture/kkkjlfejijcjgjllecmnejhogpbcigdc\n[EmacsClient.app.zip]: https://github.com/sprig/org-capture-extension/raw/master/EmacsClient.app.zip\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprig%2Forg-capture-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsprig%2Forg-capture-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsprig%2Forg-capture-extension/lists"}