veripool / verilog-mode

Verilog-Mode for Emacs with Indentation, Hightlighting and AUTOs. Master repository for pushing to GNU, verilog.com and veripool.org.
http://veripool.org/verilog-mode
GNU General Public License v3.0
257 stars 90 forks source link

Indenting mismatch between verilog-auto and indent region with non-default verilog-cexp-indent #1697

Open abradd opened 4 years ago

abradd commented 4 years ago

I'm running the latest commit (03ac87a).

If I set verilog-cexp-indent 2 and indent the code with indent-region (which uses verilog-indent-line-relative under the hood I believe), I get:

module to_inst(
  input clk,
  input rst_n,
  output logic out
  );

endmodule // to_inst

module inst (/*AUTOARG*/);

  to_inst inst_example (
    /*AUTOINST*/
    );

endmodule // inst

If I subsequently run verilog-auto the indentation on inst_example changes:

module inst (/*AUTOARG*/);

  to_inst inst_example (
    /*AUTOINST*/
                        // Outputs
                        .out            (out),
                        // Inputs
                        .clk            (clk),
                        .rst_n          (rst_n));

endmodule // inst

There are two issues as far as I can see:

I took a look at the code and the first behavior is the result of this line in verilog-auto-inst (link):

 (indent-pt (save-excursion (verilog-backward-open-paren)
              (1+ (current-column))))

and the wrapping results from some code at the end of verilog-auto-inst (link).

If you use the default value for verilog-cexp-indent the alignment is consistent across both indent-region and verilog-auto-inst. If verilog-auto-inst could be coerced to reuse the logic of verilog-indent-line-relative that should resolve the first issue.

Is there a reason the code pulls the closing parenthesis and semicolon to the end of the final port?

Cheers