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

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

bug#24427: 25.1.50; end-of-defun jumps too far


From: Robert Cochran
Subject: bug#24427: 25.1.50; end-of-defun jumps too far
Date: Sat, 01 Oct 2016 22:12:14 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux)

Marcin Borkowski <mbork@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





reply via email to

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