bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#48137: 27.2; `package-install-file' fails when loading a package fil


From: Eli Zaretskii
Subject: bug#48137: 27.2; `package-install-file' fails when loading a package file with DOS line endings
Date: Tue, 04 May 2021 14:39:02 +0300

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: Ioannis Kappas <ioannis.kappas@gmail.com>,  48137@debbugs.gnu.org
> Date: Mon, 03 May 2021 16:12:17 -0400
> 
> >> If not, I would like to suggest a slightly
> >> updated patch that is targeting .el files directly as an exemption:
> >> 
> >> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> >> index ecb2573cab..19ab0445b9 100644
> >> --- a/lisp/emacs-lisp/package.el
> >> +++ b/lisp/emacs-lisp/package.el
> >> @@ -2147,7 +2147,9 @@ package-install-file
> >>          (progn
> >>            (setq default-directory file)
> >>            (dired-mode))
> >> -      (insert-file-contents-literally file)
> >> +      (if (string-match "\\.el\\'" file)
> >> +          (insert-file-contents file)
> >> +        (insert-file-contents-literally file))
> >>        (when (string-match "\\.tar\\'" file) (tar-mode)))
> >>      (package-install-from-buffer)))
> >
> > is not something I can endorse, especially as it decodes much more
> > than just the EOL format.
> 
> package.el should do *some* decoding because it needs to look at
> the pseudo-headers in the file to generate the `<pkg>-pkg.el` which
> contains among other things the package's short description.

That's not "decoding" in the sense I used it, which is when we
_replace_ in memory the original raw bytes with the decoded contents.
"Decoding" for the purpose of parsing some part of the file is fine,
especially since here it just needs to be prepared to having an
optional CR before each LF.  (In fact, I'd be also okay with decoding
all of it into a temporary buffer, though that would probably be waste
of cycles.)

> Admittedly, these will usually work OK in undecoded buffers as well,
> but not in all cases.

In what cases this would not work?  Can those cases be handled by
directing the decoded stuff to a destination that is not the original
text, thus keeping the original text unaltered?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]