Saturday, June 30, 2018

Setting up MELPA for Emacs packages

In my journey to learn emacs, one of the first things that I wanted to do was change the theme so that it was more pleasing to the eye.  Anyone who uses a tool enough knows that if you can personalize it for you, you personalize it. 

So in researching themes ( see the emacs themes site ), I kept seeing references to MELPA, which is an emacs package manager.  Sweet!  Unfortunately, my quest to install the theme I wanted was met with the fact that it is NOT configured to use MELPA by default.  Thus, the reason for this write-up. 

In order to configure emacs to see the MELPA packages, you need to edit your .emacs file in your home directory.  If you have at least opened emacs, this file should exist.  If not, just create it and open it for editing.

To correctly enable MELPA, you will need the following as the first section of the file:

;; load emacs 24's package system. Add MELPA repository.
(when (>= emacs-major-version 24)
  (require 'package)
  (add-to-list
   'package-archives
   ;; '("melpa" . "http://stable.melpa.org/packages/") ; many packages won't show if using stable
   '("melpa" . "http://melpa.milkbox.net/packages/")
   t))
 After you save the .emacs file, you will need to restart emacs if it is already running.  If not, start it up.  Once running, you will need to his what in the emacs world is referred to as M-x.  On a mac, that is Option + the 'x' key.  I don't run Windows, so I really couldn't begin to tell you what it is on there. 

That will drop you into the M-x mini buffer.  There, type 'list-packages'.  In the main window, a columned list should appear.  The 4th column is 'archive' and should have packages that say 'melpa' (as well as 'gnu').  If so, you are good to install the theme you found. 

To install a melpa package, drop back into the M-x mini buffer and type 'package-install'.  This will change the prompt to "Install package: " which will wait for a package name.  The nice thing is that tab-complete works in emacs.  So start typing a package name and hit tab, and a list will appear in the are right above the mini buffer. Once you complete installing the packages you need, go ahead and restart emacs. 

I certainly hope this makes your emacs package installation easier.  :)

Straddling the line between editors

Since I started in Unix/Linux about 20 years ago, I have been a staunch user and supporter of vi.  I have known plenty of people that were emacs aficionados, but haven't really taken the time to learn it to the point of being proficient.  I did look at it a few years ago after starting my current job, but with all of the new things I was learning, I forwent it in favor of the things I actually needed to learn at my job.

Now, 5 1/2 year later, I have decided that I am at a point where I finally have time to learn it.  I know what vi lovers are thinking, "hell no!", and I get that.  I was like that for years.  But, after getting to work for the last 5 1/2 years with a friend that I have now known for 16 years, I have seen him operate pretty seemlessly in emacs, without needing to go to the shell that often.  I have seen some pretty cool features that nicely streamlined his workflow.

Its never easy picking up a new tool, that's for sure, especially when you like the features of your current tool, but sometimes you have to make concessions to go farther.  All that said, don't be surprised if you see emacs related posts here, as I am wanting to share what I am learning.

In closing I will provide the two initial links that I am using to start my journey down the emacs path:

Absolute Beginner's Guide To Emacs
Practical Emacs Tutorial


Hopefully, if you decide to also venture down this road, those will help you as well.  I will say that so far, the Absolute Beginner's Guide has been awesome!!


 
Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 License.