all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tracing what is loading
@ 2008-12-07  0:34 Harry Putnam
  2008-12-07  9:58 ` Juanma Barranquero
  0 siblings, 1 reply; 15+ messages in thread
From: Harry Putnam @ 2008-12-07  0:34 UTC (permalink / raw)
  To: help-gnu-emacs

I hope I've used good judgement here.  I'm running 23 but the question
is so basic I thought better to keep the line noise off the devel list
and ask here.

How can I ensure that some specific code of my choosing is loaded at
the earliest possible point when emacs starts.

What I want to do is load something like this:

;;[Tip from Kai G] make loaded files give a message
 (defadvice load (before debug-log activate)
(message "Now loading: %s" (locate-library (ad-get-arg 0))))

That will tell exactly what is loading and in what order.

Maybe there is a better or hopefully simpler way like possibly
compiling something directly into the binary when it is compiled.





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

* Re: Tracing what is loading
  2008-12-07  0:34 Harry Putnam
@ 2008-12-07  9:58 ` Juanma Barranquero
  2008-12-07 23:09   ` Harry Putnam
  0 siblings, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2008-12-07  9:58 UTC (permalink / raw)
  To: Harry Putnam; +Cc: help-gnu-emacs

On Sun, Dec 7, 2008 at 00:34, Harry Putnam <reader@newsguy.com> wrote:

> ;;[Tip from Kai G] make loaded files give a message
>  (defadvice load (before debug-log activate)
> (message "Now loading: %s" (locate-library (ad-get-arg 0))))
>
> That will tell exactly what is loading and in what order.

That will skip calls to Fload from C code (defadvice does not work for
calls from C).

> Maybe there is a better or hopefully simpler way like possibly
> compiling something directly into the binary when it is compiled.

Not necessarily simpler. If you want to do that on a permanent basis,
you can add code to Fload to show a message. If it is just once for
some debugging, you can use the trace facilities of GDB.

    Juanma




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

* Re: Tracing what is loading
       [not found] <mailman.2095.1228610078.26697.help-gnu-emacs@gnu.org>
@ 2008-12-07 10:01 ` Dmitry Dzhus
  2008-12-07 13:10 ` Michael Heerdegen
  1 sibling, 0 replies; 15+ messages in thread
From: Dmitry Dzhus @ 2008-12-07 10:01 UTC (permalink / raw)
  To: help-gnu-emacs

Harry Putnam wrote:
> I hope I've used good judgement here.  I'm running 23 but the question
> is so basic I thought better to keep the line noise off the devel list
> and ask here.
>
> How can I ensure that some specific code of my choosing is loaded at
> the earliest possible point when emacs starts.
>
> What I want to do is load something like this:
>
> ;;[Tip from Kai G] make loaded files give a message
>  (defadvice load (before debug-log activate)
> (message "Now loading: %s" (locate-library (ad-get-arg 0))))
>
> That will tell exactly what is loading and in what order.
>
> Maybe there is a better or hopefully simpler way like possibly
> compiling something directly into the binary when it is compiled.
>
>
>
See `emacs-startup-hook` and other (info "(elisp) Standard Hooks")
-- 
Happy Hacking.

http://sphinx.net.ru^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: Tracing what is loading
       [not found] <mailman.2095.1228610078.26697.help-gnu-emacs@gnu.org>
  2008-12-07 10:01 ` Tracing what is loading Dmitry Dzhus
@ 2008-12-07 13:10 ` Michael Heerdegen
  2008-12-08  4:54   ` Harry Putnam
       [not found]   ` <mailman.2193.1228712089.26697.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 15+ messages in thread
From: Michael Heerdegen @ 2008-12-07 13:10 UTC (permalink / raw)
  To: help-gnu-emacs

Maybe the variable `load-history' is interesting for you.


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

