Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

share emacs configuration between emacs 23 and emacs 24

I'm trying to put all my emacs configuration under version control in order to easily switch between different computers. Actually my preferred system is OSX (10.8.3) with emacs 24.3 from http://emacsformacosx.com/. But I can also work in other systems (more likely linux-based although different distribution ubuntu/scientific-linux) which generally are equipped with emacs 23.4. What I would like to have is a init file which check the version of emacs and the operating system, load the needed packages from emacs package manager. So far my .emacs init file for emacs 24.3 on OSX is as follow

(require 'package)
(setq package-archives '(
    ("marmalade" . "http://marmalade-repo.org/packages/")
    ("org" . "http://orgmode.org/elpa/")
    ("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)

After that there are configuration (loaded separately as for example

(load "python-sy")

which uses some packages not installed as default: in particular

color-theme
org-mode
theme-changer
ess-site
magit
auctex
python.el (fgallina implementation)

plus some other things which relies in already built-in packages I admit that I have no idea on how to start for having a .emacs init file which could be used indifferently in all the devices. Furthermore I also would like to have a way to load url-proxy-services based on the system configuration

(setq url-proxy-services '(("http" . "proxy.server.com:8080")))

Thank you for any help

like image 701
Nicola Vianello Avatar asked Jun 11 '13 14:06

Nicola Vianello


2 Answers

Relevant variables are system-type and emacs-major-version. You can use something like the following

(if (>= emacs-major-version 24)
    (progn
      ;; Do something for Emacs 24 or later
      )
  ;; Do something else for Emacs 23 or less
  )

(cond
 ((eq system-type 'windows-nt)
  ;; Do something on Windows NT
  )
 ((eq system-type 'darwind)
  ;; Do something on MAC OS
  )
 ((eq system-type 'gnu/linux)
  ;; Do something on GNU/Linux
  )
 ;; ...
 (t
  ;; Do something in any other case
  ))
like image 118
giordano Avatar answered Sep 28 '22 09:09

giordano


Along with giornado answer, you can also put your package-specific settings in a way they will be evaluated only when the package is present by testing the (require) result. Example with the bbdb package:

(when (require 'bbdb nil t)
    (progn ...put your (setq) and other stuff here... ))
like image 29
Seki Avatar answered Sep 28 '22 09:09

Seki