Org-protocol command

(define-command-global org-capture ()
  (let* ((url (quri:url-encode (buffer-url)))
         (title (quri:url-encode (buffer-title)))
         (body (quri:url-encode (%copy)))
         (org-protocol-uri
          (format nil
           "'org-protocol://capture?template=w&url=~a&title=~a&body=~a'"
           url title body)))
    (format *error-output* "Sending to Emacs:~%~a~%" org-protocol-uri)
    (uiop:run-program
     (list "timeout" "--signal=9" "5m" "emacsclient"
           org-protocol-uri))))

;; For most users, (list "emacsclient" org-protocol-uri) may be adequate.

;; Helper functions

(defun buffer-url ()
  "Returns the URL of the current buffer."
  (quri:render-uri (url (current-buffer))))

(defun buffer-title ()
  "Returns the title of the current buffer."
  (title (current-buffer)))

2 Likes