GNU bug report logs - #24427
25.1.50; end-of-defun jumps too far

Previous Next

Package: emacs;

Reported by: Marcin Borkowski <mbork <at> mbork.pl>

Date: Tue, 13 Sep 2016 12:54:02 UTC

Severity: normal

Tags: fixed, patch

Found in version 25.1.50

Fixed in version 28.1

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

Bug is archived. No further changes may be made.

Full log


Message #23 received at 24427 <at> debbugs.gnu.org (full text, mbox):

From: Robert Cochran <robert-emacs <at> cochranmail.com>
To: Marcin Borkowski <mbork <at> mbork.pl>
Cc: 24427 <at> debbugs.gnu.org, Robert Cochran <robert-emacs <at> cochranmail.com>
Subject: Re: bug#24427: 25.1.50; end-of-defun jumps too far
Date: Sat, 01 Oct 2016 22:12:14 -0700
Marcin Borkowski <mbork <at> mbork.pl> writes:

> OK, so here's the problem I found when running my personal tests for my
> `mark-defun'.
>
> Consider this Elisp buffer:
>
> ;; Comment header
>
> (defun func-1 (arg)
>   "docstring"
>   body)
> -!-
> ;; Comment before a defun
> (defun func-2 (arg)
>   "docstring"
>   body)
>
> (defun func-3 (arg)
>   "docstring"
>   body)
> (defun func-4 (arg)
>   "docstring"
>   body)
>
> ;; end
>
> where -!- means the point location.  Now press C-u 2 C-M-e, and you
> moved by one defun instead of two.

This particular problem is the result of this bit in the body of
`end-of-defun`:

#+BEGIN_SRC emacs-lisp
(if (> (point) pos)
    ;; We already moved forward by one because we started from
    ;; within a function.
    (setq arg (1- arg))
  ;; We started from after the end of the previous function.
  (goto-char pos))
#+END_SRC

When the whitespace is skipped after doing the initial position
calculations, point, which ends up either on or after the

> ;; Comment before a defun

line, is indeed after `pos`, a recording of point before doing any
movement. The assumption that we were in a function body, as stated in
the comment, doesn't hold. So the definition count is erroneously
decreased.

Nothing has come to mind for a method to fix it without breaking other
things. Perhaps the solution is obvious for someone else? Suggestions
would be nice if you have them.

(As an aside, to vent a little, it's rather frustrating that both pre-
and post-patch do what you regard as TRT in different
circumstances. Especially so because pre-patch is only doing TRT as a
result of what I would say is two bugs canceling each other
out. Obviously not your fault, but still frustrating.)

Thanks,
-- 
~Robert Cochran

GPG Fingerprint - E778 2DD4 FEA6 6A68 6F26  AD2D E5C3 EB36 4886 8871




This bug report was last modified 4 years and 287 days ago.

Previous Next


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