editorconfig.el: Hook elsewhere for the coding-system #356
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now, the file's coding system was set via an advice on
insert-file-contents
, which depends on being called from within thefind-file-noselect
advice.While it mostly works, it doesn't account for all the cases (e.g. it fails to be used when doing
write-region
), is a bit cumbersome, and does not interact well with Emacs's other ways to specify a coding-system, such asauto-coding-alist
.This patch replaces it with an advice on
find-auto-coding
, so as to integrate better with the rest of Emacs's handling of files' coding systems. An immediate benefit is that we don't need to special case jar and zip files any more becauseauto-coding-alist
does it for us already (and for many more file types like tar, exe, ...).merge-coding-systems
only when merging is actually necessary. (editorconfig-set-coding-system-revert): Adjust accordingly. (editorconfig--filename-codingsystem-hash): Delete variable. (editorconfig--advice-insert-file-contents): Delete function. (editorconfig--advice-find-auto-coding): New function. (editorconfig--advice-find-file-noselect): Don't mess with coding systems any more.(editorconfig--getting-coding-system): New var.
(editorconfig--get-coding-system): New function.
(editorconfig-mode): Advise
find-auto-coding
instead ofinsert-file-contents
.(editorconfig-version): Use
package-get-version
when available. (find-library-name, lm-version): Move their declaration to the place where we have a good reason to think they're defined. (editorconfig-exclude-regexps): Remove jar and zip patterns, not needed any more.