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

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

[elpa] externals/dired-preview ec09d4b856 27/67: Fix how delayed-mode-ho


From: ELPA Syncer
Subject: [elpa] externals/dired-preview ec09d4b856 27/67: Fix how delayed-mode-hooks are handled
Date: Sat, 8 Jul 2023 15:57:53 -0400 (EDT)

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

    Fix how delayed-mode-hooks are handled
    
    Before, the 'dired-preview--run-mode-hooks' would only be installed if
    the preview was shown in a window.  This, however, led to a situation
    where the buffer would be prepared for preview but never have time to
    be displayed because the user visited the file in the meantime.  The
    delayed hooks would never be called in that case.
---
 dired-preview.el | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/dired-preview.el b/dired-preview.el
index a9b92f9615..b59dcd2dd5 100644
--- a/dired-preview.el
+++ b/dired-preview.el
@@ -96,10 +96,7 @@ Used by the default value of 
`dired-preview-display-action-alist'."
     (dedicated . t)
     ;; FIXME 2023-06-29: Should `dired-preview-set-up-preview-window'
     ;; be part of the `body-function'?  It seems wrong as the user may
-    ;; omit this entry from the alist, thus breaking the preview. It
-    ;; is better to handle the `delayed-mode-hooks' in
-    ;; `dired-preview--find-file-no-select' and then find out another
-    ;; place to set the window parameter.
+    ;; omit this entry from the alist, thus breaking the preview.
     (body-function . dired-preview-set-up-preview-window)
     (window-parameters . ((no-other-window . t)
                           (mode-line-format . ("%e"
@@ -155,6 +152,8 @@ Always return FILE buffer."
     (if (buffer-live-p buffer)
         buffer
       (setq buffer (dired-preview--find-file-no-select file))
+      (with-current-buffer buffer
+        (add-hook 'post-command-hook #'dired-preview--run-mode-hooks nil 
:local))
       (add-to-list 'dired-preview--buffers buffer)
       buffer)))
 
@@ -242,8 +241,7 @@ Use this as the `body-function' in the user option
 `dired-preview-display-action-alist'."
   (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)))
+    (add-hook 'post-command-hook #'dired-preview--close-previews-outside-dired 
nil :local)))
 
 (defun dired-preview--display-buffer (buffer)
   "Call `display-buffer' for BUFFER.



reply via email to

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