Skip to content

Fix title editing mangling titles and block delimiters - #89

Merged
bbatsov merged 3 commits into
masterfrom
fix-title-editing
Oct 7, 2026
Merged

bbatsov merged 3 commits into
masterfrom
fix-title-editing

Conversation

@bbatsov

@bbatsov bbatsov commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Promoting or demoting == Section produced === Section === whenever the title had a newline after it, and with two-line titles disabled (the default) the editing commands still took a line above ---- or ==== for a setext title and rewrote the delimiter.

The editing commands now follow adoc-enable-two-line-title like highlighting and navigation already do. That means converting a legacy setext title with C-c C-t needs the option turned on first - nothing else in the mode sees those titles while it's off either.

adoc-title-descriptor decided whether a one-line title was enclosed
(`== Title ==`) from match group 3, which also holds the line's
trailing newline. Every title followed by a newline therefore looked
enclosed, and promoting, demoting or adjusting it added a closing
delimiter. Group 4 holds just the trailing delimiter. The existing
specs only used titles at the end of the buffer, which hid this.
adoc-promote-title and adoc-demote-title are documented to treat a nil
ARG as 1, but only the interactive spec supplied it, so a Lisp call
without an argument either did nothing or signalled wrong-type-argument
in `(- nil)'. Point not being on a title is the user's mistake, so
report it with user-error.
Highlighting, heading navigation and imenu only recognise two-line
(setext) titles when they're enabled, but adoc-title-descriptor, which
the editing commands go through, always did. With the option off (the
default) any line above a block delimiter passed for a title, so M-left
on `.Example' above `----' rewrote the delimiter as `~~~~~~~~', and
C-c C-t deleted it.

The descriptor now skips two-line titles unless they're enabled, and
C-c C-t refuses to create one while they're disabled, or deeper than
the levels two-line titles have (which used to crash).

A numeric adoc-enable-two-line-title is documented as the length of
delimiter lines that are never title underlines, but fontification
compared it against the title text. Both places now share one check on
the underline length.
@bbatsov
bbatsov merged commit abdb1d8 into master Oct 7, 2026
6 of 8 checks passed
@bbatsov
bbatsov deleted the fix-title-editing branch October 7, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant