unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Phil Sainty <psainty@orcon.net.nz>
Cc: 50646@debbugs.gnu.org
Subject: bug#50646: 28.0.50; narrow-to-defun sometimes narrows to wrong defun
Date: Sun, 19 Sep 2021 10:33:40 +0200	[thread overview]
Message-ID: <AM9PR09MB49776BF0C4FA77BB29CB1C0696DF9@AM9PR09MB4977.eurprd09.prod.outlook.com> (raw)
In-Reply-To: <3a6fa91859db00e5c382752ddedfbdd0@webmail.orcon.net.nz> (Phil Sainty's message of "Sun, 19 Sep 2021 15:41:03 +1200")

Phil Sainty <psainty@orcon.net.nz> writes:

> On 2021-09-18 05:06, arthur.miller@live.com wrote:
>> 1. run Emacs -Q -l /path/to/attached/help-mode.el
>> 2. type C-x f
>
> C-h f
>
>> 3. in minibuffer type: when RET
>> The help-mode buffer that opens should show help for 'when' form, but it
>> shows the source code for the 'pop' macro which precedes the 'when' in
>> subr.el.
>
>> The docs for 'narrow-to-defun' says the "current-defun" is one that
>> contains the point or follows the point.
>
> I can reproduce the issue using your code, but I'm not sure whether the
> reason for it is a misunderstanding of what 'point' is, some vagueness
> in the 'narrow-to-defun' docstring, or an actual regression.
>
> To eliminate the first:
>
>    "Like other positions, point designates a place between two characters
> (or before the first character, or after the last character), rather
> than a particular character.  Usually terminals display the cursor over
> the character that immediately follows point; point is actually before
> the character on which the cursor sits."
>
> -- quoted from (info "(elisp)Point")
>
>
> 'narrow-to-defun' says "The current defun is the one that contains point
> or follows point." and if you place the cursor over the opening "(" of
> "(defmacro when" then that defmacro form "follows point", and indeed
> narrow-to-defun works as intended.
>
> The issue is what happens when point is somewhere earlier than that
> position, but still *after* the previous form.  In that instance
> narrow-to-defun narrows to the previous form, which is surely what is
> happening in your code.
>
> If so, all you need for reproducing this is to experiment with
> narrow-to-defun at the various positions between two forms.
>
> That is a consequence of 'beginning-of-defun' jumping to the beginning
> of the previous defun in that situation (which to me seems like a
> reasonable behaviour for that function); but for 'narrow-to-defun'
> the effect does seem contrary to its docstring.
>
> I think we just want to change the docstring of 'narrow-to-defun' --
> the last relevant commit looks like:
>
>
> commit 050cc68b402f5998193a6026d0eeeecb9d2cb9c4
> Author: Lennart Borgman <lennart.borgman@gmail.com>
> Date:   Wed Apr 11 04:12:20 2012 +0200
>
>     `narrow-to-defun' fixup
>
>     * emacs-lisp/lisp.el (narrow-to-defun): `beginning-of-defun' goes
>     to previous function when point is on the first character of a
>     function. Take care of that in `narrow-to-defun'.
>
>     Fixes: debbugs:6157
>
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=6157
>
>
> -Phil

I have found what was the problem, but I don't know if it is a bug or not:


(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.

I don't know if that is a bug, or just me not being used to how encodings in
Emacs work. Probably not a bug.

I appologize for the inconvenience.





  parent reply	other threads:[~2021-09-19  8:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 17:06 bug#50646: 28.0.50; narrow-to-defun sometimes narrows to wrong defun arthur.miller
2021-09-18 14:09 ` Lars Ingebrigtsen
2021-09-18 17:27   ` Arthur Miller
2021-09-18 18:34     ` Arthur Miller
2021-09-19  8:34   ` Arthur Miller
2021-09-19  3:41 ` Phil Sainty
2021-09-19  6:36   ` Arthur Miller
2021-09-19 10:56     ` Phil Sainty
2021-09-19 20:02       ` Arthur Miller
2021-09-19  8:33   ` Arthur Miller [this message]
2021-09-19 10:04     ` Phil Sainty
2021-09-19 12:01       ` Eli Zaretskii
2021-09-19 12:06         ` Phil Sainty
2021-09-19 12:17           ` Eli Zaretskii
2021-09-19 12:53             ` Phil Sainty
2021-09-19 13:43               ` Eli Zaretskii
2021-09-19 14:21                 ` Phil Sainty
2021-09-19 15:22                   ` Eli Zaretskii
2021-09-19 15:25             ` bug#50646: [External] : " Drew Adams
2021-09-19 19:57       ` Arthur Miller
2021-09-20  6:02         ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AM9PR09MB49776BF0C4FA77BB29CB1C0696DF9@AM9PR09MB4977.eurprd09.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=50646@debbugs.gnu.org \
    --cc=psainty@orcon.net.nz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).