* Re: Tracing what is loading
  2008-12-07  9:58 ` Juanma Barranquero
@ 2008-12-07 23:09   ` Harry Putnam
  2008-12-08  0:41     ` Juanma Barranquero
  0 siblings, 1 reply; 15+ messages in thread
From: Harry Putnam @ 2008-12-07 23:09 UTC (permalink / raw)
  To: help-gnu-emacs

"Juanma Barranquero" <lekktu@gmail.com> writes:

> On Sun, Dec 7, 2008 at 00:34, Harry Putnam <reader@newsguy.com> wrote:
>
>> ;;[Tip from Kai G] make loaded files give a message
>>  (defadvice load (before debug-log activate)
>> (message "Now loading: %s" (locate-library (ad-get-arg 0))))
>>
>> That will tell exactly what is loading and in what order.
>
> That will skip calls to Fload from C code (defadvice does not work for
> calls from C).
>
>> Maybe there is a better or hopefully simpler way like possibly
>> compiling something directly into the binary when it is compiled.
>
> Not necessarily simpler. If you want to do that on a permanent basis,
> you can add code to Fload to show a message. If it is just once for
> some debugging, you can use the trace facilities of GDB.

  google on `emacs Fload' turns of a big mess of nothing

  A search on gmane in emacs.help group on `fload' turns up one hit and
  its just a gush of output from some kind of compile command.

  find /usr/share/emacs -iname '*fload*'
  <no hits>

I've been using emacs for 10 yrs now (Probably should not admit
that..) and I've never heard of `Fload'.

So ok, I'll bite.. what is `Fload'?
  





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

* Re: Tracing what is loading
  2008-12-07 23:09   ` Harry Putnam
@ 2008-12-08  0:41     ` Juanma Barranquero
  2008-12-08  4:46       ` Harry Putnam
  0 siblings, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2008-12-08  0:41 UTC (permalink / raw)
  To: Harry Putnam; +Cc: help-gnu-emacs

On Sun, Dec 7, 2008 at 23:09, Harry Putnam <reader@newsguy.com> wrote:

> So ok, I'll bite.. what is `Fload'?

Sorry.

Fload is the `load' function. If you search the C code, you'll see
that emacs lisp functions defined in C are called F + name of
function.

What I wanted to say is that the load function is defined in C (and
called Fload in the C code), so if you advise it you won't get
information about the times it is called from other C code (search
Fload in the src/ directory to see where does that happen). But you
can modify Fload and add code to show what it is loading.

    Juanma




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

* Re: Tracing what is loading
  2008-12-08  0:41     ` Juanma Barranquero
@ 2008-12-08  4:46       ` Harry Putnam
  0 siblings, 0 replies; 15+ messages in thread
From: Harry Putnam @ 2008-12-08  4:46 UTC (permalink / raw)
  To: help-gnu-emacs

"Juanma Barranquero" <lekktu@gmail.com> writes:

> Fload is the `load' function. If you search the C code, you'll see
> that emacs lisp functions defined in C are called F + name of
> function.
>
> What I wanted to say is that the load function is defined in C (and
> called Fload in the C code), so if you advise it you won't get
> information about the times it is called from other C code (search
> Fload in the src/ directory to see where does that happen). But you
> can modify Fload and add code to show what it is loading.

I see, so the more I think about this the more it looks pretty
daunting.  One thing that should make it easier though is that I don't
really need to track the c code..

What I'm after is to get something into the init process ahead of
everything else.  Something that reports what is loading... (except c
code).  My aim is to get one jump ahead of the OS developers who think
they need to interfere or `direct' emacs for me.  To me it can be
pretty confusing to determine what is happening as emacs starts up.

I'm just trying to see what files get loaded before my own `site-start'
file, So I can either head it off or leave it alone depending on what
it seems to try to do. The `site' in this case is just a single user
machine so no problems dealing with disgruntled users if I do stuff in
site-start.el in order to keep .emacs to some sensible size.

From Dmitrys' post I got the URL:
  (info "(elisp) Standard Hooks")
And tracked it into this section where I found this:

   (info "(elisp) Init File")

 -- Variable: before-init-hook
     This normal hook is run, once, just before loading all the init
     files (the user's init file, `default.el', and/or `site-start.el').
     (The only way to change it with real effect is before dumping
     Emacs.)

Its not at all clear what it means to say it is `run' once but it
doesn't really sound like it can be taken advantage of.

If so; Would this involve just a text edit?  I'm not at all sure how
to take advantage of a `hook'.  I have a few in my init files but they
are blatantly plagerized here or some other group like the gnus
groups.

 





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

* Re: Tracing what is loading
  2008-12-07 13:10 ` Michael Heerdegen
@ 2008-12-08  4:54   ` Harry Putnam
       [not found]   ` <mailman.2193.1228712089.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 15+ messages in thread
From: Harry Putnam @ 2008-12-08  4:54 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Maybe the variable `load-history' is interesting for you.

