Simon Wright <[email protected]> writes:
> I’m never sure when assigning an aggregate that won’t fit on one line whether
> to put the := at the end of the line before the aggregate (New_Cell below) or
> at the beginning of the line on which the aggregate starts (Another_Cell
> below).
>
> ada-mode 5.1.4 gets slightly confused about the second case, as
> indicated.
That's because The Right Way is with ":=" at the end of the line ;)
(that's my style, so that's all I tested).
> Another_Cell
> := (Stream => Stream_Pointers.Create
> (new ColdFrame.Memory_Streams.Stream_Type (Size)), -- <<<<<<<
> Copy => Stream_Pointers.Create
> (new ColdFrame.Memory_Streams.Stream_Type (Size)));
Yes, this is wrong, according to my rules for ada-mode; "(new" should be
indented relative to "(Stream".
Actually, this is an instance of a more general bug; any line that
starts with paren is indented relative to the beginning of the previous
line, ignoring containing parens on that line:
Another_Cell :=
Stream_Pointers.Create (Name
(Foo));
should be:
Another_Cell :=
Stream_Pointers.Create (Name
(Foo));
I just pushed 5.1.5 to ELPA git, but it hasn't shown up in list-packages
yet. This fix will have to wait for 5.1.6.
Here's a patch against 5.1.5; should work for 5.1.4 as well:
--- ada-wisi.el 067bfff4fd568ac9a1a4faf8e9bad6363b408c03
+++ ada-wisi.el 6db63a67fc47931877035a0903e6b500301bd116
@@ -55,18 +55,22 @@
;;;; indentation
(defun ada-wisi-current-indentation ()
- "Return indentation of current line, incremented by 1 if starts with
open-paren."
+ "Return indentation appropriate for point on current line:
+if not in paren, beginning of line
+if in paren, pos following paren."
(if (not (ada-in-paren-p))
(current-indentation)
- (save-excursion
- (back-to-indentation)
- (let ((cache (wisi-get-cache (point))))
- (if (and cache
- (eq 'open-paren (wisi-cache-class cache)))
- (1+ (current-column))
- (current-column))
- ))))
+ (or
+ (save-excursion
+ (let ((line (line-number-at-pos)))
+ (ada-goto-open-paren 1)
+ (when (= line (line-number-at-pos))
+ (current-column))))
+ (save-excursion
+ (back-to-indentation)
+ (current-column)))
+ ))
--
-- Stephe
_______________________________________________
Emacs-ada-mode mailing list
[email protected]
http://host114.hostmonster.com/mailman/listinfo/emacs-ada-mode_stephe-leake.org