[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dired-preview 4da6ee04bf 12/67: Make the display-buffer
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dired-preview 4da6ee04bf 12/67: Make the display-buffer action alist customisable |
Date: |
Sat, 8 Jul 2023 15:57:52 -0400 (EDT) |
branch: externals/dired-preview
commit 4da6ee04bf5b39f74af37532cfbe98f03f893367
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make the display-buffer action alist customisable
This addresses a TODO I had. It was also discussed with Karthik
Chikmagalur as part of the preparatory work towards a potential option
to set the other-window-scroll-buffer to the previewed buffer:
<https://lists.sr.ht/~protesilaos/general-issues/%3C87jzvp484n.fsf%40gmail.com%3E>.
---
dired-preview.el | 51 +++++++++++++++++++++++++++++++--------------------
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/dired-preview.el b/dired-preview.el
index e780a084b4..41bd7fba88 100644
--- a/dired-preview.el
+++ b/dired-preview.el
@@ -82,6 +82,34 @@
:group 'dired-preview
:type 'integer)
+(defcustom dired-preview-buffer-name "*dired-preview*"
+ "Name of preview buffer.
+Used by the default value of `dired-preview-display-action-alist'."
+ :group 'dired-preview
+ :type 'string)
+
+(defcustom dired-preview-display-action-alist
+ `((display-buffer-in-side-window)
+ (side . right)
+ (slot . -1)
+ (window-width . 0.3)
+ (dedicated . t)
+ (body-function . dired-preview-set-up-preview-window)
+ (window-parameters . ((no-other-window . t)
+ (mode-line-format . ("%e"
+ mode-line-front-space
+ ,dired-preview-buffer-name)))))
+ "The `display-buffer' action for the preview.
+This is the same data that is passed to `display-buffer-alist'.
+Read Info node `(elisp) Displaying Buffers'. As such, it is
+meant for experienced users.
+
+To ensure best results, the `body-function' in the alist must be
+set to `dired-preview-set-up-preview-window', as shown in this
+user option's default value."
+ :group 'dired-preview
+ :type 'alist)
+
(defcustom dired-preview-delay 0.7
"Time in seconds to wait before previewing."
:group 'dired-preview
@@ -106,7 +134,7 @@
(defun dired-preview--run-mode-hooks ()
"Run mode hooks in current buffer, if `delayed-mode-hooks' is non-nil.
See `dired-preview--find-file-no-select' for how hooks are
-delayed and `dired-preview--set-up-preview-window' for how this function
+delayed and `dired-preview-set-up-preview-window' for how this function
is used."
(when (and delay-mode-hooks (current-buffer))
(run-mode-hooks delayed-mode-hooks)
@@ -203,20 +231,13 @@ conforms with `dired-preview--preview-p'."
(when (not (eq major-mode 'dired-mode))
(dired-preview--close-previews)))
-(defun dired-preview--set-up-preview-window (window &rest _)
+(defun dired-preview-set-up-preview-window (window &rest _)
"Set WINDOW `:preview' parameter."
(set-window-parameter window 'dired-preview-window :preview)
(with-current-buffer (window-buffer window)
(add-hook 'post-command-hook #'dired-preview--close-previews-outside-dired
nil :local)
(add-hook 'post-command-hook #'dired-preview--run-mode-hooks nil :local)))
-(defvar dired-preview-buffer-name "*dired-preview*"
- "Name of preview buffer.")
-
-;; TODO 2023-06-13: Determine best way to make the placement of the
-;; preview configurable.
-(defvar dired-preview-display-buffer-side 'right)
-
(defun dired-preview--display-buffer-action (buffer)
"Call `display-buffer' for BUFFER.
Only do it with the current major mode is Dired."
@@ -226,17 +247,7 @@ Only do it with the current major mode is Dired."
(when (eq major-mode 'dired-mode)
(display-buffer
buffer
- ;; NOTE 2023-06-13: See TODO above.
- `((display-buffer-in-side-window)
- (side . ,dired-preview-display-buffer-side)
- (slot . -1)
- (window-width . 0.3)
- (dedicated . t)
- (body-function . dired-preview--set-up-preview-window)
- (window-parameters . ((no-other-window . t)
- (mode-line-format . ("%e"
- mode-line-front-space
-
,dired-preview-buffer-name))))))))
+ dired-preview-display-action-alist)))
(defun dired-preview--cancel-timer ()
"Cancel `dired-preview--timer' if it is a timer object."
- [elpa] externals/dired-preview 22f44d083c 10/67: Clear previewed buffers after they are killed, (continued)
- [elpa] externals/dired-preview 22f44d083c 10/67: Clear previewed buffers after they are killed, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 91fc74d122 49/67: Stop using a side window for previews, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 24bf5bce79 50/67: Add FIXME for dired-preview-display-action-alist-dwim, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 53ebf5d655 51/67: Change how window size is determined (fix 24bf5bc), ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 0fa9aab1df 53/67: Add FIXME for how/why window parameters are unset, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview ea643a8912 54/67: Simplify dired-preview-trigger, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4010cc9987 60/67: Implement garbage collection for buffer killing, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4b89363599 61/67: Delete preview windows, including the selected one, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 98815455cb 65/67: Simplify README.md, pointing to the manual instead (per 33a27a6), ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 6673bb1cd3 67/67: Update to version 0.1.0, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4da6ee04bf 12/67: Make the display-buffer action alist customisable,
ELPA Syncer <=
- [elpa] externals/dired-preview f2a720ca8f 13/67: Update dired-preview-set-up-preview-window doc to reference user option, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 04bfb749c7 22/67: Move two forms closer to where they are used, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4857868357 33/67: Harden dired-preview--close-previews-outside-dired conditionality, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 38fab3d419 38/67: Use 'file-regular-p' instead of 'file-exists-p', ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview f6bb0e3271 44/67: Add TODO to only accummulate a fixed size of buffers, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 00ab2337ca 46/67: Stop adding 'no-other-window' parameter, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview bac80501c8 55/67: Use 'unless' in dired-preview--close-previews-outside-dired, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview d9b779e2da 58/67: Use "-get" instead of "-return" in function symbols, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 7413c6f59a 62/67: Define dired-preview-global-mode, ELPA Syncer, 2023/07/08
- [elpa] externals/dired-preview 4af91a6b7c 57/67: Re-order large portions of the file, ELPA Syncer, 2023/07/08