I often come across the following popular emacs builds:
graphene
prelude
emacs-live
Currently I'm running a custom configuration, but I'd like to experiment with these builds without clobbering my current ~/.emacs.d.
Here's some background on my current installation:
I installed Emacs via Homebrew, so it's located here: /usr/local/Cellar/emacs/HEAD/Emacs.app
My current version of emacs is:
GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)
Basically, here's what I'd like to know:
What's the easiest way to switch between these builds as well as my current custom configuration?
Given my current setup, is it possible to start multiple emacs sessions, each with their respective configuration/buffers?
(Edit: I've wrapped this approach up into a shell script which I've added to the EmacsWiki.)
I'd be inclined to use the $HOME environment variable:
Firstly copy the 'distribution' (for want of a better term) into a sub-directory .emacs.d of a directory which will serve as the replacement $HOME for that distribution. i.e. /path/to/(distribution)/.emacs.d:
$ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d
$ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d
Then you can start emacs using env to set the HOME environment variable locally for that command:
$ env HOME=$HOME/emacs/prelude emacs
$ env HOME=$HOME/emacs/emacs-live emacs
They shouldn't interact with each other, so you can run them together and have multiple side-by-side emacs instances, each using a different configuration.
I see that graphene is actually an ELPA package, so it has no init.el file and needs to be installed via the package manager; but you can still use the same technique to install it in a separate clean configuration: Simply make a similar directory structure to the others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el) containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs), and finish the remainder of the installation instructions.
The down-side to this technique is that Emacs won't see all your other dot files (because it will be looking in $HOME), and so running other processes from within Emacs won't necessarily work as normal; but that's not likely to be a huge issue if you're just experimenting, and you can always symlink or copy the bits you need.
You may even prefer it that way -- the benefit is that if anything in the distribution you're trialing writes files to the home directory, it's not going to clobber your real files.
This may also be a useful approach when upgrading Emacs to a new release (if you can run both the old and the new versions side by side) as you could set up a copy of your existing config to use with the new Emacs until you're convinced everything is working, and you can edit the new config without the risk of breaking your existing one. Or flip that around, and instead keep the original config in the new/alternate location, in case you need it as a back-up.
You can symlink ~/.emacs.d, this is what I do
1) Try to keep my emacs configuration ~/.emacs.d oriented i.e. all the config files should live in that folder. For example I use workgroups2, by default it stores workgroup configuration in ~/.emacs_workgroups but I have configured it to store configuration in ~/.emacs.d/workgroups, so my entire emacs configuration is in just one folder.
2) Then I have an ~/emacs_configs folder where all config folders (basically a folder with a init.el and rest of the configuration) live, so my personal config folder will be ~/emacs_configs/iqbal, a prelude distribution will be in ~/emacs_configs/prelude
3) Then finally I symlink ~/.emacs.d to the configuration I actually want to use, eg. to use my configuration I will do ln -s ~/emacs_configs/iqbal .emacs.d. If you want to tryout some configuration just copy the configuration folder to ~/emacs_configs/whatever_name and change the symlink
Hope this helps
I create ~/.emacs.1.d/init.el file , and give it content:
(setq user-emacs-directory "~/.emacs.1.d/")
then , start emacs like this emacs -q -l ~/.emacs.1.d/init.el , now emacs used new configration.
success!!
-q is means skip the default configration ~/.emacs.d/init.el
-l is means load new configration
You can do this with chemacs2. This is the primary (only?) usecase of chemacs2.
Related
I've cloned it but I didn't find any .exe file, Nor do i see it in programs list in Control Panel of windows. I'am a bit confused as to what cloning means. I know that there is direct download .exe file on vim.org website. Its for sure that I'am beginner for all these. Please help. Thanks for the help in advance.
reading the "installation" section found in the README.md of the vim repo, you can see the filenames containing the instructions that will help you with the installation, depending on your OS.
README_ami.txt Amiga
README_unix.txt Unix
README_dos.txt MS-DOS and MS-Windows
README_mac.txt Macintosh
README_haiku.txt Haiku
README_vms.txt VMS
So, for the full information I suggest you go to those files, or go to the vim website where there is also good information about the installation.
Anyway, I will briefly explain below the information that those files and the vim website say for most common operating systems
If you're on Unix:
git clone https://github.com/vim/vim.git
cd vim/src
make
If you're on Mac
The Macintosh binaries are not on the Vim ftp site. They are produced by a few Macintosh lovers. Often they lag behind a few versions.
MacVim has more a Mac look and feel, is developed actively and most people prefer this version. Most of MacVim was made by Björn Winckler.
MacVim can be downloaded here: link
Or if you prefer, here is the MacVim homepage.
If you're on Windows:
The next instructions were copied from here.
Option A: Using the self-installing .exe
Go to vim.org/download.php and click on self-installing executable (or just click here) and follow the prompts.
Watch out for:
When an existing installation is detected, you are offered to first remove
this. The uninstall program is then started while the install program waits
for it to complete. Sometimes the windows overlap each other, which can be
confusing. Be sure the complete the uninstalling before continuing the
installation. Watch the taskbar for uninstall windows.
When selecting a directory to install Vim, use the same place where other
versions are located. This makes it easier to find your _vimrc file. For
example "C:\Program Files\vim" or "D:\vim". A name ending in "vim" is
preferred.
After selecting the directory where to install Vim, clicking on "Next" will
start the installation.
Option B: Using .zip files
Go to the directory where you want to put the Vim files. Examples:
cd C:\
cd D:\editors
If you already have a "vim" directory, go to the directory in which it is
located. Check the $VIM setting to see where it points to:
set VIM
For example, if you have
C:\vim\vim82
do
cd C:\
Binary and runtime Vim archives are normally unpacked in the same location,
on top of each other.
Unpack the zip archives. This will create a new directory "vim\vim82",
in which all the distributed Vim files are placed. Since the directory
name includes the version number, it is unlikely that you overwrite
existing files.
Examples:
pkunzip -d gvim82.zip
unzip vim82w32.zip
You need to unpack the runtime archive and at least one of the binary
archives. When using more than one binary version, be careful not to
overwrite one version with the other, the names of the executables
"vim.exe" and "gvim.exe" are the same.
After you unpacked the files, you can still move the whole directory tree
to another location. That is where they will stay, the install program
won't move or copy the runtime files.
Change to the new directory:
cd vim\vim82
Run the "install.exe" program. It will ask you a number of questions about
how you would like to have your Vim setup. Among these are:
You can tell it to write a "_vimrc" file with your preferences in the
parent directory.
It can also install an "Edit with Vim" entry in the Windows Explorer
popup menu.
You can have it create batch files, so that you can run Vim from the
console or in a shell. You can select one of the directories in your
$PATH. If you skip this, you can add Vim to the search path manually:
The simplest is to add a line to your autoexec.bat. Examples:
set path=%path%;C:\vim\vim82
set path=%path%;D:\editors\vim\vim82
Create entries for Vim on the desktop and in the Start menu.
That's it!
Vim is open source software, and its source code, i.e. all the technical files that make up Vim is (nowadays) hosted at GitHub.
Cloning that repository means you'll download all of those files to your computer (and with Git as the underlying revision control system, you'll even get the full history of all changes ever done). As Vim supports a very big set of very diverse platforms (Windows, Linux, Mac, ...), the repository itself does not (and should not) contain pre-built binaries, nor a full installer that most users expect to run. So, unless you have the intention to actively contribute to Vim by submitting bug fixes or enhancements, you don't need to clone or do anything with GitHub. If you do want to get technical, src/INSTALLpc.txt contains the instructions for building Vim on Windows. This includes choosing a compiler, installing it and the required dependencies, configuring the build, building, and then finally copying the files to a permanent location on your PC, either manually or by building and then running an installer.
For plain passive consumption of Vim (which is rewarding in itself, but may even lead you to eventually also programming it), the Downloading Vim page on vim.org has all the information that you need, with links to the most popular installers right at the top.
a word on versions
For a casual user, using the latest stable version is recommended; this is 8.2 right now; gvim82.exe is a corresponding installer for Windows. This offers the best compromise between stability and latest features. In the case of Vim, expect a new release roughly every year.
You'll also find development builds (something like 8.2.0740); these usually function as well and have the very latest features under development, but often are less stable. I would use these only if you really need a leading-edge feature, or want to report a bug. You should then probably update very frequently, and from there it's only a small step to actually cloning the repository and building everything on your own!
I am using Emacs 24 in an work environment where I cannot modify what are outside of my personal folder.
I want to install a particular package, but there is already an older version of this package installed outside of my personal folder. I have to install it manually, so I added the package folder path to 'load-path' and required it myself in init.el file. But still, after the startup, when I check the version, it showed that the version is still the older version which is loaded from a place outside of my personal folder.
My question is how can I mask that older package? In another word, how can I choose to load my version instead?
The key is to modify the the load-path variable at the very beginning of your init.el file.
add-to-list adds to the front of a list. For example, this is how I load my version of org:
(add-to-list 'load-path "~/.emacs.d/org-mode/lisp")
I also suggest that you inspect the contents of the variable (use Meta-x describe-variable). This will inform you what directories are scanned first.
Be warned, sometimes mixing packages creates weird issues. If this happens, be patient and try one package at a time.
Addendum: as Drew mentioned below, emacs will try to find a package to load
in each of the directories in the load-path, starting from its head.
So the order of the directories in it matter.
--dmg
I generally write code by logging on to a remote machine (typically AWS). I have a fairly big list of packages that I use and a fairly large .emacs.el. While I can quickly install emacs on nay remote machine, I am looking for a way to "package" my emacs and house it somewhere so that I can quickly install it on any machine I login to. Whats the best way to do this?
First you would obviously bundle everything into source control (except for a private file). Bitbucket and Gitlab offer private repos.
You can see this wiki for a way to list all the needed packages in your init file. (this is actually used by Prelude)
Then I see some options.
Use Cask
Some use Cask to manage package dependencies, some do not
The Cask file lists all dependencies:
(depends-on "cask")
(depends-on "dash")
(depends-on "evil")
Use org-mode
Some write their config in org-mode and load it with a call to org-babel, which is doable in one line in ~/.emacs.d/init.el:
(require 'org)
(require 'ob-tangle)
(org-babel-load-file (expand-file-name "~/.emacs.d/myemacs.org"))
Split your config in multiple files
and some split it in multiple elisp files.
Here some nice configs worth taking inspiration from:
Noahfrederick uses org-mode and Cask: https://github.com/noahfrederick/dots/tree/master/emacs.d
Purcell uses multiple elisp files where each require the needed package: https://github.com/purcell/emacs.d/tree/master/lisp
In init-elpa.el, he defines a function that takes a package in argument and installs it if it is not present:
(defun require-package (package &optional min-version no-refresh)
"Install given PACKAGE, optionally requiring MIN-VERSION.
If NO-REFRESH is non-nil, the available package lists will not be
re-downloaded in order to locate PACKAGE."
(if (package-installed-p package min-version)
t
(if (or (assoc package package-archive-contents) no-refresh)
(package-install package)
(progn
(package-refresh-contents)
(require-package package min-version t)))))
and in every file, he uses:
(require-package 'dired+)
Also commit the installed packages
And for your config to install quicker, you may add the installed packages into source control too. That way you can also ensure to have identical environments.
I always recommend putting the entire ~/.emacs.d under version control, including all packages and other libraries.
It's a bit more hassle, and maybe a bit messier, but if you want to guarantee the state of the configuration every time you install it somewhere new, you need to have a complete copy.
Using version control is my firm preference, because that makes it trivial to revert changes to packages, etc. So if you upgrade a package and Emacs breaks, it's a single step to put things back they way they were (and doing so doesn't require you to remember how they were).
With this approach the act of cloning a single repository is all that is required to obtain a working system in a known state; and it limits your dependence upon the availability, consistency, and permanence of remote sources to just that one repository (and if you have it locally, or even carry a copy with you, you have no remote dependencies at all).
That said, lots of people don't bother and don't experience any issues, so it's not a critical point for most people.
It would be helpful if you clarified a little more what you mean by "any" computer. It sounds like emacs already installed on the machine and you just want to configure emacs to use your packages and settings. Do you have physical access to the machine or network from which you could load files from a memory stick? If not, can you access cloud storage?
My own setup looks like this:
I have a Windows 7 machine at work and Linux Mint at home.
I have a dropbox account that holds all my emacs configuration files and packages. This dropbox account is synchronized to a local folder on each machine and my .emacs file on each computer is only one line:
(load-file "~/Dropbox/dotemacs.el")
I often tweak package files and configurations. Using dropbox keeps my settings synchronized across all computers.
If you can't install Dropbox, you could manually sync to cloud storage like git.
check https://github.com/redguardtoo/elpa-mirror,
create your own repository on a usb memory stick, it's stable because all the package versions are the version you are already using for a very long time.
That's the quickest way, basically you can get your setup on any machine in 1 min.
As the README for my repo emacs for rails devs says it is as easy as pushing your ~/.emacs.d contents to github and on the target machine:
Install emacs using homebrew (chances are you are on OS X) brew install emacs --HEAD --use-git-head --cocoa --srgb
Git clone your repo to ~/.emacs.d/
Boot emacs
If there is magic, it's using the built in package manager with ELPA and marmalade and having that check to see if packages are installed and if not, install them.
Works for me and my boxes & servers.
I often come across the following popular emacs builds:
graphene
prelude
emacs-live
Currently I'm running a custom configuration, but I'd like to experiment with these builds without clobbering my current ~/.emacs.d.
Here's some background on my current installation:
I installed Emacs via Homebrew, so it's located here: /usr/local/Cellar/emacs/HEAD/Emacs.app
My current version of emacs is:
GNU Emacs 24.3.50.1 (i386-apple-darwin13.0.0, NS apple-appkit-1265.00)
Basically, here's what I'd like to know:
What's the easiest way to switch between these builds as well as my current custom configuration?
Given my current setup, is it possible to start multiple emacs sessions, each with their respective configuration/buffers?
(Edit: I've wrapped this approach up into a shell script which I've added to the EmacsWiki.)
I'd be inclined to use the $HOME environment variable:
Firstly copy the 'distribution' (for want of a better term) into a sub-directory .emacs.d of a directory which will serve as the replacement $HOME for that distribution. i.e. /path/to/(distribution)/.emacs.d:
$ git clone https://github.com/bbatsov/prelude.git ~/emacs/prelude/.emacs.d
$ git clone https://github.com/overtone/emacs-live.git ~/emacs/emacs-live/.emacs.d
Then you can start emacs using env to set the HOME environment variable locally for that command:
$ env HOME=$HOME/emacs/prelude emacs
$ env HOME=$HOME/emacs/emacs-live emacs
They shouldn't interact with each other, so you can run them together and have multiple side-by-side emacs instances, each using a different configuration.
I see that graphene is actually an ELPA package, so it has no init.el file and needs to be installed via the package manager; but you can still use the same technique to install it in a separate clean configuration: Simply make a similar directory structure to the others, then create an init.el file (e.g. ~/emacs/graphene/.emacs.d/init.el) containing the code from the graphene installation instructions, then run emacs (e.g. env HOME=$HOME/emacs/graphene emacs), and finish the remainder of the installation instructions.
The down-side to this technique is that Emacs won't see all your other dot files (because it will be looking in $HOME), and so running other processes from within Emacs won't necessarily work as normal; but that's not likely to be a huge issue if you're just experimenting, and you can always symlink or copy the bits you need.
You may even prefer it that way -- the benefit is that if anything in the distribution you're trialing writes files to the home directory, it's not going to clobber your real files.
This may also be a useful approach when upgrading Emacs to a new release (if you can run both the old and the new versions side by side) as you could set up a copy of your existing config to use with the new Emacs until you're convinced everything is working, and you can edit the new config without the risk of breaking your existing one. Or flip that around, and instead keep the original config in the new/alternate location, in case you need it as a back-up.
You can symlink ~/.emacs.d, this is what I do
1) Try to keep my emacs configuration ~/.emacs.d oriented i.e. all the config files should live in that folder. For example I use workgroups2, by default it stores workgroup configuration in ~/.emacs_workgroups but I have configured it to store configuration in ~/.emacs.d/workgroups, so my entire emacs configuration is in just one folder.
2) Then I have an ~/emacs_configs folder where all config folders (basically a folder with a init.el and rest of the configuration) live, so my personal config folder will be ~/emacs_configs/iqbal, a prelude distribution will be in ~/emacs_configs/prelude
3) Then finally I symlink ~/.emacs.d to the configuration I actually want to use, eg. to use my configuration I will do ln -s ~/emacs_configs/iqbal .emacs.d. If you want to tryout some configuration just copy the configuration folder to ~/emacs_configs/whatever_name and change the symlink
Hope this helps
I create ~/.emacs.1.d/init.el file , and give it content:
(setq user-emacs-directory "~/.emacs.1.d/")
then , start emacs like this emacs -q -l ~/.emacs.1.d/init.el , now emacs used new configration.
success!!
-q is means skip the default configration ~/.emacs.d/init.el
-l is means load new configration
You can do this with chemacs2. This is the primary (only?) usecase of chemacs2.
In my computer I have an Emacs plugin installed with the Debian package system, but this plugin is obsolete and I'm trying to install it inside my home directory with package-install. I have installed a newer version, but if I check which version is loaded, the older one is.
I tried with load-file and the global path to the new version, but it still loads the old version.
How can I force the load of the new one? Please, imagine that I'm not the sysadmin of the computer and I cannot uninstall any software package.
When a library contains multiple files one can assume that a single main file will load the others as necessary; but if the directory isn't in the load-path then it won't be able to load them (or at least not those versions), so load-file on its own isn't going to do the trick.
I don't make much use of package.el myself, but I'd really have thought that it would manage the load-path such that it took precedence over anything in site-lisp (which is presumably where the debian package is installing things.)
Try running emacs --no-site-lisp and check that the correct version of the library is loaded. If you don't want anything from the site libraries, then that might even be your solution.
If that works, then check the load-path variable after starting Emacs normally. Unless an absolute path is given, Emacs will look at those directories in sequence, and use the first one which matches. I am guessing that for some reason your site-lisp directory is appearing before the one created by package.el.
Or perhaps the package didn't install correctly at all.
That all said, in Emacs 24.3 at least (package-initialize) is called automatically and I don't think you should need to manually load anything. Check the package-load-list variable.
Edit:
On that last note, refer to cannot open load dired-details.
At the time I hadn't noticed that Emacs doesn't initialize packages until after the user init file has loaded, so you generally will need to initialize them manually in your init file.
Try this
(defun please-load-my-stuff ()
(interactive)
(load "PATH-TO-STUFF/STUFF))
When having access to init, put just form "(load ...)" there.
If more than one file is needed, load-path must be set also that way - before load, so the other required files are accessible.