How do I load a theme that I have downloaded onto emacs? - emacs

I have the .el file downloaded on my drive but I can't figure out how to load it into emacs. I am a very big noob at emacs, just started today and am just trying to change the theme. How do I do it? A step by step process would be appreciated. I have looked on the internet on how to do it but the documentation people give is a bit confusing.

The simplest method is to load the file when you start emacs: from the command line, type emacs -l /path/to/theme.el where you will have to provide the path (absolute or relative) to the file that you downloaded.
If you want to make this change permanent, then you can modify your initialization file (the .emacs file in your home directory usually, although that depends on what OS you are running; or equivalently $HOME/.emacs.d/init.el). Add the following line at the end:
(load-file "/path/to/theme.el")
again replacing the path with whatever is appropriate in your case (but make sure it's an absolute path, so it can be found no matter where you start your emacs from).
There are other ways, but these two are enough for now: you can learn about the rest later.

Related

Sharing a .emacs between computers. Emacs overwrites .emacs that is hard linked in my Dropbox

I want to keep my .emacs in my Dropbox folder, to sync it between work and home.
I moved my .emacs to my dropbox folder and then (hard) linked it like:
ln ~/Dropbox/.emacs ~/.emacs
Then if I open ~/.emacs in emacs, edit and save it, it deletes the .emacs hard link and overwrites it with a fresh .emacs so the linkage is gone. I have two seperate copies, a newer ~/.emacs and an out-of-date ~/Dropbox/.emacs.
I could edit the ~/Dropbox/.emacs file instead, but sometimes emacs write something into the .emacs by itself (say customizing variables) and the issue occurs again.
How can I get emacs to not overwrite that particular file? Or is there a way to launch emacs and tell it where to read the .emacs from?
[edit SOLVED]
Some guy posted a comment about using soft-symlinks instead of hard-links. This actually works for me and solved the issue. But then the guy who posted the comment deleted it again for some reason. ~thank you who ever it was~
I would heartily recommend that you place your emacs configuration files into a GIT repository.
I have a github repository for all of my elisp file, which enables me to share the files with any computer and track changes.
I used softlinks instead, which solved the issue.
An alternative suggestion (which I use): Let ~/.emacs (or ~/.emacs.d/init.el) be different for each computer you use. Use that file to set up system-dependent paths— the location of your Dropbox directory, the path to diff, the colors that work best on that monitor, whatever. Then load (require) a common file that contains all of your usual (system-independent) configuration. Call it "leo-init" or something.
And I heartily agree with the prior suggestion to put your emacs config into a git repository (or other vcs). It's fantastic peace of mind to know that if you screw something up, you can go back to the way it was— or examine in detail what exactly you changed and when.

Issue With Desktop Save Mode Not Saving

Recently I have been having an issue with desktop save mode where it will not actually save my desktop. In the echo bar it says "Error while saving the desktop..." After typing no it says "Opening output file: no such file or directory, then gives the location to the path of the file". After saving a .emacs.desktop file then restarting emacs I noticed that it is saving the buffer locations in that file but is not loading that file. Thanks. Also I am not sure what has caused this to happen as it was working a couple weeks backs and nothing has changed that should make a difference.
The only thing i have in my .emacs for the desktop mode is
(desktop-save-mode 1)
Looking at the code for desktop.el here, it looks like the error is bubbling up from desktop-kill, which runs when you exit Emacs. The first thing I'd try is to check that the directory where it tries to save the desktop is sane.
Looking at the code in desktop-kill, it only tries to do anything if the variable desktop-dirname is non-nil. But that only gets set when you run M-x desktop-save for the first time: are you sure that it's set to something sensible? To check its value quickly, you can type M-: desktop-dirname RET and it should appear as a string in the message area.
If the directory is something sensible (the directory exists and you can write to it...), then I'm not sure. You'll probably have to give more information to get a solution, and it's not really clear that it's an ideal question for StackOverflow.
i should hazard that you get this error by creating a shortcut in the windows start manual via clicking addpm.exe in the ...\emacs-version\bin\ folder.
you can further modify the shortcut. go to its property->shortcut tab, you will find that the Target has value like ...\emacs-version\bin\runemacs.exe, while Start in is void. try to fill Start in with the corresponding folder ...\emacs-version\bin (actually most directories would be fine, just don't leave it blank), then everything is fine. still, the machanism behind this remains unclear to me.
or you could always creat your own shortcut manually, only make sure that the target is runemacs.exe, not any other exe file.

Password on Emacs Boot Up

I was wondering whether there is a way to ask for a specific password when booting Emacs? I think I can ask for a pre-defined password which I can define in my .emacs file but I dont know how? I'm mainly interested to do this in an x- or graphical environment..
btw, I do know that the .emacs file can be seen and etc..but in my case it's not an issue.
I use epg to keep encrypted data in file. Then it simply loaded as normal emacs lisp file, as in my config. EPG will automatically ask for passphrase, and you can analyze return code of load function to determine, was loading successful or not
If I understand correctly, you are in a situation where multiple people share the same account on a computer -- that is, not only will they run the same emacs binary, they also have the same home directory where Emacs searches for the .emacs file.
It seems like you not only want to prevent others from reading the .emacs file, you actually don't want them to be able to run emacs at all.
Unfortunately for you, Emacs can be started with -q or -Q in which case the .emacs file is not evaluated at all. Thus any "protection" that relies on your .emacs file can easily be circumvented.
How about restricting access to the emacs binary instead? Maybe make it only executable for members of a certain Unix group (which of course is pointless if multiple people share the same account), or something along those lines. But note that this will not prevent them from installing their own local copy of Emacs.

Automatically opening a file in emacs by specifying the file name

I created a TAGS file for emacs in my django project using the following command on my Linux machine
ctags -eR *
I can now jump to a symbol definition using M-. and specifying the symbol name.In my project i have py,html and css files so is there also a way i can make emacs automatically open a file, if i specify the file name ?.
Thank You
I think you are looking for project management. There are few packages to manage project directory in emacs. The best one may be ede. but Its not easy to setup. It does have some learning curve and its limitations.
Thankfully there are many easy ones. like eproject. https://github.com/jrockway/eproject/wiki
anyway you can also check out emacswiki page for more details. http://www.emacswiki.org/ProjectSettings
http://www.emacswiki.org/emacs/find-file-in-tags.el
IDO (Interactive Do) mode does this. If you activate it, C-x C-f searches for files matching what you are typing, interactively. Beware though, it may take some time to get used to it.
[edit] The search is based on files or directories you've recently visited, and you can use M-s to force a search.
From the comments, I figured that you are looking for has nothing to do with tags, you just want a better find-file that makes good automatic guesses for the path given only the file name.
For this, I use the entirely awesome ido-mode: http://emacswiki.org/emacs/InteractivelyDoThings

Change the initial directory on emacs, and also some tips for a starter

How can I change the initial directory on emacs? I started using it today and there are a lot of things to learn!
Right now I'm using M-X cd and then I change the directory that I use for C-x C-f, but in a daily work I'm going to heavily use one particular directory so I need to make the change permanent.
Also if you have some tips for a starter it will be nice.
To set a default directory, simply put
(cd "/default/path/")
in your ~/.emacs file.
Emacs has a steep learning curve, but with constant use the most common commands will soon become second nature. As you discover more, emacs may become your favorite text editor, file manager, and email reader :)
To learn emacs, I'd start by pressing C-h t to start plowing through the excellent tutorial. Have a pad of paper beside you and write down the commands as you learn them. You'll use the crib sheet at first, but after a while, as I mentioned before, your fingers will learn the key combinations without your brain conciously intervening.
Good luck and have fun!
Default directory is determined by:
(setq default-directory "~/")
in this case, set to the users home dir, but it could be somewhere else.
If this variable is not set, the initial load point for find-file will be the directory where the emacs executable lives.
EDIT: on windows, a global HOME environment variable can be defined (HOME=c:\path\to\user\home\directory), ensuring that Emacs translates ~ to the correct value. This makes the Emacs settings usable across platforms.
Start up emacs only after changing to that "initial directory", effectively setting the current directory for emacs.
This is a solution specific to Windows.
Create a shortcut to emacs.exe" called GNU Emacs
Open Properties on the GNU Emacs shortcut
Set Start in to %USERPROFILE%\Documents
This solution works for multi-user workstations whether they are on or off Active Directory.
This shortcut will start Emacs in the current user's Documents folder.
Print out the Gnu Emacs Reference card and keep it by the desk.