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

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

Re: Per-directory customizations?


From: Vagn Johansen
Subject: Re: Per-directory customizations?
Date: Fri, 30 Apr 2004 19:13:02 +0200
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (windows-nt)

Roy Smith <roy@panix.com> writes:

> Is there any way to do customizations on a per-directory basis?
> For example, I've got java project which lives in ~/dev/foo.  Anytime I 
> run M-X compile anywhere inside the ~/dev/foo hierarchy, I want the 
> command run to be "cd ~/dev/foo; ant".  I don't want to just set 
> compile-command in my .emacs file, because the right command varies 
> depending on which project (i.e. directory subtree) I'm in.
>
> Is there any way to do this?  I'm running GNU Emacs 21.2.1.

http://www.emacswiki.org/cgi-bin/wiki.pl/DirVarsPackage

With the dirvars.el package you create a file called .emacs-dirvars in
the root directory containing

    compile-command: "cd ~/dev/foo; ant"

Then this setting is automatically used by the root directory and all
subdirectories.


I use the following to store the current compile-command in a
.emacs-dirvars file.

    (defun vjo-create-dirvars-file (cmd)
      (interactive)
      (if (file-exists-p ".emacs-dirvars")
          (progn
          (find-file ".emacs-dirvars")
          (goto-char (point-max)))
        ;; else
        (progn
          (find-file ".emacs-dirvars")
          (insert ";; -*- emacs-lisp -*- \n")
          (insert ";; VJ\n")
          (insert (concat "compile-command: <QUOTE>" cmd "<QUOTE>\n"))
          (replace-string "\"" "\\\"" nil (previous-line 1) (point))
          (replace-string "<QUOTE>" "\"" nil (previous-line 1) (point))
          (save-buffer))))

-- 
Vagn Johansen


reply via email to

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