The Complete Computing Environment

Mastodon in Emacs


Let's see if this doesn't annoy me. I'm not huge excited about any Mastodon client though.

(use-package request)
(use-package mastodon
  (require 'mastodon-async)
  (mastodon-mode . visual-line-mode)
  (mastodon-tl--show-avatars t)
  (mastodon-instance-url "")
  (mastodon-active-user "rrix"))
(provide 'cce/mastodon)

here's a package override for my Emacs home-manager installation which uses a more-up-to-date fork:

mastodon = epkgs.melpaPackages.mastodon.overrideAttrs(old: {
  src = pkgs.callPackage pkgs.lib.pkgVersions.mastodon {};
  propagatedBuildInputs = old.buildInputs ++ [epkgs.request epkgs.persist];

List Timelines in Mastodon.el

This uses the Mastodon.el API to fetch the lists, select one, and display it in a buffer.

(defun mastodon-tl--show-list-timeline (&optional list-name)
  (let* ((options
          (cl-mapcar (lambda (car)
                       (cons (alist-get 'title car)
                             (alist-get 'id car)))
                     (mastodon-http--get-json (mastodon-http--api (format "lists")))))
         (chosen-name (or list-name
                           "Which list?"
                           (cl-mapcar #'car options))))
         (chosen-id (alist-get chosen-name options nil nil #'equal)))
     (concat "list-" chosen-name) (concat "timelines/list/" chosen-id) 'mastodon-tl--timeline)))

Configure an Mastodon.el frame

And this configures a frame with my favorite buffers; i wish there was a cleaner way to do this, but alas. I have some scriplets in Emacs Helper Scripts to invoke this from KRunner/WM.

(defun cce/my-mastodon.el-buffers ()
  (mastodon-tl--show-list-timeline "folks")
  (mastodon-tl--show-list-timeline "neatbots")
  (mastodon-tl--show-list-timeline "Guppies")
  (mastodon-tl--show-tag-timeline "emacs")
  (mastodon-tl--show-tag-timeline "orgmode")
  (mastodon-tl--show-tag-timeline "gunpla")

  (sit-for 5)

(defun cce/setup-mastodon-buffers ()

  (let ((actions                        ; list of buffer names
        (display-buffer-alist '(("\*mastodon.*" (display-buffer-same-window)))))
    (dotimes (i (- (length actions) 1))
    (dolist (buffer actions)
      (display-buffer buffer)
      (other-window 1))))

NEXT upstream this.