[英]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.