```lisp (defun get-org-templates () (read-from-string (uiop:run-program (list "timeout" "--signal=9" "5m" "emacsclient" "--eval" "org-capture-templates") :output :string))) (defun template-description (template) (make-instance 'prompter:suggestion :value (first template) :attributes `(("Key" ,(first template)) ("Description" ,(second template)) ("Template" ,(car (last template)))))) (defun make-org-template-source () "Create a prompt source based on the currently running emacs's org-templates" (make-instance 'prompter:source :name "Emacs Capture Templates" :constructor (mapcar #'template-description ;; Ensure that we are not listing prefix keys ;; e.g. m in the me (remove-if-not #'cddr (get-org-templates))))) (define-command-global org-capture (&optional (buffer (nyxt:current-buffer))) "Call org-protocol whith the type of capture using the BUFFER for context." (org-protocol "capture" buffer)) (define-command-global org-protocol (&optional (protocol "store-link") (buffer (nyxt:current-buffer))) "Using the supported org-protocol type PROTOCOL execute it against the given BUFFER's current url." (let ((url (render-url (nyxt:url buffer))) (title (title buffer)) (body (quri:url-encode (%copy))) (protocol-str (format nil "org-protocol://~a?" protocol)) (capture-template (when (equal protocol "capture") (format nil "template=~a&" (first (prompt :prompt "Select a capture template" :sources (list (make-org-template-source)))))))) (uiop:launch-program (list "emacsclient" ;; nyxt:*open-program* would also be an alternative (str:concat protocol-str capture-template (format nil "url=~a&title=~a&body=~a" url title body)))))) ```