且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Emacs的:有没有一种方法来创建使用Emacs一个交互式脚本?

更新时间:2023-11-03 19:13:16

看到emacswiki这个小黑客:提示在键盘宏执行。否则,你可以随时暂停宏,并在您给 C-×Q个定义过程中,请参阅Executing与变化宏的。最后,你可以定义一个函数,并使用interactive获得所需要的参数,即:

see this little hack on emacswiki: Prompting During Keyboard Macro Execution. Otherwise you can always pause a macro and insert you text execution at the points where you give C-x q during definition, see Executing Macros with Variations. Finally you can define a function and use interactive to get the required parameters, i.e.:

(defun my-build-query (table type field)
  (interactive "sTable name: \nsType of query: \nsFields to get: ")
  (message "%s (%s) from %s" type fields table)
)

您可以把这个功能在你的〜/的.emacs 执行它的Mx:我的构建查询

You could put this function in your ~/.emacs and execute it with M-x: my-build-query.

希望这给你一些三分球上手!

Hope this gives you some pointers to get started!

P.S:啊,还有一想法。对于这种东西可能更容易的方法是使用 YASnippet (看看页面上的截屏)。

P.S.: Ahh, and one more idea. The probably easier approach for this kind of stuff is to use YASnippet (have a look at the screencast on the page).