Hi,
nobody responded to my bug report, so I'll apparently have to
fix it myself... :-)
Testcase: on Windows (the fault won't show on Unix), open a Java file
and create new JDE project in the same directory (make sure
there are no other project files on the path towards the root -
it isn't that they would mask the problem, but they might be
destroyed when demonstrating it). Restart XEmacs, open the Java
file again (JDE should notice the project file) and run
jde-save-project . JDE keeps the prj.el buffer (it should save and
close it after updating but doesn't), and the contents of
the buffer are wrong.
Analysis: in a couple of cases (it's quite possible that I didn't
notice all of them), JDE needs to map a pathname to the project
file to an (existing) buffer containing the file; it does it by
checking the result of buffer-file-name on the items of
buffer-list, with string=, *not* against the raw file name, but
against a somewhat canonicalized string (in particular, a string
having directories separated - even on Windows - by slashes) and
naturally can't find the buffer... There should be a function for
this task, which handles these irritating details - and apparently
there is: get-file-buffer . So, I replaced the ad-hoc check by
a call to get-file-buffer (in 2 places, where it seemed
"clear" what's going on) and got the testcase to work.
Possible follow-up: I wonder what JDE will do with mixed-case
pathnames; I tried only all-lowercase... Overall, the Right Way
would of course be to document what *exactly* functions (like
jde-save-close-buffer) expect as a parameter, but I can't
see myself bothering with that sort of thing - the included
patch seems good enough...
Bye
Vasek
--- jde.old-el Mon Nov 26 10:12:25 2001
+++ jde.el Mon Mar 4 16:50:28 2002
@@ -1383,9 +1383,7 @@
(defun jde-save-close-buffer (project)
"Saves and closes the buffer associated with PROJECT."
- (let* ((buffer (find-if (lambda (buf)
- (string= project (buffer-file-name buf)))
- (buffer-list)))
+ (let* ((buffer (get-file-buffer project))
(standard-output buffer))
(if buffer
(progn
@@ -1404,9 +1402,7 @@
(lambda (project)
(if (and (not (string= (car project) "default"))
(member (car project) projects))
- (let ((buffer (find-if (lambda (buf)
- (string= (car project) (buffer-file-name buf)))
- (buffer-list)))
+ (let ((buffer (get-file-buffer (car project)))
standard-output)
(if (null buffer)
(setq standard-output (setq buffer (jde-save-open-buffer (car project))))
2002-03-04 Vaclav Barta <vbar(a)comp.cz>
* jde.el: use get-file-buffer to map pathname to buffer