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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:37:25+00:00 2026-06-15T20:37:25+00:00

I wrote an elisp function and a few defvar ‘s that I use to

  • 0

I wrote an elisp function and a few defvar‘s that I use to interactively add boost unit test macros. Since it is used with Boost, it will only be needed in c++-mode. Currently it is in my init file so it is always loaded in every mode.

How do I make it so this functionality is only available in c++-mode, i.e. as if I added it to the major mode itself.

  • 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-15T20:37:26+00:00Added an answer on June 15, 2026 at 8:37 pm

    If you want the code you wrote to only be loaded when needed, you can put it into a file of its own (say boost-unit-test.el), and from your .emacs you could add:

    (eval-after-load "cc-mode" '(require 'boost-unit-test))
    

    Note, this assumes the file is in your load-path and has (provide 'boost-unit-test) as one of the lines.

    Now, once this file is loaded, those variables and those commands are defined globally, and that’s just the way Emacs is. This is no different than if you left the code in your .emacs file. And, either way, it will only be loaded/evaluated once (unless you force it to load multiple times – but you have to work to do that).

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

Sidebar

Related Questions

I wrote a simple ruby function and I want to test if the function
I wrote some code to generate a boost::mpl::vector to use as a lookup table
I wrote the function (defun test () (let ((str1 foo) (str2 bar)) (loop for
I wrote a process explorer using C with GUI interface. I want to add
I wrote a PHP script that retrieves values from a MySQL Query. I used
I wrote a Flickr search engine that makes a call to either a public
I want to write a small function to add a value to a list.
I wrote this simple test code, by adapting a piece from a book, to
Wrote a small app that accesses a bunch of search websites and puts the
I wrote a windows service using VB that read some legacy data from Visual

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.