Well that cranked out a whipping 11,000+ lines.  (In an emacs that had
been up a few hours).  But I'll be darned if I could see what to do
with it.

Starting a fresh emacs like `emacs .'

The values start already at dired stuff (wrapped for mail):
  Value: 
  (("/usr/share/emacs/22.3/lisp/dired.elc" dired-listing-switches
  dired-subdir-switches dired-chown-program dired-use-ls-dired
  dired-chmod-program dired-touch-program dired-ls-F-marks-symlinks
  dired-trivial-filenames dired-keep-marker-rename dired-keep-mark

I want to know what happened further back.





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

* Re: Tracing what is loading
       [not found]   ` <mailman.2193.1228712089.26697.help-gnu-emacs@gnu.org>
@ 2008-12-08 18:21     ` Michael Heerdegen
  2008-12-08 20:09       ` Harry Putnam
  2008-12-09  6:30       ` Harry Putnam
  0 siblings, 2 replies; 15+ messages in thread
From: Michael Heerdegen @ 2008-12-08 18:21 UTC (permalink / raw)
  To: help-gnu-emacs

Please note that there already _is_ a message for every file loaded. But
because the *Messages* buffer only shows the last 50 (or so) messages,
you can't see them because starting up causes quite more messages.

Indeed all you need is `load-history'. Due to the internal structure of
lists, the last item belongs to the first load file and vice versa, so you
must read it bottom up.

I have written a command which only shows the files, in the right order:

(defun list-load-files () (interactive)
  (with-current-buffer
      (get-buffer-create "*Load History*")
    (erase-buffer)
    (insert (format "%s" "Load History\n============\n\n"))
    (mapc
     (lambda (x) (insert (format "%s\n" (car x))))
     (reverse load-history))
    (pop-to-buffer (current-buffer))))

You can eval it with M-:. Call it with M-x list-load-files.

The listing should cover all lisp files ever loaded after startup.


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

* Re: Tracing what is loading
  2008-12-08 18:21     ` Michael Heerdegen
@ 2008-12-08 20:09       ` Harry Putnam
  2008-12-09  6:30       ` Harry Putnam
  1 sibling, 0 replies; 15+ messages in thread
From: Harry Putnam @ 2008-12-08 20:09 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Please note that there already _is_ a message for every file loaded. But
> because the *Messages* buffer only shows the last 50 (or so) messages,
> you can't see them because starting up causes quite more messages.

Very kind of you to take time to explain patiently and write a nice
function that does _exactly_ what I was after.

Thank you very much.

I was suprised to see that ~/.emacs is loaded so far after so much
other stuff.  and some 118 other things are loaded even before
site-start.el which I always thought loaded very early.

Thanks again... very helpful





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

* Re: Tracing what is loading
  2008-12-08 18:21     ` Michael Heerdegen
  2008-12-08 20:09       ` Harry Putnam
@ 2008-12-09  6:30       ` Harry Putnam
  2008-12-10  2:56         ` Kevin Rodgers
  1 sibling, 1 reply; 15+ messages in thread
From: Harry Putnam @ 2008-12-09  6:30 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Please note that there already _is_ a message for every file loaded. But
> because the *Messages* buffer only shows the last 50 (or so) messages,
> you can't see them because starting up causes quite more messages.

Sorry to be back bugging you again but maybe you can add a little more
here.

Looking at that list, I see some anomalies.

The first 105 lines are of this form:
  /usr/share/emacs/22.3/lisp/term/x-win.elc

All are in /usr/share/emacs/22.3*

Then comes a line (106):

    /usr/local/GNUS/lisp/gnus-load.el

An address that is not a normal path to be searched.
How did emacs know to look there?

That is the address to gnus but not the one in the emacs
distribution.  This is the cvs version.

The information that tells emacs where to look for that lisp directory
resides in /usr/local/share/emacs/site-lisp/site-start.el

Which according to the list has not yet been loaded.

That doesn't show up until line 118
/usr/local/share/emacs/site-lisp/site-start.el

So is this listing just not accurate to that degree or is something else
going on?  I ask because I'm trying to discover when certain init
files are loaded.





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

* Re: Tracing what is loading
  2008-12-09  6:30       ` Harry Putnam
