Tutorial :What are good practices to get GNU emacs and xemacs co-habitate


I would like to make a gradual switch from GNU Emacs to Xemacs. Are there tricks I can use to have the two play well?

Currently, I see the following issues:

xemacs alters .emacs The two do not like each others .elc files.



Interesting, most appear to be moving in the other direction as I believe XEmacs to be fairly dormant (based on activity of the xemacs-announce list). Simple packages can co-exist, but many folks have given up making their packages work in both XEmacs and Emacs.

But, in answer to your question, to get your .emacs to work in both, I'd start writing a some routines to do function translation between the two. For example, at one point I needed this to get my .emacs to work in XEmacs:

(if (not (fboundp 'tags-table-files))      (defun tags-table-files ()        (tag-table-files tags-file-name)))  

Other things were triggered on the Emacs variant, which I stored in a variable GNU:

(setq GNU (not (string-match "XEmacs\\|Lucid" (emacs-version))))  (if GNU       (do-emacs-thing)    (do-xemacs-thing))  

I was keeping compiled .emacs files and did this:

(setq compiled-dot-emacs-name (format ".emacs-%d%s" emacs-major-version                                                       (if GNU "" "X")))  

Regarding compiled packages, I'd probably store all the .el files in one directory (say emacs-lisp), but have an xemacs variant (xemacs-lisp) with symlinks to the .el files. And then you just byte compile each directory from the appropriate Emacs variant, and make sure to have your load-path point to the right one.

The Emacs wiki has a page on Emacs versus XEmacs which might be a good starting point to figure out other tips to make them cohabitate. Specifically, there's a page for customizing both.


I don't use xemacs, but newer GNU emacs will check for .emacs.d/init.el as well, so maybe moving .emacs stuff to init.el makes sense. Additionally you can link it to .xemacs/init.el if you manage to keep your customization applicable for both.

There is also a discussion on what emacs to prefer on emacswiki.


I started a slow move from Xemacs to Emacs a while ago. I now use both on a daily basis. To make the transition smoother (one set of init files), I stole the following .emacs file from http://xemacs.seanm.ca/_emacs (but the link is now dead).

(setq user-init-file        (expand-file-name "init.el"                          (expand-file-name ".xemacs" "~")))  (setq custom-file        (expand-file-name "custom.el"                          (expand-file-name ".xemacs" "~")))    (if (file-exists-p user-init-file)      (load-file user-init-file))  (if (file-exists-p custom-file)      (load-file custom-file))  

My ~/.xemacs/init.el starts off with:

(unless (boundp 'running-xemacs)    (defvar running-xemacs nil))  (setq load-path (cons "~/.elisp" load-path))             ; packages for both emacsen  (if running-xemacs      (setq load-path (cons "~/.elisp/xemacs" load-path))  ; packages for Xemacs only    (setq load-path (cons "~/.elisp/gnuemacs" load-path))) ; packages for Gnuemacs only  

From then on it is pretty obvious what I have (the occasional (if running-xemacs) ...). I also deleted all the .elc files from ~/.elisp, but I presume that Trey Jackson's suggestion will work.


on modern systems i do not see the need for precompiled elisp files anymore. The benefit in looking and on the fly changing the .el-files is much more higher.

.emacs: put your own defines in .emacs_startup (or which name you prefere) and put all your gnu-enmacs stuff there and put a conditional load in your .emacs

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »