From 51c1ed3851d643c4308b165a0a2ea81eed21d6f1 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Sat, 5 Sep 2020 10:57:46 +0530 Subject: [PATCH] Usage from emacs with Doom Emacs keybindings Signed-off-by: Joseph Nuthalapati --- nimcoon.el | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 nimcoon.el diff --git a/nimcoon.el b/nimcoon.el new file mode 100644 index 0000000..5fdb2c9 --- /dev/null +++ b/nimcoon.el @@ -0,0 +1,43 @@ +;;; nimcoon.el -*- lexical-binding: t; -*- +;;; +;;; Usage in Doom Emacs +;;; Place or symlink the file into ~/.doom.d/ +;;; (load! "nimcoon") + +;;; Non-interactive functions to respond to URL clicks +(defun nimcoon-play-url (url) + "Play given url in NimCoon" + (start-process "nimcoon" nil "nimcoon" url)) + +;; Play all YouTube URLs in NimCoon +(setq browse-url-browser-function + (quote + (("youtu\\.?be" . nimcoon-play-url) + ("." . browse-url-default-browser)))) + +;;; Interactive functions +(defun nimcoon-feeling-lucky-music(query) + (interactive "sSearch query: ") + (call-process "nimcoon" nil 0 nil "-m" "-l" (format "'%s'" query))) + +(defun nimcoon-feeling-lucky-video(query) + (interactive "sSearch query: ") + (call-process "nimcoon" nil 0 nil "-l" (format "'%s'" query))) + +(defun nimcoon-download-video(query) + (interactive "sSearch query: ") + (call-process "nimcoon" nil 0 nil "-d" "-l" (format "'%s'" query))) + +(defun nimcoon-download-music(query) + (interactive "sSearch query: ") + (call-process "nimcoon" nil 0 nil "-d" "-l" "-m" (format "'%s'" query))) + +;;; Keybindings +(map! :leader + ;;; N --- NimCoon + (:prefix-map ("N" . "NimCoon") + (:prefix ("d" . "Download") + :desc "Video" "v" #'nimcoon-download-video + :desc "Music" "m" #'nimcoon-download-music) + :desc "Video" "v" #'nimcoon-feeling-lucky-video + :desc "Music" "m" #'nimcoon-feeling-lucky-music)) -- 2.43.0