Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
2017-01-11 - w3m with vlc
(defcustom fn/w3m-video-executable "vlc"
"The executable that can run a network video stream.")
(defcustom fn/w3m-video-args
;; This skews how the process is managed for vlc
;; "--one-instance"
;; "--play-and-exit"
"Extra arguments to run `fn/w3m-video-executable'")
(defun fn/w3m-video (&optional url)
"Get image video url."
(or url (w3m-anchor) w3m-current-url))
(defun fn/w3m-view-video ()
"View the video url with `fn/w3m-video-executable'"
(let ((url (w3m-url-valid (fn/w3m-video))))
(if (null url)
(w3m-message "No video at point")
(lexical-let ((video-process
(apply #'start-process
(format "%s-%s" "w3m" fn/w3m-video-executable)
(list url)))))
(with-current-buffer (current-buffer)
(setq-local fn/w3m-page-process video-process))))))
(defun fn/w3m-kill-page-process ()
"Kill the `fn/w3m-page-process' of the current buffer."
(with-current-buffer (current-buffer)
(when (and (boundp 'fn/w3m-page-process)
(process-live-p fn/w3m-page-process))
(kill-process fn/w3m-page-process))
(setq-local fn/w3m-page-process nil)))
(defun fn/w3m-auto-kill-page-process (url)
"If the page has a process, quit it."
(add-hook 'w3m-display-hook #'fn/w3m-auto-kill-page-process t)
(add-hook 'kill-buffer-hook #'fn/w3m-kill-page-process t)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment