andriamasinoro fenintsoa writes:
> Hi,
>
> I have a little problem with the "jde-resolve-relative-paths-p"
> variable. Actually, I would like to have the "." character in my
> jde-global-classpath variable but the JDE always translate it to an
> absolute path even if I set the former variable to nil.
>
> What should I do please?
>
There is a bug in the jde-normalize-path function. A fix will appear
in the next beta release. Meanwhile, you can patch jde.el with
the fixed version of jde-normalize-path included below.
- Paul
(defun jde-normalize-path (path &optional symbol)
"This function performs the following transformation on PATH:
* Replaces environment variables of the form $VAR or ${VAR} with
their values. Note that you must use the Unix notation for
environment variables on the native Windows versions of Emacs and
XEmacs.
* Replaces the tilde character with the value of the home directory,
typically specified by the HOME environment variable.
* Converts Cygwin style paths to DOS notation on Windows.
* Converts relative paths to absolute paths if
`jde-resolve-relative-paths-p' is non-nil. Paths are resolved
according to the location of the deepest project file found, or if
optional SYMBOL is non-nil, paths are resolved to the location of
the deepest project file found that defines SYMBOL.
Note: PATH can either be a path string or a symbol corresponding to a
variable that holds a path string, in which case the optional arg
SYMBOL is unnecessary."
(if (symbolp path)
(setq symbol path
path (symbol-value symbol)))
(let* ((directory-sep-char ?/)
(p (substitute-in-file-name path))
(len (length p)))
(if (and
jde-resolve-relative-paths-p
(> len 0)
(eq (aref p 0) ?.))
(let* (prj-file-path
(dir (file-name-directory (or (buffer-file-name)
default-directory))))
;; find the deepest originating project for the symbol
;; based on the current directory, and resolve to that
;; project's directory
(if symbol
(let ((prjs (get symbol 'jde-project))
(sort-fn
(lambda (x1 x2)
(let* ((dir1 (file-name-directory (car x1)))
(dir2 (file-name-directory (car x2)))
match1 match2)
(if (null dir1)
(null dir2)
(if (null dir2)
t
(setq match1 (compare-strings
dir1 0 (length dir1)
dir 0 (length dir1)))
(setq match2 (compare-strings
dir2 0 (length dir2)
dir 0 (length dir2))))
(cond
((not (eq match1 t))
(if (eq match2 t)
nil
(> (length dir1) (length dir2))))
((not (eq match2 t))
t)
((> (length dir1) (length dir2)))))))))
(setq prjs (sort prjs sort-fn))
(setq prj-file-path (caar prjs)))
(setq prj-file-path
(jde-find-project-file dir)))
(if prj-file-path
(setq dir (file-name-directory prj-file-path))
(setq dir default-directory))
(if (and (> len 1)
(eq (aref p 1) ?.))
;; path actually begins with `..', so normalize to one
;; directory up
(save-match-data
(string-match "\\.+/?" p)
(setq p (expand-file-name (substring p (match-end 0))
(expand-file-name (concat dir "../")))))
(setq p (expand-file-name p dir))))
;; Do tilde expansion but not relative path expansion when
;; jde-resolve-relative-paths-p is false.
(if (not
(or
(string= p ".")
(string-match "[.]/" p)))
(setq p (expand-file-name p))))
(setq p (jde-convert-cygwin-path p))
p))