diff options
author | Thanos Apollo <[email protected]> | 2023-07-13 06:46:31 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2023-07-13 06:46:31 +0300 |
commit | ec6341ecf1fb11904b812a5c04e8af4098ea0fd9 (patch) | |
tree | 8a6af0edfdd682a01637871f7a0f92cb7db7ee65 | |
parent | caba205e543379601fbd88ee541029cdc1b8327e (diff) |
Add yeetube--draw-buffer
Seperate the creation of *Yeetube Search* buffer to an "isolated"
function.
Making yeetube-search less complicated.
-rw-r--r-- | yeetube.el | 35 |
1 files changed, 19 insertions, 16 deletions
@@ -177,6 +177,24 @@ PREFIX [[URL/watch?v=VIDEOID][VIDEOTITLE ]]" prefix url video-id (yeetube-fix-title video-title))))) +(defun yeetube--draw-buffer (query video-titles video-ids) + "Create *Yeetube-Search* buffer for QUERY, using VIDEO-TITLES with VIDEO-IDS." + (with-current-buffer + (switch-to-buffer + (get-buffer-create "*Yeetube Search*")) + (setq buffer-read-only nil) + (erase-buffer) + (org-mode) + (insert + (format "searching: %s\nfor: %s \n* Search Results: \n \n" yeetube-query-url query)) + (yeetube-insert-content + yeetube-results-prefix yeetube-query-url + video-titles video-ids) + (yeetube-insert-info) + (setq buffer-read-only t) + (goto-char (point-min)) + (search-forward yeetube-results-prefix) + (yeetube-mode))) (defun yeetube-search (query) "Search for QUERY." @@ -232,22 +250,7 @@ PREFIX [[URL/watch?v=VIDEOID][VIDEOTITLE ]]" (if (string-match-p "vssLoggingContext" title) (pop video-ids) (push title video-titles))))))) - (with-current-buffer - (switch-to-buffer - (get-buffer-create "*Yeetube Search*")) - (setq buffer-read-only nil) - (erase-buffer) - (org-mode) - (insert - (format "searching: %s\nfor: %s \n* Search Results: \n \n" yeetube-query-url query)) - (yeetube-insert-content - yeetube-results-prefix yeetube-query-url - video-titles video-ids) - (yeetube-insert-info) - (setq buffer-read-only t) - (goto-char (point-min)) - (search-forward yeetube-results-prefix) - (yeetube-mode)))) + (yeetube--draw-buffer query video-titles video-ids))) (defun yeetube-download-video () "Download using link at point in an `'org-mode buffer with yt-dlp." |