0

I want to stop Flymake from creating temporary files in the working directory. For example, here is the contents of a csharp source code directory that I am working on.

  total used in directory 96K available 704.4 GiB
  drwxrwxr-x  2 nate nate 4.0K Apr 17 08:46 ./
  drwxrwxr-x 21 nate nate 4.0K Apr 15 11:40 ../
  -rw-rw-r--  1 nate nate 2.5K Apr 17 08:46 Hotkey_084625524204863_flymake.cs
  -rw-rw-r--  1 nate nate 2.5K Apr 17 08:46 Hotkey_084655782692576_flymake.cs
  -rw-rw-r--  1 nate nate 2.5K Apr 15 11:23 Hotkey.cs
  -rw-rw-r--  1 nate nate 1.1K Mar 22 15:05 HotkeyReference.cs
  -rw-rw-r--  1 nate nate 1.6K Apr 17 08:46 IInputHandler_084625489592816_flymake.cs
  -rw-rw-r--  1 nate nate 1.6K Apr 17 08:46 IInputHandler_084655748237326_flymake.cs
  -rw-rw-r--  1 nate nate 1.6K Apr 16 21:49 IInputHandler.cs
  -rw-rw-r--  1 nate nate 1.6K Apr 17 08:46 InputHandler_084625560513820_flymake.cs
  -rw-rw-r--  1 nate nate 1.6K Apr 17 08:46 InputHandler_084655897102355_flymake.cs
  -rw-rw-r--  1 nate nate 1.6K Mar 22 15:05 InputHandler.cs
  -rw-rw-r--  1 nate nate  15K Apr 17 08:46 Keycode_084625456646150_flymake.cs
  -rw-rw-r--  1 nate nate  15K Apr 17 08:46 Keycode_084655714954252_flymake.cs
  -rw-rw-r--  1 nate nate  15K Apr 16 11:55 Keycode.cs

These temporary files such as Keycode_084655714954252_flymake.cs cause my builds to fail.

what I've tried

This does not work because flymake-run-in-place is actually not part of flymake. flymake-run-in-place comes from emacs-flymake, which is a fork of flymake.

  • Swapping flymake for emacs-flymake

It would be much preferable to use flymake, because flymake is a built-in package, and from what I understand is guaranteed to work with eglot. Currently, using emacs-flymake with eglot causes emacs to freeze.

4
  • It may be helpful to list flymake-*-file (* stands for some characters) variables and describe-variable them.
    – shynur
    Apr 17, 2023 at 14:50
  • @Shynur most of those aren't documented as they're "internal" variables
    – nega
    Apr 17, 2023 at 14:59
  • i suppose one could override flymake-proc-create-temp-inplace() (also undocumented) which appears to be the temp file naming function.
    – nega
    Apr 17, 2023 at 15:08
  • anyway, flymake doesn't have a "user accessible" option to use a separate directory for temp files. in fact that option removed that option circa 2010/2011. i suspect with eglot becoming a default package, that option will be restored to flymake in the near future. in the meantime it would probably be easier to reconfigure your build system to use explicit file names instead of globbing files for your source files. (if your build system can't use explicit filenames it might be time to look into a new build system)
    – nega
    Apr 17, 2023 at 15:16

1 Answer 1

1

Flymake currently has no way to prevent the creation of temporary files, but I figured out a way to at least get flymake to clean up after itself so that csharp builds do not fail.

(use-package flymake
  :ensure t
  :config
  ;; Don't liter csharp files in working directory
  (let ((csharpentry (assoc "\\.cs\\'" flymake-allowed-file-name-masks)))
    (if csharpentry
        (setcdr csharpentry '(flymake-proc-simple-make-init flymake-proc-simple-cleanup)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.