Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zetteldeft-new-file-hook? #78

Closed
TRSx80 opened this issue Aug 25, 2020 · 2 comments
Closed

Add zetteldeft-new-file-hook? #78

TRSx80 opened this issue Aug 25, 2020 · 2 comments

Comments

@TRSx80
Copy link

TRSx80 commented Aug 25, 2020

Hi EFLS,

I finally got 'round to installing Zetteldeft and I been playing around with it last night and today. I think you might be right when you said you thought it would cover all my needs. 😄

I installed by cloning repo and doing package-install-from-buffer so as to make contributing easier. I suppose I would rather contribute to an existing project than re-invent the wheel from scratch. Of course I will have some personalized stuff on top which might not be appropriate for inclusion into Zetteldeft, which I may or may not publish separately. Anyway, I'm rambling a bit, back to the topic...

I thought it would be useful to have a zetteldeft-new-file-hook added near the end of zetteldeft-new-file. There is already deft-open-file-hook, (which I use) however I encountered a problem...

It seems that the order things get called is:

  1. zetteldeft-new-file calls deft-new-file-named
  2. ... which in turn calls deft-open-file
  3. ... inside of which run-hooks(deft-open-file-hook) is called

Now, I have some custom hooks that do some things automatically whenever opening a deft file. Problem here is, the buffer is empty right at this moment, because the part of zetteldeft-new-file that inserts the title hasn't happened yet. So it errors out, and never inserts the title into the newly created file buffer.

My first thought, was that the easy way to fix this would be to do as stated in title. But maybe you have some better or different idea.

Because, thinking about it, then in my-deft-open (personalized hook function) I would need to check first if the buffer is empty, in order to handle this case of being called from zettledeft-new-file while still being able to handle the other case where it gets called from opening an already existing note file (eg. from Deft interface, i.e., the regular deft-open-file-hook). Well, those would be my own problems I guess. 😄 Regardless of which, I still think this would be a good feature for Zetteldeft.

In general my thought is to maintain some personal things that cleanly apply on top of Zetteldeft, which in turn will cleanly apply on top of Deft. And I suspect you probably think the same way. Which is why I thought maybe better to discuss it first, than to simply open a PR, even though it's likely only a one liner.

In addition, there are of course other use cases besides mine. For example, initializing a new node could be solution to #77, and many other use cases, as I am sure you can imagine. Which is why I propose this in Zetteldeft, instead of just in my own stuff on top, even though the latter would likely be easier/quicker for me to implement (and I will be doing in meantime, probably).

Cheers! 🍻

@TRSx80
Copy link
Author

TRSx80 commented Aug 29, 2020

For my part, you can close this if you want. Unless you want to perhaps gather other feedback, or keep considering it, or whatever. Up to you.

For anyone else coming along later, who might be interested in this sort of feature, I plan on implementing it in a separate software package I recently started working on.

I finally realized that I had some slightly different ideas than this project (which is fine; I really enjoyed my (brief) time here!) and in fact I announced it over in this post. Since that is in some obscure offtopic and already closed thread, I decide to link it here.

If you are interested in any of the features I have been discussing in any of these issues, please subscribe to that other thread as I plan on making my initial (soft) release of my package there, as soon as I feel it is ready.

Cheers!

@EFLS
Copy link
Owner

EFLS commented Sep 20, 2020

It might make sense to include a zetteldeft-new-file-hook, separate from the Deft counterpart for the reasons you mention.

However, I am closing this issue because it seems very specific to your use case, which you'll now tackle in a separate package. Best of luck with it!

Now if other people require a new file hook, feel free to open a separate issue and we can discuss the details there.

@EFLS EFLS closed this as completed Sep 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants