Emacs lisp lambda with lexical binding?
问题 I set out to write this code snippet for "git add -p": (add-hook 'diff-mode-hook (lambda() (mapc (lambda(k) (lexical-let ((kk k)) (define-key diff-mode-map k (lambda()(interactive) (if (region-active-p) (replace-regexp "^." kk nil (region-beginning) (region-end)) (insert kk)))))) (list " " "-" "+")))) It works as I want, it's just the ugliness of 'lexical-let in the middle that bothers me. I had to add it, since the nested lambda didn't see the variable 'k. Is there a better way to write this