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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:30:19+00:00 2026-05-18T02:30:19+00:00

How can I deliver a module that requires patching flymake, with minimal startup time

  • 0

How can I deliver a module that requires patching flymake, with minimal startup time (=autoload) and minimal impact on the user’s emacs.el?

I’m working on the flymake-for-csharp module. It works with flymake, teaches it how to be more flexible with C# code files. For example, instead of just using a makefile, flymake-for-csharp can also use a .csproj file, or can invoke csc.exe directly.

The module works fine. I am now trying to make it autoload properly.

here’s the challenge.

To define which languages get flymake’d, flymake.el includes a list of file extensions (.java, .cs, .c, etc) along with the init and cleanup routines for each of those languages. There’s an entry for C# in the default flymake.el, but as I said, the default C# behavior isn’t flexible enough. To make it more flexible, I need to replace the C# entry in the flymake alist, so that it points to the new init/cleanup logic in the flymake-for-csharp module. Ya with me?

It’s no problem patching the alist at runtime. It looks like this:

  (let (elt
        (csharp-entry nil)
        (masks flymake-allowed-file-name-masks))

    ;; Find the existing C# entry
    (while (consp masks)
      (setq elt (car masks))
      (if (string= "\\.cs\\'" (car elt))
          (setq csharp-entry elt))
      (setq masks (cdr masks)))

    ;;  remove the original entry for C# ...
    (if csharp-entry
        (setq flymake-allowed-file-name-masks
              (delete csharp-entry flymake-allowed-file-name-masks)))

    ;; Now add a new entry for C#, with the custom init and cleanup methods.
    (setq flymake-allowed-file-name-masks
          (cons
           '("\\.cs\\'" flymake-for-csharp-init flymake-for-csharp-cleanup)
           flymake-allowed-file-name-masks)))

The long term solution is to persuade the authors of flymake and emacs to accept the logic that is currently in flymake-for-csharp. Then the alist will get the more flexible init/cleanup routines and bob’s your uncle.

But for now I want flymake-for-csharp to work with the existing (builtin) flymake.el. Therein lies the problem: how can I make the flymake-for-csharp autoload, while still patching the alist?

Ideally I’d like the user’s emacs.el to look like this:

(autoload 'flymake-for-csharp-init "flymake-for-csharp" nil nil)

…with possibly a small (eval-after-load .. section.

But you see, the function flymake-for-csharp-init would be called only after the flymake alist is patched to include the new entry for C#.

Is there a way around this chicken-and-egg situation?


one approach I thought of was to use (require 'flymake-for-csharp) in lieu of autoload. Within that flymake-for-csharp module, run only the patch logic, and then use autoload, somehow, for the rest of the functions. Would this be a good idea? Would this require me to deliver flymake-for-csharp in 2 distinct files?

Another approach I thought of was to use an eval-after-load on flymake.el. In that I could provide the patch function. Couple questions with this:

  • Would that work only if flymake is autoloaded? What happens with the logic within an eval-after-load for a module that is already loaded when the (outer) eval-after-load is eval’d?

  • how would I do this without impacting the user’s emacs.el?


In summary,
How can I deliver a module that requires patching flymake, with minimal startup time (=autoload) and minimal impact on the user’s emacs.el?

  • 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-18T02:30:19+00:00Added an answer on May 18, 2026 at 2:30 am

    If I understand correctly, having the user add this to their .emacs would solve the problem:

    ;;;###autoload
    (eval-after-load "flymake" '(code-that-patches-flymake-allowed-file-name-masks))
    (autoload 'flymake-for-csharp-init "flymake-for-csharp" nil nil)
    

    Now, if you work with the folks using your package, you can use the loaddefs.el trick to get this code automatically loaded by the user by putting the ;;;###autoload comment right before the eval-after-load line in your package, and then rebuild the loaddefs.el file.

    But, if you’re hoping for a solution for general usage in the internets, you need the user to have both lines in their .emacs.


    A comment on your cleanup code, I believe it can be simplified to:

    (let ((csharpentry (assoc "\\.cs\\'" flymake-allowed-file-name-masks)))
      (when csharpentry
        (setcdr csharpentry '(flymake-for-csharp-init flymake-for-csharp-cleanup))))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.