emacs - installation and configuration
- Installation
- Packages
- Init file
- Where can I find my .emacs file for Emacs running on Linux?
- Where can I find my .emacs file for Emacs running on Windows?
- Starting over
- When you clone the config files into a new computer, how to make sure all the packages are pulled from MELPA?
- How to resolve start-up issues?
- How can I reload .emacs after changing it?
custom-set-variables
andcustom-set-faces
- Troubleshooting
Installation
Linux
Arch Linux
pacman -S emacs
In a Linux (Redhat Linux) VDE provided in a corporate environment:
Installing emacs using the command sudo yum install emacs
installed an older version of emacs. I think it installed emac 24. How to install the latest version of emacs in a VDE like that?
I tried installing using homebrew but that failed because of a dependency failure. I think it complained that curl was not installed.
What is the process to compile emacs from source?
In Ubuntu:
sudo add-apt-repository universe
sudo apt update
sudo apt install emacs-gtk
Macbook:
- Run this:
brew install --cask emacs
to install the UI version. - Run this:
brew install emacs
This will not install the UI version of emacs. It will install only the terminal version. - Another method that worked for me one time in the past
- Installed emacs using homebrew. The command used is
brew install --cask emacs
- Tried to launch it using the icon in “Applications”
- Saw this error “Emacs can’t be opened because Apple cannot check it for malicious software.”
- Had to run this to get it installed with Apple’s Gatekeeper disabled.
brew reinstall --cask emacs --no-quarantine
- Was able to launch emacs successfully
- Installed emacs using homebrew. The command used is
Packages
Location of the packages
In Linux, it is /home/explorer436/Downloads/GitRepositories/<any-sub-directories>/.emacs.d/quelpa/melpa/
In Windows, the elpa directory is found in C:\Users\<username>\AppData\Roaming/.emacs.d\elpa\
How to update all packages?
Delete all the local packages and install them again.
- Remove everything in
~/.emacs.d/elpa
and launch emacs again. - It will pull all the necessary packages.
- If some of the packages are not installed properly, the
Messages
buffer will show the list of them. - Install them manually with
M-x package-install <package-name>
How to view the list of all the currently installed packages in Emacs?
If you are using Emacs in one machine, and if you want to set-up the exact same set-up settings in another machine, you need to view the list of installed packages from the package manager.
To see a list of the available packages : Meta x list-packages
Run this command till you find the first row of installed package: Ctrl s installed
Start selecting with Ctrl SPC
Go down till you reach built-in packages. Copy with Meta w
. Ctrl x b
for new buffer. Paste with Ctrl y
. Ctrl x Ctrl s
to save file.
Another alternative is, simply copy the .emacs
file from this computer to the other computer.
How to add MELPA as another source of packages in addition to GNU’s elpa?
- Hint: In order to avoid having to do this multiple times when switching between multiple machines, save the init files in GitHub so that you can just move them from machine to machine.
- The alternative is: In a browser, visit MELPA website. Grab the URL for the package archive “https://melpa.org/packages/” Meta x customize-group -> package -> Go to “package archives” -> “INS” to insert a new entry. Provide archive name and archive URL. Set the “State” to “Save for future sessions”.
After making changes to the config to add MELPA as a source of packages, run the following two commands:
Meta x
package-refresh-contents (to refresh the list of packages)Meta x
package-install
RET (to launch package install mode)- Type the name of the package you are looking for and when you find the package -> RET
Init file
https://www.emacswiki.org/emacs/InitFile
Your init file contains personal EmacsLisp code that you want to execute when you start Emacs.
If you want to look at the contents of the file within Emacs, ~ at the beginning of a file name is expanded to your HOME directory, so you can always find your .emacs
file with Ctrl x Ctrl f ~/.emacs
If you are trying to find out where the file is as opposed to looking at the contents of the file:
- It should be stored in the variable
user-init-file
. - Use
Meta x describe-variable RET user-init-file RET
orCtrl H v user-init-file
RET to check. You can also open it directly by using Meta x eval-expression RET (find-file user-init-file) RET
Where can I find my .emacs file for Emacs running on Linux?
For GnuEmacs, your init file is ~/.emacs
, ~/.emacs.el
, or ~/.emacs.d/init.el
Where can I find my .emacs file for Emacs running on Windows?
C:\Users\<username>\AppData\Roaming/.emacs
Starting over
If anything goes wrong with the customizations, delete the .emacs
file in the home directory and start from scratch or the backed up version of the file again.
When you clone the config files into a new computer, how to make sure all the packages are pulled from MELPA?
M-: (load user-init-file)
What is this doing?
- you type it in
Eval:
prompt (including the parentheses) user-init-file
is a variable holding the~/.emacs
value (pointing to the configuration file path) by default(load)
is shorter, older, and non-interactive version of(load-file)
; it is not an emacs command (to be typed inM-x
) but a mere elisp function
How to resolve start-up issues?
emacs --debug-init
How can I reload .emacs after changing it?
You can use the command load-file (~Meta x load-file~
, then press return twice to accept the default filename, which is the current file being edited).
You can also just move the point to the end of any sexp and press Ctrl xCtrl e to execute just that sexp. Usually it’s not necessary to reload the whole file if you’re just changing a line or two.
https://stackoverflow.com/a/2580726
custom-set-variables
and custom-set-faces
These blocks are added by the customize
interface.
You can move them to a separate file, though, if you like.
Just add this to your ~/.emacs.d/init.el:
(setq custom-file "~/.emacs.d/custom.el")
(load custom-file)
Troubleshooting
Debugging “Error setting nil” in Elisp
https://stackoverflow.com/questions/28086626/debugging-error-setting-nil-in-elisp
Clear custom-set-faces
and custom-set-variables
and start it again.