unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?)
@ 2012-04-14  1:26 Michael Heerdegen
  2012-04-14  2:06 ` Juanma Barranquero
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2012-04-14  1:26 UTC (permalink / raw)
  To: 11241

Hello,

steps to reproduce:

1. emacs -Q
2. load emacs-lock.el  (the source, not the compiled file)
3. In any buffer: M-x emacs-lock-mode

==>

Debugger entered--Lisp error: (void-variable arg)
  (emacs-lock--set-mode mode arg)
  (lambda (mode) (emacs-lock--set-mode mode arg))(t)
  (let ((last-message (current-message))) ((lambda (mode) (emacs-lock--set-mode mode arg)) (if (eq arg (quote toggle)) (not emacs-lock-mode) (> (prefix-numeric-value arg) 0))) (when emacs-lock-mode (setq emacs-lock--old-mode emacs-lock-mode) (setq emacs-lock--try-unlocking (and (if (eq emacs-lock-unlockable-modes t) (emacs-lock-live-process-p (current-buffer)) (assq major-mode emacs-lock-unlockable-modes)) t))) (run-hooks (quote emacs-lock-mode-hook) (if emacs-lock-mode (quote emacs-lock-mode-on-hook) (quote emacs-lock-mode-off-hook))) (if (called-interactively-p (quote any)) (progn nil (unless (and (current-message) (not (equal last-message (current-message)))) (message "Emacs-Lock mode %sabled" (if emacs-lock-mode "en" "dis"))))))
  emacs-lock-mode(toggle)
  call-interactively(emacs-lock-mode t nil)
  execute-extended-command(nil)
  call-interactively(execute-extended-command nil nil)

`arg' is free in the anonymous mode setter function in the definition
of `emacs-lock-mode':

| :variable (emacs-lock-mode .
|                              (lambda (mode)
|                                (emacs-lock--set-mode mode arg)))

Seems this is related to lexical binding.

You don't get that error when you use the compiled code, however.


Regards,

Michael.


In GNU Emacs 24.1.50.1 (i486-pc-linux-gnu, GTK+ Version 3.2.3)
 of 2012-04-10 on zelenka, modified by Debian
 (emacs-snapshot package, version 2:20120410-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11104000
Configured using:
 `configure '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/'
 '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2''






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

* bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?)
  2012-04-14  1:26 bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?) Michael Heerdegen
@ 2012-04-14  2:06 ` Juanma Barranquero
  2012-04-14 12:47   ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2012-04-14  2:06 UTC (permalink / raw)
  To: michael_heerdegen, Stefan Monnier; +Cc: 11241

> `arg' is free in the anonymous mode setter function in the definition
> of `emacs-lock-mode':

Not really, if you look at the macroexpansion of the define-minor-mode-call

  (defun emacs-lock-mode (&optional arg)
    "..."
    (interactive (list (or current-prefix-arg 'toggle)))
    (let ((#1=#:last-message (current-message)))
      ((lambda (mode) (emacs-lock--set-mode mode arg))
      ...

> Seems this is related to lexical binding.

Yes

> You don't get that error when you use the compiled code, however.

Stefan, I can "fix" this for 24.1 just by making emacs-lock.el not use
lexical-binding. But is this difference between compiled and
non-compiled code a bug in the lexical-binding support or something
expected?

    Juanma





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

* bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?)
  2012-04-14  2:06 ` Juanma Barranquero
@ 2012-04-14 12:47   ` Stefan Monnier
  2012-04-14 13:31     ` Juanma Barranquero
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2012-04-14 12:47 UTC (permalink / raw)
  To: Juanma Barranquero; +Cc: michael_heerdegen, 11241

>> You don't get that error when you use the compiled code, however.
> Stefan, I can "fix" this for 24.1 just by making emacs-lock.el not use
> lexical-binding.  But is this difference between compiled and
> non-compiled code a bug in the lexical-binding support or something
> expected?

IIRC the problem is that it's not clear whether (<function> <args>)
should treat <function> as an expression or a value.

The compiler handles such as call like (funcall #'<function> <args>)
whereas the interpreter handles it like (funcall '<function> <args>).
In dynamically scoped Elisp, there is no difference between the two, but
not with lexical scoping.
The patch below should work around the difference.

Note that using define-minor-mode's `arg' is not recommended
[ But no, I don't have a good replacement to suggest, other than to
  split the code into two functions, one behaving as a normal boolean
  minor mode and the other accepting the extra possible values. ]


        Stefan


=== modified file 'lisp/emacs-lisp/easy-mmode.el'
--- lisp/emacs-lisp/easy-mmode.el	2012-02-25 05:53:29 +0000
+++ lisp/emacs-lisp/easy-mmode.el	2012-04-14 12:41:01 +0000
@@ -260,7 +260,7 @@
 	 ;; repeat-command still does the toggling correctly.
 	 (interactive (list (or current-prefix-arg 'toggle)))
 	 (let ((,last-message (current-message)))
-           (,@(if setter (list setter)
+           (,@(if setter `(funcall #',setter)
                 (list (if (symbolp mode) 'setq 'setf) mode))
             (if (eq arg 'toggle)
                 (not ,mode)






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

* bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?)
  2012-04-14 12:47   ` Stefan Monnier
@ 2012-04-14 13:31     ` Juanma Barranquero
  2012-04-14 13:35       ` Juanma Barranquero
  0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2012-04-14 13:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 11241

On Sat, Apr 14, 2012 at 14:47, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

> The patch below should work around the difference.

Yes, it does.

The bug is harmless and unlikely, though, so this does not need to go
into 24.1 IMHO.

> Note that using define-minor-mode's `arg' is not recommended
> [ But no, I don't have a good replacement to suggest, other than to
>  split the code into two functions, one behaving as a normal boolean
>  minor mode and the other accepting the extra possible values. ]

Not worth the effort, I think.

    Juanma





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

* bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?)
  2012-04-14 13:31     ` Juanma Barranquero
@ 2012-04-14 13:35       ` Juanma Barranquero
  0 siblings, 0 replies; 5+ messages in thread
From: Juanma Barranquero @ 2012-04-14 13:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: michael_heerdegen, 11241-done

On Sat, Apr 14, 2012 at 15:31, Juanma Barranquero <lekktu@gmail.com> wrote:

> The bug is harmless and unlikely, though, so this does not need to go
> into 24.1 IMHO.

OK, you've already installed, thanks.

Closing this one.

    Juanma





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

end of thread, other threads:[~2012-04-14 13:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-14  1:26 bug#11241: 24.1.50; emacs-lock is ill uncompiled (lexical binding problem?) Michael Heerdegen
2012-04-14  2:06 ` Juanma Barranquero
2012-04-14 12:47   ` Stefan Monnier
2012-04-14 13:31     ` Juanma Barranquero
2012-04-14 13:35       ` Juanma Barranquero

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).