From 80a7b6fbc8274a7b82bc7cb3268498f53e58aaf4 Mon Sep 17 00:00:00 2001 From: mousebot Date: Wed, 5 Jan 2022 18:41:15 +0100 Subject: add function to play gif/video at point. uses mpv.el oops fix the mpv require statement --- lisp/mastodon-tl.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 87b8dfc..50f5c9e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -35,6 +35,8 @@ (require 'time-date) (require 'cl-lib) ; for cl-mapcar +(require 'mpv nil :no-error) + (autoload 'mastodon-auth--get-account-name "mastodon-auth") (autoload 'mastodon-http--api "mastodon-http") (autoload 'mastodon-http--get-json "mastodon-http") @@ -152,6 +154,7 @@ types of mastodon links and not just shr.el-generated ones.") (define-key map (kbd "u") 'mastodon-tl--update) ;; keep new my-profile binding; shr 'O' doesn't work here anyway (define-key map (kbd "O") 'mastodon-profile--my-profile) + (define-key map (kbd "") 'mastodon-tl--mpv-play-video-at-point) (keymap-canonicalize map)) "The keymap to be set for shr.el generated image links. @@ -839,6 +842,20 @@ a notification." (message "You voted for option %s: %s!" (car option) (cdr option))))))) +(defun mastodon-tl--mpv-play-video-at-point () + "Play the video or gif at point with an mpv process." + (interactive) + (let ((url (get-text-property (point) 'image-url)) + (type (mastodon-tl--property 'mastodon-media-type))) + (if url + (if (or (equal type "gifv") + (equal type "video")) + (progn + (message "'q' to kill mpv.") + (mpv-start "--loop" url)) + (message "no moving image here?")) + (message "no moving image here?")))) + (defun mastodon-tl--toot (toot) "Formats TOOT and insertes it into the buffer." (mastodon-tl--insert-status -- cgit v1.2.3 From 95894a80f93bfd6c2401be54bde82379ccf423bd Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Feb 2022 13:42:27 +0100 Subject: replace if call with or call in tl--media --- lisp/mastodon-tl.el | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index f7ca297..6e30853 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -713,10 +713,9 @@ message is a link which unhides/hides the main body." (let ((preview-url (alist-get 'preview_url media-attachement)) (remote-url - (if (alist-get 'remote_url media-attachement) - (alist-get 'remote_url media-attachement) - ;; fallback b/c notifications don't have remote_url - (alist-get 'url media-attachement))) + (or (alist-get 'remote_url media-attachement) + ;; fallback b/c notifications don't have remote_url + (alist-get 'url media-attachement))) (type (alist-get 'type media-attachement))) (if mastodon-tl--display-media-p (mastodon-media--get-media-link-rendering -- cgit v1.2.3 From f69f14d5bbcbec86bfce2115139980b346e7fe1b Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Feb 2022 13:44:06 +0100 Subject: display toot's media type when on author byline --- lisp/mastodon-tl.el | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6e30853..d0f1e49 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -116,6 +116,16 @@ If nil `(point-min)' is used instead.") (defvar-local mastodon-tl--timestamp-update-timer nil "The timer that, when set will scan the buffer to update the timestamps.") +(defun mastodon-tl--get-media-types (toot) + "Return a list of the media attachment types of the toot at point." + (let* (;(toot (mastodon-tl--property 'toot-json)) + (medias (or (alist-get 'media_attachments + (alist-get 'reblog toot)) + (alist-get 'media_attachments toot)))) + (mapcar (lambda (x) + (alist-get 'type x)) + medias))) + (defvar mastodon-tl--link-keymap (let ((map (make-sparse-keymap))) (define-key map [return] 'mastodon-tl--do-link-action-at-point) @@ -303,29 +313,37 @@ Optionally start from POS." (propertize (concat "@" handle) 'face 'mastodon-handle-face 'mouse-face 'highlight - ;; TODO: Replace url browsing with native profile viewing - 'mastodon-tab-stop 'user-handle + 'mastodon-tab-stop 'user-handle 'account account - 'shr-url profile-url - 'keymap mastodon-tl--link-keymap + 'shr-url profile-url + 'keymap mastodon-tl--link-keymap 'mastodon-handle (concat "@" handle) - 'help-echo (concat "Browse user profile of @" handle)) + 'help-echo (concat "Browse user profile of @" handle)) ")"))) (defun mastodon-tl--format-faves-count (toot) "Format a favorites, boosts, replies count for a TOOT. Used to help-echo when point is at the start of a byline, i.e. where `mastodon-tl--goto-next-toot' leaves point." - (let ((toot-to-count - (or - ;; simply praying this order works - (alist-get 'status toot) ; notifications timeline - (alist-get 'reblog toot) ; boosts - toot))) ; everything else - (format "%s faves | %s boosts | %s replies" - (alist-get 'favourites_count toot-to-count) - (alist-get 'reblogs_count toot-to-count) - (alist-get 'replies_count toot-to-count)))) + (let* ((toot-to-count + (or + ;; simply praying this order works + (alist-get 'status toot) ; notifications timeline + (alist-get 'reblog toot) ; boosts + toot)) ; everything else + (media-types (mastodon-tl--get-media-types toot)) + ;; (mastodon-tl--get-media-types toot) " ")) + (format-faves (format "%s faves | %s boosts | %s replies" + (alist-get 'favourites_count toot-to-count) + (alist-get 'reblogs_count toot-to-count) + (alist-get 'replies_count toot-to-count))) + (format-media (when media-types + (format " | media: %s" + (mapconcat #'identity media-types " "))))) + (format "%s" (concat format-faves format-media)))) + ;; (mapconcat #'identity (mastodon-tl--get-media-types toot) " ")))) + ;; (alist-get 'media_attachments toot-to-count))) + (defun mastodon-tl--byline-boosted (toot) "Add byline for boosted data from TOOT." -- cgit v1.2.3 From 225b36402f3e39d0833bbb8c88b54ca1d20412de Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Feb 2022 13:44:35 +0100 Subject: implement playing toot's moving image when point is on author byline - new: mpv-play-video-from-byline - new: find-first-video-in-attachments, returns first moving image attachment from the toot - edit mpv-play-video-at-point to accept args url and type - attachments type/url are now stored in attachments property of the byline - fetched with get-attachments-for-byline - keymap byline-keymap to allow playing with C-RET --- lisp/mastodon-tl.el | 58 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index d0f1e49..52f2d2f 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -175,6 +175,13 @@ types of mastodon links and not just shr.el-generated ones.") We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") +(defvar mastodon-tl--byline-link-keymap + (let ((map (make-sparse-keymap))) + (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) + (keymap-canonicalize map)) + "The keymap to be set for the author byline. +The idea is that you can play media without navigating to it.") + (defun mastodon-tl--next-tab-item () "Move to the next interesting item. @@ -305,6 +312,9 @@ Optionally start from POS." (mastodon-media--get-avatar-rendering avatar-url)) (propertize name 'face 'mastodon-display-name-face + ;; enable playing of videos when point is on byline: + 'attachments (mastodon-tl--get-attachments-for-byline toot) + 'keymap mastodon-tl--byline-link-keymap ;; echo faves count when point on post author name: ;; which is where --goto-next-toot puts point. 'help-echo @@ -344,6 +354,17 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." ;; (mapconcat #'identity (mastodon-tl--get-media-types toot) " ")))) ;; (alist-get 'media_attachments toot-to-count))) +(defun mastodon-tl--get-attachments-for-byline (toot) + (let ((media-attachments (mastodon-tl--field 'media_attachments toot))) + (mapcar + (lambda (attachement) + (let ((remote-url + (or (alist-get 'remote_url attachement) + ;; fallback b/c notifications don't have remote_url + (alist-get 'url attachement))) + (type (alist-get 'type attachement))) + `(:url ,remote-url :type ,type))) + media-attachments))) (defun mastodon-tl--byline-boosted (toot) "Add byline for boosted data from TOOT." @@ -864,11 +885,40 @@ a notification." (message "You voted for option %s: %s!" (car option) (cdr option))))))) -(defun mastodon-tl--mpv-play-video-at-point () - "Play the video or gif at point with an mpv process." +(defun mastodon-tl--find-first-video-in-attachments () + "Return the first media attachment that is a moving image." + (let ((attachments (mastodon-tl--property 'attachments)) + vids) + (mapcar (lambda (x) + (let ((att-type (plist-get x :type))) + (when (or (string= "video" att-type) + (string= "gifv" att-type)) + (push x vids)))) + attachments) + (first vids))) + +(defun mastodon-tl--mpv-play-video-from-byline () + "Run `mastodon-tl--mpv-play-video-at-point' on first moving image in post." + (interactive) + (let* ((video (mastodon-tl--find-first-video-in-attachments)) + (url (plist-get video :url)) + (type (plist-get video :type))) + (mastodon-tl--mpv-play-video-at-point url type))) + +(defun mastodon-tl--mpv-play-video-at-point (&optional url type) + "Play the video or gif at point with an mpv process. +URL and TYPE are provided when called while point is on byline, +in which case play first video or gif from current toot." (interactive) - (let ((url (get-text-property (point) 'image-url)) - (type (mastodon-tl--property 'mastodon-media-type))) + (let ((url (or + ;; point in byline: + url + ;; point in toot: + (get-text-property (point) 'image-url))) + (type (or ;; in byline: + type + ;; point in toot: + (mastodon-tl--property 'mastodon-media-type)))) (if url (if (or (equal type "gifv") (equal type "video")) -- cgit v1.2.3 From a9870b3c6256643ff9f3d049f358ef4a55d606f2 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Feb 2022 17:29:35 +0100 Subject: improve propertizing of boost/fave markers - previously, boost/fave markers behaved differently depending on whether they had just been created by the user, or if they were already existing and loaded with the timeline. in the first case, they'd not be part of the byline, in the second they would be. we make it that they not part of the byline, so `mastodon-tl--goto-next-toot', which works according to text properties, should always put point after them, on the author-byline. this also means that we can add help-echos and actions to the author byline without having to worry about also adding them to the boost/fave markers. fix call to format-faved-or-boosted-byline --- lisp/mastodon-tl.el | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 52f2d2f..4b746d7 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -342,7 +342,6 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." (alist-get 'reblog toot) ; boosts toot)) ; everything else (media-types (mastodon-tl--get-media-types toot)) - ;; (mastodon-tl--get-media-types toot) " ")) (format-faves (format "%s faves | %s boosts | %s replies" (alist-get 'favourites_count toot-to-count) (alist-get 'reblogs_count toot-to-count) @@ -351,8 +350,6 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." (format " | media: %s" (mapconcat #'identity media-types " "))))) (format "%s" (concat format-faves format-media)))) - ;; (mapconcat #'identity (mastodon-tl--get-media-types toot) " ")))) - ;; (alist-get 'media_attachments toot-to-count))) (defun mastodon-tl--get-attachments-for-byline (toot) (let ((media-attachments (mastodon-tl--field 'media_attachments toot))) @@ -461,20 +458,19 @@ By default it is `mastodon-tl--byline-boosted'" (boosted (equal 't (mastodon-tl--field 'reblogged toot))) (visibility (mastodon-tl--field 'visibility toot))) (concat - ;; (propertize "\n | " 'face 'default) - (propertize + ;; Boosted/favourited markers are not part of the byline, so we don't + ;; propertize them with 'byline t', as per the rest. This ensures that + ;; `mastodon-tl--goto-next-toot' puts point on author-byline not on the + ;; (F) or (B) marker. Not propertizing like this makes the behaviour of + ;; these markers consistent whether they are displayed for an already + ;; boosted/favourited toot or the result of the toot having just been + ;; favourited/boosted. (concat (when boosted - (format - (propertize "(%s) " - 'help-echo - (mastodon-tl--format-faves-count toot)) - (propertize "B" 'face 'mastodon-boost-fave-face))) + (mastodon-tl--format-faved-or-boosted-byline "B")) (when faved - (format - (propertize "(%s) " - 'help-echo - (mastodon-tl--format-faves-count toot)) - (propertize "F" 'face 'mastodon-boost-fave-face))) + (mastodon-tl--format-faved-or-boosted-byline "F"))) + (propertize + (concat ;; we propertize help-echo format faves for author name ;; in `mastodon-tl--byline-author' (funcall author-byline toot) @@ -501,6 +497,12 @@ By default it is `mastodon-tl--byline-boosted'" 'boosted-p boosted 'byline t)))) +(defun mastodon-tl--format-faved-or-boosted-byline (letter) + "Format the byline marker for a boosted or favorited status. +LETTER is a string, either F or B." + (format "(%s) " + (propertize letter 'face 'mastodon-boost-fave-face))) + (defun mastodon-tl--render-text (string toot) "Return a propertized text rendering the given HTML string STRING. -- cgit v1.2.3 From c48fb21e9b149eeac3ac96c070714eab2ee6f924 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 11 Feb 2022 18:28:09 +0100 Subject: autoloads and docstrings --- lisp/mastodon-tl.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4b746d7..3b3b692 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -63,6 +63,8 @@ (autoload 'mastodon-notifications--get "mastodon-notifications" "Display NOTIFICATIONS in buffer." t) ; interactive (autoload 'mastodon-search--insert-users-propertized "mastodon-search") +(when (require 'mpv nil :no-error) + (declare-function mpv-start "mpv")) (defvar mastodon-instance-url) (defvar mastodon-toot-timestamp-format) (defvar shr-use-fonts) ;; declare it since Emacs24 didn't have this @@ -117,7 +119,7 @@ If nil `(point-min)' is used instead.") "The timer that, when set will scan the buffer to update the timestamps.") (defun mastodon-tl--get-media-types (toot) - "Return a list of the media attachment types of the toot at point." + "Return a list of the media attachment types of the TOOT at point." (let* (;(toot (mastodon-tl--property 'toot-json)) (medias (or (alist-get 'media_attachments (alist-get 'reblog toot)) @@ -352,6 +354,7 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." (format "%s" (concat format-faves format-media)))) (defun mastodon-tl--get-attachments-for-byline (toot) + "Return a list of attachment URLs and types for TOOT." (let ((media-attachments (mastodon-tl--field 'media_attachments toot))) (mapcar (lambda (attachement) @@ -891,13 +894,13 @@ a notification." "Return the first media attachment that is a moving image." (let ((attachments (mastodon-tl--property 'attachments)) vids) - (mapcar (lambda (x) + (mapc (lambda (x) (let ((att-type (plist-get x :type))) (when (or (string= "video" att-type) (string= "gifv" att-type)) (push x vids)))) attachments) - (first vids))) + (car vids))) (defun mastodon-tl--mpv-play-video-from-byline () "Run `mastodon-tl--mpv-play-video-at-point' on first moving image in post." -- cgit v1.2.3 From 449929b5734e34aaca226fe1475fd59a10023535 Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 12 Feb 2022 10:53:58 +0100 Subject: add c-ret binding to author-byline help echo --- lisp/mastodon-tl.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3b3b692..cfab15d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -120,8 +120,7 @@ If nil `(point-min)' is used instead.") (defun mastodon-tl--get-media-types (toot) "Return a list of the media attachment types of the TOOT at point." - (let* (;(toot (mastodon-tl--property 'toot-json)) - (medias (or (alist-get 'media_attachments + (let* ((medias (or (alist-get 'media_attachments (alist-get 'reblog toot)) (alist-get 'media_attachments toot)))) (mapcar (lambda (x) @@ -350,8 +349,12 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." (alist-get 'replies_count toot-to-count))) (format-media (when media-types (format " | media: %s" - (mapconcat #'identity media-types " "))))) - (format "%s" (concat format-faves format-media)))) + (mapconcat #'identity media-types " ")))) + (format-media-binding (when (or + (member "video" media-types) + (member "gifv" media-types)) + (format " | C-RET to view with mpv")))) + (format "%s" (concat format-faves format-media format-media-binding)))) (defun mastodon-tl--get-attachments-for-byline (toot) "Return a list of attachment URLs and types for TOOT." -- cgit v1.2.3 From 581cfb870d85324b63e8edaf17a90c0b5c6a9b63 Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 12 Feb 2022 11:25:39 +0100 Subject: move get-media-types / docstrings. we have to use mastodon-tl--field for the media types. we can't use mastodon-tl--property, as the 'attachments property for the toot doesn't exist yet when we are looking. --- lisp/mastodon-tl.el | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index cfab15d..66b8baa 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -118,15 +118,6 @@ If nil `(point-min)' is used instead.") (defvar-local mastodon-tl--timestamp-update-timer nil "The timer that, when set will scan the buffer to update the timestamps.") -(defun mastodon-tl--get-media-types (toot) - "Return a list of the media attachment types of the TOOT at point." - (let* ((medias (or (alist-get 'media_attachments - (alist-get 'reblog toot)) - (alist-get 'media_attachments toot)))) - (mapcar (lambda (x) - (alist-get 'type x)) - medias))) - (defvar mastodon-tl--link-keymap (let ((map (make-sparse-keymap))) (define-key map [return] 'mastodon-tl--do-link-action-at-point) @@ -334,8 +325,10 @@ Optionally start from POS." (defun mastodon-tl--format-faves-count (toot) "Format a favorites, boosts, replies count for a TOOT. -Used to help-echo when point is at the start of a byline, -i.e. where `mastodon-tl--goto-next-toot' leaves point." +Used to help-echo when point is at the start of a byline, i.e. +where `mastodon-tl--goto-next-toot' leaves point. Also displays a +toot's media types and optionally the binding to play moving +image media from the byline." (let* ((toot-to-count (or ;; simply praying this order works @@ -356,8 +349,18 @@ i.e. where `mastodon-tl--goto-next-toot' leaves point." (format " | C-RET to view with mpv")))) (format "%s" (concat format-faves format-media format-media-binding)))) +(defun mastodon-tl--get-media-types (toot) + "Return a list of the media attachment types of the TOOT at point." + (let* ((attachments (or (alist-get 'media_attachments + (alist-get 'reblog toot)) + (alist-get 'media_attachments toot)))) + (mapcar (lambda (x) + (alist-get 'type x)) + medias))) + (defun mastodon-tl--get-attachments-for-byline (toot) - "Return a list of attachment URLs and types for TOOT." + "Return a list of attachment URLs and types for TOOT. +The result is added as an attachments property to author-byline." (let ((media-attachments (mastodon-tl--field 'media_attachments toot))) (mapcar (lambda (attachement) -- cgit v1.2.3 From 0b48cd4b41009d229c3f626e365d670c93ff662c Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 12 Feb 2022 11:37:07 +0100 Subject: use tl--field to get media attachments info --- lisp/mastodon-tl.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 66b8baa..c1b0b51 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -351,12 +351,10 @@ image media from the byline." (defun mastodon-tl--get-media-types (toot) "Return a list of the media attachment types of the TOOT at point." - (let* ((attachments (or (alist-get 'media_attachments - (alist-get 'reblog toot)) - (alist-get 'media_attachments toot)))) + (let* ((attachments (mastodon-tl--field 'media_attachments toot))) (mapcar (lambda (x) (alist-get 'type x)) - medias))) + attachments))) (defun mastodon-tl--get-attachments-for-byline (toot) "Return a list of attachment URLs and types for TOOT. -- cgit v1.2.3 From e917b98166c001ba91c596574f869c50f65b6f1d Mon Sep 17 00:00:00 2001 From: mousebot Date: Sun, 13 Feb 2022 12:57:47 +0100 Subject: docstrings/comments cleanup --- lisp/mastodon-tl.el | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4687385..a1ffb40 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -325,7 +325,7 @@ Optionally start from POS." (defun mastodon-tl--format-faves-count (toot) "Format a favorites, boosts, replies count for a TOOT. -Used to help-echo when point is at the start of a byline, i.e. +Used as a help-echo when point is at the start of a byline, i.e. where `mastodon-tl--goto-next-toot' leaves point. Also displays a toot's media types and optionally the binding to play moving image media from the byline." @@ -455,9 +455,9 @@ TIME-STAMP is assumed to be in the past." (defun mastodon-tl--byline (toot author-byline action-byline) "Generate byline for TOOT. -AUTHOR-BYLINE is function for adding the author portion of +AUTHOR-BYLINE is a function for adding the author portion of the byline that takes one variable. -ACTION-BYLINE is a function for adding an action, such as boosting +ACTION-BYLINE is a function for adding an action, such as boosting, favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'" (let ((parsed-time (date-to-time (mastodon-tl--field 'created_at toot))) @@ -465,13 +465,13 @@ By default it is `mastodon-tl--byline-boosted'" (boosted (equal 't (mastodon-tl--field 'reblogged toot))) (visibility (mastodon-tl--field 'visibility toot))) (concat - ;; Boosted/favourited markers are not part of the byline, so we don't - ;; propertize them with 'byline t', as per the rest. This ensures that - ;; `mastodon-tl--goto-next-toot' puts point on author-byline not on the - ;; (F) or (B) marker. Not propertizing like this makes the behaviour of - ;; these markers consistent whether they are displayed for an already - ;; boosted/favourited toot or the result of the toot having just been - ;; favourited/boosted. + ;; Boosted/favourited markers are not technically part of the byline, so + ;; we don't propertize them with 'byline t', as per the rest. This + ;; ensures that `mastodon-tl--goto-next-toot' puts point on + ;; author-byline, not before the (F) or (B) marker. Not propertizing like + ;; this makes the behaviour of these markers consistent whether they are + ;; displayed for an already boosted/favourited toot or as the result of + ;; the toot having just been favourited/boosted. (concat (when boosted (mastodon-tl--format-faved-or-boosted-byline "B")) (when faved -- cgit v1.2.3 From 122eedfad6805add3c19950729e9d877c78fe1de Mon Sep 17 00:00:00 2001 From: mousebot Date: Sun, 13 Feb 2022 14:39:31 +0100 Subject: make mpv an optional dependency - keymap / help-echo are conditional on mpv being installed. - maybe mpv (and company, emojify, etc.) should become hard dependencies... --- lisp/mastodon-tl.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index a1ffb40..e33aadf 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -168,10 +168,11 @@ We need to override the keymap so tabbing will navigate to all types of mastodon links and not just shr.el-generated ones.") (defvar mastodon-tl--byline-link-keymap - (let ((map (make-sparse-keymap))) - (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) - (keymap-canonicalize map)) - "The keymap to be set for the author byline. + (when (require 'mpv nil :no-error) + (let ((map (make-sparse-keymap))) + (define-key map (kbd "") 'mastodon-tl--mpv-play-video-from-byline) + (keymap-canonicalize map))) + "The keymap to be set for the author byline. The idea is that you can play media without navigating to it.") (defun mastodon-tl--next-tab-item () @@ -343,9 +344,10 @@ image media from the byline." (format-media (when media-types (format " | media: %s" (mapconcat #'identity media-types " ")))) - (format-media-binding (when (or - (member "video" media-types) - (member "gifv" media-types)) + (format-media-binding (when (and (or + (member "video" media-types) + (member "gifv" media-types)) + (require 'mpv nil :no-error)) (format " | C-RET to view with mpv")))) (format "%s" (concat format-faves format-media format-media-binding)))) -- cgit v1.2.3