13

A question already has been asked how to reload a .emacs file after changing it.

The proposed solutions were to use M-x load-file or M-x eval-region RET on the changed region.

Neither of these solutions affect other open buffers for me. Is there a way to reload the .emacs file for all open buffers?

I should also note that the M-x load-file does not have the desired effect for reasons outlined in the comments to that answer.

Community
  • 1
  • 1
Alan Turing
  • 12,223
  • 16
  • 74
  • 116

2 Answers2

18

Your .emacs file is a global configuration that gets evaluated once only. It does not get applied to each buffer individually.

How you actually achieve what you want is really going to depend on what those .emacs changes are. Some elisp will only take effect the first time it is evaluated; or when a buffer changes major modes; or when a file is loaded; etc, etc...

If you want to reload some or all of the file buffers, ibuffer makes that pretty easy:

  • M-x ibuffer RET to start ibuffer (I recommend binding this to C-xC-b).
  • /f.RET to filter by filename regexp . so as to match any filename.
  • m (on [default]) to mark all filtered buffers.
  • V (uppercase) to revert all marked buffers.

or you could replace steps 2+3 with M-x ibuffer-mark-by-file-name-regexp RET . RET. You may wish to bind that command to *f:

;; Bind `ibuffer-mark-by-file-name-regexp' to *f
(eval-after-load "ibuffer"
  '(define-key ibuffer-mode-map (kbd "* f") 'ibuffer-mark-by-file-name-regexp))

type *c-h to see all the other ibuffer-mark-* commands which are bound by default.

phils
  • 71,335
  • 11
  • 153
  • 198
3

This may strike you as brute force, but

  • it will certainly reload your init file (consider alternatives to .emacs)
  • it will reload all open buffers (provided you are using desktop, which you should)
  • it is easy

    C-x C-c
    emacs --debug-init &
    
TomRoche
  • 1,464
  • 1
  • 16
  • 25
  • 1
    Be warned that desktop.el will restore certain things (e.g. major and minor modes, and local variables) as they were originally, rather than as they would be if the buffer was created anew. If the goal is to apply new settings to those buffers, this may be an impediment. – phils Aug 27 '11 at 04:58