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
247 stars 90 forks source link

indent wrong if within and ifdef else block #1711

Closed jlechnar closed 3 years ago

jlechnar commented 3 years ago

Hello,

in the following code the indent is wrong - see ISSUE comment. Please also find attached a minimum example.

BR, Joachim

`ifdef TEST
   foo1 bar
`else
     foo2 bar // ISSUE: indent wrong, should be like for foo1 bar !
`endif
       (/*AUTOINST*/);

ifdef_instance.tar.gz

wsnyder commented 3 years ago

Verilog-mode can't really handle all the possible ifdef combinations so this is unlikely to get fixed; furthermore it will confuse the AUTOs. I suggest instead this syntax:

`ifdef TEST
 `define BAR_INST foo1
`else
 `define BAR_INST foo2
`endif
   `BAR_INST bar
     (/*AUTOINST*/
      // Inputs
      .signal                         (signal));

endmodule

// Local Variables:
// eval:(verilog-read-defines)
// End:
acr4 commented 3 years ago

I agree with Wilson. Stylistically this s is also a lot easier to read. It sets up the intent (pick a different module type based on configuration) and separates it from the boring language mechanics.

Sent from my iPhone

On Jan 23, 2021, at 10:54, Wilson Snyder notifications@github.com wrote:

 Verilog-mode can't really handle all the possible ifdef combinations so this is unlikely to get fixed; furthermore it will confuse the AUTOs. I suggest instead this syntax:

ifdef TEST define BAR_INST foo1 else define BAR_INST foo2 endif BAR_INST bar (/AUTOINST/ // Inputs .signal (signal));

endmodule

// Local Variables: // eval:(verilog-read-defines) // End: — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

jlechnar commented 3 years ago

Thanks for the suggested syntax that works also for me.