help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: suggestion for portable emacs customizations


From: Fabrice Niessen
Subject: Re: suggestion for portable emacs customizations
Date: Thu, 30 May 2013 10:42:01 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.3 (windows-nt)

Hi Luca,

Luca Ferrari wrote:
> I'm beginning to have a lot of virtual machines where I have to run
> emacs, and I would like to have them all configured the same way with
> the same extensions (e.g., autocomplete) and configurations. Is there
> a smart way to provide a kind of "distribution" so that I can ease and
> automate the configuration of the multiple installations?
> The first thing  was thinking about was to set up a ~/.emacs directory
> will all the lisp extensions and to raw copy it, but there could be a
> smarter way...
> Any idea?

The approach I chose: have one (huge) Emacs config file [1], and as less
system-dependent customs as possible. So, I consider it OK to have "when
running-ms-windows" or such conditions, but I don't like "conds" with the
different machine names. At least, I try to avoid that as much as I can, and
abstract the differences between the machines.

Now, regarding the loading of packages, I choose to:

- put them in a distributed (versioning) system: SVN, Git or DropBox.

- replace explicit `require' calls by `try-require' calls which won't fail
  (and stop processing the rest of your .emacs) if the package is not present.

--8<---------------cut here---------------start------------->8---
      (defvar lvn/missing-packages nil
        "List of packages that `try-require' can't find.")

      ;; require a feature/library if available; if not, fail silently
      (defun try-require (feature)
        "Attempt to load a library or module. Return true if the
      library given as argument is successfully loaded. If not, instead
      of an error, just add the package to a list of missing packages."
        (let (lvn/time-start)
          (condition-case err
              (progn
                (message "(info) Checking for `%s'..." feature)
                (if (stringp feature)
                    (load-library feature)
                  (setq lvn/time-start (float-time))
                  (require feature))
                (message "(info) Checking for `%s'... %s (loaded in %.2f s)"
                         feature
                         (locate-library (symbol-name feature))
                         (- (float-time) lvn/time-start))
                t)
            (file-error
             (progn
               (message "(info) Checking for `%s'... missing" feature)
               (add-to-list 'lvn/missing-packages feature 'append))
             nil))))
--8<---------------cut here---------------end--------------->8---

Best regards,
Fabrice Niessen

[1] Under a VCS, so that you can easily propagate your changes from one
machine to the others.

PS- If you're interested, here's a link to my .emacs file, provided as a
library (called "emacs-leuven"):
https://www.assembla.com/code/emacs-leuven/git/nodes/master/emacs-leuven.el

-- 
Fabrice Niessen
Leuven, Belgium


reply via email to

[Prev in Thread] Current Thread [Next in Thread]