There is a lot of useful information flying around in Mastodon. Some of it I would like to archive in my text-based database (i.e. org-roam). To access Mastodon inside Emacs I use mastodon.el. This little hack copies an org-ified version of the “toot” at point in the mastodon.el timeline to the clipboard. It uses the URL of said toot to pull it’s title from the web (via org-web-tools) and creates an org-link as the heading/context for the toot. The content of the toot is then pasted between #+begin_quote and #+end_quote. I also added a keybinding (“j”) for this to work inside mastodon.el.
Caveats: For boosted toots you need to focus on the original toot first (via “T”). Line breaks are still a bit of a mess.
(defun lt/mastodon-toot--copy-orgified-toot-to-clipboard () "Copy org-ified toot at point to clipboard." (interactive) (let* ((toot (mastodon-tl--property 'toot-json))) (when toot (let* ((url (alist-get 'url toot)) (content (mastodon-tl--content toot)) (html (org-web-tools--get-url url)) (title (org-web-tools--html-title html)) (complete-toot (concat "\[\[" url "\]\[" title "\]\]\n\n" "#+begin_quote\n" content "\n#+end_quote\n\n"))) (kill-new complete-toot) (message "Copied: '%s' to the clipboard." title))))) (define-key mastodon-mode-map (kbd "j") 'lt/mastodon-toot--copy-orgified-toot-to-clipboard)
Update 2023_02_04: I played around with this setup and decided to directly paste the toot into an org-journal entry. The following code will add that functionality to the keybinding “J” (when in Mastodon.el).
(defun lt/mastodon-toot--copy-orgified-toot-to-org-journal () "Copy org-ified toot at point to org-journal." (interactive) (lt/mastodon-toot--copy-orgified-toot-to-clipboard) (org-journal-new-entry nil) (org-yank)) (define-key mastodon-mode-map (kbd "J") 'lt/mastodon-toot--copy-orgified-toot-to-org-journal)
Btw: If you replace
(org-journal-new-entry nil) in the second snipped with
(org-capture nil "xyz") (whereby xyz stands for a template key) this should also work with org-capture.