如何在elisp中传递一个参数作为参数? [英] How do I pass a function as a parameter to in elisp?

查看:146
本文介绍了如何在elisp中传递一个参数作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在elisp中传递一个方法,然后
使该方法执行。这是一个例子:

I'm trying to pass one method to another in elisp, and then have that method execute it. Here is an example:

(defun t1 ()
  "t1")

(defun t2 ()
  "t1")

(defun call-t (t)
  ; how do I execute "t"?
  (t))

; How do I pass in method reference?
(call-t 't1)


推荐答案

首先,我不确定命名您的函数 t 正在帮助,因为't'被用作真值

First, I'm not sure that naming your function t is helping as 't' is used as the truth value in lisp.

说,以下代码适用于我:

That said, the following code works for me:

(defun test-func-1 ()  "test-func-1"
   (interactive "*")
   (insert-string "testing callers"))

(defun func-caller (callee)
  "Execute callee"
  (funcall callee))

(func-caller 'test-func-1)

请注意使用'funcall',触发实际的函数调用。

Please note the use of 'funcall', which triggers the actual function call.

这篇关于如何在elisp中传递一个参数作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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