* bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
@ 2012-09-27 20:44 Changa Imara
2012-09-27 21:19 ` Glenn Morris
0 siblings, 1 reply; 4+ messages in thread
From: Changa Imara @ 2012-09-27 20:44 UTC (permalink / raw
To: 12528
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
2012-09-27 20:44 bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list Changa Imara
@ 2012-09-27 21:19 ` Glenn Morris
2012-09-27 21:22 ` Glenn Morris
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2012-09-27 21:19 UTC (permalink / raw
To: Changa Imara; +Cc: 12528
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
2012-09-27 21:19 ` Glenn Morris
@ 2012-09-27 21:22 ` Glenn Morris
2012-09-28 7:41 ` Glenn Morris
0 siblings, 1 reply; 4+ messages in thread
From: Glenn Morris @ 2012-09-27 21:22 UTC (permalink / raw
To: Changa Imara; +Cc: 12528
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list
2012-09-27 21:22 ` Glenn Morris
@ 2012-09-28 7:41 ` Glenn Morris
0 siblings, 0 replies; 4+ messages in thread
From: Glenn Morris @ 2012-09-28 7:41 UTC (permalink / raw
To: 12528-done
Version: 24.3
Installed something to trunk that hopefully fixes this.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-09-28 7:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 20:44 bug#12528: 24.2; Emacs fails to use lexical-binding when run from script or in file-local variable list Changa Imara
2012-09-27 21:19 ` Glenn Morris
2012-09-27 21:22 ` Glenn Morris
2012-09-28 7:41 ` Glenn Morris
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).