20

I went over my configuration files and wanted to do some cleanup.

My understanding of with-eval-after-load was that its body would be evaluated right after the related package is loaded. While cleaning up my configurations files and splitting them even more, I wanted to enclose every package configuration with with-eval-after-load. Everything went as expected until I enclosed the configuration for helm and helm-projectile.

Here is what I had in mind (lisp/init-helm.el):

(with-eval-after-load 'helm
  (setq helm-mode-line-string "")
  (add-to-list 'helm-sources-using-default-as-input 'helm-source-man-pages)
  (define-key global-map (kbd "C-c m") 'helm-imenu)
  (define-key global-map (kbd "C-x b") 'helm-buffers-list))

(with-eval-after-load 'helm-command
  (global-set-key (kbd "M-x") 'helm-M-x))

(with-eval-after-load 'helm-projectile
  (helm-projectile-on))

After restarting Emacs, I get this window size issue:

emacs-window-size-issue

This is how I resize my window:

(set-frame-parameter nil 'fullscreen 'fullboth)

I'm guessing I am misusing with-eval-after-load, how would one sanitize his Emacs configuration and make sure nothing breaks no matter what package are installed ?

8
  • This is utterly bizarre. (Possibly a bug?)
    – PythonNut
    Commented May 18, 2015 at 19:07
  • Do you have any idea what this could be related to? I'm using railwaycat's OS X port and I don't want to add an issue where this doesn't belong :). Commented May 19, 2015 at 7:24
  • 8
    I tried to use with-eval-after-load to wrap all of my package-related customizations once. Then I saw the light and started using use-package instead.
    – itsjeyd
    Commented May 19, 2015 at 8:00
  • @itsjeyd This looks very handy and convenient indeed ! I ran into some trouble however: I commented out (package-initialize) and replaced it with (require 'use-package) but I will get File error: Cannot open load file, no such file or directory, use-package when restarting Emacs. And yet, once Emacs has started I can eval (require 'use-package) with no issue. Finally, I even tried with-eval-after-load, still same error. The readme isn't very clear on how to install use-package when using packages from package.el. Commented May 25, 2015 at 10:58
  • 1
    Show us your .emacs, preferably a stripped-down version that demonstrates the problem with as few lines and as few external packages as possible. This probably has to do with timing of frame setup vs package load during startup. But without seeing your code, there's not much we can do. Also tell us which version of Emacs you're using. Commented May 27, 2015 at 12:33

2 Answers 2

2

I use with-eval-after-load a lot, mostly for adding or removing elements to or from lists after the default values have been evaluated. That way I don't have to keep track of changes in the default values.

As for the problem with your helm initialization, the documentation recommends that (require 'helm-config) be present in your init.el or its dependencies.

I've found that it's easier just to require helm-config during initialization rather than relying on autoload, especially since I would be loading it almost immediately most of the time anyway.

1
1

Turns out it had nothing to do with helm initialization (or little).

In my everlasting quest to optimize Emacs' start-up time, I have moved all of interface related things at the very beginning of my configuration. That includes the pseudo fullscreen that I use.

Putting the corresponding line before any of the heavy lisp was loaded fixed my issue.

Here is my configuration for reference.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.