@ 2008-12-10  2:56         ` Kevin Rodgers
  2008-12-10  8:47           ` Harry Putnam
       [not found]           ` <mailman.2437.1228898847.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 15+ messages in thread
From: Kevin Rodgers @ 2008-12-10  2:56 UTC (permalink / raw)
  To: help-gnu-emacs

Harry Putnam wrote:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
> 
>> Please note that there already _is_ a message for every file loaded. But
>> because the *Messages* buffer only shows the last 50 (or so) messages,
>> you can't see them because starting up causes quite more messages.
> 
> Sorry to be back bugging you again but maybe you can add a little more
> here.
> 
> Looking at that list, I see some anomalies.
> 
> The first 105 lines are of this form:
>   /usr/share/emacs/22.3/lisp/term/x-win.elc
> 
> All are in /usr/share/emacs/22.3*

I think those were dumped into the emacs executable.

> Then comes a line (106):
> 
>     /usr/local/GNUS/lisp/gnus-load.el
> 
> An address that is not a normal path to be searched.
> How did emacs know to look there?
> 
> That is the address to gnus but not the one in the emacs
> distribution.  This is the cvs version.

Hmmm, perhaps that directory was in load-path at some point,
or the file was loaded using its absolute file name.

> The information that tells emacs where to look for that lisp directory
> resides in /usr/local/share/emacs/site-lisp/site-start.el
> 
> Which according to the list has not yet been loaded.
> 
> That doesn't show up until line 118
> /usr/local/share/emacs/site-lisp/site-start.el
> 
> So is this listing just not accurate to that degree or is something else
> going on?  I ask because I'm trying to discover when certain init
> files are loaded.

Does /usr/local/GNUS/lisp/gnus-load.el show up in the list when you
start emacs with -Q?  What about the other files between it and
/usr/local/share/emacs/site-lisp/site-start.el?

-- 
Kevin Rodgers
Denver, Colorado, USA





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

* Re: Tracing what is loading
  2008-12-10  2:56         ` Kevin Rodgers
@ 2008-12-10  8:47           ` Harry Putnam
       [not found]           ` <mailman.2437.1228898847.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 15+ messages in thread
From: Harry Putnam @ 2008-12-10  8:47 UTC (permalink / raw)
  To: help-gnu-emacs

Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:


[...]

>> All are in /usr/share/emacs/22.3*
>
> I think those were dumped into the emacs executable.
>
>> Then comes a line (106):
>>
>>     /usr/local/GNUS/lisp/gnus-load.el
>>
>> An address that is not a normal path to be searched.
>> How did emacs know to look there?
>>
>> That is the address to gnus but not the one in the emacs
>> distribution.  This is the cvs version.
>
> Hmmm, perhaps that directory was in load-path at some point,
> or the file was loaded using its absolute file name.
>
>> The information that tells emacs where to look for that lisp directory
>> resides in /usr/local/share/emacs/site-lisp/site-start.el
>>
>> Which according to the list has not yet been loaded.
>>
>> That doesn't show up until line 118
>> /usr/local/share/emacs/site-lisp/site-start.el
>>
>> So is this listing just not accurate to that degree or is something else
>> going on?  I ask because I'm trying to discover when certain init
>> files are loaded.
>
> Does /usr/local/GNUS/lisp/gnus-load.el show up in the list when you
> start emacs with -Q?  What about the other files between it and
> /usr/local/share/emacs/site-lisp/site-start.el?

No and site-start.el doesn't either but then they shouldn't with -Q

Even with -Q though I do see one anomaly.  
The whole list (108) lines), with the exception of two lines near the
end are all in /usr/share/emacs/22.3. and you've suggested how that happens.

  /usr/share/emacs/site-lisp/subdirs.el  (loads at 102)

Again that seams normal enough.

And this one is a little puzzling:

  /home/reader/.abbrev_defs (loads at line 106)

But of course ~/.emacs is not loaded with the -Q flag so what
instructs emacs to load ~/.abbrev_defs?  I thought ~/.emacs was doing
that. I do have code there about .abbrev_defs, But as you can see,
even with -Q something has caused emacs to load ~/.abbrev_defs.

I'm beginning to think my initial thought to track things in the
*Messages* buffer is a better place to track init files.

The history-list shows the cart before the horse in several instances
and the list is cluttered with too much stuff that isn't related to
init files.

Here is a similar example.. loading emacs without -Q:

/anex/usr/local/share/emacs/site-lisp/whats_loading.el (line 110)
/usr/local/GNUS/lisp/gnus-load.el (line 111)

