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 8489487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:50:38+00:00 2026-06-10T21:50:38+00:00

By default Emacs will not highlight constants, struct members, function calls etc (unless inside

  • 0

By default Emacs will not highlight constants, struct members, function calls etc (unless inside the definition). I am talking about C major mode here.

I want some basic highlighting, just based on text matching. For example, A word containing only upper case and underscore, [A-Z_]+, for example SOME_CONST, is a constant (unless otherwise highlighted). Similarly, I can match for [a-zA-Z_][a-zA-Z0-9_]\s( as function call; ->[a-zA-Z_][a-zA-Z0-9_]* as a struct member etc.

How can I do this emacs ?

  • 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-10T21:50:40+00:00Added an answer on June 10, 2026 at 9:50 pm

    I think the elisp function that you want is font-lock-add-keywords. I’ve added the following to my .emacs and gotten what I think you want for upper case words:

    (font-lock-add-keywords 'c-mode '("\\<\[A-Z_\]\+\\>"))
    

    You’d have to add a bit more to handle integer constants. Some of the documentation around this warns that if you’re not intelligent about your regular expressions it can slow things down dramatically, and that you should use regexp-opt for matching multiple keywords.

    The part that was a bit confusing for me is that the argument to font-lock-add-keywords can be a regular expression.

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

Sidebar

Related Questions

How to change default emacs mark-paragraph function behaviour to not select first empty line?
I use the Python-mode (not the default one comes with emacs 23). I could
I would like to have which-function-mode on by default when I open up Emacs.
Emacs, by default, does not indent pre-processor code. I know it has historical roots
My .emacs contains (setq browse-url-browser-function 'browse-url-default-macosx-browser) to open links in .org files via Chrome.
I started using Emacs (ESS) as a default R editor (yes, @Dirk, as you've
Here is my try : #!/Usr/bin/emacs --script (let ((default-directory /home/vision)) (shell-command git pull;) but
I am using emacs 23.3 I heard that emacs 23.3 include cedet by default
I have a line in my .emacs which set a default font: (set-default-font Monaco-10)
When working in Emacs, I use the compile command (F12 by default) to run

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.