emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marlin Strub <marlin.strub@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [PATCH] org.el: Adapt org-cycle to work with headlines with hidden stars
Date: Fri, 11 Sep 2020 14:45:29 +0200	[thread overview]
Message-ID: <CAOo8FztuNdRzV_mm7n2a4AQS-2QapKYE0XK9JWpwm7P_gjYgUQ@mail.gmail.com> (raw)

[-- Attachment #1.1: Type: text/plain, Size: 869 bytes --]

Hello everyone,

I looked into using text properties to hide all the stars in org headings
(with org-starless-mode [1]),
and noticed that `org-cycle' didn't reliably cycle the visibility of
headings anymore.

Trying to find the reason for this, I found that `org-cycle' uses
`move-beginning-of-line' in combination
with a regexp to detect headings. The problem is that
`move-beginning-of-line' ignores invisible text
such that the regexp fails to match. The attached patch changes
`move-beginning-of-line' to
`beginning-of-line', which does not ignore invisible text.

This solves the issue with hidden stars, but I have a feeling that I'm
missing something. Is there a
problem with using `beginning-of-line' instead of `move-beginning-of-line'
or could this patch be

Thanks a lot for looking into this,

[1] https://github.com/TonCherAmi/org-starless

[-- Attachment #1.2: Type: text/html, Size: 1196 bytes --]

[-- Attachment #2: 0001-org.el-Adapt-org-cycle-to-work-with-headlines-with-h.patch --]
[-- Type: application/octet-stream, Size: 1191 bytes --]

From 4ba5026a96c6cee4f0320f70f46245b551af2647 Mon Sep 17 00:00:00 2001
From: Marlin Strub <marlin@Marlins-MacBook-Pro.local>
Date: Fri, 11 Sep 2020 13:50:06 +0200
Subject: [PATCH] org.el: Adapt org-cycle to work with headlines with hidden

* lisp/org.el (org-cycle): Use `beginning-of-line' instead of
`move-beginning-of-line' to move point to the beginning of
line (including any invisible characters) such that org-outline-regexp
matches headlines with hidden stars (such as those produced by

 lisp/org.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 71dbc611e..722338ff0 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -6346,7 +6346,7 @@ Use `\\[org-edit-special]' to edit table.el tables"))
 				 (= (line-beginning-position)
 				    (org-element-property :post-affiliated
-		     (save-excursion (move-beginning-of-line 1)
+		     (save-excursion (beginning-of-line 1)
 				     (looking-at org-outline-regexp)))
 		 (or (bolp) (not (eq org-cycle-emulate-tab 'exc-hl-bol))))

             reply	other threads:[~2020-09-11 12:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 12:45 Marlin Strub [this message]
2020-09-13 17:18 ` [PATCH] org.el: Adapt org-cycle to work with headlines with hidden stars Bastien
2020-09-14  7:12   ` Marlin Strub
2020-09-14 13:37     ` Bastien
2020-09-14 13:48       ` Marlin Strub

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:

  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=CAOo8FztuNdRzV_mm7n2a4AQS-2QapKYE0XK9JWpwm7P_gjYgUQ@mail.gmail.com \
    --to=marlin.strub@gmail.com \
    --cc=emacs-orgmode@gnu.org \


* 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


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).