From: Ihor Radchenko <yantar92@gmail.com>
To: D <d.williams@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: Re: org-forward-heading-same-level and the invisible-ok argument
Date: Fri, 28 Aug 2020 21:43:24 +0800 [thread overview]
Message-ID: <87tuwm7uo3.fsf@localhost> (raw)
In-Reply-To: <67d953fc-3396-8038-4302-6e1ad4cde72c@posteo.net>
> + (mapcar #'org-invisible-p
> + (number-sequence (line-beginning-position)
> + (1- (line-end-position)))))
This is a bad idea. org--line-visible-p will be called for every single
invisible headline. If you check every single point at every single
invisible headline, it can be extremely slow.
Better do something like below (or maybe even without narrow-to-region,
not sure if that may cause significant overhead):
(defun org--line-visible-p ()
"Return t if the current line is partially visible."
(save-restriction
(narrow-to-region (line-beginning-position) (1- (line-end-position)))
(let ((visible t)
(p (point-min)))
(while (and visible (< p (point-max)))
(when (org-invisible-p p)
(setq visible nil))
(setq p (next-single-char-property-change p 'invisible)))
visible)))
Best,
Ihor
D <d.williams@posteo.net> writes:
>> I do not think that setting visibility the leading stars is a correct
>> approach to control the movement commands. After second though about the
>> issue you raised in the first email, I think that it would make more
>> sense for org-forward-heading-same-level to check if any part of the
>> heading line is visible to decide if we need to skip it (instead of
>> current approach checking only the point at the beginning of the
>> headline). Any mode aiming to make org-forward-heading-same-level skip a
>> heading will then just need to make the whole heading invisible.
>> Skipping partially visible headlines would be a violation of the
>> docstring.
>
> Good point! I think this would be a more or less reasonable patch, then.
>
> Cheers,
> D.
> From 4c0f638104f689780de317af5f715384152459bd Mon Sep 17 00:00:00 2001
> From: "D. Williams" <d.williams@posteo.net>
> Date: Fri, 28 Aug 2020 14:15:31 +0200
> Subject: [PATCH] org.el: let heading navigation check the entire heading for
> visibility
>
> * org.el (org-forward-heading-same-level): check complete heading instead of the first char
>
> TINYCHANGE
> ---
> lisp/org.el | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/lisp/org.el b/lisp/org.el
> index 71dbc611e..26f815e19 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -20478,6 +20478,15 @@ entry."
> ((looking-at-p re) (forward-line))
> (t (throw 'exit t))))))))
>
> +(defun org--line-visible-p ()
> + "Return t if the current line is partially visible."
> + (and
> + (memq nil
> + (mapcar #'org-invisible-p
> + (number-sequence (line-beginning-position)
> + (1- (line-end-position)))))
> + t))
> +
> (defun org-forward-heading-same-level (arg &optional invisible-ok)
> "Move forward to the ARG'th subheading at same level as this one.
> Stop at the first and last subheadings of a superior heading.
> @@ -20499,8 +20508,7 @@ non-nil it will also look at invisible ones."
> (cond ((< l level) (setq count 0))
> ((and (= l level)
> (or invisible-ok
> - (not (org-invisible-p
> - (line-beginning-position)))))
> + (org--line-visible-p)))
> (cl-decf count)
> (when (= l level) (setq result (point)))))))
> (goto-char result))
> --
> 2.26.2
next prev parent reply other threads:[~2020-08-28 13:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-25 16:46 org-forward-heading-same-level and the invisible-ok argument D
2020-08-26 1:30 ` Ihor Radchenko
2020-08-26 21:33 ` [PATCH] " D
2020-08-27 11:49 ` Ihor Radchenko
2020-08-28 12:27 ` [PATCH] " D
2020-08-28 13:43 ` Ihor Radchenko [this message]
2020-08-28 17:49 ` D
2020-08-29 5:10 ` Ihor Radchenko
2020-08-30 22:07 ` [PATCH] " D
2020-09-06 6:35 ` Bastien
2020-09-06 11:09 ` D
2020-09-07 5:06 ` Bastien
2020-09-07 6:25 ` Ihor Radchenko
2020-09-07 18:31 ` D
2020-09-08 9:28 ` Bastien
2020-09-08 20:00 ` D
2020-09-09 8:09 ` Bastien
2020-09-09 4:15 ` Ihor Radchenko
2020-09-09 8:08 ` Bastien
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.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tuwm7uo3.fsf@localhost \
--to=yantar92@gmail.com \
--cc=d.williams@posteo.net \
--cc=emacs-orgmode@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/org-mode.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).