Where does emacs look for the .emacs file? Is it simply looking for the file that is accessible anywhere in the PATH? Right now I simply have it in my user home directory on OS X. I have read that it is wise to place this file under version repo, which would mean moving it to a new directory and putting a .git in there (my VCS preference). Is this fine? How does emacs know where the file is located?
The simplest thing to do is move your ~/.emacs file to ~/.emacs.d/init.el. Emacs will find ~/.emacs.d/init.el automatically.
Then you can put all of .emacs.d/ under version control.
For example:
cd ~
mkdir .emacs.d
mv .emacs .emacs.d/init.el
cd .emacs.d
git init
Starting with Emacs 23, the variable user-emacs-directory holds the location of .emacs.d
You can get a more detailed explanation here
Putting your configuration file under a git repository is good. Just use .gitignore to the files you don't want to track!
My suggestion is to put your custom configuration Emacs lisp file under some directory and then load them in your Init file (~/.emacs.d/init.el) like this:
(load "~/myconfig/my_emacs_config.el")
Related
I am a newbie Emacs user, and have a problem when trying to install a new Emacs package. The package is https://github.com/tlh/workgroups.el.
I followed the file installation instructions in the accompanying README.md file: I copied the content of the "workgroup.el" into a new textfile with the same name, saved it to the same directory as my init.el file ("Put workgroups.el somewhere on your Emacs load path"), and added (require 'workgroups) to my init.el file ("Add this line to your .emacs file: (require 'workgroups)").
However, when saving and closing Emacs, and then opening my init file I get the
following error message
"File error: Cannot open load file, no such file or directory, workgroups "
Why doesn't Emacs recognize the new package?
Thanks in advance for any help : )
The directory where your init file lives (which is either your home directory or your ~/.emacs.d directory) is not in your Emacs load-path by default, and should not be added to it. (Recent versions of Emacs will complain if you do that.)
Instead place the new elisp library into a sub-directory named something like ~/.emacs.d/lisp, and add that to your load-path, by adding the following to your init file:
(add-to-list 'load-path (expand-file-name "~/.emacs.d/lisp"))
I would like to remove the 80 characters per line limit when pylint is checking files in Emacs (I am using the Elpy package for Emacs). I am on Debian Wheezy, and I'm using the backported Emacs24.
I checked the docs out here regarding the pylintrc hierarchy: http://docs.pylint.org/run.html#command-line-options, and tried placing a pylintrc and a .pylintrc file in my working directory with no luck. I also tried putting a .pylintrc in my home directory, again with no effect.
I suppose the question might be asked, "what is my working directory when I call pylint from inside Emacs?". I don't have a good answer to that question...
Where should the pylint configuration file be placed? Should it be .pylintrc or pylintrc?
create file:
~/.flake8rc
[flake8] ignore = E501
#max-line-length = 160
AFAIK emacs flymake is using flake8 by default (?)
Try putting it in:
~/.config/pylintrc
If the ~/.config directory doesn't exist, create it. If that doesn't work try:
~/.pylintrc
You can place the .pylintrc wherever you like and then tell Emacs what to use with...
(add-hook 'python-mode-hook
(lambda ()
(setq flycheck-python-pylint-executable "~/.local/bin/pylint")
(setq flycheck-pylintrc "~/.emacs.d/settings/.pylintrc")))
I found this answer on the Emacs Stackexchange flycheck cannot find module for pylint and on my system ~/.emacs.d/settings/.pylintrc is a symlink to the rc file from work repository.
Currently my .emacs file is found in /home
So is my .emacs.d folder and I suppose some other files like diary, notes etc will be created in this folder.
I find this really messy and I want all my emacs related files(including the .emacs) and folders in a single folder, say /home/EmacsHome
How do I do that in Ubuntu 12.04? In windows I did this by setting an environment variable HOME to the path of EmacsHome. But, in Ubuntu, the HOME variable will be used for several other programs as well, so I dont want to change that.
Emacs already supports a config directory for holding everything Emacs-related: ~/.emacs.d. Just use that.
Rename ~/.emacs to ~/.emacs.d/init.el, and you're virtually done.
If you have any other emacs-specific files outside of that directory, you might need to set a variable here or there to relocate them, or simply rename the file -- these days the defaults tend to automatically be within ~/.emacs.d, but an older filename in the home directory might still take precedence.
e.g.: the bookmarks file used to be ~/.emacs.bmk but if you haven't customized the variable then you can simply rename it to ~/.emacs.d/bookmarks. See C-h f locate-user-emacs-file RET and M-x find-variable RET bookmark-default-file RET for details.
If you're not sure how to proceed for any given file(s), you could just update the question with the details.
And as Alberto Zaccagni said, just create a symlink if you want an alternative name to access the directory. Although personally I would suggest retaining ~/.emacs.d as the real directory, and making the alternative name the link, like so:
ln -s ~/.emacs.d /home/EmacsHome
You could create a symbolic link to them, like so
ln -s /home/EmacsHome ~/.emacs.d
The first argument is the folder where you want the folders to be, the second one is where emacs usually looks for its configuration files, so with this approach you can put the folder wherever you like.
This works for OSX, so perhaps for you too . . . just change the paths to whatever suits your needs. The user-emacs-directory is where you would set the equivalent of .emacs.d. I have everything related to Emacs in my user-emacs-directory. If you use package manager, the elpa directory would be automatically crated there also.
(setq default-directory "~/.0.data/")
(setq user-emacs-directory "~/.0.data/.0.emacs/")
(setq diary-file "~/emacs/diary")
There's also another solution:
cd your-directory
HOME=$PWD emacs -L .
taken from https://github.com/capitaomorte/yasnippet#important-note-regarding-bug-reporting
I tried to use virtualenv virtualenv.el file posted here.
But I set the wrong directory. (Moreover, it seems that it requires I put my virtualenvs in the .virtualenv directory, not in the disparate directories where I've written them on my machine.)
How can I change this back? Now when I run M-x virtualenv-workon I don't have the same intro prompt I had the first time.
Update
Following the note left in the comments and the documentation, I added the following file to my project folder:
/home/fred/projectname/.dir-locals.el
this contains the following:
((nil . ((virtualenv-workon . "venv")
(virtualenv-default-directory . "/home/fred/projectname/venv"))))
However, still when I open emacs in my project directory and type M-x virtualenv-workon it only finds local (default) not venv. What am I missing?
I just had the same problem. I know the post is older and virtualenv.el is depricated, but in case anybody else also stumbles across this:
When you run M-x virtualenv-workon for the first time, it creates an entry in your .emacs file. The file should be found in your home directory. The entry is under custom-set-variables and is called virtualenv-root. You can open the file and adjust the path manually to whatever location you would like.
My c/c++ projects tend to have fairly straightforward directory structures which separate out src, include, bin, etc. I also tend to have a master makefile in the uppermost directory. When working like this in Emacs, I always have to issue M-x cd uppermost-dir in order for my compilation shortcuts to work as expected.
Is there a way to keep the current directory the same as the one from which I launch Emacs? That is, can I stop Emacs from changing it's working directory when I open a file?
Alternatively, is there something crucial I'm missing about the typical workflow with a directory hierarchiy like this exclusively in Emacs?
One way you can do this:
Make a file in the root directory of your project call .dir-locals.el
This will be read whenever you open a file in the directory or it's sub-directories.
In order to back up to the root folder and run make as your compile command, just put this in the .dir-locals.el file.
((nil . ((compile-command . "cd ~/mycode/c/; make"))))
nil is the mode to set local variables for (nil means any), so to do this for only C++ mode you could do this instead ...
((c++-mode . ((compile-command . "cd ~/mycode/c/; make"))))
Obviously you can set up a list with more options, say running ant for java files and so on.
emacs manual entry for directory locals
Invoke make with the --directory argument to force it to change to that directory before doing anything:
make --directory /path/to/your/project
Change to the project directory (where the Makefile is located) and call compile:
(defun my-compile ()
(interactive)
(when-let (default-directory (locate-dominating-file default-directory "Makefile"))
(call-interactively 'compile)))
The current directory associated with a buffer that's associated with a file is normally the directory containing the file. You can change it, but it's not necessary for what you want to do.
Set the variable compilation-directory through a file-local variable (typically relative to the current file, e.g. "../..") or through .dir-locals.el.
I used to M-x compile <RET> cd /path/to/project && make -j8 but prefer the method by Ben nowadays.