]> njoseph.me Git - nimcoon.git/commitdiff
Usage from emacs with Doom Emacs keybindings
authorJoseph Nuthalapati <njoseph@riseup.net>
Sat, 5 Sep 2020 05:27:46 +0000 (10:57 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Sat, 5 Sep 2020 05:27:46 +0000 (10:57 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
nimcoon.el [new file with mode: 0644]

diff --git a/nimcoon.el b/nimcoon.el
new file mode 100644 (file)
index 0000000..5fdb2c9
--- /dev/null
@@ -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
+      ;;; <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))