From 606b783acb3388249c38264f8e37e08af832e1ea Mon Sep 17 00:00:00 2001 From: Ioannis Kappas Date: Tue, 20 Jul 2021 15:53:34 +0200 Subject: Allow installing packages with DOS line endings * lisp/emacs-lisp/package.el (package-install-from-buffer): Allow installing files with different line ending conventions (Unix, DOS and Macos) (bug#48137). --- lisp/emacs-lisp/package.el | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'lisp/emacs-lisp/package.el') diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 6bbd4c99763..f1daa8d124a 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2195,8 +2195,24 @@ Downloads and installs required packages as needed." ((derived-mode-p 'tar-mode) (package-tar-file-info)) (t - (save-excursion - (package-buffer-info))))) + ;; Package headers should be parsed from decoded text + ;; (see Bug#48137) where possible. + (if (and (eq buffer-file-coding-system 'no-conversion) + buffer-file-name) + (let* ((package-buffer (current-buffer)) + (decoding-system + (car (find-operation-coding-system + 'insert-file-contents + (cons buffer-file-name + package-buffer))))) + (with-temp-buffer + (insert-buffer-substring package-buffer) + (decode-coding-region (point-min) (point-max) + decoding-system) + (package-buffer-info))) + + (save-excursion + (package-buffer-info)))))) (name (package-desc-name pkg-desc))) ;; Download and install the dependencies. (let* ((requires (package-desc-reqs pkg-desc)) @@ -2222,6 +2238,7 @@ directory." (setq default-directory file) (dired-mode)) (insert-file-contents-literally file) + (set-visited-file-name file) (when (string-match "\\.tar\\'" file) (tar-mode))) (package-install-from-buffer))) -- cgit v1.2.3