elisp であるメソッドを別のメソッドに渡し、そのメソッドにそれを実行させようとしています。次に例を示します。
(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)
まず、lispの真理値t
として「t」が使用されているため、関数に名前を付けることが役立つかどうかはわかりません。
そうは言っても、次のコードは私のために機能します:
(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」の使用に注意してください。
Emacs Lisp マニュアルの「 §13.7 Anonymous Functions」の末尾にある注記には、シンボルが常に関数の名前を付けていることをバイト コンパイラに通知する代わりに、 で関数をクォートできると書かれています。#'
'