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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:16:41+00:00 2026-06-04T11:16:41+00:00

I have wrote simple macro to define interactive function and bind it to key

  • 0

I have wrote simple macro to define interactive function and bind it to key at same time
(That what my previous question related)
The only thing, that annoy me, that it looks ugly without highlighting.
It called such way:

(define-and-bind-command foo "C-x £" (message "Hello world"))

I want define-and-bind-command and foo be highlighted.
Well, to get define-and-bind-command highlighted, I can use wrapper around defmacro,
altho is not so pretty, and I have no idea about foo.
I know it is possible, because argument of require is highlighted with const face.

Or, probably, I am inventing wheel, and there is an another lisp mode with more
advanced highlighting?

  • 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-04T11:16:42+00:00Added an answer on June 4, 2026 at 11:16 am

    highlighting the ‘define-and-bind-command’ can be achieved very easily using ‘font-lock-add-keywords’, usage would be

    (defun my-elisp-mode-keywords()
      (font-lock-add-keywords nil
        '(
          ("\\<\\(define-and-bind-command\\)" . 'font-lock-keyword-face)
        )
      )
    )
    

    Of course you could change the ‘font-lock-keyword-face’ to any face of your liking or create and use your own face. You can find the name for a face already used very easy by moving the point (cursor) over the font-locked part of text and entering ‘describe-face’ followed by a return.

    Edit2: Oh and of course you need to hook that defun to some hook, for elisp mode that would be:

    (add-hook 'emacs-lisp-mode-hook 'my-elisp-mode-keywords)
    

    Highlighting the foo part can be done using a regexp.
    Unfortunately I can not yet help you with that part because I’m not sure how to match a regexp containing the ‘define-and-bind-command’ but highlighting only the word after.
    Edit: unless you want to highlight both the ‘define-and-bind-command’ and the foo part in the same face, then it should be very easy. But I guess you want them to have different faces?
    Edit3: Corrected my code, stackoverflow ate some braces before…
    Edit4: Okay, I have a solution for matching the second part only, I have not tested it extensively but it seems to work. I have allowed for foo to contains any character but a space (and newline I think), I guess one could restrict that event futher to a-zA-z0-9 and “-“, so feel free to change that to your liking. The Code responsible for matching only the foo part is

    ("\\bdefine-and-bind-command\s\\([^\s]*\\)" 1 'font-lock-function-name-face t)
    

    Insert that in the line after the other font-lock keyword in the above function and you’re good to go. The regexp matches ‘define-and-bind-command’ which must begin a word (that’s the \b for) followed by a space and then it returns (font-locks) everything followed until a space exists.

    Hope this helps!

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

Sidebar

Related Questions

I have got a Wavecom Supreme GSM modem. I wrote a simple application that
Hello every one I have wrote a simple code in html5 in which I
I've wrote this simple piece of code. And I have a slight problem with
I'm writing a simple web app in PHP that needs to have write access
I have to write a program that sniffs network packets (part1-the simple part). And
Question simple and quick: I have started to use Netbeans to write some code
I've seen how to define the __MyCompanyName__ macro value that displays in all header
everyone I wrote simple music player, but I have one problem. I used ajax
I have a simple report that I want to export to a CSV file.
I have a very simple mail merge that is connected to an SQL server

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.