UP | HOME

JemPkg

Table of Contents

What is JemPkg about?

JemPkg is an elisp library that provides:

  • Emacs installation configuration using profiles (home, work machine, laptop, etc).
  • Packaging capabilities of elisp code.

Download

JemPkg 0.0.4

Changes from JemPkg 0.0.3:

  • Critical bug fixed.

JemPkg 0.0.3

Changes from JemPkg 0.0.2:

  • Minor fixes.

JemPkg 0.0.2

Changes from JemPkg 0.0.1:

  • pkgs/ renamed to elisp/
  • A finer control on which package directory is appended into the load-path
  • Interactive package listing facility: M-xjem-pkg-list-packages

Creating a basic directory hierarchy

First of all, you should setup a basic directory hierarchy where hold all your elisp packages and your configuration for those. The base directory name should be contained on the `jem-pkg-site-base' variable. I use to set my jempkg site base on ~/emacs.

The structure of a jempkg managed directory looks like:

emacs/  
  jem-pkg.el
  etc/
  sitename1/
     packagename1[%packageversion1].el
     packagename2[%packageversion2].el
     ...
  sitename2/
     packagename1.el
     packagename2.el
     ...
  elisp/
     packagename1[%packageversion1]/
     packagename2[%packageversion2]/
     ...

In that way, the package sources are contained on emacselisp, each package on a separate subdirectory. Configuration for each package is holded into the corresponding `etc/sitename/packagename[%packageversion].el' file.

Setting profiles

In JemPkg terminology, a "site" is a configuration schema. On my laptop i usually run different confs (or diferent packages) with respect my other machines (the one located on my work, the one located on my house, fencepost.gnu.org, etc). Since some configuration is shared among all these machines, there are a default site called "common" that is always loaded.

The content of an `.emacs' file running jem-pkg would be:

;;; Configure and load jem-pkg
(add-to-list 'load-path "~/emacs")  ;; Or where you have jem-pkg.el
 
(require 'jem-pkg)
(setq jem-pkg-site-base "~/emacs")
(setq jem-pkg-sites 
 '(("common" ("pkg1" "pkg2" ... "pkgn"))
   ("laptop" ("pkg3" "pkg4"))
   ("house" ("pkg5"))
   ("work" ("pkg6"))
   ...))

(jem-pkg-site-init)

That is all you need to have on your `.emacs'. All other package specific configuration can be on the `etc/' subdirectory.

What (jem-pkg-site-init) does

When 'jem-pkg-site-init' is invoked, it perform the following actions:

  • Get the system name and interpret it as the current site.
  • Build the package database (info about all the packages on `elisp/')
  • Initialize the `load-path' with all installed packages that appear on "common" and the actual site. If the package mentioned in 'jem-pkg-sites' is virtual (it is not backed by actual elisp files) then the load-path is left untouched.
  • Load the configuration for the "common" site.
  • Load the configuration for the current site (the one inferred on 1)).

An example

Lets see an example. Suppose we want to setup `jem-pkg' to manage our local emacs site. We want to setup two sites: "laptop" and "house". We use the vm mailreader to fetch mail in both machines, but with different mail sources. We also want to display battery information on the modeline only while running the laptop. Since we use cvs emacs on the laptop and emacs 21 on the house machine, we need two different versions of bbdb for each machine.

The first step is to make the directory structure:

~/emacs/  
   jem-pkg.el
   etc/
     common/
        common.el
        vm.el
        templatery.el
     laptop/
        laptop.el
        vm.el
        bbdb%2.34.el
        battery.el
     house/
        house.el
        vm.el
        bbdb%2.00.el                 
  elisp/
     vm%7.18/
     bbdb%2.34/
     bbdb%2.00/

The `elisp/packagename[%packageversion]/' directories contain the actual sources for these packages. Note that the `%packageversion' is optional. Indeed, since we use only one version of vm for all our sites, we could rename `elispvm%7.18' to `elisp/vm'. The `etc/site' contain the configuration files for each site. First of all, there are always a `site.el' file named after the site name (common.el, laptop.el, house.el). These files are for general configuration of the site (configuration that do not pertain to a concrete or big package). Then, comes package configuration files. You name a package configuration file after the name of the package, perhaps specifying the version of the package. So for the `bbdb' package you can setup `etc/sitename/bbdb.el' (that is loaded for any bbdb version) or `etc/sitename/bbdb%2.34.el' (that is loaded only if using `elisp/bbdb%2.34'). Note the `templatery.el' and `battery.el'. `templatery.el' contain specific configuration for templates (my templates). `battery.el' contain specific configuration for the battery package, that is shipped with emacs and therefore it is not on `elisp/battery'. Any "package" name specified on `jem-pkg-sites' is loaded with that configuration, even if there is not an actual package on `elisp/'.

The package listing major mode in action

JemPkg provides a major mode to list and access the current packages installed and loaded into the Emacs.

This buffer list all the packages currently loaded into your emacs by
JemPkg, categorized by site names (including "common").

common:

elpoint        0.2.0
apel           (unknown)
preview-latex  0.9.1
auctex         11.55
dismal         1.4
emms           (unknown)
icalendar      (unknown)
eldav          (unknown)
lisppaste      (unknown)
xml-rpc        1.6.4
url            (unknown)
dictionary     (unknown)
templatery     (unknown)
abbreviaty     (unknown)
color-theme    6.5.0
smtpmail       (unknown)
w3m            1.4.4
monk           8.1
mailcrypt      3.5.6
planner        (unknown)
remember       1.0
emacs-wiki     2.69
erc            5.0rev1.749
imaxima        0.7
tramp          2.0.45
bbdb           2.34
vm             7.18
misc           (unknown)

termi:

color-theme  6.5.0
imaxima      0.7

An ~/.emacs file using jem-pkg

;;;; .emacs
;; Jose E. Marchesi <jemarch@gnu.org>
;;                  <jemarch@es.gnu.org>


;;; Configure and load JemPkg
(add-to-list 'load-path "~/emacs")


(require 'jem-pkg) 
(setq jem-pkg-site-base "~/emacs")

(setq jem-pkg-sites 
      '(("common"
     ("bbdb"
      "tramp"
      "imaxima"
      "erc"
      "emacs-wiki"
      "planner"
      "mailcrypt"
      "monk"
      "w3m"
      "smtpmail"
      "color-theme"
      "abbreviaty"
      "templatery"
      "dictionary"
      "url"
      "xml-rpc"
      "lisppaste"
      "eldav"
      "icalendar"
      "emms"
      "dismal"))
    ("termi"
     ("imaxima"
      "color-theme"))
    ("desarrollo"
     ("imaxima"))))

(jem-pkg-site-init)

;;;;; Fin de fichero 
;;;;; A partir de aquĆ­, dragones

Author: Jose E. Marchesi

Date: 2013-11-20 20:15:15 CET

HTML generated by org-mode 7.4 in emacs 24

Copyright (C) 2010 Jose E. Marchesi. Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.