kiwanami / emacs-edbi

Database Interface for Emacs Lisp
350 stars 34 forks source link

Unable to save query editor file content to file. #32

Closed proofit404 closed 9 years ago

proofit404 commented 9 years ago

It is really handy use find-file and save-buffer functionally with query editor buffers. Currently I use insert-file and manually copy-paste edited content back to the opened file buffer.

kiwanami commented 9 years ago

Will you teach me some use-case?

proofit404 commented 9 years ago

Sure.

Example one.

We write some event logs in our database. Fox example traceback in background worker. I have few SQL scripts which make some analytic on this data. I often need open some of this file, correct some conditions, save file, insert file content into db query editor. I repeat this sequence few times until I got satisfactory query result.

Example two.

We have SQL files with database scheme. When I correct any of this file most of times I need execute only one paragraph from this file. Every time I need to execute paragraph, I manually copy it to query editor file.

Possible solution.

I think we can add query editor minor mode which will mimic default SQL send commands. But instead of product interactive will bind this buffer to the db viewer or open connection buffer. This behavior is similar to slime when you send only part of the file to the inferior lisp process.

Maybe there is a reason to replace query editor major mode with minor mode at all. If we press c or C in db viewer we can simply open new SQL buffer bind to that db viewer. In this case we doesn't need query editor history at all because this will handled by Emacs default undo or undo-tree systems.

proofit404 commented 9 years ago

If you doesn't interesting in this solution I can implement this as external minor-mode.

kiwanami commented 9 years ago

Hi @proofit404 Thank you for your report for use-cases and I'm sorry for my late response.

I recognize these use-cases but I'm not sure what solution is the best. I'm just using edbi's query buffer, but I heard some people want to send a SQL fragment from the string literal in code buffers. Your minor mode idea is great. It would reduce the moving cost between edbi's query buffer and other buffers. If you could implement it, it would be welcome!

proofit404 commented 9 years ago

In case of send a SQL fragment from the string literal in code buffers this can be implemented with second minor mode (something like edbi-code-mode). I think we need to simplify api also. Make it looks like cl-dbi for example.

I'd like to contribute following:

If you think this changes can make sense to the project I can implement each of it part by part. I can start after new year holidays.

kiwanami commented 9 years ago

That's great! I also think that we could make a smart DB API for emacs lisp. Well, I think this is big project. I would help you as much as possible.

I'm sorry for my slow response because of my full-time job and other projects.

proofit404 commented 9 years ago

I totally agree with you. I have full-time job and bunch of projects on github. Its very difficult to work 12 hours per day. But I use edbi every day at my full-time job. I want to improve it. I'll try my best to implement features above.

First commit can take long time for me because I'll need to learn much background. Perl, epc, ctable for example. I'll create PR with first changes nearly twentieth of January.

proofit404 commented 9 years ago

Hello one more time. I think about best order to implement mentioned features. Most of it will depend on api design. I think that better way to implement each part separately and then plan api on all those needs. After api impementation we can merge all project all together. So I close this issue for now.

kiwanami commented 9 years ago

Hi @proofit404 I think that is better too.

Thank you.