capture
capture copied to clipboard
emacs org-mode protocol handler for macOS
-
Capture [[./Capture.png]] ** Objective
Capture is another wrapper to use org-protocol an a MacOs machine. There are plenty already existing and depending on the Emacs port org-protocol support ist often built in.
[[./screenshot.png]]
Capture does create only a small Emacs frame, so most of the current context is still visisble to the user whilst capturing. For this all existing Emacs frame should be minimised to the Dock.
** Usage
*** Installation
As usual the application must be present in the Application
Folder. Additionally the user is asked to allow Capture to call System
Events by AppleScript. This is necessary because the Focus should be on
calling application after capture.
*** Browserscript
**** Using capture To use Capture to capture a link to the current page #+BEGIN_SRC js javascript:location.href='capture://capture?template=l &url='+encodeURIComponent(window.location.href)+' &title='+encodeURIComponent(document.title)+' &body='+encodeURIComponent(window.getSelection())+'; #+END_SRC
To use e.g. Homebrew's Emacs' ~org-protocol~ directly:
**** Using org-protocol
#+BEGIN_SRC js
javascript:location.href='org-protocol://capture?template=l
&url='+encodeURIComponent(window.location.href)+'
&title='+encodeURIComponent(document.title)+'
&body='+encodeURIComponent(window.getSelection())';
#+END_SRC
*** Additional emacs config
**** Make capture window disappear when done #+BEGIN_SRC emacs-lisp ;;; ;; Capture floating frame ;; ;; taken from: http://www.windley.com/archives/2010/12/capture_mode_and_emacs.shtml ;;;
(defadvice org-capture-finalize (after delete-capture-frame activate) "Advise capture-finalize to close the frame" (if (equal "capture" (frame-parameter nil 'title)) (delete-frame)))
(defadvice org-capture-destroy (after delete-capture-frame activate) "Advise capture-destroy to close the frame" (if (equal "capture" (frame-parameter nil 'title) (delete-frame))))
;; make the frame contain a single window. by default org-capture ;; splits the window. (add-hook 'org-capture-mode-hook 'delete-other-windows)
(defadvice org-switch-to-buffer-other-window (after supress-window-splitting activate) "Delete the extra window if we're in a capture frame" (if (equal "capture" (frame-parameter nil 'title)) (delete-other-windows))) #+END_SRC
#+RESULTS:
: org-switch-to-buffer-other-window
** The Unicorn
The Unicorn is courtesy of [[https://pixabay.com/de/users/lohrelei-1422286/][Lohrelei]]