计算.emacs时未启用词法绑定
以下是我的计算.emacs时未启用词法绑定,emacs,elisp,lexical-scope,Emacs,Elisp,Lexical Scope,以下是我的.emacs中的一些摘录: (setq lexical-binding t) ;; .emacs (custom-set-variables ;; custom-set-variables was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;;
.emacs
中的一些摘录:
(setq lexical-binding t)
;; .emacs
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(diff-switches "-u")
'(tab-always-indent (quote complete)))
;...
(require 'dired)
;...
(dotimes (i 12) (define-key dired-mode-map (kbd (concat "<f" (number-to-string (1+ i)) ">"))
(lambda ()
(interactive)
(goto-char (point-min))
(forward-line (+ 4 i)))))
(setq词法绑定t)
;; .emacs
(自定义设置变量)
;自定义设置变量由自定义添加。
如果你手工编辑,可能会把它弄糟,所以要小心。
;init文件应该只包含一个这样的实例。
如果不止一个,它们就不能正常工作。
'(差动开关“-u”)
'(制表符始终缩进(引用完整)))
;...
(需要“dired”)
;...
(dotimes(i 12)(定义键驱动模式映射(kbd(concat“”))
(lambda()
(互动)
(转到字符(最小点))
(前线(+4 i(())))
这应该将dired模式下的f1
键绑定到f12
,并将其绑定到文件列表中跳转到特定文件的命令(忽略
和。
)。然而,最初,在启动emacs之后,这些键不起作用-我收到一条错误消息转发行:符号作为变量的值为void:I
。但是,当我转到.emacs
的顶行并按C-x C-e计算该行,然后转到上面引用的最后一行并按C-x C-e计算该dotimes
表达式时,这些功能键开始工作
为什么呢
顺便说一句,如果我评估整个缓冲区,它也不起作用。结果是有必要替换
(setq lexical-binding t)
与
手册暗示了这一点,但实际上并没有直截了当地说出来。考虑提交一份文档错误报告:M-x report emacs bug
。一般规则是:永远不要做(setq词法绑定t)
,因为它可能不会做你认为的事情。(setq词法绑定t)
以上更改了缓冲区中词法绑定的值,该值在读取~/.emacs
时恰好是当前值,这很可能是*scratch*
。
;; -*- lexical-binding: t -*-