1

If I modify my .emacs file I usually call eval-buffer to apply all changes to existing buffers without restarting emacs. Now I have the following lines to invoke helm-mini each time emacs starts:

(if (< (length command-line-args) 2) 
(setq initial-buffer-choice (car (helm-mini)))
)

The problem is that if I call eval-buffer it displays a helm mini buffer each time.

How can I make emacs exclude those lines when calling eval-buffer or alternatively, how can I change the code lines above such that the problem doesn't occur anymore?

2
  • Use eval-region instead and select the region to be evaluated. Or, comment out what you don't want to be evaluated when calling eval-buffer. Or, simply put in conditions to prevent certain portions of code from being evaluated -- e.g., (defvar foo nil) -- and set the variable to either t or nil -- (if foo . . .).
    – lawlist
    Aug 19, 2016 at 22:03
  • This looks like a duplicate, but I don't have the time to look for it...
    – Drew
    Aug 19, 2016 at 22:33

1 Answer 1

3

If you want to call (helm-mini) after Emacs has started up, you can add it to emacs-startup-hook in your init file:

(add-hook 'emacs-startup-hook #'helm-mini)

This way Emacs will run this function upon startup, but not upon re-evaluation of your init file.

2
  • What does the # do?
    – student
    Aug 20, 2016 at 7:31
  • When 'foo is compiled, it's fine if foo it not a function. When #'foo is compiled, Emacs will warn about foo not being a function.
    – zck
    Aug 20, 2016 at 16:43

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.