Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:03:23+00:00 2026-06-04T03:03:23+00:00

In Verilog you enclose code blocks between the words ‘begin’ and ‘end’ like this:

  • 0

In Verilog you enclose code blocks between the words ‘begin’ and ‘end’ like this:

if(foo) begin
   x <= 1'b0;
   y <= 1'b0;
end else begin
   x <= x_d;
   y <= y_d;
end

Is there any way to set begin and end as parentheses in Emacs, so that you can use check-parens or similar to find any that are mismatched?

I’ve tried adding this (and variations of) to my ~/.emacs file, but it doesn’t like it…

(modify-syntax-entry ?begin "(end" )
(modify-syntax-entry ?end ")begin" )

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:03:24+00:00Added an answer on June 4, 2026 at 3:03 am

    Sadly, Emacs’s parenthesis matching infrastructure doesn’t understand much of multi-character tokens. The new library SMIE added in Emacs-23.4 is partly intended to address this issue. It lets major modes describe the syntax of the language (in a very limited kind of grammar) after which things like C-M-f and C-M-b will know how to jump over logical elements, e.g. skip from a begin to its matching end. As LindyDancer notes, such things are usually needed for indentation, and indeed the main motivation behind SMIE was to provide a generic indentation engine.

    Now Verilog doesn’t use SMIE but it does implement similar navigation commands. So you could probably try something like

    (defun sm-verilog-check-parens ()
      (save-excursion
        (goto-char (point-min))
        (while (not (eobp))
          (verilog-forward-sexp))))
    

    Tho I do not know if verilog-forward-sexp will give you appropriate warnings/errors if it bumps into the end of buffer at an unexpected moment.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Verilog tutorial (see the table at the end) suggests that { } is
I have problems with this Verilog code. Basically, it won't let me do the
The Verilog Golden Reference Guide on page 12 warns against unsynthesisable always blocks, and
Reading some Verilog code, there seem to be two ways of defining arguments in
I'm reading some third party Verilog, and found this: function [31:0] factorial; input [3:0]
Looking at some code I'm maintaining in System Verilog I see some signals that
I am assigned with the task of verifying some verilog based RTL code. Now,
I am trying to design a 4-bit adder subtracter in verilog. This is only
I am trying to convert some Verilog code that produces a slower clock from
I need to use rational numbers in my Verilog code. I looked for any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.