gjlayde <
georg...@web.de> writes:
> Ben Bacarisse schrieb am Donnerstag, 4. Mai 2023 um 21:51:06 UTC+2:
>> gjlayde <
georg...@web.de> writes:
>>
>> > I am using emacs-lisp mode to edit RTL (Register Transfer Language)
>> > files. I chose elistp because that's close to RTL.
>> >
>> > Indentation works fine, except when I have to break very long
>> > lines. Suppose the following example:
>> >
>> > [(set (pc)
>> > (if_then_else
>> > (match_operator 0 "ordered_comparison_operator"
>> > [(match_operand:PSI 1 "register_operand" "r,r,d ,r ,d,r")
>> > (match_operand:PSI 2 "nonmemory_operand" "L,r,s ,s ,M,n")])
>> > (label_ref (match_operand 3 "" ""))
>> > (pc)))
>> > (clobber (match_scratch:QI 4 "=X,X,&d,&d ,X,&d"))]
>> >
>> > What I want is that "[" and "]" basically behave like "(" and ")".
>> In my emacs-lisp-mode, [ and ] already behave like ( and ) because []s
>> are used for vectors and must nest correctly with ()s.
>> > In particular, it appears that indentation of the line starting with
>> > "[" is far too much and aligns with the next space in the line above.
>> ( does this as well as [. The arguments in a form are lined up with
>> each other:
>
> Your examples are indented fine.
Well, no, not really! I had intended them to explain the problem so you
had something more concrete to explore (I have no solution for you). I
was illustrating the "align arguments in forms" pattern but I just
happened to use short symbols.
> But in a simple example like
> (aaaaaaaaaaaaa b
> [c d])
Yes, that's the case I showed only with a sorter symbol in the first
position. I thought you already knew that the indentation was based on
the length of that symbol. I was just explaining that the mode is
trying to line up function arguments.
If you break after aaaaaaaaaaaaa, you won't get that layout, but that's
not the solution you want either. You want a simple l*n indent where l
is the nesting level and n is something small you can choose: 1, 2 or 3
maybe.
> The "[" is aligned with "b", thus the indentation of the 2nd line is
> arbitrarily far to the right, and breaking lines does (almost) not
> lead to shorter lines.
>
> I'd like to indent "[" with the 1st or second letter of "aaaaaaaaaaa".
Yes, I know. I think you will have to define an indent function as I
said. But that is not going to be easy. You'll have to find some
documentation to help you. I tried a simple case, but it did not work
as I had hoped.
--
Ben.