1

How do I configure a dedicated location for lock files and auto-save files that works on MS-Windows, GNU/Linux, and macOS? I'm using GNU Emacs 28.2

The following works on GNU/Linux but not on MS-Windows for me:

(setq lock-file-name-transforms
      '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backup/\\1" t))
      auto-save-file-name-transforms
      '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backup/\\1" t)))

However, my backup directory setting does work for both GNU/Linux and MS-Windows:

(setq backup-directory-alist '((".*" . "~/.emacs.d/backup/")))
shynur
  • 4,065
  • 1
  • 3
  • 23

1 Answers1

1

The following works on GNU/Linux but not on MS-Windows for me:

(setq lock-file-name-transforms
      '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backup/\\1" t))
      auto-save-file-name-transforms
      '(("\\`/.*/\\([^/]+\\)\\'" "~/.emacs.d/backup/\\1" t)))

This is obviously because a pathname on MS-Windows doesn't begin with / -- but you wrote "\\`/...". You might want to correct it to "\\`[[:alpha:]]:/...".

shynur
  • 4,065
  • 1
  • 3
  • 23
  • use `system-type` to determine whether Emacs is running on MS-Windows – shynur Aug 22 '23 at 16:54
  • Some MS-Windows pathnames do begin with `/`, like `//wsl.localhost/Ubuntu/...` – Victor Lyuboslavsky Aug 23 '23 at 21:31
  • @VictorLyuboslavsky: I see no need to mention `//wsl` here *if you don't say you use WSL in your question* -- if you want to take WSL into consideration, what about FTP, SSH? ||| If you use WSL, say it in your question. If not, please let me know whether my answer solves your problem. – shynur Aug 24 '23 at 04:58