From: Alex <alex.giorev@gmail.com>
To: 50139@debbugs.gnu.org
Subject: bug#50139: 27.2; An issue with outline-move-subtree-down
Date: Fri, 20 Aug 2021 23:15:27 +0300 [thread overview]
Message-ID: <1bf8567a-7b33-fa88-85ef-a7d5b8f55603@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1747 bytes --]
Consider a buffer in |outline-mode| having the following text (it is
important that the buffer ends in a newline):
* first heading
the body of the first heading
* second heading
the body of the second heading
Now position point on the second heading and invoke |M-x
outline-hide-subtree|, after which go to the first heading and invoke
|M-x outline-move-subtree-down|. On my computer, this resulted in the
first heading appearing to be on the same visual line as the second.
I've figured out why this happens. It is because
|outline-end-of-subtree| works a bit differently depending on whether
the subtree is the last one in the buffer. In this case, point will be
positioned at the end of the buffer, but when the subtree is not the
last one, it will be positioned on the last position of the last line of
the subtree, before the newline which separates it from the next
heading. I think this implementation is more consistent, as it works the
same in both cases:
|(defun outline-end-of-subtree ()
"Move to the end of the current subtree.
More precisely, move to the last position of the last line of the
subtree: the
position before the newline character of that line."
(outline-back-to-heading)
(let ((level (funcall outline-level)))
;; this loop stops at the end of the buffer or on the first heading
whose
;; level is not less than that of the current subtree
(while (and (not (eobp))
(> (progn (outline-next-heading)
(funcall outline-level))
level)))
(if (eobp)
(if (= (char-before) ?\n) (backward-char))
(backward-char)))) |
[-- Attachment #2: Type: text/html, Size: 2224 bytes --]
next reply other threads:[~2021-08-20 20:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 20:15 Alex [this message]
2021-08-21 12:59 ` bug#50139: 27.2; An issue with outline-move-subtree-down Lars Ingebrigtsen
2021-08-21 13:19 ` Stephen Berman
2021-08-21 13:29 ` 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=1bf8567a-7b33-fa88-85ef-a7d5b8f55603@gmail.com \
--to=alex.giorev@gmail.com \
--cc=50139@debbugs.gnu.org \
/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).