简体   繁体   English

在Emacs Verilog模式下的if语句后插入“begin”

[英]Insert “begin” after if statement in Emacs Verilog Mode

I have been using Emacs to create and modify Verilog codes for some time now. 我一直在使用Emacs来创建和修改Verilog代码。 However, in Verilog mode, I am facing a small issue when I try to insert an "if" statement using the emacs command: 但是,在Verilog模式下,当我尝试使用emacs命令插入“if”语句时,我遇到了一个小问题:

Cc Ct ?

The following is an example of how the statement is created in the above scenario: 以下是在上述场景中如何创建语句的示例:

if (a<b) begin
// the rest of the code

However I need emacs to insert the "begin" in the next line as shown below: 但是我需要emacs在下一行中插入“begin”,如下所示:

if (a<b)
begin
//rest of the code

After digging through the Verilog customization options available, I found one option named Verilog Indent Begin After If which I think is supposed to produce the above effect. 在深入了解可用的Verilog定制选项之后,我找到了一个名为Verilog Indent Begin After If选项,我认为它应该产生上述效果。 However toggling this option did not give my any visible changes. 但是,切换此选项并未给出任何可见的更改。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Looking at the code you will see that the function: 查看代码,您将看到该函数:

(define-skeleton verilog-sk-if
  "Insert a skeleton if statement."
  > "if (" '(verilog-sk-prompt-condition) & ")" " begin" \n
  > _ \n
  > (- verilog-indent-level-behavioral) "end " \n )

actually defines a skeleton. 实际上定义了一个骨架 Just copy paste and add another line-break: 只需复制粘贴并添加另一个换行符:

(define-skeleton my-verilog-sk-if
  "Insert a skeleton if statement."
  > "if (" '(verilog-sk-prompt-condition) & ")" \n " begin" \n
  > _ \n
  > (- verilog-indent-level-behavioral) "end " \n )

now we just need to hook our function over the old one in verilog-mode: 现在我们只需要在verilog模式下将我们的函数挂钩到旧函数:

(add-hook 'verilog-mode-hook
          '(lambda ()
             ;; this is quite the hack because we don't respect
             ;; the usual prefix of verilog-mode but sufficient for us
             (define-key verilog-mode-map "\C-c\C-t?"
                         'my-verilog-sk-if)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM