繁体   English   中英

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

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

我一直在使用Emacs来创建和修改Verilog代码。 但是,在Verilog模式下,当我尝试使用emacs命令插入“if”语句时,我遇到了一个小问题:

Cc Ct ?

以下是在上述场景中如何创建语句的示例:

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

但是我需要emacs在下一行中插入“begin”,如下所示:

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

在深入了解可用的Verilog定制选项之后,我找到了一个名为Verilog Indent Begin After If选项,我认为它应该产生上述效果。 但是,切换此选项并未给出任何可见的更改。

任何帮助将不胜感激。

查看代码,您将看到该函数:

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

实际上定义了一个骨架 只需复制粘贴并添加另一个换行符:

(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 )

现在我们只需要在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