protesilaos / dired-preview

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

Generalize to a file preview library? #9

Closed shankar2k closed 5 months ago

shankar2k commented 11 months ago

Hi Prot,

I've been trying to preview a file in a temporary side window off and on for years, and then I came across your package, which solves the problem quite elegantly!

I believe the functionality of previewing a file in this way can be easily generalized to other packages besides Dired. For example, I made a small package called Deft Preview which enables this kind of file previewing in Deft. Please feel free to take a look at it. To each achieve the preview functionality in Deft Preview, I made use of two of your functions: dired-preview-display-file and (breaking the abstraction) the private function dired-preview--close-previews. In addition, in my package, I duplicated the behavior of dired-preview--close-previews-outside-dired almost entirely, with the only difference being the major mode that I check for. I think that this common behavior could be capture in a smaller file preview library that could be leveraged by Dired Preview, my Deft Preview package, and perhaps others.

It looks that the philosophy in modern Emacs package development is to make packages small and complementary, such as in the Vertico-Consult-Orderless-Marginalia-Embark set of packages. If you agree with my idea of separating out a general file preview library, would you be interested in discussing it further?

protesilaos commented 10 months ago

From: shankar2k @.***> Date: Mon, 20 Nov 2023 03:42:59 -0800

Hi Prot,

Hello there!

I've been trying to preview a file in a temporary side window off and on for years, and then I came across your package, which solves the problem quite elegantly!

The core functionality is fine. Though I want to expand on it to handle large files.

I believe the functionality of previewing a file in this way can be easily generalized to other packages besides Dired.

You are right.

For example, I made a small package called Deft Preview which enables this kind of file previewing in Deft. Please feel free to take a look at it. To each achieve the preview functionality in Deft Preview, I made use of two of your functions: dired-preview-display-file and (breaking the abstraction) the private function dired-preview--close-previews. In addition, in my package, I duplicated the behavior of dired-preview--close-previews-outside-dired almost entirely, with the only difference being the major mode that I check for. I think that this common behavior could be capture in a smaller file preview library that could be leveraged by Dired Preview, my Deft Preview package, and perhaps others.

It looks that the philosophy in modern Emacs package development is to make packages small and complementary, such as in the Vertico-Consult-Orderless-Marginalia-Embark set of packages. If you agree with my idea of separating out a general file preview library, would you be interested in discussing it further?

I am happy to move things in that direction. Though I am not sure if it is easier to write a generic preview library or continue with what we have and then abstract from it. My problem right now is that I still have not had time to finalise the specific implementation to gracefully handle large files. Hopefully I can do it soon.

All the best, Prot

-- Protesilaos Stavrou https://protesilaos.com

shankar2k commented 10 months ago

I am happy to move things in that direction. Though I am not sure if it is easier to write a generic preview library or continue with what we have and then abstract from it. My problem right now is that I still have not had time to finalise the specific implementation to gracefully handle large files. Hopefully I can do it soon.

I agree, I think you should continue what what you have. Seeing your recent Emacs Advent Calendar post on Reddit, you clearly have a lot of your plate! I will try to better understand your code and maybe then I can propose a good way to abstract it.

protesilaos commented 5 months ago

Maybe we will do this in the future, but for now it is not actionable. The immediate goal is to get all the previews right. Then we can think about generalising it. Closing the issue. Thanks!