1

I would like to keep all emacs related stuff (backup files, emacs-places, ido-last, etc.) in one place, namely ~/.emacs.d directory.

Is there general option for this or I have to set it individually for each package?

6

As far as I know there is no way to globally ensure packages save state only in your user-emacs-directory. That said, with newer releases of Emacs it is increasingly rare to find packages that don't already do this by default. (To use your example, Ido writes ~/.emacs.d/ido.last by default in my current Emacs 24.4 install.) I've configured this per package in the past and have been able to remove most of those settings.

The obvious exception is backup files. You do need to configure this using e.g.

(setq backup-directory-alist '(("." . "~/.emacs.d/backups"))) 
| improve this answer | |
  • 2
    Just checking my init files and I see that smex still defaults to ~/.smex-items rather than using ~/.emacs.d. So you're still going to have to watch for dotfiles that show up in your home dir and go hunt for the appropriate Emacs setting. For smex, that would be smex-save-file. – glucas Oct 16 '14 at 20:53
  • I've filed a fix for smex. – sanityinc Oct 18 '14 at 12:28
2

Your init file contains personal EmacsLisp code that you want to execute when you start Emacs.

  • For GnuEmacs, it is ~/.emacs or _emacs or ~/.emacs.d/init.el.
  • For XEmacs, it is ~/.xemacs or ~/.xemacs/init.el.
  • For AquamacsEmacs, it is ~/.emacs or ~/Library/Preferences/Aquamacs Emacs/Preferences.el

Courtesy of emacswiki

When Emacs is started, it normally tries to load a Lisp program from an initialization file, or init file for short. This file, if it exists, specifies how to initialize Emacs for you. Emacs looks for your init file using the filenames ~/.emacs, ~/.emacs.el, or ~/.emacs.d/init.el;

Courtesy of gnu

To answer, I'll say, everything should be inside ~/.emacs.d/ directory and inside this directory, there should be a file named init.el

EDIT

Now, inside ~/.emacs.d/init.el, you can configure whatever you want about your emacs related stuff, among other things, differents paths that should be used by emacs.

for example:

  • (setq backup-directory-alist '(("" . "~/.emacs.d/emacs_backup")))
  • (add-to-list 'load-path "~/.emacs.d/elisp")
  • (setq abbrev-file-name "~/.emacs.d/abbrev_definitions")
  • (setq recent-save-file "~/.emacs.d/recentf")
| improve this answer | |
  • I think you are misunderstanding the question. As I understand it, the OP is looking for a way to tell emacs that any peripheral files generated by emacs (e.g. backups, caches, bookmarks, histories, etc.) should be placed in a single location, and not spread throughout $HOME or /usr/share, or anywhere else. – nispio Oct 16 '14 at 21:50
  • @nispio indeed, I misunderstood the question, red it too quickly :( – Nsukami _ Oct 16 '14 at 22:02
0

Emacs 23.1 introduced the locate-user-emacs-file function, to help library authors to help users to relocate dot files within ~/.emacs.d/

Ideally, everything which used to look for a file in the home directory will now use this function to first look for the new preferred name:

locate-user-emacs-file is a compiled Lisp function in `files.el'.

(locate-user-emacs-file NEW-NAME &optional OLD-NAME)

Return an absolute per-user Emacs-specific file name.
If NEW-NAME exists in `user-emacs-directory', return it.
Else if OLD-NAME is non-nil and ~/OLD-NAME exists, return ~/OLD-NAME.
Else return NEW-NAME in `user-emacs-directory', creating the
directory if it does not exist.

Note that this means it's possible that some of your dot files in your home directory can simply be renamed to something in your user-emacs-directory, and Emacs will still find and use them.

Whether this is the case for any particular file, and exactly what it should be renamed to, is up to the author of the library in question. Check the library's code for uses of locate-user-emacs-file to find out if and how it is being used.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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