diff options
author | Thanos Apollo <[email protected]> | 2023-07-01 08:55:24 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2023-07-01 08:55:24 +0300 |
commit | 371db30c10157d649a4e59ff5747b27500c87590 (patch) | |
tree | e557f5107c59bcc4c0a09ceadc32c69eff641f9c | |
parent | 0491065bf79c6f00a0a4efcb74f8738b6b76bd55 (diff) |
Define yt-mode
- Add minor mode
- Define keybindings and doc them to *Yeetube-Search* buffer
-rw-r--r-- | yeetube.el | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -65,9 +65,19 @@ Example Usage: :safe #'stringp :group 'yeetube) +(define-minor-mode yt-mode + "Yeetube mode." + :init-value nil + :lighter " yt-moden" + :keymap (let ((map (make-sparse-keymap))) + (define-key map (kbd "p") 'yt-play) + (define-key map (kbd "RET") 'yt-play) + (define-key map (kbd "d") 'yt-download-video) + map)) + (defun yt-play () - "Open the link at point in an `'org-mode buffer with `'mpv." (interactive) + "Open the link at point in an `'org-mode buffer with `'mpv." (let ((url (org-element-property :raw-link (org-element-context)))) (when (string-prefix-p "http" url) @@ -103,16 +113,20 @@ Example Usage: (setq buffer-read-only nil) (erase-buffer) (org-mode) - (insert "\n* Search Results: \n \n") + (insert + "~p~ /or/ ~RET~ to play video\n" + "\n~d~ to download" + "\n* Search Results: \n \n") (cl-loop for (videoId . videoTitle) in (cl-mapcar #'cons (reverse videoIds) (reverse videoTitles)) do (insert (format "+ [[https://www.youtube.com/watch?v=%s][%s ]]\n" videoId videoTitle))) - (setq buffer-read-only t)))) + (setq buffer-read-only t) + (yt-mode)))) (defun yt-download-video () - "Download using link at point in an `'org-mode buffer with yt-dlp." (interactive) + "Download using link at point in an `'org-mode buffer with yt-dlp." (let ((url (org-element-property :raw-link (org-element-context)))) (when (string-prefix-p "http" url) |