summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2015-03-03 14:23:49 -0500
committerStefan Monnier <monnier@iro.umontreal.ca>2015-03-03 14:23:49 -0500
commit7133f262bbd818509825a3317c91e91e62bd56fb (patch)
tree182940a43f6f17d5ee5fbe339d27cdb40c503b0f /lisp/emacs-lisp
parentcecf4afebb394351a78c48d05e81a1e55af6da32 (diff)
downloademacs-7133f262bbd818509825a3317c91e91e62bd56fb.tar.gz
emacs-7133f262bbd818509825a3317c91e91e62bd56fb.tar.bz2
emacs-7133f262bbd818509825a3317c91e91e62bd56fb.zip
* lisp/progmodes/gud.el: Use lexical-binding.
Fixes: debbugs:19966 * lisp/emacs-lisp/gv.el (gv-ref): Warn about likely problematic cases.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/gv.el17
1 files changed, 14 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/gv.el b/lisp/emacs-lisp/gv.el
index 5d6e6e1b372..fae3bcb86f6 100644
--- a/lisp/emacs-lisp/gv.el
+++ b/lisp/emacs-lisp/gv.el
@@ -493,9 +493,20 @@ This is like the `&' operator of the C language.
Note: this only works reliably with lexical binding mode, except for very
simple PLACEs such as (function-symbol 'foo) which will also work in dynamic
binding mode."
- (gv-letplace (getter setter) place
- `(cons (lambda () ,getter)
- (lambda (gv--val) ,(funcall setter 'gv--val)))))
+ (let ((code
+ (gv-letplace (getter setter) place
+ `(cons (lambda () ,getter)
+ (lambda (gv--val) ,(funcall setter 'gv--val))))))
+ (if (or lexical-binding
+ ;; If `code' still starts with `cons' then presumably gv-letplace
+ ;; did not add any new let-bindings, so the `lambda's don't capture
+ ;; any new variables. As a consequence, the code probably works in
+ ;; dynamic binding mode as well.
+ (eq (car-safe code) 'cons))
+ code
+ (macroexp--warn-and-return
+ "Use of gv-ref probably requires lexical-binding"
+ code))))
(defsubst gv-deref (ref)
"Dereference REF, returning the referenced value.