当某些库可能因设计而丢失时,处理“警告:分配给自由变量”
我的模式的字节编译: (defun dict-setup-expansions () "Add `dict-mode' specific expansions." (set (make-local-variable 'er/try-expand-list) (list #'dict-mark-article))) 给出警告: Warning: assignment to free variable `er/try-expand-list' 这是正常情况,因为er/try-expand-list是在externa中定义的;库expand-region位于http://elpa.gnu.org 我的模式将扩展名注册到expand-region库,但是可以在没有expand-region模式的情况下运行我的模式。 我认为处理警告的正确方法是添加声明: (defvar er/try-expand-list) defvar 文档说: The `defvar' form also declares the variable as "special", so that it is always dynamically bound even if `lexical-binding' is t. 我用-*- lexical-binding: …