Re: Bugs introduced that affected jde-import-all

"Jeff Peck" <[email protected]>
Newsgroups gmane.emacs.jdee.devel
Message-ID <7F56DA8FA43E4E3BA517BE68809CF456@blue>
Ok, i see, the repeated inserts are the side-effect that Len mentioned when
he checked in the "default to wisent-java"
We need to find out why the buffer is not reparsed after the insert.

As fo the extra newlines, I tend to agree that adding new lines should not
be necessary.
But the original code, given:
--snip--
import java.util.Map; // the last import
--snip--
will produce:
--snip--
import java.util.Map;
  // the last import
--snip--
And if you need to import HashMap, then it produces:
--snip--
import java.util.Map; import java.util.HashMap;

 //the last import
--snip--

So the prior code is already inserting a newline, that is not because of the
patch.
And as you see, it puts the newline (and any subsequent imports) in the
wrong place.

The new code: (forward-line 1) (setq insertion-point (point))
TTBOMK, *should* generally cause the spurious newline to *not* be inserted
(as it will move to a [generally] existing empty line)
[and IMHO, the occasional extra line is less problem that the consistent
failure of the prior (and now current?) code]

...

But on further investigation, we find that the parser is not "consistent"
Depending on what follows the final 'import' line,  the overlay/region may
end
on the line with the import or a line or two after (so (eolp) will fail...
causing a newline insertion)

I'll amend the code to move back to the preceding blank line.
The new code looks like:
       (unless (eolp)  ; that is: if there is a comment after the import 
statement
  (forward-line 1)
  (setq insertion-point (point)))
       (unless (and (bolp) (eolp)) (insert "\n"))
I think that will solve the problem you were seeing.
(although the failure to reparse may still cause its problems)



------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.