From: Robert Cochran <robert-emacs@cochranmail.com>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: 24427@debbugs.gnu.org
Subject: bug#24427: 25.1.50; end-of-defun jumps too far
Date: Sat, 01 Oct 2016 22:12:14 -0700 [thread overview]
Message-ID: <8737kftjv5.fsf@cochranmail.com> (raw)
In-Reply-To: <87r38cw7bp.fsf@mbork.pl> (Marcin Borkowski's message of "Thu, 22 Sep 2016 12:35:22 +0200")
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
next prev parent reply other threads:[~2016-10-02 5:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 12:53 bug#24427: 25.1.50; end-of-defun jumps too far Marcin Borkowski
2016-09-13 20:26 ` Robert Cochran
2016-09-13 20:30 ` Robert Cochran
2016-09-20 18:31 ` Robert Cochran
2016-09-21 19:59 ` Marcin Borkowski
2016-09-22 10:35 ` Marcin Borkowski
2016-10-02 5:12 ` Robert Cochran [this message]
2018-06-17 17:50 ` Noam Postavsky
2020-08-11 14:03 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8737kftjv5.fsf@cochranmail.com \
--to=robert-emacs@cochranmail.com \
--cc=24427@debbugs.gnu.org \
--cc=mbork@mbork.pl \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.