Chobbes / org-chef

A package for making a cookbook and managing recipes with org-mode.
MIT License
327 stars 33 forks source link

Feature: Pantry #21

Open cartesian-theatrics opened 5 years ago

cartesian-theatrics commented 5 years ago

I just discovered this package and it's awesome, great work! One killer feature to me would be to have a separate list the the user maintains, call it the "pantry", where they put all the ingredients they currently have. Then, there is just a single command that runs through your recipes and puts a check-mark for any ingredients that you currently have. That would make it easy to tell which of your recipes you have the ingredients for and what you might want to shop for. Further, the little "ratio" indicator built into check-boxes would also give a great, quick indication of how close you are to being able to make that recipe.

My sense is you could get away with just fuzzy string matching, but there could be a variety of approaches here. If I get the chance, I may work on this feature myself and see how it works out. Would there be any interest in making it part of org-chef?

Regards, John

Chobbes commented 5 years ago

Yeah, this is something that I would love to have as well. I'm not sure if I will ever get around to implementing it myself (I think these are things which always sound really nice, but end up being tedious to use in practice --- but maybe you don't necessarily maintain a list of all the things you have but go "I have tomatoes and tofu, what do I make?"). Anyway, I'm always open to pull requests and would be delighted if somebody made an attempt at something like this :).

The main problem would of course just be matching up the ingredients, but also keeping track of amounts could be a problem if you wanted to do that due to all of the different ingredients. That said, maybe you just ignore quantities, and you can just skim the recipes and see if you have enough.

I'm not sure I would want checkboxes in my recipes for this, though. Maybe that would be fine, but I think I'd prefer to have some sort of agenda view or something.

It's also worth keeping in mind that some people like to use beorg / orgzly on their phones, and will look at the recipes there when shopping. It's worth keeping in mind exposing this information in these apps as well.

cartesian-theatrics commented 5 years ago

Thanks for the quick response. You're right this may end up being a yak shave, but I do kinda like the idea of, "here's everything I have, what can I make?". That is a situation I often find myself in, and it's a fairly tedious manual process if you have a good number of recipes. Who knows, may be worth a shot.

Chobbes commented 5 years ago

It's a common request from people, so it would probably be worth a shot! I'm not sure if I'll get around to it in the near future, but I'm 100% happy to make suggestions and accept pull requests :).

cartesian-theatrics commented 5 years ago

Okay, well I may take a shot at it in maybe a week or two. I don't have a lot of experience programming org, but we'll see how it goes. Thanks for your input, and I'm definitely open to any additional food for thought you might you have.

The agenda view idea is interesting, I'll have to look into that. One thing I like about the checkbox thing is that it can easily be viewed from the Orgzly mobile app. I don't think it's possible to have a custom agenda view in the app.

Chobbes commented 5 years ago

Yeah, the checkbox thing has that advantage with orgzly :). You can sort of have custom views in orgzly. Like there are custom searches, but yeah, it's not enough to build this view up. Having a separate pantry file listing what they have might be "good enough".

I'm personally not a huge fan of anything that does bulk changes to my org files (adding checkboxes and whatnot). Though, this is probably just because the things that I have used that do this either don't work / don't handle some edge-case for me! If it was nice and seamless I'd probably love it, haha :).

cartesian-theatrics commented 5 years ago

That's a good point, mutating org-tree may well be brittle. Another option is to have a command a bit like org-clock-report that generates a table in place with all the recipes filled out.

jmicahc commented 5 years ago

Finally got around to implementing the feature while on break, at least in crude form: https://github.com/jmicahc/org-chef/pull/1/files

For now, I just went with a checkbox based approach. We'll see if it ends up being useful. The feature could fairly easily be made to be completely opt-in, but I took license in my fork to slightly modify the recipe template to support a TAG view of all the recipes which allows you to quickly see (1) the size of each recipe and (2) the number of ingredients currently in your pantry.

Feedback is more than welcome (including on style - elisp and the incredibly imperative programming model definitely goes against the grain for me), but may or may not have time to work on this in the future (depending on if it ends up being useful).

jmicahc commented 5 years ago

fyi - @cartesian-theatrics is my work account. Same person.

Chobbes commented 5 years ago

Oh, awesome! I'll take a peek at this and how it works when I get the chance, but I wanted to say thanks for trying this right away!

I'm not 100% sure how I feel about modifying the recipe template. Looks like you added the [3/5] checkbox total thing, I'll have to see what else changed. It might be good if we can make it optional / make it easy to convert between the formats. It's nice that it seems like it isn't a huge change, though!

Chobbes commented 5 years ago

Also, feel free to send an actual pull request! Might make sense to get that started and then we can modify that from there.

jmicahc commented 5 years ago

Thanks! Other than adding the checkbox total, the only change to the template is removing the "Ingredients" headline. The reason for that change was so that the checkbox total could be displayed next to the recipe title. There's probably a better, more compatible solution here. I'll go ahead and open a PR after cleaning it up a tad.