18

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 ?

Drew
  • 75,699
  • 9
  • 109
  • 225
Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30
  • This is utterly bizarre. (Possibly a bug?) – PythonNut May 18 '15 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 :). – Mathieu Marques May 19 '15 at 07:24
  • 8
    I tried to use `with-eval-after-load` to wrap all of my package-related customizations once. Then I [saw the light](https://www.youtube.com/watch?v=2TSKxxYEbII) and started using [`use-package`](https://github.com/jwiegley/use-package) instead. – itsjeyd May 19 '15 at 08: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. – Mathieu Marques May 25 '15 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](http://www.gnu.org/software/emacs/manual/html_node/elisp/Startup-Summary.html). But without seeing your code, there's not much we can do. Also tell us which version of Emacs you're using. – Gilles 'SO- stop being evil' May 27 '15 at 12:33
  • @Gilles I actually put a link to [my dot files](https://bitbucket.org/angrybacon/dotemacs/src/ae2eba9abd6e6abb826e49198b5b2a21661ed904/lisp/init-helm.el#cl-19) in the post. Since then I started to use `use-package` as @itsjeyd advised, and I can't replicate the issue. I noticed that when I was wrapping `helm-command` and `helm-projectile`, Emacs would start up instantly (as in so fast that it's like it didn't load any package). – Mathieu Marques May 27 '15 at 14:47
  • @MathieuMarques [This](https://github.com/lunaryorn/.emacs.d/blob/master/init.el#L42) is a nice config I used as a guide on how to use use-package. – clemera Aug 16 '15 at 10:34
  • The answer to your original question is here: http://emacs.stackexchange.com/q/3624/9895 (but I like what I see of `use-package` too!) – Greg A. Woods Oct 23 '15 at 05:31

2 Answers2

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.

tak
  • 186
  • 4
  • I've changed since then to use `use-package`, and even while requiring `helm-config` I still get the same issue. Here is my updated config setup: https://bitbucket.org/angrybacon/dotemacs/src. – Mathieu Marques Nov 27 '15 at 19:33
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.

mmmmmm
  • 491
  • 1
  • 4
  • 19
Mathieu Marques
  • 1,953
  • 1
  • 13
  • 30