Emacs compilation question - getting discrepancies after visiting source files

Just discovered an annoying “feature”: if I visit a class file in my compilation path with emacs and don’t save it before re-compiling the class library, I will get a discrepancy error. Somehow sclang tries to compile all classes twice over, resulting in a bunch of duplicates. The problem disappears when I save the file. Even more annoying, this seems to happen even when I haven’t made much of a change to a file, just moving around in it seems to trigger the behavior. Is there any way to deal with this?

SC, when scanning directories, doesn’t properly ignore emacs’s #...# backup files. It’s a really unnecessary bug that I’m pretty sure I (among others) reported quite some time ago, but which never got fixed. There should be some threads in the forum archives about it.

hjh

2 Likes

Ah, great to know! Very annoying bug indeed. Well, that just gives me a nice kick in the behind to enable auto-save-mode instead and stuff all the backup files in a separate directory in addition to that… That should hopefully solve the problem. I’m no fan of emacs’ habit of polluting the directories with all kinds of temporary files, so this should make the file system a bit tidier.

1 Like

… this seems to do the trick:

(setq backup-directory-alist '(("." . "~/.config/emacs/backup"))
      backup-by-copying t    ; Don't delink hardlinks
      version-control t      ; Use version numbers on backups
      delete-old-versions t  ; Automatically delete excess backups
      kept-new-versions 20   ; how many of the newest versions to keep
      kept-old-versions 5    ; and how many of the old
      )
(auto-save-visited-mode 1)
(setq auto-save-file-name-transforms
          `((".*" ,temporary-file-directory t)))
(setq lock-file-name-transforms
          `((".*" ,temporary-file-directory t)))

Oh, that’s cool. I will start using this.

Something like a .gitignore solution in sclang could be a good enhancement too.

1 Like