GNU bug report logs - #12528
24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list

Previous Next

Package: emacs;

Reported by: Changa Imara <changa.imara <at> sonomaacademy.org>

Date: Thu, 27 Sep 2012 21:07:01 UTC

Severity: minor

Found in version 24.2

Fixed in version 24.3

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12528 in the body.
You can then email your comments to 12528 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#12528; Package emacs. (Thu, 27 Sep 2012 21:07:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Changa Imara <changa.imara <at> sonomaacademy.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 27 Sep 2012 21:07:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Changa Imara <changa.imara <at> sonomaacademy.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.2; Emacs fails to use lexical-binding when run from script or in
	file-local variable list
Date: Thu, 27 Sep 2012 13:44:22 -0700
I'm attempting to run the following script:
===start script===
#!/usr/local/bin/emacs --script
;;; -*- lexical-binding: t -*-

(defun foo ()
  (setq x 100))

(defun bar ()
  (let ((x 0))
    (foo)
    x))


(message "%d" (bar))  ; would expect x to still be 0 here
===end script===

With lexical binding enabled the script should return 0. Otherwise it
will return 100. However, when set to be executable and run from the
shell with a command like
"./lexical-binding-test.el", emacs fails to use lexial-binding.

According to the manual: "In shell scripts, the first line is used to
identify the script interpreter, so you cannot put any local variables
there. To accommodate this, Emacs looks for local variable
specifications in the second line if the first line specifies an
interpreter. " This does not seem to be the case.

I also tried setting lexical-bindings using a file local variable list.
This doesn't seem to work either.



In GNU Emacs 24.2.1 (x86_64-apple-darwin, NS apple-appkit-1038.36)
 of 2012-08-27 on bob.porkrind.org
Windowing system distributor `Apple', version 10.3.1138
Configured using:
 `configure '--host=x86_64-apple-darwin' '--build=i686-apple-darwin'
 '--with-ns' 'build_alias=i686-apple-darwin'
 'host_alias=x86_64-apple-darwin' 'CC=gcc -mmacosx-version-min=10.5''

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: nil
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  hi-lock-mode: t
  recentf-mode: t
  eldoc-mode: t
  elisp-slime-nav-mode: t
  paredit-mode: t
  hl-line-mode: t
  idle-highlight-mode: t
  ido-ubiquitous-mode: t
  show-paren-mode: t
  global-linum-mode: t
  linum-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


Features:
(shadow sort flyspell ispell mail-extr emacsbug message rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mailabbrev gmm-utils mailheader
sendmail tramp-cache tramp tramp-compat format-spec tramp-loaddefs debug
shell pcomplete comint regexp-opt ansi-color pp lisp-mnt misearch
multi-isearch mule-util parse-time mail-utils network-stream starttls
url-cache url-http tls mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
url-gw url-auth url url-proxy url-privacy url-expand url-methods
url-history url-cookie url-util url-parse auth-source eieio byte-opt
bytecomp byte-compile cconv macroexp assoc gnus-util password-cache
url-vars mm-util mail-prsvr mailcap finder-inf hi-lock newcomment
files-x recentf tree-widget wid-edit eldoc elisp-slime-nav etags ring
paredit hl-line saveplace idle-highlight-mode thingatpt yasnippet
help-mode view cl htmlize-autoloads starter-kit-lisp-autoloads
elisp-slime-nav-autoloads starter-kit-autoloads edmacro kmacro smex
starter-kit-misc ido-ubiquitous ido paren starter-kit-defuns uniquify
advice help-fns advice-preload magit-autoloads info easymenu
ido-ubiquitous-autoloads smex-autoloads find-file-in-project-autoloads
idle-highlight-mode-autoloads paredit-autoloads yasnippet-autoloads
package tabulated-list linum 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)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12528; Package emacs. (Thu, 27 Sep 2012 21:20:01 GMT) Full text and rfc822 format available.

Message #8 received at 12528 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Changa Imara <changa.imara <at> sonomaacademy.org>
Cc: 12528 <at> debbugs.gnu.org
Subject: Re: bug#12528: 24.2;
	Emacs fails to use lexical-binding when run from script or in
	file-local variable list
Date: Thu, 27 Sep 2012 17:19:16 -0400
lexical-binding is not a normal file local variable and literally must
be on the first line of the file (bug#10605). This is documented, but
I guess nobody thought about Emacs scripts till now. There is no way to
make that work at present AFAICS.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#12528; Package emacs. (Thu, 27 Sep 2012 21:23:02 GMT) Full text and rfc822 format available.

Message #11 received at 12528 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Changa Imara <changa.imara <at> sonomaacademy.org>
Cc: 12528 <at> debbugs.gnu.org
Subject: Re: bug#12528: 24.2;
	Emacs fails to use lexical-binding when run from script or in
	file-local variable list
Date: Thu, 27 Sep 2012 17:22:45 -0400
Glenn Morris wrote:

> lexical-binding is not a normal file local variable and literally must
> be on the first line of the file (bug#10605). This is documented, but
> I guess nobody thought about Emacs scripts till now. There is no way to
> make that work at present AFAICS.

Without changing Emacs, I mean.




Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Fri, 28 Sep 2012 07:43:01 GMT) Full text and rfc822 format available.

Notification sent to Changa Imara <changa.imara <at> sonomaacademy.org>:
bug acknowledged by developer. (Fri, 28 Sep 2012 07:43:02 GMT) Full text and rfc822 format available.

Message #16 received at 12528-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 12528-done <at> debbugs.gnu.org
Subject: Re: bug#12528: 24.2;
	Emacs fails to use lexical-binding when run from script or in
	file-local variable list
Date: Fri, 28 Sep 2012 03:41:52 -0400
Version: 24.3

Installed something to trunk that hopefully fixes this.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 26 Oct 2012 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 195 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.