reddit / emacs

Fastest way to take a quick note on MacOS or Windows?

Status-Detective-783 · 2022-02-20 18:08
Suppose I'm browsing in Chrome. I want to take a quick org-capture note. But I don't want to have to `⌘-TAB` (or `ALT-TAB` in Windows) over to emacs and then `C-c c` to org-capture. That takes too much time and breaks my flow. I just want to press some magic MacOS (or Windows) key that will automagically switch me to emacs AND do the org-capture command. Bonus points if doing the above can also automatically carry over the URL that I'm currently on. I assume I'd need to use some kind of "macro" software.
radicalzephyr · 2022-02-20 19:17
This is more of a MacOS question than an emacs one because you want to automate the interactive with the OS. But you may want to look into [Automater](https://macosxautomation.com/automator/index.html) or [AppleScript](https://macosxautomation.com/applescript/index.html).
orissus · 2022-02-20 20:23
Hammerspoon for automation, uses Lua script, pretty easy to add own functions. And Karabiner to bind CAPS as metas key. So when I want to capture to Org mode I invoke Caps+V and am greeted with hammerspoon prompt. It runs she’ll script that append to a file ( can be simple bash with >> or emacs capture). -edit autocorrect typos.
trae · 2022-02-21 03:13
Similar to what I do. SUPER-F toggles an external org-capture window, so I never have to switch to emacs. SUPER-K captures the frontmost Safari window title & url to Inbox. Edit: The super key is driven by Karabiner. It's bound to Shift-Option-Control-Command OR my Cap lock key.
NihilistDandy · 2022-02-21 07:17
You probably want `org-protocol`. https://github.com/xuchunyang/setup-org-protocol-on-mac https://orgmode.org/worg/org-contrib/org-protocol.html I have a bookmarklet that captures links of interest to my inbox for review later; my template includes the link, the page title, and any text I have selected on capture.
BobKoss · 2022-02-21 15:42
[https://github.com/kuanyui/copy-as-org-mode](https://github.com/kuanyui/copy-as-org-mode) just ran across this this morning. Haven’t tried it yet.
Status-Detective-783 · 2022-02-21 16:40
Thanks! Evidently, that's for Mozilla (Firefox).
fragbot2 · 2022-02-22 06:27
I'm glad someone responded with org-protocol. I've set it up several times on various OSX machines. I had some good notes on it but the external application link is dead so I'll need to do it from memory. First, I created a script using Apple's script editor: on open location my_data do shell script "/usr/local/bin/emacsclient --no-wait '" & my_data & "'" end open location I'm pretty sure that after doing this I either created or edited the Info.plist file associated with the script: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleIdentifier</key> <string>com.apple.ScriptEditor.id.OrgProtocol</string> <key>CFBundleName</key> <string>OrgProtocol</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>WindowState</key> <dict> <key>bundleDividerCollapsed</key> <true/> <key>bundlePositionOfDivider</key> <real>0.0</real> <key>dividerCollapsed</key> <false/> <key>eventLogLevel</key> <integer>2</integer> <key>name</key> <string>ScriptWindowState</string> <key>positionOfDivider</key> <real>443</real> <key>savedFrame</key> <string>1167 349 700 678 0 0 1920 1055 </string> <key>selectedTab</key> <string>description</string> </dict> <key>CFBundleURLTypes</key> <string>org-protocol</string> <array> <dict> <key>CFBundleURLName</key> <string>org-protocol</string> <key>CFBundleURLSchemes</key> <array> <string>org-protocol</string> </array> </dict> </array> </dict> </plist> I then created two bookmarks--one that grabs links and the other that grabs a link + data: javascript:location.href='org-protocol://store-link?url=%27+encodeURIComponent(location.href)+%27&title=%27+encodeURIComponent(document.title) javascript:location.href='org-protocol://capture?template=c%27+%27&url=%27+encodeURIComponent(window.location.href)+%27&title=%27+encodeURIComponent(document.title)+%27&body=%27+encodeURIComponent(window.getSelection()); While it's tricky to setup the first time, it works really well.