From: Ihor Radchenko <yantar92@posteo.net>
To: Sterling Hooten <hooten@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Completely hide properties drawer in 9.6
Date: Mon, 16 Jan 2023 14:16:49 +0000 [thread overview]
Message-ID: <87wn5mk1im.fsf@localhost> (raw)
In-Reply-To: <FF611837-3543-46E0-B54D-744119FF96D9@gmail.com>
Sterling Hooten <hooten@gmail.com> writes:
> In order to both have newly added properties automatically adopt the
> invisibility text-property the interior characters of the properties
> box needs to be sticky. But this conflicted with being able to type
> with the point before the hidden text. To satisfy both these
> requirements I applied =property-drawer-hidden-interior= as a folding
> spec which was sticky to all but the first two and last two characters
> of the property drawer. Then I applied =property-drawer-hidden-edges=
> to these two remaining chunks. In this way you can add in new
> properties and they'll be invisible, but typing at the edges appears
> visibly.
>
> Is there an alternative way of doing this without two separate folding
> specs? Maybe an additional key for ":interior-sticky" which is sticky
> on all characters sharing the same spec, but not sticky at the front
> and rear?
In theory, it is possible to add something like :interior-sticky.
However, it will be against how Emacs' sticky properties work.
An alternative approach you may use is hooking into font-lock.
Fontification will be re-applied upon editing, and you can hide only the
property drawer and nothing else. And you will not need to deal with
edge cases with inserting text.
> I couldn't quite figure out what the :fragile setting was.
:fragile makes sure that things are unfolded when a drawer is no longer
a drawer. Imagine:
<point>:drawer:<begin fold>
Some text.
:end:
<end fold>
Then, you delete ":":
drawer:
Some text.
:end:
:fragile defines rules allowing to auto-unfold the drawers (or anything
else) as needed.
We would not want the drawer above to remain folded as you would not be
able to use <TAB> to unfold any more - tab will no longer see a "drawer"
at point.
> #+begin_src emacs-lisp
> (defun org-fold-show-property-drawer (&optional arg)
> "Unhide property drawer in heading at point.
> With non-nil ARG show the entire subtree."
> (org-with-wide-buffer
> (org-back-to-heading)
> (let* ((beg (point))
> (end (if arg (org-element-property :end (org-element-at-point))
> (org-next-visible-heading 1)
> (1+ (point)))))
> (org-fold-region beg end nil
> 'property-drawer-hidden-edges)
> (org-fold-region beg end nil
> 'property-drawer-hidden-interior))))
>
> (defun org-fold-hide-property-drawer (&optional arg)
> "Completely hide the property drawer in heading at point.
> With non-nil ARG hide the entire subtree."
> (org-with-wide-buffer
> (org-back-to-heading)
> (let* ((beg (point))
> (end (if arg (org-element-property :end (org-element-at-point))
> (org-next-visible-heading 1)
> (1+ (point)))))
> (org-fold--hide-property-drawers beg end))))
> #+end_src
>
> Is there a faster or better way of getting the boundary points for a
> heading without the subheadings? I've wanted this feature in a few
> other situations but don't know a clean way to fetch it. I suppose you
> could also just have that the regex stop searching for the beginning
> of the property box after 2 lines past the heading, since the
> properties box needs to be in the first two lines.
You can use the following at or inside a drawer:
(org-element-lineage (org-element-at-point) '(section))
:begin and :end will contain current section boundaries. "section" is
all the text under the parent heading, up to the first child. The AST is:
(heading
(section
[(planning)]
[(property-drawer)]
[(paragraph1)]
...)
(subheading)
...)
> The default =org-end-of-meta-data= will go past any blank lines and
> only stop at a non-empty line. I would prefer for hitting <RETURN> on
> a headline to act as if the planning line and properties box were
> immutable, and just pass directly after them. For this I wrote a
> version that will stop after the logbooks or property drawer.
>
> Is there a better way to do this? I tried using the match-data but it
> seemed unreliable (if there's nothing but blank lines after the meta
> data it matches on the next heading).
You can just use `org-element-at-point'. At planning, `org-element-type'
will be 'planning. At property drawer - 'property-drawer. At drawer -
'drawer. :end property will include blank lines, but you can also check
:post-blank that will contain the number of blank lines at the end.
Check out `org--at-headline-data-p' implementation.
> I am also experiencing a weird (overlay?) problem with i-search. After
> implementing when I search for things it will make all of the windows
> greyed out, and then only show the matching characters. I can see the
> text again if I =mark-whole-buffer=. But I don't know what's causing
> this.
No idea here. Need more information.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
next prev parent reply other threads:[~2023-01-16 14:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 5:37 Completely hide properties drawer in 9.6 Sterling Hooten
2022-12-14 9:15 ` Ihor Radchenko
2022-12-14 14:37 ` Sterling Hooten
2022-12-14 15:14 ` Ihor Radchenko
2022-12-14 18:27 ` Sterling Hooten
2022-12-14 18:40 ` Ihor Radchenko
2022-12-23 3:33 ` Sterling Hooten
2023-01-16 14:16 ` Ihor Radchenko [this message]
2022-12-16 9:38 ` Jean Louis
2022-12-16 11:46 ` Ihor Radchenko
2022-12-16 14:44 ` Jean Louis
2022-12-16 15:18 ` Ihor Radchenko
2022-12-17 23:54 ` Jean Louis
2022-12-18 13:26 ` [Feature] Store heading properties remotely, outside the Org file (was: Completely hide properties drawer in 9.6) Ihor Radchenko
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=87wn5mk1im.fsf@localhost \
--to=yantar92@posteo.net \
--cc=emacs-orgmode@gnu.org \
--cc=hooten@gmail.com \
/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).