protesilaos / dired-preview

Automatically preview file at point in Emacs Dired.
GNU General Public License v3.0
57 stars 2 forks source link

entering a directory does not preview the file at point #4

Closed gitrj95 closed 6 months ago

gitrj95 commented 1 year ago

hi, prot. i hope you are well

it seems there are two conditions whereby previews do not happen when i would expect them:

  1. when opening dired and point sits on a file: that first file does not trigger preview until i move around
  2. when jumping inside a directory and point sits on a file: that file does not trigger preview as above

i have not inspected the code, but presumably these issues are related

protesilaos commented 1 year ago

Hello @gitrj95!

when opening dired and point sits on a file: that first file does not trigger preview until i move around

This is a known issue. I need to think how best to approach it.

when jumping inside a directory and point sits on a file: that file does not trigger preview as above

How are you jumping around? Which commands are involved? In principle, we want to cover this scenario.

gitrj95 commented 1 year ago

repro:

  1. open dired
  2. move point to subdirectory
  3. "RET" to enter directory
  4. move to some file (preview shows)
  5. "^" to move back to parent directory
  6. move to some file (preview shows)
  7. re-enter the directory as per the above
  8. point is "remembered" at the file at (4), but no preview shows

the remembering of point in (8) may be caused by saveplace; i don't recall the precise origin of the semantics, here

protesilaos commented 1 year ago

I am not using saveplace and do know about this issue. It is tricky how we should deal with it. Right now the preview is triggered by a motion in the current Dired buffer, such that we do not have to keep track of all window/buffer changing across Emacs. I am not sure how else we can approach this without broading the state we are keeping track of.

ghost commented 1 year ago

I solved these issues by adding dired-find-file dired dired-jump to the variable dired-preview-trigger-commands

(defvar dired-preview-trigger-commands
  '(dired-next-line dired-previous-line dired-mark dired-goto-file dired-find-file dired dired-jump)
  "List of Dired commands that trigger a preview.")
protesilaos commented 1 year ago

From: Nofint @.***> Date: Sat, 9 Sep 2023 23:58:35 -0700

I solved these issues by adding dired-find-file dired dired-jump to the variable dired-preview-trigger-commands

(defvar dired-preview-trigger-commands
  '(dired-next-line dired-previous-line dired-mark dired-goto-file dired-find-file dired dired-jump)
  "List of Dired commands that trigger a preview.")

This seems reasonable. Have you noticed any downsides with this addition? If not, we can update the package accordingly and I am happy to receive a pull request from you.

-- Protesilaos Stavrou https://protesilaos.com

ghost commented 1 year ago

From: Nofint @.***> Date: Sat, 9 Sep 2023 23:58:35 -0700 I solved these issues by adding dired-find-file dired dired-jump to the variable dired-preview-trigger-commands (defvar dired-preview-trigger-commands '(dired-next-line dired-previous-line dired-mark dired-goto-file dired-find-file dired dired-jump) "List of Dired commands that trigger a preview.") This seems reasonable. Have you noticed any downsides with this addition? If not, we can update the package accordingly and I am happy to receive a pull request from you. -- Protesilaos Stavrou https://protesilaos.com

At the moment, I haven't encountered any issues. So maybe I should submit a pull request.

protesilaos commented 6 months ago

This has been done. Closing now. Thanks!