unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12938: 24.2; Lexical binding leaks into package-install somehow
@ 2012-11-19 21:07 Magnar Sveen
  2012-11-20 18:53 ` Glenn Morris
  2012-11-23 21:31 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Magnar Sveen @ 2012-11-19 21:07 UTC (permalink / raw)
  To: 12938

[-- Attachment #1: Type: text/plain, Size: 13338 bytes --]

Create a test.el file with these contents:

    ;;; -*- lexical-binding: t -*-

    (add-to-list 'package-archives '("melpa" . "
http://melpa.milkbox.net/packages/") t)
    (package-initialize)
    (package-refresh-contents)
    (package-install 'multiple-cursors)

And load it. Notice that the compiler warnings includes:

    assignment to free variable `strings'

Remove multiple-cursors from .emacs.d/elpa, change lexical-binding to
nil, and load the file again.

Notice that the compiler warning about 'strings' does not show up.

In other words, the lexical binding in test.el leaks into the
installation of multiple-cursors.

Here is the code in question that generates the warning:

    (defun mc/region-strings ()
      (let ((strings (list (buffer-substring-no-properties (point)
(mark)))))
        (mc/for-each-fake-cursor
         (add-to-list 'strings (buffer-substring-no-properties
                                (mc/cursor-beg cursor)
                                (mc/cursor-end cursor))))
        strings))

    (defmacro mc/for-each-fake-cursor (&rest forms)
      "Runs the body for each fake cursor, bound to the name cursor"
      `(mapc #'(lambda (cursor) ,@forms)
             (mc/all-fake-cursors)))




In GNU Emacs 24.2.1 (x86_64-apple-darwin10.8.0, NS apple-appkit-1038.36)
 of 2012-09-04 on fi-bp-202.local
Windowing system distributor `Apple', version 10.3.1038
Configured using:
 `configure '--prefix=/usr/local/Cellar/emacs/24.2' '--without-dbus'
 '--enable-locallisppath=/usr/local/share/emacs/site-lisp'
 '--infodir=/usr/local/Cellar/emacs/24.2/share/info/emacs' '--with-ns'
 '--disable-ns-self-contained' 'CC=/usr/bin/gcc-4.2' 'CFLAGS=-Os -w
 -pipe -march=core2 -msse4 -mmacosx-version-min=10.6'
 'LDFLAGS=-L/usr/local/lib''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-auto-refine-mode: t
  elisp-slime-nav-mode: t
  show-paren-mode: t
  global-hl-line-mode: t
  ido-ubiquitous-mode: t
  wrap-region-global-mode: t
  wrap-region-mode: t
  persp-mode: t
  yas/global-mode: t
  yas/minor-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-subword-mode: t
  subword-mode: t
  shell-dirtrack-mode: t
  recentf-mode: t
  delete-selection-mode: t
  global-auto-revert-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<down> <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <left> <C-left> <C-left> <C-left>
<C-left> <C-left> <C-left> <C-right> <right> <right>
<up> <right> <C-right> <C-right> <C-right> <C-right>
<C-right> <C-right> <C-right> <C-right> <C-left> M-w
q <up> <up> <up> <up> <return> C-y <return> C-_ C-_
C-_ <down> <down> <up> <up> <return> C-y C-_ C-_ <down>
<up> <return> C-y <return> <up> <up> M-j <down> C-k
<down> <down> <down> C-x C-s C-x C-f e l p <backspace>
<backspace> <backspace> . e m <return> e l <return>
C-d <down> <down> <down> <down> <down> <down> <down>
<down> <down> <down> <down> <down> <down> <down> <down>
D y y <up> <up> <up> q <up> <up> <up> <up> <up> <left>
<left> <left> <left> <left> <backspace> n i l <down>
<down> <down> <down> <down> <down> C-x C-s M-: <up>
<return> y <S-right> C-s s t r i n g s C-s C-s C-s
<up> <up> <up> <up> <up> <home> C-x k <return> C-x
0 <up> <up> <up> <up> <up> <left> <C-left> C-d C-d
C-d t <down> <down> <down> <down> <down> <down> <down>
<up> <up> <up> <up> <up> <up> <backspace> n i l C-x
C-s <down> <down> <down> <down> <down> C-x f e l p
C-g C-x C-f <return> <return> C-d g <down> <down> <down>
<up> <down> D y y q <down> C-x C-s M-: <down> <up>
<return> y <S-right> <end> <home> <end> <home> C-s
s t r i n g s C-s C-s C-s <down> <down> <up> <up> C-x
k y <backspace> <return> C-x 0 <up> <up> <up> <up>
<up> <C-left> M-d t C-x C-s <down> <down> <down> <down>
C-x C-f <return> <return> C-d f q g <up> D y y q M-:
<up> <return> y <S-right> q <down> <down> C-SPC <C-up>
<C-up> M-w <down> <down> <down> <down> <down> <down>
<down> M-x r e p o r t - <return>

Recent messages:
Compiling
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/multiple-cursors.el...done
Wrote
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/multiple-cursors.elc
Checking /Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110...
Compiling
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/rectangular-region-mode.el...done
Wrote
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/rectangular-region-mode.elc
Checking /Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110...
Done (Total of 7 files compiled, 1 skipped)
Loading /Users/fimasvee/test.el (source)...done
t
Mark set
line-move-visual: End of buffer

Load-path shadows:
/Users/fimasvee/.emacs.d/elpa/php-mode-20121015.6/php-mode hides
/Users/fimasvee/.emacs.d/site-lisp/php-mode/php-mode
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/rectangular-region-mode
hides
/Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/rectangular-region-mode
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/multiple-cursors
hides /Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/multiple-cursors
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/multiple-cursors-pkg
hides
/Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/multiple-cursors-pkg
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/multiple-cursors-core
hides
/Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/multiple-cursors-core
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/mc-mark-more
hides /Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/mc-mark-more
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/mc-edit-lines
hides /Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/mc-edit-lines
/Users/fimasvee/.emacs.d/elpa/multiple-cursors-20121118.2110/mc-cycle-cursors
hides /Users/fimasvee/.emacs.d/site-lisp/multiple-cursors/mc-cycle-cursors
/Users/fimasvee/.emacs.d/site-lisp/s/examples hides
/Users/fimasvee/.emacs.d/site-lisp/dash/examples
/Users/fimasvee/.emacs.d/site-lisp/s/examples-to-tests hides
/Users/fimasvee/.emacs.d/site-lisp/dash/examples-to-tests
/Users/fimasvee/.emacs.d/site-lisp/s/examples-to-docs hides
/Users/fimasvee/.emacs.d/site-lisp/dash/examples-to-docs
/Users/fimasvee/.emacs.d/site-lisp/s/ert hides
/Users/fimasvee/.emacs.d/site-lisp/dash/ert
/Users/fimasvee/.emacs.d/site-lisp/fill-column-indicator/fill-column-indicator
hides /Users/fimasvee/.emacs.d/site-lisp/fill-column-indicator
~/.emacs.d/users/fimasvee/init hides /Users/fimasvee/.emacs.d/init
/Users/fimasvee/.emacs.d/elpa/magit-20121030.2025/rebase-mode hides
/usr/local/share/emacs/site-lisp/rebase-mode
/Users/fimasvee/.emacs.d/site-lisp/delsel/delsel hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/delsel
/Users/fimasvee/.emacs.d/custom hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/custom
/usr/local/share/emacs/site-lisp/trampver hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/trampver
/usr/local/share/emacs/site-lisp/tramp hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp
/usr/local/share/emacs/site-lisp/tramp-uu hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-uu
/usr/local/share/emacs/site-lisp/tramp-smb hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-smb
/usr/local/share/emacs/site-lisp/tramp-sh hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-sh
/usr/local/share/emacs/site-lisp/tramp-loaddefs hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-loaddefs
/usr/local/share/emacs/site-lisp/tramp-gw hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-gw
/usr/local/share/emacs/site-lisp/tramp-ftp hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-ftp
/usr/local/share/emacs/site-lisp/tramp-compat hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-compat
/usr/local/share/emacs/site-lisp/tramp-cmds hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-cmds
/usr/local/share/emacs/site-lisp/tramp-cache hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/net/tramp-cache
/Users/fimasvee/.emacs.d/elpa/magit-20121030.2025/.dir-locals hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/gnus/.dir-locals
/Users/fimasvee/.emacs.d/site-lisp/s/ert hides
/usr/local/Cellar/emacs/24.2/share/emacs/24.2/lisp/emacs-lisp/ert

Features:
(shadow sort mail-extr emacsbug message rfc822 mml mml-sec mm-decode
mm-bodies mailabbrev gmm-utils mailheader sendmail
multiple-cursors-autoloads tar-mode sh-script executable term ehelp
electric pp timezone cus-edit cus-start cus-load octomacs
setup-ruby-mode ruby-mode-expansions ruby-mode markdown-mode mule-util
cal-move octomacs-autoloads autoload mail-utils parse-time
network-stream starttls url-cache url-http tls url-gw url-auth url
url-proxy url-privacy url-expand url-methods url-history url-cookie
yaml-mode find-dired vc ediff-merg ediff-diff ediff-wind ediff-help
ediff-util ediff-mult ediff-init ediff vc-dispatcher rebase-mode rx
conf-mode setup-js2-mode js2-imenu-extras js2-refactor js2r-conveniences
js2r-conditionals js2r-wrapping js2r-functions js2r-vars js2r-iife
js2r-formatting js2r-helpers disp-table js2-mode-expansions js2-mode
cc-langs css-mode-expansions css-mode ibuf-ext ibuffer dired-x
zencoding-mode rename-sgml-tag crappy-jsp-mode js-mode-expansions js
newcomment cc-mode-expansions cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs jsp-expansions
html-mode-expansions sgml-mode org-wl org-w3m org-vm org-rmail org-mhe
org-mew org-irc org-jsinfo org-infojs org-html org-exp ob-exp
org-exp-blocks org-agenda org-info org-gnus org-docview org-bibtex
bibtex org-bbdb setup-org org-mode-expansions org ob-emacs-lisp
ob-tangle ob-ref ob-lob ob-table org-footnote org-src ob-comint ob-keys
ob ob-eval org-pcomplete org-list org-faces org-compat org-entities
org-macs noutline outline cal-menu calendar cal-loaddefs hippie-exp
misearch multi-isearch tabify setup-magit magit-svn magit-bisect
magit-key-mode magit diff-mode log-edit pcvs-util add-log vc-git unsafep
elisp-slime-nav etags oppdrag-mode diminish server mac my-misc
appearance zoom-frm frame-cmds frame-fns avoid paren hl-line
key-bindings windmove smex setup-ido ido-ubiquitous ido browse-kill-ring
fill-column-indicator multifiles change-inner smart-forward wgrep
setup-rgrep grep compile eproject esh-var esh-io esh-cmd esh-ext
esh-proc esh-arg eldoc esh-groups eshell esh-module esh-mode esh-util
jump-char multiple-cursors rectangular-region-mode mc-mark-more
thingatpt mc-cycle-cursors mc-edit-lines multiple-cursors-core rect
inline-string-rectangle mark-more-like-this mark-multiple expand-region
text-mode-expansions expand-region-custom expand-region-core s
file-defuns imenu mode-mappings setup-paredit paredit setup-html-mode
setup-ffip find-file-in-project setup-wrap-region wrap-region
setup-perspective perspective setup-ace-jump-mode ace-jump-mode
setup-yasnippet buster-snippets buster-snippet-helpers yasnippet
dropdown-list help-mode view setup-hippie setup-shell shell-command
setup-dired dired-details dash exec-path-from-shell sane-defaults
uniquify undo-tree edmacro kmacro diff smooth-scrolling warnings subword
winner tramp-cache tramp-sh tramp tramp-compat tramp-loaddefs shell
pcomplete comint ansi-color ring format-spec advice advice-preload
recentf tree-widget wid-edit delsel easy-mmode autorevert setup-package
clojure-test-mode-autoloads elisp-slime-nav-autoloads elnode-autoloads
elnode ert derived help-fns find-func ewoc easymenu debug cl dired
regexp-opt db json web dotassoc kv url-util url-parse auth-source assoc
gnus-util password-cache url-vars mailcap mm-encode mail-parse rfc2231
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr creole-autoloads
db-autoloads exec-path-from-shell-autoloads fakir-autoloads
gist-autoloads gh-autoloads eieio byte-opt bytecomp byte-compile cconv
macroexp htmlize-autoloads kv-autoloads logito-autoloads magit-autoloads
nrepl-autoloads clojure-mode-autoloads paredit-autoloads
pcache-autoloads finder-inf php-mode-autoloads slime-js-autoloads
slime-repl-autoloads slime-autoloads web-autoloads package
tabulated-list setup-elnode saveplace time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel ns-win tool-bar dnd fontset image fringe
lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer loaddefs button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process ns multi-tty
emacs)

[-- Attachment #2: Type: text/html, Size: 17395 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12938: 24.2; Lexical binding leaks into package-install somehow
  2012-11-19 21:07 bug#12938: 24.2; Lexical binding leaks into package-install somehow Magnar Sveen
@ 2012-11-20 18:53 ` Glenn Morris
  2012-11-21  4:56   ` Glenn Morris
  2012-11-23 21:31 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Glenn Morris @ 2012-11-20 18:53 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 12938


I guess this could be summarized as:

mkdir foo
echo '(eval-when-compile (message "lex = %s" lexical-binding))' > foo/bar.el

Create test.el with contents

  ;; -*- lexical-binding: t -*-
  (byte-recompile-directory "foo/" 0)

emacs -Q --batch -l ./test.el
  -> lex = t





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12938: 24.2; Lexical binding leaks into package-install somehow
  2012-11-20 18:53 ` Glenn Morris
@ 2012-11-21  4:56   ` Glenn Morris
  0 siblings, 0 replies; 5+ messages in thread
From: Glenn Morris @ 2012-11-21  4:56 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 12938

Glenn Morris wrote:

>   ;; -*- lexical-binding: t -*-
>   (byte-recompile-directory "foo/" 0)

I don't actually know what TRTD is there; but I still think package.el
should compile files in a separate Emacs instance, which would avoid
this problem as well as others.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10125#17





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12938: 24.2; Lexical binding leaks into package-install somehow
  2012-11-19 21:07 bug#12938: 24.2; Lexical binding leaks into package-install somehow Magnar Sveen
  2012-11-20 18:53 ` Glenn Morris
@ 2012-11-23 21:31 ` Stefan Monnier
  2012-11-23 21:50   ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2012-11-23 21:31 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 12938

> In other words, the lexical binding in test.el leaks into the
> installation of multiple-cursors.

Yuck!
Can you test the patch below to confirm it fixes the problem for you?


        Stefan


=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- lisp/emacs-lisp/bytecomp.el	2012-11-20 19:05:20 +0000
+++ lisp/emacs-lisp/bytecomp.el	2012-11-23 21:28:58 +0000
@@ -1720,6 +1720,8 @@
         (setq input-buffer (get-buffer-create " *Compiler Input*"))
       (erase-buffer)
       (setq buffer-file-coding-system nil)
+      ;; Don't inherit lexical-binding from caller (bug#12938).
+      (set (make-local-variable 'lexical-binding) nil)
       ;; Always compile an Emacs Lisp file as multibyte
       ;; unless the file itself forces unibyte with -*-coding: raw-text;-*-
       (set-buffer-multibyte t)






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#12938: 24.2; Lexical binding leaks into package-install somehow
  2012-11-23 21:31 ` Stefan Monnier
@ 2012-11-23 21:50   ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2012-11-23 21:50 UTC (permalink / raw)
  To: Magnar Sveen; +Cc: 12938-done

> Can you test the patch below to confirm it fixes the problem for you?

Forget it, that patch was at the wrong place (kill-all-local-variables)
gets called soon after that, defeating this approach.  I've installed
the patch below instead, which seems to fix the problem.


        Stefan


=== modified file 'lisp/emacs-lisp/bytecomp.el'
--- lisp/emacs-lisp/bytecomp.el	2012-11-20 19:05:20 +0000
+++ lisp/emacs-lisp/bytecomp.el	2012-11-23 21:44:46 +0000
@@ -1748,6 +1748,9 @@
         ;; There may be a file local variable setting (bug#10419).
         (setq buffer-read-only nil
               filename buffer-file-name))
+      ;; Don't inherit lexical-binding from caller (bug#12938).
+      (unless (local-variable-p 'lexical-binding)
+        (setq-local lexical-binding nil))
       ;; Set the default directory, in case an eval-when-compile uses it.
       (setq default-directory (file-name-directory filename)))
     ;; Check if the file's local variables explicitly specify not to






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-23 21:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19 21:07 bug#12938: 24.2; Lexical binding leaks into package-install somehow Magnar Sveen
2012-11-20 18:53 ` Glenn Morris
2012-11-21  4:56   ` Glenn Morris
2012-11-23 21:31 ` Stefan Monnier
2012-11-23 21:50   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).