Emacs:如何访问所有 sql 模式缓冲区并设置适当的 sql 缓冲区
我在 emacs 中 sql 模式的典型用法是
:打开 foo.sql 文件并开始编辑
b.决定我想使用 sql-send-region c 的键绑定来运行它
。启动我的自定义(db-connect)函数来连接到适当的数据库并创建一个 *SQL* 缓冲区。
但是 foo.sql 不知道 *SQL* 缓冲区的存在,除非我在缓冲区中执行“mx sql-mode”以刷新其环境并检测此时存在这样的缓冲区。我想在自定义 db-connect 函数中嵌入一些代码,以使用 sql-mode 访问所有缓冲区并更新 sql-buffer 变量。我确信有几个堆栈溢出成员之前一定做过这个或类似的事情。
谢谢,
SetJmp
My typical usage of sql-mode in emacs is to:
a. open a foo.sql file and begin editing
b. decide I want to run it using the key bindings for sql-send-region
c. fire up my custom (db-connect) function to connect to an appropriate db and create a *SQL* buffer.
However the foo.sql doesn't know about the existence of the *SQL* buffer unless I perform a "m-x sql-mode" in the buffer in order to refresh its environment and detect that such a buffer exists at this point. I would like to embed some code in my custom db-connect function to visit all buffers using sql-mode and update the sql-buffer variable. I am sure several stack overflow members must have done this or something similar before.
Thanks,
SetJmp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
快速查看 sql.el 文件会发现命令 sql-set-sqli-buffer-generally ,也许这适合您?
另一种处理方法是通过在主模式挂钩中调用
kill-local-variable
来终止sql-buffer
的缓冲区本地变体。 (这样,效果是所有 SQL 缓冲区都会与最新的 SQL 缓冲区通信。)免责声明:我对 SQL 或 SQL 模式一无所知,只了解 Emacs。
A quick look in the
sql.el
file revealed the commandsql-set-sqli-buffer-generally
, maybe this is something for you?Another way you could hand this is to kill the buffer-local variant of
sql-buffer
by callingkill-local-variable
in your major-mode hook. (That way, the effect would be that all SQL buffers would talk to the latest SQL buffer.)Disclaimer: I don't know anything about SQL or SQL mode, only Emacs in general.
我已经实现了这个小帮助函数来按主要模式过滤缓冲区。
您可以传递 'sql-mode 作为参数,您将获得所有打开的 sql 缓冲区的列表。
I've implemented this small helper function to filter buffers by their major-mode
You can pass 'sql-mode as the argument and you'll get a list of all open sql buffers.