branch: externals/eev commit 9a002086e55eba6a025eb41f41f272cfcb98c59a Author: Eduardo Ochs <edrx@circe.birdland> Commit: Eduardo Ochs <edrx@circe.birdland>
Now `find-video' and `find-audio' use `find-mpv-video' and `find-mpv-audio'. --- ChangeLog | 16 +++- VERSION | 4 +- eev-audiovideo.el | 143 +++++++++++++++++++++++------------ eev-elinks.el | 40 ++++++++++ eev-intro.el | 217 ++++++++++++++++++++++++++++++++---------------------- eev-mode.el | 3 +- 6 files changed, 279 insertions(+), 144 deletions(-) diff --git a/ChangeLog b/ChangeLog index beaa153..c37f123 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,17 @@ -2019-08-12 Eduardo Ochs <eduardoo...@gmail.com> +2019-08-15 Eduardo Ochs <eduardoo...@gmail.com> - * eepitch.el (eepitch-shell3, eepitch-lua52, eepitch-lua53): new - functions. + * eev-audiovideo.el (find-video, code-video, find-code-video) + (find-audio, code-audio, find-code-audio): these aliases now point + to the corresponding mpv-video and mpv-audio functions. + + * eev-intro.el (find-audiovideo-intro): rewrote many sections. + + * eev-mode.el (eev-mode-map-set): new binding: `M-h M-a' -> + `find-code-audiovideo-links'. + + * eev-elinks.el (find-code-audiovideo-links): new function. + +2019-08-12 Eduardo Ochs <eduardoo...@gmail.com> * eev-audiovideo.el (find-mpv-video, ee-find-mpv-video) (code-mpv-video, find-code-mpv-video, ee-code-mpv-video) diff --git a/VERSION b/VERSION index 03e53f7..5729a1e 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ -Mon Aug 12 09:12:28 GMT 2019 -Mon Aug 12 10:12:28 BST 2019 +Thu Aug 15 05:08:07 GMT 2019 +Thu Aug 15 06:08:07 BST 2019 diff --git a/eev-audiovideo.el b/eev-audiovideo.el index 1d44a51..17f0576 100644 --- a/eev-audiovideo.el +++ b/eev-audiovideo.el @@ -37,9 +37,11 @@ ;; ;; but that needs to be rewritten... +;; «.find-mplayer» (to "find-mplayer") +;; «.find-termplayer» (to "find-termplayer") ;; «.find-mpv-video» (to "find-mpv-video") ;; «.find-mpv-audio» (to "find-mpv-audio") -;; «.find-termplayer» (to "find-termplayer") +;; «.aliases» (to "aliases") @@ -197,7 +199,20 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")" ;;; \___\___/ \__,_|\___| \_/ |_|\__,_|\___|\___/ ;;; -;; mplayer for video files +;;; _ +;;; _ __ ___ _ __ | | __ _ _ _ ___ _ __ +;;; | '_ ` _ \| '_ \| |/ _` | | | |/ _ \ '__| +;;; | | | | | | |_) | | (_| | |_| | __/ | +;;; |_| |_| |_| .__/|_|\__,_|\__, |\___|_| +;;; |_| |___/ +;; +;; «find-mplayer» (to ".find-mplayer") +;; Play video files with mplayer. +;; Note that: +;; 1. mplayer is obsolete - see https://en.wikipedia.org/wiki/Mpv_(media_player) +;; 2. this should be called `find-mplayer-video' to follow the conventions on +;; hyphens in: (find-eevfile "eev-pdflike.el") +;; 3. this is very old code. ;; (defun find-mplayer (fname &optional pos &rest rest) "Open FNAME with mplayer, with a GUI (in fullscreen mode, for video files)." @@ -229,6 +244,56 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")" ")) +;;; _ _ +;;; | |_ ___ _ __ _ __ ___ _ __ | | __ _ _ _ ___ _ __ +;;; | __/ _ \ '__| '_ ` _ \| '_ \| |/ _` | | | |/ _ \ '__| +;;; | || __/ | | | | | | | |_) | | (_| | |_| | __/ | +;;; \__\___|_| |_| |_| |_| .__/|_|\__,_|\__, |\___|_| +;;; |_| |___/ +;; +;; «find-termplayer» (to ".find-termplayer") +;; Play audio files with mplayer (in an xterm). +;; Note that: +;; 1. mplayer is obsolete - see https://en.wikipedia.org/wiki/Mpv_(media_player) +;; 2. this should be called `find-mplayer-audio' to follow the conventions on +;; hyphens in: (find-eevfile "eev-pdflike.el") +;; 3. this is very old code. +;; +(defvar ee-termplayer-term-options '("xterm" "-geometry" "+200+100" "-e")) +(defvar ee-termplayer-options ()) +(defun ee-mplayer-audio-options () ee-termplayer-options) +(defun ee-find-termplayer (fname &optional pos &rest rest) + `(,@ee-termplayer-term-options + "mplayer" + ,fname + ,@(if pos `("-ss" ,(ee-secs-to-mm:ss pos))) + ,@(ee-mplayer-audio-options) + )) +(defun find-termplayer (fname &optional pos &rest rest) + "Open FNAME with mplayer, without a GUI (in a terminal - for audio files)." + (interactive "sFile name: ") + (find-bgprocess (ee-find-termplayer fname pos))) + +(defun code-termplayer (c fname) + (eval (ee-read (ee-code-termplayer c fname)))) +(defun find-code-termplayer (c fname) + (find-estring-elisp (ee-code-termplayer c fname))) +(defun ee-code-termplayer (c fname) + (ee-template0 "\ + ;; {(ee-S `(find-code-termplayer ,c ,fname))} + ;; + (defun find-{c} (&optional time &rest rest) + (interactive (list (ee-time-around-point))) + (setq ee-audiovideo-last 'find-{c}) + (if (eq time t) + \"Just setting the default audio\" + (find-termplayer {(ee-S fname)} time))) + ")) + + + + + ;;; _ _ ;;; _ __ ___ _ ____ __ __ _(_) __| | ___ ___ @@ -271,17 +336,26 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")" +;;; _ _ +;;; _ __ ___ _ ____ __ __ _ _ _ __| (_) ___ +;;; | '_ ` _ \| '_ \ \ / /____ / _` | | | |/ _` | |/ _ \ +;;; | | | | | | |_) \ V /_____| (_| | |_| | (_| | | (_) | +;;; |_| |_| |_| .__/ \_/ \__,_|\__,_|\__,_|_|\___/ +;;; |_| +;; ;; «find-mpv-audio» (to ".find-mpv-audio") -;; (find-es "mplayer" "mpv-audio") +;; Play audio with mpv (running in an xterm). +;; This is immature code. My notes are here: +;; (find-es "mplayer" "mpv-audio") ;; -(setq ee-mpv-term-options '("xterm" "-geometry" "+200+100" "-e")) -(setq ee-mpv-audio-options '("--vid=no")) +(defvar ee-mpv-term-options '("xterm" "-geometry" "+200+100" "-e")) +(defvar ee-mpv-audio-options '("--vid=no")) (defun ee-find-mpv-audio (fname &optional pos &rest rest) `(,@ee-mpv-term-options "mpv" ,fname ,@(if pos `("--start" ,(ee-secs-to-mm:ss pos))) - ,@(ee-mpv-audio-options) + ,@ee-mpv-audio-options )) (defun find-mpv-audio (fname &optional pos &rest rest) "Open FNAME with mpv, without a GUI (in a terminal - for audio files)." @@ -307,12 +381,24 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")" +;;; _ _ +;;; __ _| (_) __ _ ___ ___ ___ +;;; / _` | | |/ _` / __|/ _ \/ __| +;;; | (_| | | | (_| \__ \ __/\__ \ +;;; \__,_|_|_|\__,_|___/\___||___/ +;;; +;; «aliases» (to ".aliases") +(defalias 'find-video 'find-mpv-video) +(defalias 'code-video 'code-mpv-video) +(defalias 'find-code-video 'find-code-mpv-video) -(defalias 'find-video 'find-mplayer) -(defalias 'code-video 'code-mplayer) -(defalias 'find-code-video 'find-code-mplayer) +(defalias 'find-audio 'find-mpv-audio) +(defalias 'code-audio 'code-mpv-audio) +(defalias 'find-code-audio 'find-code-mpv-audio) +;; (find-code-brfile 'find-audio :local 'braudiol :dired 'braudiod) + (code-brfile 'find-audio :local 'braudiol :dired 'braudiod) ;; (find-code-brfile 'find-video :local 'brvideol :dired 'brvideod) (code-brfile 'find-video :local 'brvideol :dired 'brvideod) @@ -326,46 +412,7 @@ See: (find-audiovideo-intro \"`eev-avadj-mode'\")" ;;; | (_| (_) | (_| | __/_____| (_| | |_| | (_| | | (_) | ;;; \___\___/ \__,_|\___| \__,_|\__,_|\__,_|_|\___/ -;; «find-termplayer» (to ".find-termplayer") -;; mplayer in an xterm, for audio files -;; -(defvar ee-termplayer-term-options '("xterm" "-geometry" "+200+100" "-e")) -(defvar ee-termplayer-options ()) -(defun ee-mplayer-audio-options () ee-termplayer-options) -(defun ee-find-termplayer (fname &optional pos &rest rest) - `(,@ee-termplayer-term-options - "mplayer" - ,fname - ,@(if pos `("-ss" ,(ee-secs-to-mm:ss pos))) - ,@(ee-mplayer-audio-options) - )) -(defun find-termplayer (fname &optional pos &rest rest) - "Open FNAME with mplayer, without a GUI (in a terminal - for audio files)." - (interactive "sFile name: ") - (find-bgprocess (ee-find-termplayer fname pos))) - -(defun code-termplayer (c fname) - (eval (ee-read (ee-code-termplayer c fname)))) -(defun find-code-termplayer (c fname) - (find-estring-elisp (ee-code-termplayer c fname))) -(defun ee-code-termplayer (c fname) - (ee-template0 "\ - ;; {(ee-S `(find-code-termplayer ,c ,fname))} - ;; - (defun find-{c} (&optional time &rest rest) - (interactive (list (ee-time-around-point))) - (setq ee-audiovideo-last 'find-{c}) - (if (eq time t) - \"Just setting the default audio\" - (find-termplayer {(ee-S fname)} time))) - ")) - -(defalias 'find-audio 'find-termplayer) -(defalias 'code-audio 'code-termplayer) -(defalias 'find-code-audio 'find-code-termplayer) -;; (find-code-brfile 'find-audio :local 'braudiol :dired 'braudiod) - (code-brfile 'find-audio :local 'braudiol :dired 'braudiod) diff --git a/eev-elinks.el b/eev-elinks.el index 16506f7..0705277 100644 --- a/eev-elinks.el +++ b/eev-elinks.el @@ -80,6 +80,7 @@ ;; «.find-code-pdf-links» (to "find-code-pdf-links") ;; «.find-pdf-links» (to "find-pdf-links") +;; «.find-code-audiovideo-links» (to "find-code-audiovideo-links") @@ -1376,6 +1377,45 @@ See: (find-here-links-intro \"5. `find-here-links-1'\")" +;; «find-code-audiovideo-links» (to ".find-code-audiovideo-links") +;; +(defun find-code-audiovideo-links (&optional fname c &rest pos-spec-list) +"Visit a temporary buffer containing hyperlinks and..." + (interactive (list (and (eq major-mode 'dired-mode) (ee-dired-to-fname)))) + (if fname (setq fname (ee-shorten-file-name fname))) + (setq fname (or fname "{fname}")) + (setq c (or c "{c}")) + (let ((dir (file-name-directory fname))) + (apply 'find-elinks-elisp + `((find-code-audiovideo-links ,fname ,c ,@pos-spec-list) + ;; Convention: the first sexp always regenerates the buffer. + ;; + ;; (find-efunction 'find-code-pdf-links) + ,(ee-template0 "\ +;; See: (find-eev-quick-intro \"9.1. `code-c-d'\") +;; (find-pdf-like-intro \"9. Generating three pairs\" \"`M-h M-p'\") +;; (find-audiovideo-intro \"2.1. `find-code-audiovideo-links'\") + +;; (find-fline {(ee-S (file-name-directory fname))}) +\(code-c-d \"{c}\" \"{(file-name-directory fname)}\") +;; \(find-{c}file \"\") + +;; (find-audio \"{fname}\") +\(code-audio \"{c}audio\" \"{fname}\") +;; \(find-{c}audio) + +;; (find-video \"{fname}\") +\(code-video \"{c}video\" \"{fname}\") +;; \(find-{c}video) +") + ) + pos-spec-list))) + +;; Tests: +;; (find-code-audiovideo-links "~/eev-videos/three-keys-2.mp4") + + + ;; ------------------------------------------------------------ ;; Old stuff: diff --git a/eev-intro.el b/eev-intro.el index 2bea417..cff5320 100644 --- a/eev-intro.el +++ b/eev-intro.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 2019aug10 +;; Version: 2019aug15 ;; Keywords: e-scripts ;; ;; Latest version: <http://angg.twu.net/eev-current/eev-intro.el> @@ -6356,22 +6356,29 @@ It is meant as both a tutorial and a sandbox. +Prerequisite: + (find-pdf-like-intro) +This intro is being rewritten. + + + + 1. Time offsets =============== Links to audio and video files are similar to links to pdf-like documents, but instead of page numbers we use \"time offsets\" to refer to positions. Time offsets are strings like 1:23, 12:34, or 1:23:45. The sexp hyperlinks below should all work if you have the -files that they refer to: +files that they refer to, and if you have mpv and xterm installed: (find-audio \"/tmp/mysong.mp3\") (find-audio \"/tmp/mysong.mp3\" \"1:23\") - (find-audio \"/tmp/mysong.mp3\" \"1:23\" \"comment are ignored\") + (find-audio \"/tmp/mysong.mp3\" \"1:23\" \"comments are ignored\") (find-video \"/tmp/myvideo.mp4\") (find-video \"/tmp/myvideo.mp4\" \"1:23\") - (find-video \"/tmp/myvideo.mp4\" \"1:23\" \"comment are ignored\") + (find-video \"/tmp/myvideo.mp4\" \"1:23\" \"comments are ignored\") -Note that they work by invoking an external player - mplayer, by +Note that they work by invoking an external player - mpv, by default - and its error messages appear here: (find-ebuffer \"*Messages*\") @@ -6379,65 +6386,7 @@ default - and its error messages appear here: -2. Shorter hyperlinks to audio and video files -============================================== -If you type `M-V' (`eewrap-audiovideo') on a line containing a -shorthand word and a file name of an audio or video file, for -example, here, - - sunwillset ~/Zoe_Keating/Sun_Will_Set.ogg - -you will get something like this: - - ;; (find-fline \"~/Zoe_Keating/\") - (code-audio \"sunwillset\" \"~/Zoe_Keating/Sun_Will_Set.ogg\") - (code-video \"sunwillset\" \"~/Zoe_Keating/Sun_Will_Set.ogg\") - ;; (find-sunwillset) - ;; (find-sunwillset \"0:00\") - -you should delete the line with the wrong sexp by hand - in this -case the wrong one is the one with `code-video', as we are -working with a sound file - and execute the other one; this will -define a function called `find-sunwillset', that plays the audio -file with `find-audio'. Run this this sexp to inspect its code: - - (find-code-audio \"sunwillset\" \"/tmp/Zoe_Keating__Sun_Will_Set.ogg\") - -you will notice that running `find-sunwillset' sets a variable, -with: - - (setq ee-audiovideo-last 'find-sunwillset) - -As we shall see soon, some operations play again the default -audio or video file, starting from some given time offset. The -default is always what is stored in `ee-audiovideo-last', and -each call to a short hyperlink of the form `find-xxxaudio' or -`find-xxxvideo' sets that variable. - - - -3. Passing options to mplayer -============================= -By default mplayer is called with just a few command-line options, -besides the ones that tell it at what position to start playing - -typically just these for videos, - - -fs -osdlevel 2 - -to make it run in full-screen mode with an on-screen display -showing the current position, and no options for audio. - -If you want to change this you should redefine these functions: - - (ee-mplayer-video-options) - (ee-mplayer-audio-options) - - - - - - -4. `eev-avadj-mode' +2. `eev-avadj-mode' =================== \"avadj-mode\" is a shorthand for \"audio/video adjust mode\". When `eev-avadj-mode' is active we get keys for adjusting time @@ -6451,8 +6400,9 @@ point. The keys are: M-p play the default audio/video file at a time offset You can toggle eev-avadj-mode on and off with `M-x -eev-avadj-mode', or with this sexp: +eev-avadj-mode', or with these sexps: + (eev-avadj-mode 0) (eev-avadj-mode) When it is on you will see an \"avadj\" at the mode line. Let's @@ -6480,9 +6430,13 @@ execute these sexps occasionally to check if they are really pointing to the right places, and then make further adjustments; we are not doing that yet. +The idea of a \"default audio/video file\" will be explained +later. + + -5. The time-from-bol +3. The time-from-bol ==================== All the keys in eev-avadj-mode operate on the \"time-from-bol\" of the current line: the first occurrence, in the current line, @@ -6508,7 +6462,7 @@ Try to evaluate these sexps: and now try `M-0 M-p' on these lines: ;; 4:19 blah - ;; 2:19 + ;; 2:19 For more realistic examples, see: @@ -6517,6 +6471,112 @@ For more realistic examples, see: +4. Short hyperlinks to audio and video files +============================================ +This sexp + + (code-video \"eevtk2video\" \"~/eev-videos/three-keys-2.mp4\") + +defines a function `find-eevtk2video'. Note that the function +definition in + + (find-code-video \"eevtk2video\" \"~/eev-videos/three-keys-2.mp4\") + +has this line: + + (setq ee-audiovideo-last 'find-eevtk2video) + +Every call to a function with a name like `find-*audio' or +`find-*video' sets the variable `ee-audiovideo-last'. + + + + +4.1. `find-code-audiovideo-links' +--------------------------------- +The easist way to produce `code-audio' or `code-video' hyperlinks +uses `M-h M-a', that calls `find-code-audiovideo-links' and is +very similar to: + + (find-pdf-like-intro \"9. Generating three pairs\") + (find-pdf-like-intro \"9. Generating three pairs\" \"M-h M-p\") + +A test: + + (eepitch-shell) + (eepitch-kill) + (eepitch-shell) + mkdir ~/eev-videos/ + cd ~/eev-videos/ + wget -nc http://angg.twu.net/eev-videos/three-keys-2.mp4 + + # (find-code-audiovideo-links \"~/eev-videos/three-keys-2.mp4\" \"eevtk2\") + # (find-fline \"~/eev-videos/\") + # (find-fline \"~/eev-videos/\" \"three-keys-2.mp4\") + # ^ Type `M-h M-a' on the line with the .mp4 + +\[Todo: explain M-p in eev-avadj-mode] + + + +4.2. `eewrap-audiovideo' +------------------------ +If you type `M-V' (`eewrap-audiovideo') on a line containing a +shorthand word and a file name of an audio or video file, for +example, here, + + sunwillset ~/Zoe_Keating/Sun_Will_Set.ogg + +you will get something like this: + + ;; (find-fline \"~/Zoe_Keating/\") + (code-audio \"sunwillset\" \"~/Zoe_Keating/Sun_Will_Set.ogg\") + (code-video \"sunwillset\" \"~/Zoe_Keating/Sun_Will_Set.ogg\") + ;; (find-sunwillset) + ;; (find-sunwillset \"0:00\") + +you should delete the line with the wrong sexp by hand - in this +case the wrong one is the one with `code-video', as we are +working with a sound file - and execute the other one; this will +define a function called `find-sunwillset', that plays the audio +file with `find-audio'. Run this this sexp to inspect its code: + + (find-code-audio \"sunwillset\" \"/tmp/Zoe_Keating__Sun_Will_Set.ogg\") + +you will notice that running `find-sunwillset' sets a variable, +with: + + (setq ee-audiovideo-last 'find-sunwillset) + +As we shall see soon, some operations play again the default +audio or video file, starting from some given time offset. The +default is always what is stored in `ee-audiovideo-last', and +each call to a short hyperlink of the form `find-xxxaudio' or +`find-xxxvideo' sets that variable. + + + +5. Passing options to mplayer +============================= +By default mplayer is called with just a few command-line options, +besides the ones that tell it at what position to start playing - +typically just these for videos, + + -fs -osdlevel 2 + +to make it run in full-screen mode with an on-screen display +showing the current position, and no options for audio. + +If you want to change this you should redefine these functions: + + (ee-mplayer-video-options) + (ee-mplayer-audio-options) + + + + + + 6. Youtube-dl ============= Videos at Youtube are identified by unique 11-char codes that are @@ -6731,29 +6791,6 @@ To change the dir strings \"~/videos/\", \"~/videos/tech/\", \"/tmp/videos/\", buffers, change the variables `ee-youtubedl-dir', `ee-youtubedl-dir2', `ee-youtubedl-dir3', `ee-youtubedl-dir4.' - - -How to download -=============== - - - -Test the download -================= - - -Create short links -================== - - - - - (find-youtubedl-links \"/tmp/\" \"TITLE\" \"abcdefghijk\" \".mp4\" \"{stem}\") - (find-youtubedl-links nil nil \"abcdefghijk\") - - (find-eev \"eev-audiovideo.el\") - (find-eev \"eev-audiovideo.el\" \"eev-avadj-mode\") - " pos-spec-list))) ;; (find-audiovideo-intro) diff --git a/eev-mode.el b/eev-mode.el index cf12857..417e3b2 100644 --- a/eev-mode.el +++ b/eev-mode.el @@ -19,7 +19,7 @@ ;; ;; Author: Eduardo Ochs <eduardoo...@gmail.com> ;; Maintainer: Eduardo Ochs <eduardoo...@gmail.com> -;; Version: 2019jun21 +;; Version: 2019aug15 ;; Keywords: e-scripts ;; ;; Latest version: <http://angg.twu.net/eev-current/eev-mode.el> @@ -116,6 +116,7 @@ and: (find-eval-intro \"`M-k'\")" ;; (find-eev-quick-intro "4. Creating Elisp Hyperlinks") ;; (find-eev-quick-intro "4. Creating Elisp Hyperlinks" "`M-h M-h'") ;; Source: (find-eev "eev-elinks.el") + (define-key eev-mode-map "\M-h\M-a" 'find-code-audiovideo-links) (define-key eev-mode-map "\M-h\M-d" 'find-debpkg-links) (define-key eev-mode-map "\M-h\M-f" 'find-efunction-links) (define-key eev-mode-map "\M-h\M-g" 'find-grep-links)