Search Youtube

Some time ago I showed you how to do Google queries from Emacs. The approach used in that articles is pretty generic and can be used for the creation of various similar commands. Let’s create a command that searches in YouTube:

(defun er-youtube ()
  "Search YouTube with a query or region if any."
    (url-hexify-string (if mark-active
                           (buffer-substring (region-beginning) (region-end))
                         (read-string "Search YouTube: "))))))

This command will display the query results in your default browser.

I’d suggest binding the command to C-c y if you plan to use it regularly.

(global-set-key (kbd "C-c y") #'er-youtube)

youtube is available in Prelude (but with a prelude- prefix).