Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

run peep-dired-display-file-other-window when the selected line changes after applying a mark in dired #18

Open
DivineDominion opened this issue Oct 29, 2020 · 2 comments

Comments

@DivineDominion
Copy link

peep-dired works when you hit the arrow keys or C-n/C-p. When you use n/p in the dired buffer, point will move down a line, but the peeped-at file won't change.

Similarly, when you peep at a file and press d to mark for deletion, dired puts point one line further down. peep-dired will not pick up these changes either. That makes interaction a bit awkward; the best quick fix after hitting d (using peep to review files for deletion) is to hit C-p C-n to move the selection up and down and then show the correct file preview.

There's no hook in dired.el to react to point position changes.

  • Maybe it makes sense to add a buffer-local hook to moving point in general, sort of a reactive approach? Downside: this would peep at files when you scroll.
  • Or advise around dired-mark? That will fix this issue and keep the scrolling/paging behavior unchanged.

(I know that you're looking for a new maintainer, but I wanted to submit this to track the request. Maybe I can figure out how to implement this myself.)

@DivineDominion
Copy link
Author

Ok that was rather simple :)

(defun ct/peep-dired-display-file-after-mark (&rest args)
  "Peep at file at point in dired after changing a mark."
  (peep-dired-display-file-other-window))

(advice-add #'dired-mark :after #'ct/peep-dired-display-file-after-mark)

Will test this some more and then propose a PR.

@DivineDominion
Copy link
Author

Noticed I need to add a check if peep-dired is running at all, otherwise this will produce warnings/errors in the minibuffer

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant