emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dired-preview 7d581dea62 4/8: Add DIY code section and


From: ELPA Syncer
Subject: [elpa] externals/dired-preview 7d581dea62 4/8: Add DIY code section and show example for dired-preview+ready-player
Date: Sun, 28 Jul 2024 09:57:55 -0400 (EDT)

branch: externals/dired-preview
commit 7d581dea623be4b44a52cfb1a55379d7be98cfea
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>

    Add DIY code section and show example for dired-preview+ready-player
---
 README.org | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/README.org b/README.org
index 1f762003ec..13b9ef892f 100644
--- a/README.org
+++ b/README.org
@@ -221,6 +221,57 @@ Remember to read the doc string of each of these variables 
or functions.
 (dired-preview-global-mode 1)
 #+end_src
 
+* Do-It-Yourself extensions
+:PROPERTIES:
+:CUSTOM_ID: h:c2a592d0-da08-4737-ad90-e031d7be471d
+:END:
+
+In this section we include sample code to help users further configure
+~dired-preview~ to suit their needs.
+
+** The ~dired-preview-with-window~ macro
+:PROPERTIES:
+:CUSTOM_ID: h:f5a5f8ed-4b03-4afc-96e2-83904be19739
+:END:
+
+#+findex: dired-preview-with-window
+The Lisp macro ~dired-preview-with-window~ can be used in custom
+functions to evaluate its =BODY= with the Dired Preview window as the
+selected one. Use this to perform some action on the preview window's
+buffer.
+
+[[#h:1765efb1-f9fe-4379-8ef3-668e573e299b][Combine ~dired-preview~ with 
~ready-player~]]
+
+** Combine ~dired-preview~ with ~ready-player~
+:PROPERTIES:
+:CUSTOM_ID: h:1765efb1-f9fe-4379-8ef3-668e573e299b
+:END:
+
+The ~ready-player~ package by Alvaro Ramirez produces a usable buffer
+for multimedia files that are otherwise not readable inside of Emacs.
+This buffer includes media controls and shows metadata of the file.
+With ~ready-player~, the user can launch an external program to play
+the media. It is neat!
+
+When ~dired-preview~ requests the preview of a multimedia file, it is
+displayed using ~ready-player~ under the hood. We can then write our
+own commands to call ~ready-player~ functions inside the previewed
+buffer ([[#h:f5a5f8ed-4b03-4afc-96e2-83904be19739][The 
~dired-preview-with-window~ macro]]). Here is a sample:
+
+#+begin_src emacs-lisp
+(defun prot/ready-player-dired-preview-play-toggle ()
+  "Call `ready-player-toggle-play-stop' on the currently previewed media file."
+  (interactive)
+  (if-let ((file (dired-file-name-at-point))
+           (media (concat "\\." (regexp-opt ready-player-supported-media t) 
"\\'"))
+           (_ (string-match-p media file)))
+      (dired-preview-with-window
+       (call-interactively #'ready-player-toggle-play-stop))
+    (user-error "Cannot do something useful with `ready-player' here")))
+
+(define-key dired-preview-mode-map (kbd "C-c C-p") 
#'prot/ready-player-dired-preview-play-toggle)
+#+end_src
+
 * Acknowledgements
 :PROPERTIES:
 :CUSTOM_ID: h:72a35028-5b0c-4835-9e3a-8869b9241f1a



reply via email to

[Prev in Thread] Current Thread [Next in Thread]