this post was submitted on 31 Oct 2023
2 points (100.0% liked)

Emacs

305 readers
1 users here now

A community for the timeless and infinitely powerful editor. Want to see what Emacs is capable of?!

Get Emacs

Rules

  1. Posts should be emacs related
  2. Be kind please
  3. Yes, we already know: Google results for "emacs" and "vi" link to each other. We good.

Emacs Resources

Emacs Tutorials

Useful Emacs configuration files and distributions

Quick pain-saver tip

founded 1 year ago
MODERATORS
 

I have the entire elpa directory added into a git repository so that I always have a known good setup that I can fall back on. This works well when I am cloning it in linux machines but when I clone it in windows machines, it doesn’t work.

I have removed all the .elc files since those are not cross compatible but it still didn’t work and I realise that it’s because the generated autoload file is specified to be using unix style line endings (LF) but when I cloned it in the windows machine, the autoload files will have dos style line endings (CRLF) therefore causing the issue.

Interestingly, the init file also uses CRLF and it still works presumably because it does not have the same specified coding as the generated autoload files.

How should I get around this problem? I’m thinking of setting core.autocrlf to false on my windows machine. While that works, I will have to remember to create new files in my .emacs.d with only LF to keep the git repo clean and also presumably for it to work. I also thought about regenerating those autoloads after a clone but I’m not sure how to do so. Hence, I’m looking to see whether others have better solutions to this problem.

Edit: I realise I can set core.autocrlf to input so that git will automatically convert any CRLF to LF on commit therefore resolving the issue. Regardless, I am still interested to hear from the others who version control their elpa directory on what is their strategy.

top 7 comments
sorted by: hot top controversial new old
[–] _cnt0@sh.itjust.works 2 points 10 months ago

https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings

Git has some questionable defaults for handling of line endings which differ between linux (/unix), Windows and Mac OS. When using tools which handle line endings the same on all platforms (usually developed for linux initially), you have to set core.autocrlf to false, or it will cause problems.

This git feature is from a time when editors/IDEs on different platforms couldn't handle different line endings. In the past decade I have never seen a case where the different autocrlf settings solved a problem, but plenty where it caused problems.

[–] zsome@alien.top 1 points 10 months ago

I started to play with that to store the eln files on the vc and create a "binary only" emacs ...
I don't know it is theoretically possible or not (to use the eln files without el ones).

[–] lebensterben@alien.top 1 points 10 months ago (1 children)

config --global core.autocrlf true

[–] _cnt0@sh.itjust.works 2 points 10 months ago

Being the (absolutely idiotic) Windows default, this is more likely the cause of the problems. When working with tools coming from the linux/unix ecosystem this should always be set to false.

[–] github-alphapapa@alien.top 1 points 10 months ago

Probably not what you want to do, but IIUC you could run Emacs from Cygwin and it wouldn't have that problem.

[–] Zuerill@alien.top 1 points 10 months ago

I only have my .emacs file under version control, which automatically installs missing packages through use-package's :ensure parameter.

The downside is of course that it takes a while after a fresh checkout.

[–] mok000@alien.top 1 points 10 months ago

Change to straight.el package manager, it downloads git repos you can lock and even add your own.