unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: [drew.adams@oracle.com: RE: weird defadvicebugwithbyte-compilation]
Date: Sun, 11 Dec 2005 22:44:15 -0800	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICAEBHDAAA.drew.adams@oracle.com> (raw)
In-Reply-To: <DNEMKBNJBGPAOPIJOOICIEBGDAAA.drew.adams@oracle.com>

        > It does, as far as I can tell. I don't understand all of it,
        > however, I admit. I still don't understand, for instance:
        >
        > 1. why byte-compiling the defadvice in bar.el would eval
        >    my-mode (my-mode does not even appear in bar.el)

        I think it doesn't eval it, it just sees that my-mode is not bound.
        The warning says "reference to free variable `my-mode'", see the
        backtrace.  This is a standard warning from the byte compiler, it is
        meant to help you detect typos in variable names.

    OK. I was confused because it was the byte-compilation that led
    ultimately to x-create-frame raising an unbound var error.

        > 2. why evaling the defadvice in foo.el would eval my-mode
        >    (the BODY of defadvice is not supposed to be quoted)

        Because defadvice byte-compiles the function it creates on
        the fly, I guess.

    But it is only the defadvice in bar.el, not the defadvice in
    foo.el, that has the keyword `compile'.

    And even if it does byte-compile foo.el on the fly (for
    whatever reason), why would it eval my-mode - the body of a
    defadvice is not supposed to need
    to be quoted (it is not evaled by defadvice).

    That is, I don't understand why a byte-compiler warning of a potentially
    unbound variable would lead to a *Backtrace* being created - a
    warning is not an error, and even byte-compiler errors (as opposed to
    warnings) do not result in a *Backtrace*.

        > 5. why selecting (require 'foo) and doing eval-region does
        >    not manifest the bug, but putting the cursor after
        >   (require 'foo) and doing `C-x C-e' does manifest the bug.

        Because, by default, eval-expression-debug-on-error is t, and it
        affects C-x C-e.  If I set eval-expression-debug-on-error to nil,
        Emacs behaves with C-x C-e like it does with eval-region: it doesn't
        pop up the *Backtrace* buffer in a separate frame, and the
        bug doesn't happen.

    Ah - thanks. That makes sense, given your explanation of the bug being
    manifested in x-create-frame.

    I don't understand, however, your statement that when the byte compiler
    tries to display special-buffer *Compile Log* in a separate
    frame "it hits
    the problem with the void variable again". What is the "problem with the
    void variable"? For the byte-compiler it was only a question of
    displaying a
    warning, there was no error to be raised. Why would display of
    *Compile Log*
    in a separate frame raise an unbound-variable error?

Nevermind; I understand now what happened (wrt the unbound var, not the
crash bug). I was confused about who was raising the unbound var error, but
I see now that x-create-frame was doing so because the menu-enable property
evaled it for a menu-bar menu when x-create-frame tried to create the
*Compile Log* frame (which has a menu-bar).

This makes me wonder now if byte-compiling in defadvice (i.e. on the fly)
should display a *Compile Log* buffer at all. I don't know. In any case,
that's clearly the cause of the problem here (but not the explanation of the
crash bug).

I still have a question, however, about how best to use define-minor-mode to
define the mode variable so that it can be used in a put 'menu-enable. Is it
necessary to do the define-minor-mode before doing the put? I guess so; but
in that case, I prefer the old method of defining a minor-mode function and
its variable (defcustom) separately. The problem is the same, but I always
place variable definitions at the top, and such a defcustom would be defined
before the  variable was used in the put 'menu-enable. In the new system, I
was calling the minor-mode function first thing (in .emacs), to set the
variable, but that function couldn't be called until its defining library
was loaded, and that meant that the variable wasn't defined when the
*Compile Log* was displayed when byte-compiling a defadvice in the file.

Moral (for me): Either don't use define-minor-mode at all or use it first
thing in a file, before you make any references (even quoted references,
like here) to its mode variable.

Thanks for helping me understand, and good luck with the crash bug. - Drew

  reply	other threads:[~2005-12-12  6:44 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-05  2:36 [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard Stallman
2005-12-07 18:55 ` Chong Yidong
2005-12-08  4:53   ` Richard M. Stallman
2005-12-08 16:14     ` Drew Adams
2005-12-09 13:17       ` Eli Zaretskii
2005-12-09 14:07         ` Chong Yidong
2005-12-09 18:37         ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-10  4:14         ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard M. Stallman
2005-12-11 18:17           ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-12  5:23             ` Richard M. Stallman
2005-12-12  5:40               ` [drew.adams@oracle.com: RE: weird defadvice bugwithbyte-compilation] Drew Adams
2005-12-13  3:14                 ` Richard M. Stallman
2005-12-13  3:52                   ` [drew.adams@oracle.com: RE: weird defadvicebugwithbyte-compilation] Drew Adams
2005-12-13 23:33                     ` Richard M. Stallman
2005-12-14  1:05                       ` [drew.adams@oracle.com: RE: weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-14  1:24                         ` Johan Bockgård
2005-12-14  3:41                           ` [drew.adams@oracle.com: Drew Adams
2005-12-14  3:45                             ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-14 17:17                             ` [drew.adams@oracle.com: Johan Bockgård
2005-12-14 21:29                               ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-14 23:43                                 ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Johan Bockgård
2005-12-15  1:46                                   ` [drew.adams@oracle.com:RE:weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-11 20:21         ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Eli Zaretskii
2005-12-11 21:35           ` [drew.adams@oracle.com: RE: weird defadvice bug withbyte-compilation] Drew Adams
2005-12-12  5:52             ` Eli Zaretskii
2005-12-12  6:11               ` [drew.adams@oracle.com: RE: weird defadvice bugwithbyte-compilation] Drew Adams
2005-12-12  6:44                 ` Drew Adams [this message]
2005-12-12 21:22                   ` [drew.adams@oracle.com: RE: weird defadvicebugwithbyte-compilation] Eli Zaretskii
2005-12-12 21:53                     ` [drew.adams@oracle.com: RE: weirddefadvicebugwithbyte-compilation] Drew Adams
2005-12-13  4:30                       ` Eli Zaretskii
2005-12-13  4:59                         ` [drew.adams@oracle.com: Drew Adams
2005-12-12  5:23           ` [drew.adams@oracle.com: RE: weird defadvice bug with byte-compilation] Richard M. Stallman
2005-12-12  6:11             ` Eli Zaretskii
2005-12-13  3:14               ` Richard M. Stallman
2005-12-13  4:39                 ` Eli Zaretskii
2005-12-13 23:33                   ` Richard M. Stallman
2005-12-14 19:38                     ` Eli Zaretskii
2005-12-15  2:09                       ` Richard M. Stallman
2005-12-15  4:46                         ` Eli Zaretskii
2005-12-16  1:51                           ` Richard M. Stallman
2005-12-16 19:48                             ` Eli Zaretskii
2005-12-16 20:14                             ` Eli Zaretskii
2005-12-17  1:05                               ` Richard M. Stallman
2005-12-17  8:29                                 ` Eli Zaretskii
2005-12-17 23:59                                   ` Richard M. Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICAEBHDAAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).