jschaf / esup

ESUP - Emacs Start Up Profiler
398 stars 22 forks source link

Problem emulating load with eval #53

Open alastairdb opened 6 years ago

alastairdb commented 6 years ago

It seems commit 81f5f4da26b2b9e8c4ce9cc0272c3fb7ea4dbf3e changed esup-child.el to use advice on the load function. The advised function then steps through the code one sexp at at time doing an eval. This causes problems with the files automatically generated by package-install, which all contain lines such as:

(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))

The #$ construct is handled by load, but generates an error with eval.

On a related note, since my esup only works when esup-child-max-depth is 0, how does one set this variable?

colinxy commented 6 years ago

Having the same problem here. More specifically, it always fails with the following error:

  ERROR(profile-sexp) at /home/colinxy/.emacs.d/elpa/yasnippet-20180412.1548/yasnippet-autoloads.el:4 with sexp (add-to-list (quote load-path) (directory-file-name (or (file-name-directory nil) (car load-path)))): error=(wrong-type-argument stringp nil)

Results will be incomplete due to errors.
jschaf commented 6 years ago

Oh, I didn't realize load had special variables.

I added the customize variable esup-depth for controlling the depth. So, set esup-depth via customize or setq and it will get passed to esup-child.

jschaf commented 6 years ago

There's a couple ways to handle this:

  1. Don't intercept any load calls. That feels like throwing the baby out with the bathwater.
  2. Don't intercept files that end in -autoloads.el.
  3. Use a customized read-function that sets #$ to the current file name.
raxod502 commented 6 years ago

Just dynamically bind load-file-name to the appropriate value. That will cause read to expand #$ correctly. I had to do this for straight.el to correctly read autoloads files that used #$, for example.

etu commented 6 years ago

Getting exactly this same error just by initializing package.el:

  ERROR(profile-sexp) at /nix/store/xklyvs4b31dl37pyfyjbvri69wckgmmr-emacs-packages-deps/share/emacs/site-lisp/elpa/memoize-20180614.1230/memoize-autoloads.el:5 with sexp (add-to-list (quote load-path) (directory-file-name (or (file-name-directory nil) (car load-path)))): error=(wrong-type-argument stringp nil)

Would be nice is a fix was made so esup can be used with package.el at all :smile:

bymoz089 commented 5 years ago

Please fix it! This bug makes esup completely incompatible with package.el!

A crappy workaround this bug:

  1. write a shell skript /tmp/sed.sh:
    #/bin/bash
    FILE="$PWD/$1"
    sed -i.bak -e "s|^\(.*\)#\$\(.*\)$|;;\1#$\2\n\1\"$FILE\"\2|" "$1"
  2. then cd to the ~/.emacs/elpa directory
  3. then call this script with find:
    find . -iname "*-autoloads.el" -exec /tmp/sed.sh {} \;
kiennq commented 3 years ago

Ping, is there workaround for this that I can set in init.el?

undefinedDarkness commented 3 years ago

Any luck with this?