[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
- [elpa] externals/dired-preview updated (7b1d5f6733 -> d461945762), ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview e217d844ca 1/8: Add macro dired-preview-with-window, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview c3e3027eed 2/8: Autoload dired-preview-with-window macro, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview 7d581dea62 4/8: Add DIY code section and show example for dired-preview+ready-player,
ELPA Syncer <=
- [elpa] externals/dired-preview bedaa9114a 6/8: Reposition two declarations closer to where they are used, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview 500a291de1 7/8: Include dired-flag-file-deletion in the list of dired-preview-trigger-commands, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview 9a26b0c36c 5/8: Make dired-preview-hexl-toggle use dired-preview-with-window, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview fd6aeb4667 3/8: Tweak the sample configuration, ELPA Syncer, 2024/07/28
- [elpa] externals/dired-preview d461945762 8/8: Move dired-preview--window-parameter-p closer to where it is used, ELPA Syncer, 2024/07/28