GNU bug report logs - #50646
28.0.50; narrow-to-defun sometimes narrows to wrong defun

Previous Next

Package: emacs;

Reported by: arthur.miller <at> live.com

Date: Fri, 17 Sep 2021 17:07:02 UTC

Severity: normal

Tags: moreinfo

Found in version 28.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Arthur Miller <arthur.miller <at> live.com>
Cc: 50646 <at> debbugs.gnu.org
Subject: bug#50646: 28.0.50; narrow-to-defun sometimes narrows to wrong defun
Date: Sun, 19 Sep 2021 22:04:13 +1200
On 2021-09-19 20:33, Arthur Miller wrote:
> (with-temp-buffer
>   (insert-file-contents-literally (expand-file-name file 
> source-directory))
> 
> It is the utf-8. When I use `insert-file-contents' instead, it works as
> intended.
> 
> I guess insert-file-contents-literally does not preserve same coding as 
> what I
> have in the temp-buffer by deafault, so things get messed-up. I don't 
> know if I
> explain it well, but that seems to be the problem.

Yes, all of the following things from `insert-file-contents' are NOT 
done
by `insert-file-contents-literally':

  "This function does code conversion according to the value of
  ‘coding-system-for-read’ or ‘file-coding-system-alist’, and sets the
  variable ‘last-coding-system-used’ to the coding system actually used.

  In addition, this function decodes the inserted text from known 
formats
  by calling ‘format-decode’, which see.

I don't believe you would typically use *-literally unless you 
specifically
wanted to avoid all of those things (or some of the things, and were 
happy
to take care of the others in your own code).

I do also think that the docstring for `insert-file-contents-literally' 
can
be made clearer, firstly just with a newline so that the context for the
final sentence does not begin in the middle of a paragraph, and secondly
so that when users are reading this for the first time it's more obvious
(before reaching that final sentence) that the list of "modifications" 
are
things which do NOT happen if you use this function.

How does this look?

 (defun insert-file-contents-literally (filename &optional visit beg end 
replace)
   "Like `insert-file-contents', but only reads in the file literally.
 See `insert-file-contents' for an explanation of the parameters.
-A buffer may be modified in several ways after reading into the buffer,
-due to Emacs features such as format decoding, character code
-conversion, `find-file-hook', automatic uncompression, etc.
+
+In other circumstances a buffer may be modified in several ways after
+reading into the buffer, due to Emacs features such as format decoding,
+character code conversion, `find-file-hook', automatic uncompression, 
etc.

 This function ensures that none of these modifications will take 
place."
   (let ((format-alist nil)





This bug report was last modified 3 years and 329 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.