From ddb5b07e1e43c7b44877bae9d786dbb80ca95311 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 17 Jan 2025 09:48:03 +1100 Subject: [emacs] Adding buttons to infobox --- emacs/.emacs.d/lisp/my/my-ytdl.el | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'emacs/.emacs.d/lisp/my/my-ytdl.el') diff --git a/emacs/.emacs.d/lisp/my/my-ytdl.el b/emacs/.emacs.d/lisp/my/my-ytdl.el index 2811793..bf917ce 100644 --- a/emacs/.emacs.d/lisp/my/my-ytdl.el +++ b/emacs/.emacs.d/lisp/my/my-ytdl.el @@ -94,14 +94,25 @@ (string-match-p "^/watch\\?v=.*" (url-filename urlobj))) (equal "youtu.be" (url-host urlobj))))) +(require 'hmm) +(defvar my-ytdl-player 'hmm-external-mpv "Function to play ytdl urls.") + +(defun my-ytdl-video-render-info (info url) + (setf (alist-get 'webpage_url info) + (concat (alist-get 'webpage_url info) + " -- " (buttonize "play" (lambda (_) + (funcall my-ytdl-player url))) + " " (buttonize "context" + (lambda (_) + (funcall my-url-context-function url))))) + (infobox-render + (infobox-translate info (infobox-default-specs info)) + `(my-ytdl-video-infobox ,url) + (called-interactively-p 'interactive))) + (defun my-ytdl-video-infobox (url) (interactive "sytdl video url: ") - (let* ((info (my-ytdl-video-info url)) - (specs (infobox-default-specs info))) - (infobox-render - (infobox-translate info specs) - `(my-ytdl-video-infobox ,url) - (called-interactively-p 'interactive)))) + (my-ytdl-video-render-info (my-ytdl-video-info url) url)) ;;; fixme: autoload (defun my-ytdl-video (urls) -- cgit v1.2.3