'作为变量的符号值是无效的:'在 lambda 内部的 defun 上使用参数时
'Symbol's value as variable is void:' when using parameter on defun inside lambda
我想让这个功能更短一些。
(defun defkey-arg2 ()
(exwm-input-set-key (kbd "s-g")
(lambda ()
(interactive)
(start-process-shell-command gkamus nil gkamus))))
然后我用 2 个参数(按键绑定和应用程序名称)编写较短的函数
(defun defkey-arg2 (key command) (...)
当我尝试将密钥作为参数时,它会起作用
(defun defkey-arg2 (key)
(exwm-input-set-key (kbd key)
(lambda ()
(interactive)
(start-process-shell-command gkamus nil gkamus))))
(defkey-arg2 "s-g")
但是,当我尝试编写这样的函数时
(defun defkey-arg2 (key command)
或
(defun defkey-arg2 (command)
(exwm-input-set-key (kbd "s-g")
(lambda ()
(interactive)
(start-process-shell-command command nil command)))
(defkey-arg2 "gkamus")
它引发错误:
Symbol's value as variable is void:' when using parameter on defun
lambda
的正文未被评估。使用反引号,command
的值可以代入结果表达式。
(defun defkey-arg2 (command)
(define-key (current-local-map)
(kbd "s-g")
`(lambda ()
(interactive)
(start-process-shell-command ,command nil ,command))))
我想让这个功能更短一些。
(defun defkey-arg2 ()
(exwm-input-set-key (kbd "s-g")
(lambda ()
(interactive)
(start-process-shell-command gkamus nil gkamus))))
然后我用 2 个参数(按键绑定和应用程序名称)编写较短的函数
(defun defkey-arg2 (key command) (...)
当我尝试将密钥作为参数时,它会起作用
(defun defkey-arg2 (key)
(exwm-input-set-key (kbd key)
(lambda ()
(interactive)
(start-process-shell-command gkamus nil gkamus))))
(defkey-arg2 "s-g")
但是,当我尝试编写这样的函数时
(defun defkey-arg2 (key command)
或
(defun defkey-arg2 (command)
(exwm-input-set-key (kbd "s-g")
(lambda ()
(interactive)
(start-process-shell-command command nil command)))
(defkey-arg2 "gkamus")
它引发错误:
Symbol's value as variable is void:' when using parameter on defun
lambda
的正文未被评估。使用反引号,command
的值可以代入结果表达式。
(defun defkey-arg2 (command)
(define-key (current-local-map)
(kbd "s-g")
`(lambda ()
(interactive)
(start-process-shell-command ,command nil ,command))))