all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* eval-after-load causes void-variable error
@ 2013-01-17 23:53 Sean McAfee
  2013-01-18  0:07 ` Barry Margolin
  0 siblings, 1 reply; 12+ messages in thread
From: Sean McAfee @ 2013-01-17 23:53 UTC (permalink / raw)
  To: help-gnu-emacs

For a long time I had this in my .emacs file:

(require 'ffap)
(add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook))

I recently decided to optimize it a bit and changed it to:

(eval-after-load 'ffap
  '(add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook)))

Now, however, as soon as the ffap command is activated, I get an error:

Lisp error: (void-variable ffap-alist)

Somehow, using eval-after-load is causing the variable ffap-alist to be
unbound, or not bound in the first place.  Does anyone have any idea
what's going on?


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

* Re: eval-after-load causes void-variable error
  2013-01-17 23:53 eval-after-load causes void-variable error Sean McAfee
@ 2013-01-18  0:07 ` Barry Margolin
  2013-01-18  1:35   ` Le Wang
                     ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Barry Margolin @ 2013-01-18  0:07 UTC (permalink / raw)
  To: help-gnu-emacs

In article <bp8ip6vs6xk.fsf@usca1uw-JZWWPM1.sanmateo.corp.akamai.com>,
 Sean McAfee <eefacm@gmail.com> wrote:

> For a long time I had this in my .emacs file:
> 
> (require 'ffap)
> (add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook))
> 
> I recently decided to optimize it a bit and changed it to:
> 
> (eval-after-load 'ffap
>   '(add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook)))
> 
> Now, however, as soon as the ffap command is activated, I get an error:
> 
> Lisp error: (void-variable ffap-alist)
> 
> Somehow, using eval-after-load is causing the variable ffap-alist to be
> unbound, or not bound in the first place.  Does anyone have any idea
> what's going on?

When you use a feature name rather than a filename (i.e. a symbol rather 
than a string) in eval-after-load, it evals as soon as the feature is 
provided, not after the file is loaded. ffap.el contains

(provide 'ffap)

at the beginning of the file, so your expression gets evaluated before 
ffap-alist has been initialized. It really should be at the end, since 
the feature doesn't really exist until the whole file is loaded.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: eval-after-load causes void-variable error
  2013-01-18  0:07 ` Barry Margolin
@ 2013-01-18  1:35   ` Le Wang
  2013-01-18  3:21   ` Dmitry Gutov
       [not found]   ` <mailman.17773.1358479324.855.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 12+ messages in thread
From: Le Wang @ 2013-01-18  1:35 UTC (permalink / raw)
  To: Barry Margolin; +Cc: help-gnu-emacs

On Fri, Jan 18, 2013 at 8:07 AM, Barry Margolin <barmar@alum.mit.edu> wrote:
> When you use a feature name rather than a filename (i.e. a symbol rather
> than a string) in eval-after-load, it evals as soon as the feature is
> provided, not after the file is loaded. ffap.el contains
>
> (provide 'ffap)
>
> at the beginning of the file, so your expression gets evaluated before
> ffap-alist has been initialized. It really should be at the end, since
> the feature doesn't really exist until the whole file is loaded.

Definitely using the filename is preferred, however reading the source
of `eval-after-load' on 24.2.1 it seems like this has been "fixed".

	;; For features, the after-load-alist elements get run when `provide' is
	;; called rather than at the end of the file.  So add an indirection to
	;; make sure that `form' is really run "after-load" in case the provide
	;; call happens early.


> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***



-- 
Le



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

* Re: eval-after-load causes void-variable error
  2013-01-18  0:07 ` Barry Margolin
  2013-01-18  1:35   ` Le Wang
@ 2013-01-18  3:21   ` Dmitry Gutov
       [not found]   ` <mailman.17773.1358479324.855.help-gnu-emacs@gnu.org>
  2 siblings, 0 replies; 12+ messages in thread
From: Dmitry Gutov @ 2013-01-18  3:21 UTC (permalink / raw)
  To: Barry Margolin; +Cc: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:

