Emacs的:有没有一种方法来创建使用Emacs一个交互式脚本? [英] Emacs: Is there a way to create a interactive script using Emacs?

查看:126
本文介绍了Emacs的:有没有一种方法来创建使用Emacs一个交互式脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Emacs,但在震惊什么,我真的可以做,多少时间可以节省(宏节省大量的时间)。但我不知道这是可能创造基于脚本一步它会要求用户输入并执行基于code。例如,也许我想创建一个SQL查询所以会提示是这样的:

I am new to emacs, but shocked at what I can really do and how much time it saves (Macros save A LOT of time). But I was wondering it was possible to create step based scripts where it asks the user for input and executes code based on that. For example maybe I want to create a SQL query so it would prompt something like:

>table name?
myTable
>type of query (select, insert, update, delete)
select
>fields to get
name, id
>Result query is "select (name, id) from myTable"

这只是一个想法的轮廓,但我奇怪,因为这样的事情将是有有益的。有人提到AWK脚本,但我不知道这是正确的树树皮或没有。我在Windows上,但我不认为重要的一大堆。

This is just an outline of an idea but I was wonder because something like this would be useful to have. Someone mentioned AWK scripts but I wasn't sure if that was the right tree to bark up or not. I am on Windows but I don't think that matters a whole lot.

我绝对AP preciate这个任何信息,谢谢

I definitely appreciate any info on this, Thanks

推荐答案

看到emacswiki这个小黑客:提示在键盘宏执行。否则,你可以随时暂停宏,并在您给 C-×Q个定义过程中,请参阅<一个点插入文本你执行href=\"http://www.gnu.org/software/emacs/manual/html_node/emacs/Keyboard-Macro-Query.html#Keyboard-Macro-Query\">Executing与变化宏的。最后,你可以定义一个函数,并使用<一个href=\"http://www.gnu.org/s/emacs/manual/html_node/elisp/Using-Interactive.html#Using-Interactive\">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).

这篇关于Emacs的:有没有一种方法来创建使用Emacs一个交互式脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