You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most of the tools for interacting with Postgres on Emacs usually do not format the tables properly and lack that interactive feel of a Lisp Machine. I think this project is the perfect candidate for that!
Scope
Here I try to implement a script interface where you can either open or type your own SQL queries in a buffer, and eval specifically the ones you selected, without copying and pasting on the minibuffer, or having it all by itself on a buffer via e and E.
How it is implemented
I made a new mode called pgmacs-script-mode that is a minor mode of a buffer with its major mode as sql-mode. Then I made an action called pgmacs--script that passes over the local variables to the script buffer.
The main limitation I found to open arbitrary files would be passing over the local variables. Using (sql-mode) instead of (pgmacs-script-mode) in pgmacs--script simply overrides the connection, so it seems like I need an extension of pgmacs-mode. I also wanted to experiment with lsp-mode and how it behaves using the same connection.
Notes
Please do provide criticism if the feature is desirable and if we should redesign the idea. I would be very eager to have it properly implemented;
I still have not finished documenting as I don't know if the idea is sound.
@emarsden could you please share your input here? I would like to know if you want this feature in your package, and if so, what would be the way forward with this?
Also, great work so far. I am very glad you started this effort
I think you could implement pgmacs-run-sql-region and perhaps pgmacs-run-buffer-sql to also work in a random buffer (opened with find-file). Add a global variable pgmacs--connections to which the pgmacs--con buffer-local variable is added whenever a new PGmacs connection is created. In pgmacs-run-sql-region & friends, ask the user which connection to use if the list pgmacs--connections contains more than a single element.
Probably the underlying pgmacs-run-sql should behave in a nicer manner for SQL that returns an empty row set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Most of the tools for interacting with Postgres on Emacs usually do not format the tables properly and lack that interactive feel of a Lisp Machine. I think this project is the perfect candidate for that!
Scope
Here I try to implement a script interface where you can either open or type your own SQL queries in a buffer, and eval specifically the ones you selected, without copying and pasting on the minibuffer, or having it all by itself on a buffer via
eandE.How it is implemented
I made a new mode called
pgmacs-script-modethat is a minor mode of a buffer with its major mode assql-mode. Then I made an action calledpgmacs--scriptthat passes over the local variables to the script buffer.The main limitation I found to open arbitrary files would be passing over the local variables. Using
(sql-mode)instead of(pgmacs-script-mode)inpgmacs--scriptsimply overrides the connection, so it seems like I need an extension ofpgmacs-mode. I also wanted to experiment withlsp-modeand how it behaves using the same connection.Notes