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

  • Home
  • SEARCH
  • 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 3989372
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:21:56+00:00 2026-05-20T06:21:56+00:00

I can color keywords in emacs using the following lisp code in .emacs: (add-hook

  • 0

I can color keywords in emacs using the following lisp code in .emacs:

(add-hook 'c-mode-common-hook
          (lambda () (font-lock-add-keywords nil
           '(("\\<\\(bla[a-zA-Z1-9_]*\\)" 1 font-lock-warning-face t)))))

This code color all keywords that start with “bla”. Example: blaTest123_test

However when I try to add @ (the ‘at’ symbol) instead of “bla”, it doesn’t seem to work. I don’t think @ is a special character for regular expressions.

Do you know how I can get emacs to highlight keywords starting with the @ symbol?

  • 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-05-20T06:21:56+00:00Added an answer on May 20, 2026 at 6:21 am

    Your problem is the \< in your regexp, which

    matches the empty string, but only at the beginning of a word. `\<‘ matches at the beginning of the buffer (or string) only if a word-constituent character follows.

    and @ is not a word-constituent character.

    See: M-: (info "(elisp) Regexp Backslash") RET

    This unrestricted pattern will colour any @:

    (font-lock-add-keywords nil
      '(("@" 0 font-lock-warning-face t)))
    

    And this will do something like what you want, by requiring either BOL or some white space immediately beforehand.

    (font-lock-add-keywords nil
      '(("\\(?:^\\|\\s-\\)\\(@[a-zA-Z1-9_]*\\)" 1 font-lock-warning-face t)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using System.Drawing.Color, is there anything in Visual Studio that can display the color
How can I set the background color of an HTML element using css in
In the Full .NET framework you can use the Color.FromArgb() method to create a
How can I change the color of a DataGridView border when BorderStyle = FixedSingle?
How can I set the background color of a specific item in a System.Windows.Forms.ListBox
I can't seems to change the default color of the required field validator. In
How can I remove the black background color in the corners of the ellipse?
Where can I find a list of all the C# Color constants and the
Is there an HTML color wheel that I can throw in my site that
Heres the link: DAMNIE6TOHELL As you can see if viewed in glorious 'IE6-o-color', the

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.