> In article <bp8ip6vs6xk.fsf@usca1uw-JZWWPM1.sanmateo.corp.akamai.com>,
>  Sean McAfee <eefacm@gmail.com> wrote:
>
>> For a long time I had this in my .emacs file:
>> 
>> (require 'ffap)
>> (add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook))
>> 
>> I recently decided to optimize it a bit and changed it to:
>> 
>> (eval-after-load 'ffap
>>   '(add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook)))
>> 
>> Now, however, as soon as the ffap command is activated, I get an error:
>> 
>> Lisp error: (void-variable ffap-alist)
>> 
>> Somehow, using eval-after-load is causing the variable ffap-alist to be
>> unbound, or not bound in the first place.  Does anyone have any idea
>> what's going on?
>
> When you use a feature name rather than a filename (i.e. a symbol rather 
> than a string) in eval-after-load, it evals as soon as the feature is 
> provided, not after the file is loaded. ffap.el contains
>
> (provide 'ffap)
>
> at the beginning of the file

Does it? If we're talking about ffap.el distributed with Emacs, I only
see the `provide' from at the end of the file. And according to
`vc-annotate', it's been there for a few years now.



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

* Re: eval-after-load causes void-variable error
       [not found]   ` <mailman.17773.1358479324.855.help-gnu-emacs@gnu.org>
@ 2013-01-18  5:15     ` Barry Margolin
  2013-01-18  7:19       ` Dmitry Gutov
       [not found]       ` <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 12+ messages in thread
From: Barry Margolin @ 2013-01-18  5:15 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.17773.1358479324.855.help-gnu-emacs@gnu.org>,
 Dmitry Gutov <dgutov@yandex.ru> wrote:

> Barry Margolin <barmar@alum.mit.edu> writes:
> 
> > In article <bp8ip6vs6xk.fsf@usca1uw-JZWWPM1.sanmateo.corp.akamai.com>,
> >  Sean McAfee <eefacm@gmail.com> wrote:
> >
> >> For a long time I had this in my .emacs file:
> >> 
> >> (require 'ffap)
> >> (add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook))
> >> 
> >> I recently decided to optimize it a bit and changed it to:
> >> 
> >> (eval-after-load 'ffap
> >>   '(add-to-list 'ffap-alist (cons +my-ffap-regexp+ #'my-ffap-hook)))
> >> 
> >> Now, however, as soon as the ffap command is activated, I get an error:
> >> 
> >> Lisp error: (void-variable ffap-alist)
> >> 
> >> Somehow, using eval-after-load is causing the variable ffap-alist to be
> >> unbound, or not bound in the first place.  Does anyone have any idea
> >> what's going on?
> >
> > When you use a feature name rather than a filename (i.e. a symbol rather 
> > than a string) in eval-after-load, it evals as soon as the feature is 
> > provided, not after the file is loaded. ffap.el contains
> >
> > (provide 'ffap)
> >
> > at the beginning of the file
> 
> Does it? If we're talking about ffap.el distributed with Emacs, I only
> see the `provide' from at the end of the file. And according to
> `vc-annotate', it's been there for a few years now.

I'm still running Emacs 22.2, it's the first non-comment in the file.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: eval-after-load causes void-variable error
  2013-01-18  5:15     ` Barry Margolin
@ 2013-01-18  7:19       ` Dmitry Gutov
       [not found]       ` <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry Gutov @ 2013-01-18  7:19 UTC (permalink / raw)
  To: Barry Margolin; +Cc: help-gnu-emacs

Barry Margolin <barmar@alum.mit.edu> writes:
> I'm still running Emacs 22.2, it's the first non-comment in the file.

I see.

I'm still surprised, though, that neither you nor the OP mentioned
you're using a years-old version of Emacs.



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

* Re: eval-after-load causes void-variable error
       [not found]       ` <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>
@ 2013-01-18 17:57         ` Sean McAfee
  2013-01-18 18:08           ` Barry Margolin
  2013-01-18 18:34           ` Dmitry Gutov
  2013-01-18 18:00         ` Barry Margolin
  1 sibling, 2 replies; 12+ messages in thread
From: Sean McAfee @ 2013-01-18 17:57 UTC (permalink / raw)
  To: help-gnu-emacs

Dmitry Gutov <dgutov@yandex.ru> writes:
> Barry Margolin <barmar@alum.mit.edu> writes:
>> I'm still running Emacs 22.2, it's the first non-comment in the file.
>
> I see.
>
> I'm still surprised, though, that neither you nor the OP mentioned
> you're using a years-old version of Emacs.

23.1 here.  It's the most recent pre-built version offered by my version
of Ubuntu.

I've tried to build Emacs 24 the old-fashioned way on a few occasions,
but it's an enormous pain in the ass for some reason.


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

* Re: eval-after-load causes void-variable error
       [not found]       ` <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>
  2013-01-18 17:57         ` Sean McAfee
@ 2013-01-18 18:00         ` Barry Margolin
  1 sibling, 0 replies; 12+ messages in thread
From: Barry Margolin @ 2013-01-18 18:00 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>,
 Dmitry Gutov <dgutov@yandex.ru> wrote:

> Barry Margolin <barmar@alum.mit.edu> writes:
> > I'm still running Emacs 22.2, it's the first non-comment in the file.
> 
> I see.
> 
> I'm still surprised, though, that neither you nor the OP mentioned
> you're using a years-old version of Emacs.

Since my observation was consistent with the symptom he described, I 
assumed it probably hadn't changed.  I didn't think it was likely we 
were both using outdated versions.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: eval-after-load causes void-variable error
  2013-01-18 17:57         ` Sean McAfee
@ 2013-01-18 18:08           ` Barry Margolin
  2013-01-18 19:04             ` Eli Zaretskii
       [not found]             ` <mailman.17839.1358535836.855.help-gnu-emacs@gnu.org>
  2013-01-18 18:34           ` Dmitry Gutov
  1 sibling, 2 replies; 12+ messages in thread
From: Barry Margolin @ 2013-01-18 18:08 UTC (permalink / raw)
  To: help-gnu-emacs

In article <bp8a9s6z85r.fsf@usca1uw-JZWWPM1.sanmateo.corp.akamai.com>,
 Sean McAfee <eefacm@gmail.com> wrote:

> Dmitry Gutov <dgutov@yandex.ru> writes:
> > Barry Margolin <barmar@alum.mit.edu> writes:
> >> I'm still running Emacs 22.2, it's the first non-comment in the file.
> >
> > I see.
> >
> > I'm still surprised, though, that neither you nor the OP mentioned
> > you're using a years-old version of Emacs.
> 
> 23.1 here.  It's the most recent pre-built version offered by my version
> of Ubuntu.
> 
> I've tried to build Emacs 24 the old-fashioned way on a few occasions,
> but it's an enormous pain in the ass for some reason.

My problem with upgrading is that I have an enormous collection of 
extensions that I copied when I left a former employer (about 15 years 
ago). When I tried to compile and load them in Emacs 24, too much stuff 
broke, and I've never had the time to try to debug it all.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

* Re: eval-after-load causes void-variable error
  2013-01-18 17:57         ` Sean McAfee
  2013-01-18 18:08           ` Barry Margolin
@ 2013-01-18 18:34           ` Dmitry Gutov
  1 sibling, 0 replies; 12+ messages in thread
From: Dmitry Gutov @ 2013-01-18 18:34 UTC (permalink / raw)
  To: Sean McAfee; +Cc: help-gnu-emacs

Sean McAfee <eefacm@gmail.com> writes:

> Dmitry Gutov <dgutov@yandex.ru> writes:
>> Barry Margolin <barmar@alum.mit.edu> writes:
>>> I'm still running Emacs 22.2, it's the first non-comment in the file.
>>
>> I see.
>>
>> I'm still surprised, though, that neither you nor the OP mentioned
>> you're using a years-old version of Emacs.
>
> 23.1 here.  It's the most recent pre-built version offered by my version
> of Ubuntu.

Judging by the release dates, it could be alredy fixed in 23.2, and
almost definitely fixed in 23.3 and 23.4.

> I've tried to build Emacs 24 the old-fashioned way on a few occasions,
> but it's an enormous pain in the ass for some reason.

You could use Damien Cassou's PPA:

https://launchpad.net/~cassou/+archive/emacs



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

* Re: eval-after-load causes void-variable error
  2013-01-18 18:08           ` Barry Margolin
@ 2013-01-18 19:04             ` Eli Zaretskii
       [not found]             ` <mailman.17839.1358535836.855.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Eli Zaretskii @ 2013-01-18 19:04 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Barry Margolin <barmar@alum.mit.edu>
> Date: Fri, 18 Jan 2013 13:08:38 -0500
> 
> My problem with upgrading is that I have an enormous collection of 
> extensions that I copied when I left a former employer (about 15 years 
> ago). When I tried to compile and load them in Emacs 24, too much stuff 
> broke, and I've never had the time to try to debug it all.

You could ask for help here or on emacs-devel.



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

* Re: eval-after-load causes void-variable error
       [not found]             ` <mailman.17839.1358535836.855.help-gnu-emacs@gnu.org>
@ 2013-01-18 19:17               ` Barry Margolin
  0 siblings, 0 replies; 12+ messages in thread
From: Barry Margolin @ 2013-01-18 19:17 UTC (permalink / raw)
  To: help-gnu-emacs

In article <mailman.17839.1358535836.855.help-gnu-emacs@gnu.org>,
 Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Barry Margolin <barmar@alum.mit.edu>
> > Date: Fri, 18 Jan 2013 13:08:38 -0500
> > 
> > My problem with upgrading is that I have an enormous collection of 
> > extensions that I copied when I left a former employer (about 15 years 
> > ago). When I tried to compile and load them in Emacs 24, too much stuff 
> > broke, and I've never had the time to try to debug it all.
> 
> You could ask for help here or on emacs-devel.

If I had time to figure out what's broken and what questions I could 
post, I could probably fix it myself.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


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

end of thread, other threads:[~2013-01-18 19:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17 23:53 eval-after-load causes void-variable error Sean McAfee
2013-01-18  0:07 ` Barry Margolin
2013-01-18  1:35   ` Le Wang
2013-01-18  3:21   ` Dmitry Gutov
     [not found]   ` <mailman.17773.1358479324.855.help-gnu-emacs@gnu.org>
2013-01-18  5:15     ` Barry Margolin
2013-01-18  7:19       ` Dmitry Gutov
     [not found]       ` <mailman.17789.1358493580.855.help-gnu-emacs@gnu.org>
2013-01-18 17:57         ` Sean McAfee
2013-01-18 18:08           ` Barry Margolin
2013-01-18 19:04             ` Eli Zaretskii
     [not found]             ` <mailman.17839.1358535836.855.help-gnu-emacs@gnu.org>
2013-01-18 19:17               ` Barry Margolin
2013-01-18 18:34           ` Dmitry Gutov
2013-01-18 18:00         ` Barry Margolin

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.