From: Peter G. <pe...@ar...> - 2005-02-14 20:10:29
|
On Mon, 14 Feb 2005 at 12:58:56 -0500, Randall Randall wrote: > > On Feb 14, 2005, at 12:21 PM, Peter Graves wrote: > > I feel reasonably confident about undertaking that sort of thing in > > Lisp mode or Java mode, since I use j to work on Lisp and Java code > > every day, and I'd notice any breakage right away. > > Oh, well, in that case... :) > > One thing that's has been a bit frustrating for me is J's > string-highlighting. I often have code that contains > strings with literal line breaks, which break J's parenthesis > flashing and indentation. For example, code like > > (defun whatever () > (let ((string "This is a short string, but > we'll pretend that's it's long enough to want > to break")) > ...)) > > will indent correctly on the line *after* the string, > but the lines of string don't indent the way code would, > nor do they not indent at all (which would be correct > behavior for some uses, though since I mostly work with > HTML and SQL I wouldn't prefer that behavior), instead > taking on the indentation of the line the string was > started on. The parenthesis after a string ends, when > it wasn't started on that line, no longer matches up > with any parenthesis outside the string, but parenthesis > *inside* a multi-line string do match up with parenthesis > before the string starts. Further parenthesis do correctly > match if they aren't on the same line as the end of a > multi-line string, and code indents correctly after the > line on which it ends. Yes. Parentheses within comments trigger similarly amusing behavior, too. To begin with, I'm not really sure how a quoted string should be indented. (defun whatever () (let ((string "This is a short string, but we'll pretend...")) ..)) is one possibility, but you could also make a case for: (defun whatever () (let ((string "This is a short string, but we'll pretend...")) ..)) In each case, the string will end up with an embedded newline, but with the first approach, you'll also end up with a bunch of leading whitespace on the second line; how much whitespace you get will depend on the overall indentation of the surrounding code. On the other hand, if you've got: (defun whatever () (format t "This is a short string, but ~ we'll pretend...")) ..)) the #\~ at the end of the first line of the quoted string will make FORMAT ignore the newline and the leading whitespace on the next line, so in this situation you probably do want it indented as shown. Now, in the case of strings fed directly to FORMAT where there's an unescaped #\~ before the line break, j could (in a perfect world) recognize that situation and indent the string as shown in the last example above. But what is the correct behavior in the other case? On the other hand, parenthesis matching is simply broken in the presence of multiline quoted strings or comments containing parentheses. Quoted or commented-out parentheses should clearly be ignored. > I haven't sent a patch yet because I haven't been upset > enough by this to figure out enough Java to fix it, as I'm > not a Java programmer, so far. If you wait long enough, > I will eventually fix this myself and send a patch. :) Once in a while I do a little bit of work on the indentation code in LispMode.java, but mostly I put it off, because the long-term plan is to rewrite LispMode.java in Lisp, and I'd rather work on the Lisp version myself. It would probably just take a day or two to build up the scaffolding to be able to do getCorrectIndentation() in Lisp, but I've been trying to avoid distraction from my other duties... :) > In the meantime, thank you for such a great editor! Thanks for your comments! -Peter |