为了让中文输入法输入英文标点, 我做了如下设置:
(define-key evil-insert-state-map (kbd "=") (lambda () (interactive) (insert "=")))
(define-key evil-insert-state-map (kbd "-") (lambda () (interactive) (insert "-")))
(define-key evil-insert-state-map (kbd "・") (lambda () (interactive) (insert "`'")))
(define-key evil-insert-state-map (kbd "¥") (lambda () (interactive) (toggle-input-method) (insert-dollar-or-math-env)))
但我觉得这样写起来太重复, 我想写成一个循环.
(setq my/chinese-punctuation-alist '(("#" . "#")))
我写成:
(dolist (ele my/chinese-punctuation-alist)
(define-key evil-insert-state-map (kbd (car ele)) (lambda () (interactive) (insert (cdr ele)))))
这样不行, 原因是定义 lambda 的时候, 并没有对 (cdr ele) 求值. 等到执行这个 lambda 函数, 它会说找不到 ele. 我该如何改写呢?