[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding proble
From: |
Stefan Monnier |
Subject: |
bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?) |
Date: |
Sat, 14 Apr 2012 08:47:09 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux) |
>> You don't get that error when you use the compiled code, however.
> Stefan, I can "fix" this for 24.1 just by making emacs-lock.el not use
> lexical-binding. But is this difference between compiled and
> non-compiled code a bug in the lexical-binding support or something
> expected?
IIRC the problem is that it's not clear whether (<function> <args>)
should treat <function> as an expression or a value.
The compiler handles such as call like (funcall #'<function> <args>)
whereas the interpreter handles it like (funcall '<function> <args>).
In dynamically scoped Elisp, there is no difference between the two, but
not with lexical scoping.
The patch below should work around the difference.
Note that using define-minor-mode's `arg' is not recommended
[ But no, I don't have a good replacement to suggest, other than to
split the code into two functions, one behaving as a normal boolean
minor mode and the other accepting the extra possible values. ]
Stefan
=== modified file 'lisp/emacs-lisp/easy-mmode.el'
--- lisp/emacs-lisp/easy-mmode.el 2012-02-25 05:53:29 +0000
+++ lisp/emacs-lisp/easy-mmode.el 2012-04-14 12:41:01 +0000
@@ -260,7 +260,7 @@
;; repeat-command still does the toggling correctly.
(interactive (list (or current-prefix-arg 'toggle)))
(let ((,last-message (current-message)))
- (,@(if setter (list setter)
+ (,@(if setter `(funcall #',setter)
(list (if (symbolp mode) 'setq 'setf) mode))
(if (eq arg 'toggle)
(not ,mode)