How can I save my Emacs settings? - emacs

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.

Related

emacs font setting does not load at start

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.)

emacs orgmode -- how to export html file to other directory instead of the same directory with .org file

emacs 24.2.1 and org mode version 8.0.3,Although I have referred to the resolution in Emacs Org-mode - Export to another directory?, add below statement to the .org file directly. after pressing C-c C-e h o,the .html file still come to the current directory.
#+bind: org-export-publishing-directory "~/org/exported_html/"
and i have also tried to add below statement to .emacs file. but still not work out what i want.
(setq org-export-publishing-directory "~/org/exported_html")
anyone who can give me an advice? thanks.
The var you're using is for publishing. What you do with C-c C-e is exporting (unless you then press P or such for publishing "projects"). I think your Org file must be part of a project, and then your variable would make sense. Not 100% sure, to be further tested.

How to make speedbar list the C functions + Unable to use sr-speedbar+macro+command history

I am new to Emacs on Windows XP and have multiple queries which I could not find/understand after a lot of search.
I understand that speedbar will support showing of C functions list. As mentioned in http://stackoverflow.com/questions/259364/how-do-i-configure-emacs-speedbar-for-c-sharp-mode, I added the code in .emacs as
(speedbar 1)
(add-to-list 'speedbar-fetch-etags-parse-list
'("\\.c" . speedbar-parse-c-or-c++tag))
I see the speedbar startup but it never shows the functions. Maybe I need to install etags but cannot find it. I also found gtags but could never find a binary
I copied sr-speedbar.el in ~/emacs.d/ directory. I added (require 'sr-speedbar) in .emacs, commented out speedbar related code, reloaded M-x ~/.emacs but did not find any sr-speedbar. If I uncomment speedbar code and comment sr-speedbar, it shows the speedbar on loading. Emacs is able to find sr-speedbar.el in ~/emacs.d/ directory since if I change filename, it shows an error: unable to find sr-speedbar.
I wanted to make a keyboard macro for logging using tramp and ssh. However, when I record a macro, I have to delete multiple characters to provide the path from the beginnig i.e. emacs automatically shows the last path and so I have to delete all the characeters and then start again with ssh://. The keyboard macro records all backspaces and returns error if the backspaces are more than the length of the current path. Is there a way to avoid it
I configured linum package. I want it to start at the beginning of emacs session automatically with typing M-x linum. How can I do that?
Is there way to retrieve command history (not shell commands) and then replay some command
Thanks again for patience on reading until the point :-)
For C, C++, and other languages, supported by CEDET/Semantic, the Speedbar is able to show functions & other objects. But you need to setup Semantic correctly, for example, you can use my article in CEDET.
As I understand, to enable linum-mode globally, you need to put (global-linum-mode 1) into your ~/.emacs
For 3, there are two options:
just type "/ssh:blabla" at the end of the pre-inserted directory (this directory will be ignored as witnessed by it becoming grey).
do C-a C-k to erase the content of the minibuffer.
For 5, there is repeat-complex-command bound to C-x ESC ESC and there is repeat bound to C-x z.

How do I find which .emacs file has been loaded?

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

How to open files automatically when starting emacs?

A newbie question and probably very bingable (had to use that word once :-)), but as I gather thats both ok for SO : How can you get files to open automatically when starting emacs?
I guess it sth. like executing the find file command in your .emacs but the exact notation isn't clear to me.
C-h b
This opens the help showing the correspondence between key-bindings and elisp functions.
Look for
C-x C-f
in it (you can do it by typing C-s C - x space C - f), you find find-file. Now, do
C-h f find-file
and it tells you, among other things, the syntax :
(find-file FILENAME &optional WILDCARDS)
So just try
(find-file "/path/to/your/file")
in your .emacs
Are you thinking of having it re-open files you've looked at before? The desktop package remembers files and re-opens them when you restart. Depending on your emacs version, you enable by simply adding this to your .emacs (for 22.1+ versions):
(desktop-save-mode 1)
And after that, it's pretty much automatic. Whatever files you had open before will be re-opened (provided you start from the same directory, b/c that's where the desktop configuration file is saved) - unless you add a change that forces a single desktop for all sessions.
There are bunches of variants of that functionality, which are listed in the session management page.
If you're calling it from the terminal , can't you just go
emacs FileName
You could desktop-save which basically restores the last session you were working with. When you restart emacs, it looks for a saved session in your folder and loads your files.
See link text