views:

145

answers:

3

A long time ago,when I wrote my .emacs setup[1], I used a shell script to compile and join the whole thing. The thing is now very old and "crusty", so I am now rewriting it to replace things such as:

(defmacro make-new-comment( mode face strcom color1 color2)
   (list 'progn
         `(make-face ',face)     
         `(if (not (assoc ,strcom ,(intern (concat (symbol-name mode) "-comments-alist"))))
              (setf ,(intern (concat (symbol-name mode) "-comments-alist"))
              (append ,(intern (concat (symbol-name mode) "-comments-alist")) '((,strcom . ,face)))
              )
          )
        `(modify-face ',face ,color1 ,color2 nil t nil nil nil nil)
   )
)

and something occured to me. When compiling I access several environmental variables giving information about the system, for example[2], the full name of most programs called by some mode that uses comint[3]. Rather then reading environmental variables, i could use some autoconf like tool to tweak the .emacs files and then compile them.

The problem is that autoconf is just plain ugly. I considered cmake, but the documentation is very poor especially on constructing your own build system. I'm not familar with alternate systems.

Suggestions?

[1]: To make clear, by .emacs setup I mean the 30 or so files and two subdirs of code that I have. Not to mention several packages that ( well at the time of inclusion ) are not part of the standard emacs distribution.

[2] I've replaced eg with "" since apparently many people do not know that eg means for example. Either that or they don't know what an example is.

[3] Such as diff-mode, and ruby-mode.

+1  A: 

which diff?

More details would be useful here. Are these environment variables that you set yourself? or things provided by your distro?

Somewhat ironically, it sounds suspiciously like emacs' incredibly powerful built-in scripting is what you're looking for.

jkerian
+1  A: 

I agree with jkerian: why are you assembling your .emacs from parts? Here is what I do: break it down by language or feature and use require and provide. My .emacs looks like:

; -*- emacs-lisp -*-
(add-to-list 'load-path "~/elisp/personal")

(require 'jdk-generic)
(require 'jdk-haskell)
(require 'jdk-keywiz)
(require 'jdk-lua)
(require 'jdk-ocaml)
(require 'jdk-org)
(require 'jdk-php)
(require 'jdk-tex)
(require 'jdk-text)
(require 'jdk-whitespace)

Each individual file in ~/elisp/personal then sets up support for a language or whatever, then provides jdk-whatever. Here is jdk-lua.el:

(add-to-list 'load-path "~/elisp/packages/lua-mode-20071122")
(add-to-list 'auto-mode-alist '("\\.lua$" . lua-mode))
(autoload 'lua-mode "lua-mode" "Lua editing mode." t)
(provide 'jdk-lua)

Notice that I keep all elisp packages in ~/elisp/packages. This means I can copy my .emacs and ~/elisp directory just about anywhere and have it work straight away.

Jack Kelly
+1  A: 

From what I understand, you want a script to autodetect where are your tools (like diff, grep...) instead of manually telling your .emacs where they are through environment variables.

If you are on a unix-like platform, all your tools like diff, grep, should already be on your PATH and emacs should have no problem finding them. So, in your .emacs you should not use any environment variable and put directly tools name in your configuration.

If your goal is to make a portable .emacs that could be executed on Windows for example, then you should put all the gnuwin32 tools in your PATH too, so that emacs find them without problem. But for Windows, you'll have to do many other tiny arrangements for emacs commands to work properly as on a unix system.

Using a tool like autoconf is something very time-consuming for something that could be well handled by customizing one single .emacs file. If you have specific things to do for a particular system, you could write elisp code like this :

(if (eq window-system 'w32)
    (progn ... ))

Also, if you want to automate the byte compilation of all your .el files, you could use a command like this on your shell :

emacs --batch -f batch-byte-compile *.el
Jérôme Radix