fix(emacs): mastodon timeline transient

This commit is contained in:
Pavel Korytov 2023-07-28 14:25:39 +03:00
parent eac134c545
commit ab0d01c525
2 changed files with 11 additions and 10 deletions

View file

@ -5885,7 +5885,7 @@ ENTRY is an instance of `elfeed-entry'."
(remove-hook 'kill-emacs-hook #'my/mastodon-mode-line-persist-meta) (remove-hook 'kill-emacs-hook #'my/mastodon-mode-line-persist-meta)
(my/mastodon-mode-line-persist-meta))))) (my/mastodon-mode-line-persist-meta)))))
(defun my/mastodon-get-update-funciton (hide-boosts hide-replies) (defun my/mastodon-get-update-funciton (hide-replies hide-boosts)
(lambda (toots) (lambda (toots)
(let* ((is-profile (eq (mastodon-tl--get-buffer-type) 'profile-statuses)) (let* ((is-profile (eq (mastodon-tl--get-buffer-type) 'profile-statuses))
(hide-replies (and (not is-profile) hide-replies)) (hide-replies (and (not is-profile) hide-replies))
@ -5899,9 +5899,6 @@ ENTRY is an instance of `elfeed-entry'."
(or (not hide-boosts) (or (not hide-boosts)
(not (alist-get 'reblog toot))))) (not (alist-get 'reblog toot)))))
toots))) toots)))
(message "Hide replies: %s" hide-replies)
(message "Hide boosts: %s" hide-boosts)
(message "Buffer: %s" (buffer-name))
(mapc #'mastodon-tl--toot toots)))) (mapc #'mastodon-tl--toot toots))))
(defun my/mastodon-tl--get-home (hide-replies hide-boosts) (defun my/mastodon-tl--get-home (hide-replies hide-boosts)

View file

@ -8084,12 +8084,12 @@ Send =/detach= to all servers. Kinda strange that there's no such function alrea
#+end_src #+end_src
*** Mastodon *** Mastodon
Mastodon is a decentralized social media network. I use an instance called [[https://emacs.ch/][emacs.ch]] Mastodon is a decentralized social media network. I use an instance called [[https://emacs.ch/][emacs.ch]].
**** Package configuration **** Package configuration
[[https://codeberg.org/martianh/mastodon.el][mastodon.el]] is an Emacs client for Mastodon. [[https://codeberg.org/martianh/mastodon.el][mastodon.el]] is an Emacs client for Mastodon.
The default UI is a bit rough, but Nicolas Rougier's [[https://github.com/rougier/mastodon-alt][mastodon-alt]] package makes things a bit more how I would like to see them. The default UI is rather rough, but Nicolas Rougier's [[https://github.com/rougier/mastodon-alt][mastodon-alt]] package makes things a bit more how I would like to see them.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package mastodon (use-package mastodon
@ -8168,6 +8168,8 @@ The package also doesn't have evil bindings. I implement a few basic bindings he
**** Modeline segment **** Modeline segment
This is my attempt to make a modeline indicator for new mastodon notifications. This is my attempt to make a modeline indicator for new mastodon notifications.
Edit [2023-07-28 Fri]: I'll probably remove that, don't feel like it's actually useful.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar my/mastodon-mode-string "") (defvar my/mastodon-mode-string "")
@ -8260,8 +8262,11 @@ This is my attempt to make a modeline indicator for new mastodon notifications.
(my/mastodon-mode-line-persist-meta))))) (my/mastodon-mode-line-persist-meta)))))
#+end_src #+end_src
**** Timeline Transient **** Timeline Transient
The default =mastodon-tl--get-home-timeline= allows only to hide replies, and not boosted posts.
So here's a custom update function:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun my/mastodon-get-update-funciton (hide-boosts hide-replies) (defun my/mastodon-get-update-funciton (hide-replies hide-boosts)
(lambda (toots) (lambda (toots)
(let* ((is-profile (eq (mastodon-tl--get-buffer-type) 'profile-statuses)) (let* ((is-profile (eq (mastodon-tl--get-buffer-type) 'profile-statuses))
(hide-replies (and (not is-profile) hide-replies)) (hide-replies (and (not is-profile) hide-replies))
@ -8275,12 +8280,10 @@ This is my attempt to make a modeline indicator for new mastodon notifications.
(or (not hide-boosts) (or (not hide-boosts)
(not (alist-get 'reblog toot))))) (not (alist-get 'reblog toot)))))
toots))) toots)))
(message "Hide replies: %s" hide-replies)
(message "Hide boosts: %s" hide-boosts)
(message "Buffer: %s" (buffer-name))
(mapc #'mastodon-tl--toot toots)))) (mapc #'mastodon-tl--toot toots))))
#+end_src #+end_src
In order to use it, the function has to be passed to =mastodon-tl--init=:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defun my/mastodon-tl--get-home (hide-replies hide-boosts) (defun my/mastodon-tl--get-home (hide-replies hide-boosts)
(mastodon-tl--init (mastodon-tl--init
@ -8292,6 +8295,7 @@ This is my attempt to make a modeline indicator for new mastodon notifications.
nil)) nil))
#+end_src #+end_src
And a transient to use it.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(with-eval-after-load 'mastodon (with-eval-after-load 'mastodon
(require 'transient) (require 'transient)