我是elisp的新手.http://www.gnu.org/s/emacs/manual/html_node/elisp/Interactive-Codes.html#Interactive-Codes列出交互式参数的"代码字符",AFAIK在提示时修改输入机制的行为用户输入(例如:如果您指定输入是存在的文件名,emacs的自动完成功能将查找存在的文件名).
我试图找到一个已经存在的书签名称的代码 - 即:Emacs会提示用户输入一个书签名称,并在压片Emacs会显示可能的书签名称的完成.
这样的代码存在吗?
我对存储库模式和依赖注入很新.我遇到的几乎所有存储库模式都有某种GetAll()方法,如下所示:
public interface IRepository<T>
{
IQueryable<T> GetAll();
// other CRUD methods here...
}
Run Code Online (Sandbox Code Playgroud)
我在实现此接口和GetAll()方法时遇到问题,因为我正在调用一个存储过程,该存储过程需要一个基于用户输入而更改的参数.我不想在存储库接口中添加ad-hoc方法,例如IQueryable<T> GetAll(string input);.我也不想在构造函数中添加一个参数,因为它对我来说有点乱:
public class ConcreteRepository : IRepository<Entity>
{
string _storedProcedureInput;
public ConcreteRepository(string storedProcedureInput)
{
_storedProcedureInput = storedProcedureInput;
public IQueryable<Entity> GetAll()
{
// Call to stored procedure goes here passing in the
// _storedProcedureInput variable.
}
}
Run Code Online (Sandbox Code Playgroud)
我也使用依赖注入,所以我必须在绑定时向构造函数添加一些动态输入:
Bind<IRepository<Entity>>().To<ConcreteRepository>().WithConstructorArgument(?)
Run Code Online (Sandbox Code Playgroud)
有什么建议?
更新:
我想重用IRepository接口.例如,在一个程序中,我使用EF4实现GetAll()方法,而在另一个程序中,我使用标准ADO.NET来调用存储过程,如上例所示.
c# stored-procedures dependency-injection repository-pattern
我广泛使用缓冲区菜单在缓冲区之间切换.我想列出文件或dired的缓冲区.我怎样才能做到这一点?
这个问题并不是要找到一个解决方案,而是要解释我从SQL Server中看到过的奇怪行为.
我有一个带有以下签名的存储过程:
alter procedure MySP @param1 uniqueidentifier,
@param2 uniqueidentifier,
@param3 uniqueidentifier
Run Code Online (Sandbox Code Playgroud)
给定一组参数,这个过程需要很长时间才能从C#(使用SqlCommand.ExecuteReader())运行 - 大约2分钟.在直接查询会话中使用相同的参数,SP在2秒内运行.
花了很长时间,我甚至不会试图解释我们如何偶然发现这个解决方案,但这就是我们所做的:
在SP的开头,我们声明了3个局部变量并将它们分配给参数的值,如下所示:
declare @param1_copy uniqueidentifier,
@param2_copy uniqueidentifier,
@param3_copy uniqueidentifier
select @param1_copy = @param1,
@param2_copy = @param2,
@param3_copy = @param3
Run Code Online (Sandbox Code Playgroud)
然后,在SP的其余部分,我们用本地副本替换对输入参数的所有引用.
瞧.SP在2秒内执行.这里的团队非常棒.
现在,女士们,先生们,任何人都可以解释这种行为吗?
Bob Glickstein 在“编写 GNU Emacs 扩展”的第 3 章中描述了一种建议滚动功能的方法。(他建议让它们可逆,所以我们必须在滚动之前保存状态。)
例如,对于向上滚动命令,此建议是这样完成的
(defadvice scroll-up-command (before reversibilate activate compile)
"If it wants to be reversible, it must save the former state."
(save-before-scroll))
Run Code Online (Sandbox Code Playgroud)
好。我当然必须对所有滚动命令执行此操作。所以我想对它们进行排序,并想一起为它们提供建议。
(setq reversible-scroll-commands
[scroll-up-command
scroll-down-command
scroll-left-command
scroll-right-command])
Run Code Online (Sandbox Code Playgroud)
(我使用一个向量来保存 5 个引号。)
但现在我被困住了。
(mapcar
(lambda (fun-name)
(defadvice fun-name (before reversibilate activate compile)
"If it wants to be reversible, it must save the former state."
(save-before-scroll)))
reversible-scroll-commands)
Run Code Online (Sandbox Code Playgroud)
将建议(不存在的)函数 fun-name 四次,因为 defadvice 是一个宏,并且不评估 fun-name。
有什么办法吗?
(我正在使用 Emacs 24)
我试图定义一个结构,其中包含我想知道的一些属性,以及基本结构不需要的任意数量的其他属性.
(defstruct (node (:type list)) label [other args here])
Run Code Online (Sandbox Code Playgroud)
我知道你可以在一个函数中做到:
(defun foo (arg1 &rest args) ...)
Run Code Online (Sandbox Code Playgroud)
有某种&rest等价物defstruct吗?
我只是在学习口齿不清,所以我有一种感觉,我错过了一些东西.如果没有&rest相应的,关于我如何去做这个的任何想法?提前致谢!
如何在Emacs的lisp模式中突出显示所有函数的名称?我希望他们加粗.
换句话说,所有的单词从(第一个到第一个space.不要关心例外(a . b)
就像GitHub一样:

假设我有两个列表,((1 2 3))并且(((1 2 3)) ((4 5))).我希望能够判断第一个列表是否是第二个列表的成员.我试图使用subsetp,但它不会为此查询返回true.我怎么能做到这一点?
当您将文本从一个缓冲区复制到另一个缓冲区(Mw和Cy)时,它会使用font-lock复制文本,当您粘贴它时,它会显示缓冲区中的颜色并复制文本.是否可以更改它以使用新缓冲区中的字体显示?
我使用异步来调用elisp中的异步函数.
首先,我在github上测试自述文件代码并且运行良好.
然后我写了一个测试代码:
(defun async-function ()
(async-start
;; What to do in the child process
(lambda ()
(shell-command-to-string "~/test.sh"))
;; What to do when it finishes
(lambda (result)
(message "Async process done, result is: %s" result)))
Run Code Online (Sandbox Code Playgroud)
test.sh代码非常简单:
#! /usr/bin/env sh
sleep 2
echo "shell finish"
Run Code Online (Sandbox Code Playgroud)
它可以工作,但是当我改变这样的lisp代码时失败了:
;;;###autoload
(defun test ()
(shell-command-to-string "~/test.sh"))
(defun async-function ()
(async-start
;; What to do in the child process
(lambda ()
(test))
;; What to do when it finishes
(lambda (result)
(message "Async process done, …Run Code Online (Sandbox Code Playgroud) emacs ×6
elisp ×4
lisp ×3
c# ×2
common-lisp ×2
asynchronous ×1
bookmarks ×1
colors ×1
defadvice ×1
font-lock ×1
membership ×1
structure ×1