I am trying to add "~/" to the emacs load path, because for whatever reason it is not there. I managed to find the command for adding to the emacs load path:
(add-to-list 'load-path "~/")
When I execute this command the load-path variable contains all the stuff it did before, and "~/" is added to the list. The problem is when I quit emacs, the next time it starts the "~/" had been removed from the list, the change is not persistent. How do I add something to the emacs load-path variable permanently?
Adding to the .emacs file won't work here, because the problem is that the .emacs file, which is in the ~/ directory, is not being loaded, so modifying the .emacs file won't fix this problem.
I guess there is a typo in phils' comment. The right way should be C-h v user-init-file RET. Maybe you customized this variable in some other places and you forgot. Try changing the value of this variable back to the default.
Related
I want to open a few (or at least one) .org file(s) upon starting spacemacs and I can not achieve this. I suspect it would be the same lisp code for spacemacs and emacs.
Thus far I found this little snippet
(find-file "~/todo.org") from this blog post
but it doesn't work when I put it down in the end of my .spacemacs file. I'm not sure if I should put it in init.el file because I think part of spacemacs philosophy is to just add everything to the .spacemacs file to make it easy.
Are you sure there is no buffer for that file, perhaps not displayed? (From your comment the answer to this is that the buffer is present but not displayed.)
Try with an init file that has only that find-file expression. If that works (displays the file buffer) then ensure that you put that expression last in your init file.
If that simple change (putting the sexp last) doesn't (also) work then bisect your init file to find out what other code there is interfering.
You should add (find-file "your-file") inside the function dotspacemacs/user-config.
Try adding it as the last line in the function (I tested it here and it worked).
To find the "correct" init.el file use the command SPC f e d (or M-x spacemacs/find-dotfile).
I put my font setting at a separate font_settings.el file and load it with:
(load-library "font_settings")
at the end of init.el.
But every time I start Emacs, emacs seems not load the settings.
I have to eval-buffer to evaluate init.el to let it work.
So it seems the settings are OK but loading sequence or the way I load it is not right...
Any thoughts?
The code of font_settings.el is here (too long):
http://pastebin.com/ExpY1mTy
Is font_settings.el in your load-path? If not, put it there or add the directory that contains it:
(add-to-list 'load-path "/the/full/directory/name/my-directory/")
See the Emacs manual, node Lisp Libraries.
You can check whether the library was actually loaded by using C-h v load-history. (Alternatively, you can check whether something that the library defines actually gets defined.)
I have my emacs configuration file under ~/.emacs with just one declaration:
(setq default-directory "/var/www/")
What I want to do is to C-x C-f and go directly to my apache directory. But I tried using C-x C-f and my current directory is HOME.
The file gets loaded, because I used this: (shell) and the shell gets opened. Anyone knows where my error is? I just want to set the start-up directory in htdocs.
default-directory does not do what you seem to think. C-h v
default-directory
default-directory is a variable defined in `buffer.c'.
Its value is "/"
Local in buffer stackoverflow.com/questions/14914353; global value is nil
Automatically becomes buffer-local when set in any fashion.
This variable is safe as a file local variable if its value
satisfies the predicate `stringp'.
Documentation:
Name of default directory of current buffer. Should end with slash.
To interactively change the default directory, use command `cd'.
It's a buffer-local (i.e. buffer specific) variable, meaning its value is
different depending on which buffer is currently active. So when you think you've set it to
"/var/www", you are simply visiting a file already in that directory.
If you want to open a file from "/var/www", you need to make your own command
that binds "/var/www" to default-directory.
Just in case someone is wondering how to do this:
As #Pacha was saying, when emacs starts, the welcome screen shows up and it will change your working directory to the command-line-default-directory
So, for example, If you want your default directory to be "~/", add this to your .emacs and you should be on track.
(setq command-line-default-directory "~/")
(setq default-directory "~/")
Solved it, it was a really weird problem.
Every time I try to open a file from the default buffer (*GNU Emacs*) it changes the default directory to ~/, but when I try to open a file from another buffer, it opens to the one I specified in my variable.
I am using the Emacs editor, and every time I start Emacs, I lose my previous settings.
For example, every time I have to type:
M-x cua-mode RET
M-x auto-complete-mode RET
How can I save my settings in Emacs?
Thanks.
You can add them to your .emacs file.
(cua-mode)
(auto-complete-mode)
If you find that there are already things in your .emacs file, then you might want to add the commands at the end.
The best answer I can think of is to point you at the manual:
http://www.gnu.org/software/emacs/manual/html_node/emacs/Customization.html
In particular, see the sections on "Easy Customization" and the "Init File"; but I would recommend at least skimming over everything in this section.
In your emacs directory there is a site-lisp folder. Normally it will be empty. you could create a file default.el in this folder. Add these two lines
(cua-mode t)
(auto-complete-mode)
and save it.This will be executed during Init. If you want to set environment variables for your emacs application only(not permanent) add a file called site-start.el in the site-lisp directory and define value for that variable ex:(setenv "VARIABLENAME" "value"). The site-lisp directory is in the standard search path for Lisp library.
How do I get emacs to tell me the location of the .emacs file it has loaded?
My situation is simply when I do sudo emacs, it loads up a very different .emacs file than the one in my home directory. I can get around with by doing M-x eval-buffer on my own .emacs file, but that's a lot of extra steps, plus it doesnt seem to clear out the goofy binds in whatever .emacs file is being loaded. If anything, I'd simply like to find the .emacs file and remove some of the stranger binds (c-n, c-p, c-a all rebound to strange stuff)
My main question is still, how do I get emacs to tell me the location of the .emacs file it has loaded?
The init file used is stored in the variable 'user-init-file'. To see this use 'describe-variable' (C-h v), type in 'user-init-file' and it will display the file used.
You could try to see what file is found by:
C-x C-f ~/.emacs RET
~ gets translated to the value of the HOME environment variable. Emacs looks for .emacs, then .emacs.elc (the byte compiled version), then .emacs.el, then ~/.emacs.d/init.elc and ~/.emacs.d/init.el. This documentation shows the alternatives. It also depends on the environment variabls LOGNAME and USER.
You can also check out the contents of the *Messages* buffer - though you should set (setq message-log-max t) (if you can) to ensure that all the Messages are kept. Inside that buffer there are lines that look like:
Loading /home/tjackson/.emacs.tjackson.el (source)...
which will show what files were loaded.
You should also check out the Find-Init documentation that shows even more files that can be loaded like the site-start.el, and terminal specific initialization (new to me).
If you are on Linux, you could try this to see what files are opened by emacs when it launches.
sudo strace -o /tmp/emacs.txt -e open emacs