110 lines
3.6 KiB
Org Mode
110 lines
3.6 KiB
Org Mode
:PROPERTIES:
|
|
:ID: mastodon_in_emacs
|
|
:END:
|
|
#+TITLE: Mastodon in Emacs
|
|
#+filetags: :Project:Emacs:CCE:Communication:
|
|
#+PROPERTY: header-args :mkdirp yes :results none
|
|
#+AUTO_TANGLE: t
|
|
|
|
#+ARCOLOGY_KEY: cce/mastodon-in-emacs
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
#+ARROYO_MODULE_WANTS: cce/configure_packaging.org
|
|
#+ARROYO_EMACS_MODULE: mastodon
|
|
|
|
Let's see if this doesn't annoy me. I'm not huge excited about any Mastodon client though.
|
|
|
|
#+begin_src emacs-lisp :tangle cce/mastodon.el :noweb yes
|
|
(use-package request)
|
|
(use-package mastodon
|
|
:config
|
|
(require 'mastodon-async)
|
|
<<list-timelines>>
|
|
<<setup-frame>>
|
|
:hook
|
|
(mastodon-mode . visual-line-mode)
|
|
:custom
|
|
(mastodon-tl--show-avatars t)
|
|
(mastodon-instance-url "https://tenforward.social")
|
|
(mastodon-active-user "rrix"))
|
|
(provide 'cce/mastodon)
|
|
#+end_src
|
|
|
|
here's a package override for my [[id:cce/emacs][Emacs]] home-manager installation which uses a more-up-to-date fork:
|
|
|
|
#+ARROYO_HOME_EPKGS: overrides/mastodon.nix
|
|
#+begin_src nix :tangle ~/arroyo-nix/overrides/mastodon.nix
|
|
mastodon = epkgs.melpaPackages.mastodon.overrideAttrs(old: {
|
|
src = pkgs.callPackage pkgs.lib.pkgVersions.mastodon {};
|
|
propagatedBuildInputs = old.buildInputs ++ [epkgs.request epkgs.persist];
|
|
});
|
|
#+end_src
|
|
|
|
* List Timelines in Mastodon.el
|
|
:PROPERTIES:
|
|
:ID: 20220723T193839.847353
|
|
:END:
|
|
|
|
This uses the Mastodon.el API to fetch the lists, select one, and display it in a buffer.
|
|
|
|
#+begin_src emacs-lisp :noweb-ref list-timelines
|
|
(defun mastodon-tl--show-list-timeline (&optional list-name)
|
|
(interactive)
|
|
(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
|
|
(completing-read
|
|
"Which list?"
|
|
(cl-mapcar #'car options))))
|
|
(chosen-id (alist-get chosen-name options nil nil #'equal)))
|
|
(mastodon-tl--init
|
|
(concat "list-" chosen-name) (concat "timelines/list/" chosen-id) 'mastodon-tl--timeline)))
|
|
#+end_src
|
|
|
|
* 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 [[id:20220723T195008.486029][Emacs Helper Scripts]] to invoke this from KRunner/WM.
|
|
|
|
#+begin_src emacs-lisp :noweb-ref setup-frame
|
|
(defun cce/my-mastodon.el-buffers ()
|
|
(interactive)
|
|
(mastodon-tl--show-list-timeline "folks")
|
|
(mastodon-notifications--get)
|
|
(mastodon-tl--get-home-timeline)
|
|
(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)
|
|
(cce/setup-mastodon-buffers))
|
|
|
|
|
|
(defun cce/setup-mastodon-buffers ()
|
|
(interactive)
|
|
(delete-other-windows)
|
|
|
|
(let ((actions ; list of buffer names
|
|
'("*mastodon-notifications*"
|
|
"*mastodon-list-folks*"
|
|
"*mastodon-home*"
|
|
"*mastodon-list-neatbots*"
|
|
"*mastodon-list-Guppies*"
|
|
"*mastodon-tag-orgmode*"
|
|
"*mastodon-tag-emacs*"
|
|
"*mastodon-tag-gunpla*"))
|
|
(display-buffer-alist '(("\*mastodon.*" (display-buffer-same-window)))))
|
|
(dotimes (i (- (length actions) 1))
|
|
(split-window-right)
|
|
(balance-windows))
|
|
(dolist (buffer actions)
|
|
(display-buffer buffer)
|
|
(other-window 1))))
|
|
#+end_src
|
|
|
|
** NEXT upstream this.
|