Title: RE: relative paths

Hi Stefan,
        I had a similar problem to solve, and used defadvice and environment variables instead of relative paths (which are very error prone and hard to maintain anyway). In my .emacs I have the following:

;;;{{{ set PTM_VOB and JARS_PATH environment variables
;;; based on file name of current buffer.
(setq vob-name "ptm")
(defun extract-vob-mount-path (path-components path-prefix)
        ""
        (if (string= vob-name (car path-components))
                        (concat path-prefix vob-name)
                (extract-vob-mount-path (cdr path-components)
                                                                        (concat path-prefix (car path-components) "/")))

)

(defun set-ptm-vob-var ()
  "Sets the PTM_VOB environment variable to the mounting point directory
   of the view containing the current buffer.
   For example: d:/Views/NASCIF_VIEW/ptm"
  (interactive)
  (setq vob-mount-path
                                (extract-vob-mount-path (split-string (buffer-file-name) "/") ""))
  (setenv "PTM_VOB" vob-mount-path)
  (setenv "JARS_PATH" (concat vob-mount-path "/RunTime/CentrexIP/jars"))
  (setenv "MI2_APPS" (concat vob-mount-path "/RunTime/CentrexIP/MI2/apps"))
  (message (getenv "PTM_VOB")))

; set PTM_VOB and JARS_PATH env variables based on loaded project
(defadvice jde-load-project-file (before set-ptm-vob-var-advice
                                         activate compile)
  "When loading a new project, also resets the PTM_VOB environment variable
   to match the mouting path of the current file"
  (set-ptm-vob-var))
;;;}}}

set-ptm-vob-var sets two environment variables, that depend on my ClearCase View. Their content is set based on the current buffer path, and instead of searching from the leaf up (like in a relative path) I start from the root down until I reach a known segment (the project root directory). I then set this absolute path in an environment variable, which is used by the JDE customization variables.

Good luck,
        Nascif

> -----Original Message-----
> From: Paul Kinnucan [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 12:32 AM
> To: Stefan Heimann
> Cc: [EMAIL PROTECTED]
> Subject: Re: relative paths
>
>
> At 02:46 AM 8/10/2001 +0200, you wrote:
> >Hi!
> >
> >I have the following project file:
> >
>
> This does not look like a project file to me. It looks like a
> .emacs file.
> I would suspect that you actually do not have a project file
> in your source
> hierarchy, in which case the JDE would treat relative paths
> as relative to
> the directory of the current source buffer, which appears to be the
> behavior you are experiencing.
>
> - Paul
>
> P.S. using setq to set JDE customization variables usually leads to
> problems. Please read the JDE user's guide section on customizing JDE
> variables.
>
> >
> >(setq jde-resolve-relative-paths t)
> >(defvar tmp-javacode-dir "~/javacode-tmp")
> >
> >(defvar cp  '("./"
> >          tmp-javacode-dir
> >          "./../../../lib/ejb.jar"
> >          "$JIKESPATH"))
> >
> >(custom-set-variables
> > '(jde-global-classpath cp)
> > '(jde-compile-option-directory tmp-javacode-dir)  ;;
> necessary for all the
> >completion commands
> > '(compile-command (concat "~/root-room-access/build.sh"))
> >)
> >
> >
> >I think I followed the rules described in the documentation, I don't
> >want to use absolute path in my project file. The problem is: When I
> >invoke the comiler, the paths are interpreted relativly to the file I
> >want to compile and not to the project file. Because I don't
> know what
> >structure my source code directory will habe, I don't see any way to
> >write a portable project file. The solution would be treating the
> >paths relativ to the location of the project file.
> >
> >Any suggestions??
> >
> >By Stefan
>
>

Reply via email to