Both of those things are loaded from site-start.el (I'm pretty sure
that's the only place.  And the `shadow' list bears that out too.

  /usr/local/share/emacs/site-lisp/site-start.el (line 119)

The history list has site-start.el loading 8,9 lines after 2 items
that are only loaded from site-start.el.

But looking at the *Messages* output.. things appear in the right
order.  However, I don't see the init files gentoo developers have
stuck in /usr/share/emacs/site-lisp.  

I think they are loading somewhere before my site-start.el file but
neither the history-list or *Messages* shows it.

I can probably get to the bottom of it by putting a message in those
files or something... still the whole init process is pretty confusing.









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

* Re: Tracing what is loading
       [not found]           ` <mailman.2437.1228898847.26697.help-gnu-emacs@gnu.org>
@ 2008-12-10 19:14             ` Michael Heerdegen
  2008-12-11  1:46               ` Harry Putnam
  0 siblings, 1 reply; 15+ messages in thread
From: Michael Heerdegen @ 2008-12-10 19:14 UTC (permalink / raw)
  To: help-gnu-emacs

Hello again,

~/.abbrevs is the default value of `abbrev-file-name', defined in
`paths.el'. This is set also with emacs -Q.

`load-history' is a flat list, so we can't expect that it reflects the
recursive load history perfectly. I don't know if file names are added
when loading the file starts or when it ends.

Maybe interesting for you:
There is a variable `message-log-max' which defines how much messages
are remembered in the *Messages* buffer. One can set it to `t' which
means `no limit', but of course its to late for you to do this after
startup. `message-log-max' is defined in `.../emacs/src/xdisp.c', maybe
one can simply edit and recompile this file?

P.S.: Why do you have to know which files are loaded at which time that
exactly?


Michael


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

* Re: Tracing what is loading
  2008-12-10 19:14             ` Michael Heerdegen
@ 2008-12-11  1:46               ` Harry Putnam
  0 siblings, 0 replies; 15+ messages in thread
From: Harry Putnam @ 2008-12-11  1:46 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Heerdegen <michael_heerdegen@web.de> writes:

>
> P.S.: Why do you have to know which files are loaded at which time that
> exactly?

Sort of a nothing reason really.  I started out trying to figure out
what OS developers (of gentoo)  had inserted in places that would load
before my own site-start file.

I could have just put (message "here I is") in them and seen if that
turned up before site-start.el.

So far as having unlimited Messages buffer;  I don't find that it gets
over run just on a startup, and thats the only time I was concerned
with.

Gentoo developers put these files in place when you install emacs with
their `emerge' tool:

 /usr/share/emacs/site-lisp/site-gentoo.el

This directory:

 /usr/share/emacs/site-lisp/site-gentoo.d

And these files:

  ls /usr/share/emacs/site-lisp/site-gentoo.d

  20emacs-22-gentoo.el
  20emacs-cvs-23-gentoo.el
  50bbdb-gentoo.el
  50git-gentoo.el
  50guile-gentoo.el
  50libidn-gentoo.el
  50librep-gentoo.el
  50sawfish-gentoo.el
  65emacs-wget-gentoo.el
  71emacs-w3m-gentoo.el
  

It appears to be some kind of timed loading.  I was trying to figure
out what it all did.

Sorry to have made so much line noise about this. 





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

end of thread, other threads:[~2008-12-11  1:46 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.2095.1228610078.26697.help-gnu-emacs@gnu.org>
2008-12-07 10:01 ` Tracing what is loading Dmitry Dzhus
2008-12-07 13:10 ` Michael Heerdegen
2008-12-08  4:54   ` Harry Putnam
     [not found]   ` <mailman.2193.1228712089.26697.help-gnu-emacs@gnu.org>
2008-12-08 18:21     ` Michael Heerdegen
2008-12-08 20:09       ` Harry Putnam
2008-12-09  6:30       ` Harry Putnam
2008-12-10  2:56         ` Kevin Rodgers
2008-12-10  8:47           ` Harry Putnam
     [not found]           ` <mailman.2437.1228898847.26697.help-gnu-emacs@gnu.org>
2008-12-10 19:14             ` Michael Heerdegen
2008-12-11  1:46               ` Harry Putnam
2008-12-07  0:34 Harry Putnam
2008-12-07  9:58 ` Juanma Barranquero
2008-12-07 23:09   ` Harry Putnam
2008-12-08  0:41     ` Juanma Barranquero
2008-12-08  4:46       ` Harry Putnam

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.