branch: externals/dired-preview
commit 5338f5c1a70e8c11c9c43a053f991b44483c8c09
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Make commit 3ba4c3f more resilient
The previous version assumed 'dired-file-name-at-point' to always
return a non-nil value.
---
dired-preview.el | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/dired-preview.el b/dired-preview.el
index 9cfdaaf804..a9b92f9615 100644
--- a/dired-preview.el
+++ b/dired-preview.el
@@ -251,15 +251,16 @@ Only do it with the current major mode is Dired."
;; We check for `dired-mode' because we want to avoid the scenario
;; where the user switches to another buffer/window/frame before the
;; timer elapses.
- (when (and (eq major-mode 'dired-mode)
- ;; FIXME 2023-06-29: We check again for the file in Dired
- ;; because this function runs on a timer and we only want
- ;; it to happen if the file at point is still the one we
- ;; were about to display. There probably is a better way
- ;; of doing things, given that `dired-file-name-at-point'
- ;; is called by the `dired-preview-display-file' that
- ;; ultimately calls this one.
- (eq buffer (get-file-buffer (dired-file-name-at-point))))
+ (when-let* (((eq major-mode 'dired-mode))
+ ;; FIXME 2023-06-29: We check again for the file in Dired
+ ;; because this function runs on a timer and we only want
+ ;; it to happen if the file at point is still the one we
+ ;; were about to display. There probably is a better way
+ ;; of doing things, given that `dired-file-name-at-point'
+ ;; is called by the `dired-preview-display-file' that
+ ;; ultimately calls this one.
+ (file (dired-file-name-at-point))
+ ((eq buffer (get-file-buffer file))))
(display-buffer
buffer
dired-preview-display-action-alist)))