emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DocView AutoFitting via "doc-view-autofit-mode"


From: Stefan Monnier
Subject: Re: DocView AutoFitting via "doc-view-autofit-mode"
Date: Wed, 25 Apr 2012 23:19:13 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.94 (gnu/linux)

>>>>> "Stefan" == Stefan Monnier <address@hidden> writes:

>> Hm, I seem to have expressed myself a bit poorly,
>> so let me clear it up:

>>> ;;; foo.el --- Foo -*- lexical-binding: t -*-
>>> 
>>> (defun foo (window)
>>> (message "%s" window))
>>> 
>>> (defun bar ()
>>> (interactive)
>>> (lexical-let ((foobar (selected-window)))
>>> (foo foobar)))

> Ah, thanks, I understand now.  Sorry, for reading your earlier message
> without enough care.  So the problem has nothing to do with "named
> functions".  You can just use

>   (lexical-let ((foobar (selected-window)))
>     (message "hello %s" foobar))

> in a lexical-binding buffer to reproduce the problem.  Indeed, it seems
> that lexical-let doesn't work with lexical-binding.  Not a big deal, but
> we should at least try to signal it in a way that's less cryptic.

I've just installed the patch below in the trunk, which fixes
the problem.


        Stefan


--- lisp/emacs-lisp/cl-macs.el  2012-01-19 07:21:25 +0000
+++ lisp/emacs-lisp/cl-macs.el  2012-04-26 01:25:25 +0000
@@ -1488,13 +1488,19 @@
                  (list '(defun . cl-defun-expander))
                  cl-macro-environment))))
     (if (not (get (car (last cl-closure-vars)) 'used))
-       (list 'let (mapcar (function (lambda (x)
-                                      (list (caddr x) (cadr x)))) vars)
-             (sublis (mapcar (function (lambda (x)
+        ;; Turn (let ((foo (gensym))) (set foo <val>) ...(symbol-value foo)...)
+        ;; into (let ((foo <val>)) ...(symbol-value 'foo)...).
+        ;; This is good because it's more efficient but it only works with
+        ;; dynamic scoping, since with lexical scoping we'd need
+        ;; (let ((foo <val>)) ...foo...).
+       `(progn
+           ,@(mapcar (lambda (x) `(defvar ,(caddr x))) vars)
+           (let ,(mapcar (lambda (x) (list (caddr x) (cadr x))) vars)
+           ,(sublis (mapcar (lambda (x)
                                          (cons (caddr x)
-                                               (list 'quote (caddr x)))))
+                                    (list 'quote (caddr x))))
                              vars)
-                     ebody))
+                    ebody)))
       (list 'let (mapcar (function (lambda (x)
                                     (list (caddr x)
                                           (list 'make-symbol




reply via email to

[Prev in Thread] Current Thread [Next in Thread]