From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Daniel =?UTF-8?Q?Mart=C3=ADn?= via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#50560: 28.0.50; 'insert-file-contents-literally' on multibyte buffers Date: Mon, 13 Sep 2021 10:42:51 +0200 Message-ID: References: <87zgshotc1.fsf@gmail.com> Reply-To: Daniel =?UTF-8?Q?Mart=C3=ADn?= Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40247"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (darwin) Cc: 50560@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 13 10:44:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPhZS-000A9N-Bp for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 10:44:10 +0200 Original-Received: from localhost ([::1]:51002 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPhZR-0001CE-47 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Sep 2021 04:44:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPhZK-0001C2-2M for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:44:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPhZJ-0000rN-Nj for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:44:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mPhZJ-0006SH-LN for bug-gnu-emacs@gnu.org; Mon, 13 Sep 2021 04:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Daniel =?UTF-8?Q?Mart=C3=ADn?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Sep 2021 08:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50560 X-GNU-PR-Package: emacs Original-Received: via spool by 50560-submit@debbugs.gnu.org id=B50560.163152258424738 (code B ref 50560); Mon, 13 Sep 2021 08:44:01 +0000 Original-Received: (at 50560) by debbugs.gnu.org; 13 Sep 2021 08:43:04 +0000 Original-Received: from localhost ([127.0.0.1]:44319 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPhYO-0006Qu-0l for submit@debbugs.gnu.org; Mon, 13 Sep 2021 04:43:04 -0400 Original-Received: from sonic303-19.consmr.mail.ir2.yahoo.com ([77.238.178.200]:34235) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPhYL-0006QE-Ks for 50560@debbugs.gnu.org; Mon, 13 Sep 2021 04:43:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048; t=1631522575; bh=8OOC62hafss5Xeotahy+ml5uBT5UjTlFjJSiCRb9R+Y=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=PnCt+hBZn8Az3CxIT/i6RLhHZyMxmWFPiwKu+kISt6SWOLLF3JxYf3exFkgTTJ1avo4x8obQW1fGuLAnJHUcCfrQiNESxD6GlpH48MqW0sbm6VnoFYRkSHalUXFLLwTx7J8dKze/jj3OzV5+KgupzXlQ+WiUFDgbi1w4fw1fRQc8aLQ8lWEHJpn2aYnDEL8BxNOW+0d1vxsENdpR0jug/r39rJ5DxtH+R4ToEoMmBxwTuX/WHJL4y/k1SKf+THdpyDXtMn1ShpDNqjHjhUn5FKQbGCxslWCB0JvUJt1nmFUOE0yOd67NZI98406GcDBOw9P7Gi9yQNhd3cykcRPGoA== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1631522575; bh=8wBBe1Z3OtTmLIwyQshgrNsIY/lW0EX9magcvDRL/JE=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=Erw5jHlWrq0HW+Xpivpveqa9KqnGlcfzubmL7aa5fAy5gZiW10HmBxXS3ejnO8+170ImvzJb5wV0hg9YzImYxLnmk9qQFflpdbrRESQOOUtqc8wP0IW1oIgjiH5r0w7gGmdQle+2Cnh8wLnVytdy9sYGoMsNfWHI0Mo+r7Sw94qhuAK0gka2zzfVjNrXhRnVSUkPntzzZ6gfpu0ayjVyyCO33KxWoTwNoF4auCbfdXJmFjU8y+wfpa8CUpWNxqXI35R3vi+2XaC39l9csdHG7cgfAVKtw/nj2UYEGMoBlkh4xZlcg0AuzlpVffY9sNQ6vGbHQNsNUSjnf4X0AxnwEg== X-YMail-OSG: sjyqOt8VM1knxCNiBi.l3KkjQqiRdIyBCBAtOzKlSUXpM.XPm6lpCUHgRDVvqWO iRkhS70xgJZMOr.xcohkcGqmKeZX5gIUEsqTXgupGpxCFJNMn1JaomuLFhL0uuYlEg1a6DjAgcUH KAtbEFLdLWy0fq2sOrQLRqlivymTXR5TGPHHgnjY2zqHByv0PD02r0CpeOY8P.errfIKbHIbbR9P h68_fkIHciQFZrxPeP53g58TYBJxJavJqaK5abM07lsClLpnPav8l1pNV9fPwdUDIvYRicfBNABe yqCrCBNmMMhUB2hk7Nr9M.DWetaS3f6HXHAwDLryhshMmSJRXaVg7FMwxbVX.cXlkSQgIqY79ym3 .UVr4WWMYFdlCDlodVH6JKHhsw.K1mU7puBMhOBKeIzZwLYpxTqsvrxfm5.p9cmvjVaIFk2evWWg ryjdKvv5ya_Qva3zliLtvrcRjJfEHNvXAw9Oi8Y2.Gg57UHgAcfGbCG5P1KsLaxjXINVyVXFGiKT Ibo6nAt4SIujjOT9S8Q1Jq8kiT66lnew1YY6zjFDQ8l1CDdzEP8b3wVhFf9TBT3un6d8pk9x446I 2XnEmbBpHDaslCEits1XH_6sSejICjyQpxcEYWAI1OsT1NNP7wflL2SBgnY4asnyNfzth.UyQqKy xo2M0Jy33zR04q9wHqjDkWMJmo5JXdNckEStlTYY.fAhj8tN8jwy7agudwCaqieBTpa7P1xQZche OLYt2ZHbQ0MzHrr3tHKLQpoRSUJX1eXnyjvJUtTuqkZQfBupjrBy4ur_b28G8NWb36Du0d3VWj2w .zWEkpX.uRLlUCXXtRMnyKi3..s6aK74O2rvU3JUT0 X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Mon, 13 Sep 2021 08:42:55 +0000 Original-Received: by kubenode524.mail-prod1.omega.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 7ef3712771f83d327caf5c4465766786; Mon, 13 Sep 2021 08:42:52 +0000 (UTC) In-Reply-To: <87zgshotc1.fsf@gmail.com> (Augusto Stoffel's message of "Mon, 13 Sep 2021 08:58:06 +0200") X-Mailer: WebService/1.1.18924 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214202 Archived-At: Augusto Stoffel writes: > I thought 'insert-file-contents-literally' literally just inserted the > file contents, as bytes, but I noticed that in the following code > > (create-image > (with-temp-buffer > (set-buffer-multibyte nil) > (insert-file-contents-literally "picure.jpg") > (buffer-substring-no-properties (point-min) (point-max))) > nil t) > > the call to 'set-buffer-multibyte' is really essential. > > Is this intended? If so, I think a note in the doctring is due. It is intended, and the source of confusion may be the apparently symmetric `find-file-literally`, which _does_ make the buffer unibyte before filling the new buffer with the contents from a file (and documents this behavior). But if you think about it, it makes sense that `insert-file-contents-literally` does not set the buffer as unibyte, because it's intended for programmatic cases where you insert the content inside a buffer that may already have other content, so making the buffer unibyte unconditionally may cause unexpected results. So yeah, perhaps we can add a small sentence that clarifies this behavior.