* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--fontify-delimiter): When `markdown-ts-hide-markup'
is enabled in `markdown-ts-view-mode', also hide the whole line
containing a `fenced_code_block_delimiter' (including its
terminating newline) so Eldoc/LSP markdown snippets render
without stray blank lines around the code block. Scoped to
view-mode and to fenced delimiters on purpose: the same handler
is shared by inline delimiters (emphasis, code span, link
brackets) where munching surrounding whitespace would collapse
word separators, and tuning rendering for
hide-markup-while-editing is not a goal.
The grammar reports leading spaces as part of the atx_heading "marker"
and we cannot use the length of the marker as a result. Instead, count
the number of consecutive # after any blanks to determine its "level."
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--fontify-atx-heading): Count the octothorpes rather
than using the length of the marker node's text.
Do not assume every command run in
'markdown-ts--run-command-in-code-block' produces output that needs to
be merged from the temp/work buffer into the source buffer. One example
is 'xref-find-definitions', the temp buffer of which is unrelated to the
source buffer.
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts-code-block-commands): Add 'complete-symbol'.
(markdown-ts-code-block-ignore-output-commands): New defvar.
(markdown-ts--run-command-in-code-block): Ignore command output
when necessary.
Replace the "c" character-prompt interactive spec with
'read-multiple-choice', which presents named options instead of
requiring users to decode the prompt string and type a single
character.
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts-table-align-column): Use 'read-multiple-choice'.
Adjust ALIGN docstring punctuation.
* lisp/textmodes/markdown-ts-mode-x.el
(markdown-ts-toc-insert-template): Use 'read-multiple-choice'.
This new derived mode is intended for consumers that render
Markdown content for display rather than editing, such as Eglot
and Eldoc when showing documentation popups and buffers. It
pre-sets the relevant customizations (markup hidden, inline
images on, hard-line-break markup hidden, native code-block
fontification, table and code-block context minor modes off),
makes the buffer read-only, and uses its own keymap derived from
'special-mode-map' so navigation keys behave like a viewer.
A pre-init hook lets callers normalize buffer content before the
grammar parses it; 'markdown-ts-add-final-newline' is the
default so that markup depending on a terminating newline parses
correctly. 'markdown-ts-buffer-string' returns the rendered
buffer string with overlay faces flattened into text properties,
which is useful for callers that capture the rendered output.
Along the way: 'list_marker_parenthesis' is now recognized as an
ordered list marker; the strikethrough query is simplified to a
single rule; thematic breaks span the window via an ':extend'
underline when the face supports it.
* lisp/textmodes/markdown-ts-mode.el (markdown-ts-view-mode):
New read-only derived mode.
(markdown-ts-view-mode-map): New keymap.
(markdown-ts-view-mode-pre-init-hook): New hook, defaulting to
'markdown-ts-add-final-newline'.
(markdown-ts-mode--initialize): New helper, factored out of
'markdown-ts-mode' so 'markdown-ts-view-mode' can reuse the
parser readiness and setup logic after overriding local
variables.
(markdown-ts-mode): Call 'markdown-ts-mode--initialize'.
(markdown-ts-add-final-newline): New function.
(markdown-ts-buffer-string): New function.
(markdown-ts-unordered-list-marker): New defcustom.
(markdown-ts-hard-line-break-backslash)
(markdown-ts-hard-line-break-space): Accept the symbol 'hide.
(markdown-ts--fontify-hard-line-break): Honor 'hide.
(markdown-ts--fontify-atx-heading)
(markdown-ts--fontify-setext-heading)
(markdown-ts--fontify-atx-delimiter)
(markdown-ts--fontify-unordered-list-marker)
(markdown-ts--list-item-depth): New functions supporting clean
rendering when markup is hidden.
(markdown-ts--fontify-thematic-break): Use ':extend' underline
span when the face supports it.
(markdown-ts--resolve-display-value): Accept non-cons values.
(markdown-ts--list-ordered-item-p): Also recognize
'list_marker_parenthesis'.
(markdown-ts--range-settings): Mark markdown-inline embed as
':local t'.
(markdown-ts--set-up): Create the markdown-inline parser only in
the inline setup branch; drop the redundant
'markdown-ts-hide-markup' make-local-variable.
(markdown-ts--treesit-settings): Route atx and setext headings
to their dedicated fontifiers; route unordered list markers
through 'markdown-ts--fontify-unordered-list-marker'; move
'strikethrough' to the simpler paragraph-inline query.
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--treesit-settings): Add a new font-lock block for
'paragraph-inline' that handles strikethrough nodes more
carefully.
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts--treesit-settings): Move the 'code_span' and
'code_span_delimiter' font-lock rules into a separate block with
':override prepend' instead of 'append'. The heading feature
(level 1) applies its face via 'font-lock-append-text-property',
so a code span that later appends 'markdown-ts-code-span' ends
up with '(markdown-ts-heading-N markdown-ts-code-span)', where
the heading face takes priority and the code-span face is
suppressed. Prepending ensures 'markdown-ts-code-span' appears
first in the face list and wins visually.
* lisp/textmodes/markdown-ts-mode.el (markdown-ts-inline-images):
Now buffer local.
(markdown-ts--fontify-image): Defensively test for graphical
display before rendering images.
* lisp/textmodes/sgml-mode.el (sgml--find-<>-backward): Ignore
SGML tags that happen to occur within comments. This also means
that the contents of comments are not indented, but also do not
affect the indentation of tags following the comments as well.
(Bug#80841)
Overhaul 'markdown-ts-mode' with comprehensive fontification,
code block handling, editing commands, fill-paragraph support,
inline image previews, a mode menu, and table editing. Add
'markdown-ts-mode-x.el' with conversion/export and TOC support.
* lisp/textmodes/markdown-ts-mode.el: Add Version,
Package-Requires, and Keywords header fields. Expand Commentary
with documentation for code block language modes, code block
commands, bidirectional text, and known tree-sitter grammar
bugs.
(require 'goto-addr, xref, icons): New requirements.
(markdown-ts): New customization group with :version and
:package-version tags.
(markdown-ts-hide-markup): Add :version and :package-version.
(markdown-ts-ellipsis): New option for folded heading ellipsis.
(markdown-ts-menu-bar-show): New option to toggle mode menu.
(markdown-ts-default-folding): New option for default fold
level.
(markdown-ts-inline-images): New option to display inline
images.
(markdown-ts-image-max-width): New option for image max width.
(markdown-ts-display-remote-inline-images): New option for
remote image handling.
(markdown-ts--resolve-display-value): New helper to resolve
display values using char-displayable-p.
(markdown-ts-checked-checkbox): New option for checked checkbox
display string or icon.
(markdown-ts-checked-checkbox-icon): New icons.el icon for the
checked variant.
(markdown-ts-unchecked-checkbox): New option for unchecked
checkbox display string or icon.
(markdown-ts-unchecked-checkbox-icon): New icons.el icon for the
unchecked variant.
(markdown-ts-thematic-break-character): New option for thematic
break display character.
(markdown-ts-hard-line-break-backslash): New option for the
glyph shown in place of a trailing-backslash hard line break
when markup is hidden.
(markdown-ts-hard-line-break-space): New option for the glyph
shown in place of a trailing-spaces hard line break when markup
is hidden.
(markdown-ts-code-block-in-context-mode-lighter): New option for
code block context mode lighter string.
(markdown-ts-inhibit-code-block-mode-warnings): New option to
inhibit code-block major-mode messages and warnings.
(markdown-ts-table-default-column-width): New option for default
table column width.
(markdown-ts-enable-table-mode): New option to enable table
mode.
(markdown-ts-table-auto-align): New option for triggers that
cause automatic table alignment.
(markdown-ts-table-align-features): New option for table align
features.
(markdown-ts-in-table-mode-lighter): New option for
markdown-ts-in-table-mode lighter string.
(markdown-ts-emphasis, markdown-ts-bold)
(markdown-ts-strikethrough, markdown-ts-link)
(markdown-ts-link-destination, markdown-ts-code-span)
(markdown-ts-code-block, markdown-ts-code-block-markup-hidden)
(markdown-ts-indented-code-block, markdown-ts-html-tag)
(markdown-ts-html-block, markdown-ts-thematic-break)
(markdown-ts-entity-reference)
(markdown-ts-numeric-character-reference, markdown-ts-latex)
(markdown-ts-table-header, markdown-ts-table-cell)
(markdown-ts-table-delimiter-cell, markdown-ts-task-unchecked)
(markdown-ts-task-checked): New faces.
(markdown-ts-hard-line-break-backslash)
(markdown-ts-hard-line-break-backslash-hidden)
(markdown-ts-hard-line-break-space)
(markdown-ts-hard-line-break-space-hidden): New faces for the
two hard-line-break variants, with distinct shown/hidden
appearances.
(markdown-ts-in-code-block): New face for when point is inside a
fenced code block.
(markdown-ts-table): New face for Markdown pipe table
background.
(markdown-ts-in-table): New face for markdown-ts-in-table-mode
when point is in a table.
(markdown-ts--set-up-inline): New variable for lightweight setup
in embedded inline markdown-ts-mode buffers used by code block
commands.
(markdown-ts-default-code-block-mode): New variable to define
default mode for anonymous code blocks.
(markdown-ts-fontify-code-blocks-natively): New option to
enable/disable native fontification of fenced code block
contents.
(markdown-ts-enable-code-block-context-mode): New option to
enable/disable code block context integration.
(markdown-ts-code-block-modes): New variable replacing
markdown-ts--code-block-language-map and
markdown-ts-code-block-source-mode-map with unified language to
mode mapping including heuristic lookup.
(markdown-ts-code-block-force-conventional-modes): New variable
listing tree-sitter modes whose fontification of code block
content should be harvested via a temporary buffer.
(markdown-ts-table-export-buffer): New constant for table export
output buffer name.
(markdown-ts--table-row-types, markdown-ts--table-cell-types)
(markdown-ts--table-delimiter-cell-types)
(markdown-ts--table-delimiter-cell-subtypes): New constants for
pipe table node type classification.
(markdown-ts--make-link-button): New function to create
clickable link buttons with mailto, browse-url, and find-file
dispatch.
(markdown-ts--fontify-link-destination): New fontifier that
hides link destinations when markup is hidden.
(markdown-ts--link-ref-cache, markdown-ts--link-ref-cache-tick)
(markdown-ts--link-ref-definitions)
(markdown-ts--resolve-link-ref): New link reference definition
cache with case-insensitive matching per CommonMark spec.
(markdown-ts--fontify-link-node): New fontifier for inline,
reference, shortcut, and collapsed links as clickable buttons.
(markdown-ts--fontify-autolink): New fontifier for URI and email
autolinks with angle bracket hiding.
(markdown-ts--fontify-link-ref-label)
(markdown-ts--fontify-link-ref-destination): New fontifiers for
link reference definitions.
(markdown-ts--slug-github-strip-re, markdown-ts--slug-github)
(markdown-ts--slug-pandoc, markdown-ts--explicit-id-re)
(markdown-ts--heading-text-and-id)
(markdown-ts--heading-id-cache)
(markdown-ts--heading-id-cache-tick)
(markdown-ts--build-heading-ids, markdown-ts--heading-ids)
(markdown-ts--follow-fragment): New fragment link support with
GitHub and Pandoc slug algorithms.
(markdown-ts--latex-block-valid-p)
(markdown-ts--fontify-latex-block): New LaTeX/math fontifier
with cross-paragraph validation.
(markdown-ts--fontify-backslash-escape): New fontifier that
hides backslash in escapes except inside LaTeX blocks.
(markdown-ts--decode-entity, markdown-ts--fontify-entity): New
HTML entity decoder and fontifier using org-entities and
sgml-char-names with display property for decoded values.
(markdown-ts--fontify-checkbox): New fontifier showing the
configured checkbox glyph when markup is hidden.
(markdown-ts--fontify-hard-line-break): New fontifier for
'hard_line_break' nodes.
(markdown-ts--fontify-heading): New fontifier for ATX and Setext
headings.
(markdown-ts--fontify-thematic-break): New fontifier showing
horizontal line when markup is hidden.
(markdown-ts--fontify-code-block): New fontifier applying
background overlay to code blocks with language and mode
properties.
(markdown-ts-at-code-block-p)
(markdown-ts-code-block-language-at)
(markdown-ts-code-block-mode-at): New accessors for code block
overlay properties.
(markdown-ts--imenu-code-block-node-p): New helper for imenu
code block detection.
(markdown-ts--image-alone-on-line-p)
(markdown-ts--fontify-image): New inline image display with
standalone and inline positioning.
(markdown-ts--bare-url-regexp)
(markdown-ts--bare-email-uri-regexp)
(markdown-ts--fontify-bare-uri): New bare URL/email
fontification via jit-lock using goto-addr regexps.
(markdown-ts--treesit-settings): Rewrite with dedicated faces,
custom fontifiers, and new font-lock features for all inline and
block elements. Also add a new 'error' font-lock feature
highlighting tree-sitter ERROR nodes.
(markdown-ts--code-block-languages)
(markdown-ts--code-block-non-ts-modes): New buffer-local alists
for code block language tracking.
(markdown-ts--harvest-mode-treesit-configuration): Rename from
markdown-ts--harvest-treesit-configs with delay-mode-hooks.
(markdown-ts--configure-current-buffer): Rename from
markdown-ts--add-config-for-mode.
(markdown-ts--language-at-node): New helper extracting language
symbol from code_fence_content node.
(markdown-ts--non-ts-fontify-cache): New buffer-local hash table
caching fontification results for non-tree-sitter code blocks.
(markdown-ts--fontify-non-ts-collect-faces): New function
harvesting face properties from a mode in an indirect or
temporary buffer.
(markdown-ts--fontify-non-ts-code-block): New fontifier for
non-tree-sitter modes via temporary buffer font-lock.
(markdown-ts--code-block-language-mode): New function with
heuristic mode name probing.
(markdown-ts--code-block-ts-language): Rename from
markdown-ts--convert-code-block-language with support for non-ts
modes and recursive markdown handling.
(markdown-ts-code-block-commands)
(markdown-ts-code-block-thing-commands)
(markdown-ts-code-block-region-commands): New command lists for
code-block context execution.
(markdown-ts--enable-code-block-in-context-mode)
(markdown-ts--maybe-run-command-in-code-block)
(markdown-ts--code-block-xref-find-definitions)
(markdown-ts--run-command-in-code-block): New code block minor
mode with temp-buffer command dispatch.
(markdown-ts--code-block-newline): New command for newline
inside code blocks, dispatching to the block's mode.
(markdown-ts--range-settings): Update range configuration;
remove :range-fn treesit-range-fn-exclude-children.
(markdown-ts--remove-image-overlays)
(markdown-ts--outline-view-change): New helpers for image
overlay management during outline fold/unfold.
(markdown-ts--outline-invisible-p): New helper testing whether a
position is inside an outline-folded region.
(markdown-ts--host-ranges-notifier): New function pruning stale
code block overlays when the host parse tree changes.
(markdown-ts--barf-if-not-mode): New helper signaling a
user-error when the current buffer is not derived from
markdown-ts-mode.
(markdown-ts-code-block-in-context-mode): New minor mode enabled
when point is within a fenced code block, activating
markdown-ts-code-block-in-context-mode-map so eligible commands
dispatch to the block's major mode.
(markdown-ts--set-hide-markup): Clear image overlays when
toggling markup visibility.
(markdown-ts--set-inline-images)
(markdown-ts-toggle-inline-images): New functions for toggling
inline image display.
(markdown-ts--parser-heading-max-level): New constant.
(markdown-ts--heading-at-point, markdown-ts--heading-level)
(markdown-ts--section-at-point): New heading navigation helpers.
(markdown-ts-promote, markdown-ts-demote): New commands for
heading and list item promotion/demotion with region support.
(markdown-ts--promote-or-demote)
(markdown-ts--promote-or-demote-region): New heading level
adjustment functions.
(markdown-ts-move-subtree-up, markdown-ts-move-subtree-down):
New commands for moving sections and list items.
(markdown-ts--section-folded-p)
(markdown-ts--move-subtree-up-or-down): New subtree move with
folding state preservation.
(markdown-ts-toggle-checkbox): New command to toggle task list
checkboxes.
(markdown-ts--list-item-at-point): New helper with block quote
marker handling.
(markdown-ts--list-marker-width, markdown-ts--list-item-region)
(markdown-ts--list-ordered-item-p): New list item helpers.
(markdown-ts--list-promote-or-demote): New function with ordered
list nesting guard.
(markdown-ts--list-node-bol, markdown-ts--list-move): New list
item movement functions.
(markdown-ts-renumber-list): New command for sequential list
renumbering with prefix argument support.
(markdown-ts--list-item-new-marker)
(markdown-ts--new-marker-for-line): New marker string generators
for list item insertion.
(markdown-ts--line-block-quote-depth): New helper counting block
quote depth.
(markdown-ts-newline): New RET command for context-aware
newline.
(markdown-ts-insert-list-item): New M-RET command that creates a
new list item.
(markdown-ts--fill-unfillable-block-query): New tree-sitter
query for unfillable blocks.
(markdown-ts--list-item-text-column): New helper for list item
text alignment.
(markdown-ts--fill-list-item): New function filling within list
items without merging adjacent items.
(markdown-ts--adaptive-fill): New adaptive fill function for
list item continuation.
(markdown-ts--fill-forward-paragraph): New paragraph motion
respecting list items and unfillable blocks.
(markdown-ts-fill-paragraph): New fill-paragraph-function with
cond* dispatch for lists, block quotes, HTML comments, and
unfillable blocks.
(markdown-ts--fill-html-comment): New HTML comment filler with
continuation alignment.
(markdown-ts--block-quote-prefix): New helper preserving
existing block quote marker style.
(markdown-ts--fill-block-quote): New block quote filler with
list item text column alignment.
(markdown-ts-emphasis-alist): New alist of emphasis markers.
(markdown-ts--emphasis-node-at-point): New tree-sitter based
emphasis detection.
(markdown-ts-remove-emphasis): New command removing emphasis at
point or region.
(markdown-ts-emphasize): New interactive emphasis insertion with
region wrapping and word-at-point support.
(markdown-ts-insert-structure): New command for inserting code
blocks, block quotes, and dividers.
(markdown-ts--insert-code-block): New function with language
completion from known modes.
(markdown-ts--insert-block-quote): New function with region
wrapping.
(markdown-ts--insert-divider): New function for horizontal
rules.
(markdown-ts--apply-ellipsis): New function applying custom
ellipsis via display table.
(markdown-ts--set-up): Rename from markdown-ts-setup.
(markdown-ts-outline-cycle): New TAB command cycling outline
visibility on headings.
(markdown-ts-mode-map): New keymap for code block navigation,
bindings for heading navigation, structure editing, emphasis,
and list operations.
(markdown-ts-code-block-in-context-mode-map): New keymap for
code block context.
(markdown-ts-mode-menu): New menu bar with Show/Hide, Navigate
Headings, Edit Structure, and Editing sections.
(markdown-ts-mode): Add outline-minor-mode, ellipsis, folding,
fill-paragraph integration, code-block-context-mode hooks,
comment settings, and outline-view-change-hook. Use
markdown-ts-mode directly in auto-mode-alist instead of
markdown-ts-mode-maybe.
(markdown-ts-mode-install-parsers): New command for installing
required and optional tree-sitter language grammars.
(markdown-ts-code-block-context-mode): New minor mode for code
block context.
(markdown-ts--find-code-block-delimiter)
(markdown-ts--find-next-code-block-delimiter): New helpers for
locating fenced code block delimiter nodes.
(markdown-ts-move-to-next-code-block)
(markdown-ts-move-to-previous-code-block): New commands for
navigating between fenced code blocks.
(markdown-ts--table-abutting-pos, markdown-ts--table-node-cell)
(markdown-ts--table-node-row, markdown-ts--table-parse-error-p):
New pipe table node helpers.
(markdown-ts-at-table-p): New predicate returning non-nil when
point is at or within a pipe table.
(markdown-ts--enable-in-table-mode): New helper enabling
markdown-ts-in-table-mode from post-command-hook.
(markdown-ts--table-body-row-near-pos): New helper locating the
nearest body row to a position.
(markdown-ts--table-compute-node-column)
(markdown-ts-table--goto-column): New helpers for column-based
table navigation.
(markdown-ts--table-aligners, markdown-ts--table-make-aligner)
(markdown-ts--table-align-cell): New table cell alignment
helpers.
(markdown-ts-table-insert-table): New command to insert a pipe
table with configurable rows and columns.
(markdown-ts-table-delete-table): New command to delete the pipe
table at point.
(markdown-ts-table-previous-row, markdown-ts-table-next-row)
(markdown-ts-table-previous-cell, markdown-ts-table-next-cell):
New commands for navigating table rows and cells.
(markdown-ts-table-insert-row-below)
(markdown-ts-table-insert-row-above)
(markdown-ts-table-clone-row-below)
(markdown-ts-table-clone-row-above)
(markdown-ts-table-insert-row): New commands for inserting and
cloning table rows.
(markdown-ts-table-delete-row, markdown-ts-table-move-row-up)
(markdown-ts-table-move-row-down, markdown-ts-table-move-row):
New commands for deleting and moving table rows.
(markdown-ts-table-insert-column-left)
(markdown-ts-table-insert-column-right)
(markdown-ts-table-clone-column-left)
(markdown-ts-table-clone-column-right)
(markdown-ts-table-insert-column): New commands for inserting
and cloning table columns.
(markdown-ts-table-delete-column)
(markdown-ts-table-move-column-left)
(markdown-ts-table-move-column-right)
(markdown-ts-table-move-column): New commands for deleting and
moving table columns.
(markdown-ts-table-align-column-left)
(markdown-ts-table-align-column-center)
(markdown-ts-table-align-column-right)
(markdown-ts-table-align-column): New commands for setting
column alignment.
(markdown-ts-table-align-table): New command to align all
columns in the table at point.
(markdown-ts-table-transpose-table): New command to transpose
the table at point.
(markdown-ts-table-convert-csv-region)
(markdown-ts-table-convert-tsv-region)
(markdown-ts-table-convert-region): New commands to convert
delimited text regions to pipe tables.
(markdown-ts-table-export-table-csv)
(markdown-ts-table-export-table-tsv)
(markdown-ts-table-export-table): New commands to export the
pipe table at point to CSV or TSV format.
(markdown-ts-in-table-mode-map): New keymap for
markdown-ts-in-table-mode.
(markdown-ts--code-block-in-context-mode-ov): New buffer-local
variable for code block context overlay.
(markdown-ts--code-block-in-context-mode-update-ov): New
function updating the code block context overlay.
(markdown-ts-in-table-mode): New minor mode enabled when point
is within a pipe table, activating markdown-ts-in-table-mode-map.
(markdown-ts--in-table-mode-ov)
(markdown-ts--in-table-mode-get-ov)
(markdown-ts--table-tick-update)
(markdown-ts--table-tick-stale-p)
(markdown-ts--in-table-mode-update-ov): New helpers supporting
markdown-ts-in-table-mode overlay management.
(markdown-ts-table-mode): New minor mode providing table editing
commands and auto-alignment.
(markdown-ts-mode-maybe): Remove; auto-mode-alist now uses
markdown-ts-mode directly.
Auto-mode-alist: Add .markdown and .mdx extensions.
* lisp/textmodes/markdown-ts-mode-x.el: New file providing extra
features for markdown-ts-mode.
(markdown-ts-commonmark-spec-url, markdown-ts-gfm-spec-url): New
constants for CommonMark and GFM specification URLs.
(markdown-ts-browse-commonmark-spec)
(markdown-ts-browse-gfm-spec): New commands to browse the
CommonMark and GFM specifications.
(markdown-ts-convert): New customization group for Markdown
conversion/export features.
(markdown-ts-default-converter): New option to set the default
format and converter for Markdown export.
(markdown-ts-convert-display-function): New option specifying
the function used to display converted output.
(markdown-ts-converters): New variable listing format/converter
configurations for pandoc, cmark, cmark-gfm, markdown, and
markdown.pl.
(markdown-ts-convert-file, markdown-ts-convert): New commands to
convert Markdown buffers or files to HTML, PDF, and other
formats via external converters.
(markdown-ts-toc): New customization group for table of contents
features.
(markdown-ts-toc-generate-warn-if-none): New option controlling
behavior when no TOC is found during generation.
(markdown-ts-toc-update-before-save-mode-lighter): New option
for the before-save TOC update minor mode lighter string.
(markdown-ts-toc-slug-function): New option to select the slug
algorithm used for TOC heading anchors.
(markdown-ts--toc-handles, markdown-ts--toc-handle-classes): New
variables defining TOC handle types and classes.
(markdown-ts--toc-expand-candidate-handles, markdown-ts--tocs)
(markdown-ts--tocs-sanity-check)
(markdown-ts--toc-collect-candidates)
(markdown-ts--toc-list-item-depth)
(markdown-ts--toc-atx_header-normalize)
(markdown-ts--toc-text-normalizers)
(markdown-ts--toc-text-normalize): New internal helpers for TOC
parsing and text normalization.
(markdown-ts-toc-update-before-save-mode): New minor mode that
regenerates tables of contents before saving.
(markdown-ts-toc-clear-and-remove, markdown-ts-toc-clear): New
commands to remove or clear TOC bodies.
(markdown-ts-toc-insert-template): New command to insert a TOC
template at point.
(markdown-ts-toc-generate): New command to generate tables of
contents in the current buffer.
Includes fixes for: (bug#80613) (bug#80625) (bug#80690)
Co-authored-by: Stéphane Marks <shipmints@gmail.com>
* lisp/textmodes/sgml-mode.el (sgml-whitespace-sensitive-tags):
Add new variable.
(sgml-calculate-indent): Check if in the context of a tag
specified by 'sgml-whitespace-sensitive-tags'.
(html-mode): Set 'sgml-whitespace-sensitive-tags' to not adjust
the indentation within <pre> and <textarea> tags.
* lisp/textmodes/sgml-mode.el (sgml-validate-command): If no
known program is installed, fall back to nil as the default
value instead of a warning message.
* lisp/textmodes/sgml-mode.el (sgml-quick-keys): Replace with
user option, that adjusts 'sgml-mode-map'.
(sgml-mode-map): Don't insert quick keys.
(html-quick-keys): Replace with user option, that adjusts
'html-mode-map'.
(html-mode-map): Don't insert quick keys.
* lisp/textmodes/flyspell.el (flyspell-generic-progmode-verify):
Take into account the word 'flyspell-auto-correct-previous-word'
moved to (i.e., the word starting at point, not the character
before point), when checking whether it should be checked/corrected
by flyspell-prog-mode. (Bug#80289)
Copyright-paperwork-exempt: yes
* lisp/textmodes/emacs-news-mode.el (emacs-news-find-heading):
HEADING must be a complete line, otherwise we have false positives
and false negatives. (Bug#80569)
* lisp/subr.el (any): Rename from this ...
(member-if): ... to this. All uses changed.
(any): New function alias.
* lisp/emacs-lisp/cl-seq.el (cl-member-if): Mark obsolete.
* lisp/obsolete/cl.el (member-if): Delete obsolete function
alias.
* doc/lispref/lists.texi (List Elements):
* doc/misc/cl.texi (Lists as Sets):
* etc/NEWS: Document the change.
* lisp/subr.el (any): Rename from this ...
(member-if): ... to this. All uses changed.
Implement '&key KEY-FN' for backwards compatibility.
(any): New function alias.
* lisp/emacs-lisp/cl-seq.el (cl-member-if): Make an alias for
'member-if'.
* lisp/obsolete/cl.el (member-if): Delete obsolete function
alias.
* doc/lispref/lists.texi (List Elements):
* doc/misc/cl.texi (Lists as Sets):
* etc/NEWS: Document the change.
Variable names to control indentation have never been
standardized, but over the years some conventions have naturally
arisen, mostly the use of `FOO-indent-offset`,
`FOO-basic-offset`, or `FOO-indent-level` for `FOO-mode`.
When the new TS modes were introduced, a mistake was made that
I failed to catch at the time, where those modes used
`FOO-mode-indent-offset` instead of the "standard" `FOO-indent-offset`.
In order to save packages like `editorconfig-mode` and `indent-bars-mode`
from having to cater to yet-another-convention, rename those
vars to what they should have been all along.
* lisp/editorconfig.el (editorconfig-indentation-alist): Remove the
ad-hoc entries for the deviating modes using `FOO-mode-indent-offset`.
* lisp/textmodes/toml-ts-mode.el (toml-ts-indent-offset):
* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-js-css-indent-offset)
(mhtml-ts--js-css-indent-offset):
* lisp/textmodes/html-ts-mode.el (html-ts-indent-offset):
* lisp/progmodes/typescript-ts-mode.el (typescript-ts-indent-offset):
* lisp/progmodes/php-ts-mode.el (php-ts-indent-offset)
(php-ts-js-css-indent-offset, php-ts-html-indent-offset):
* lisp/progmodes/json-ts-mode.el (json-ts-indent-offset):
* lisp/progmodes/java-ts-mode.el (java-ts-indent-offset)
(java-ts-method-chaining-indent-offset):
* lisp/progmodes/go-ts-mode.el (go-ts-indent-offset):
* lisp/progmodes/csharp-mode.el (csharp-ts-indent-offset):
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-indent-offset):
* lisp/progmodes/c-ts-mode.el (c-ts-indent-offset):
Rename `FOO-mode-indent-offset` to `FOO-indent-offset`,
with obsolete alias.
* lisp/textmodes/markdown-ts-mode.el
(markdown-ts-hide-markup): New defcustom controlling
visibility of markup delimiters.
(markdown-ts--fontify-delimiter): Fontify delimiter nodes and
conditionally apply invisibility.
(markdown-ts--set-hide-markup): Internal helper to update
invisibility state.
(markdown-ts-toggle-hide-markup): Interactive command to toggle
delimiter visibility.
(markdown-ts-setup): Initialize delimiter hiding according to
'markdown-ts-hide-markup' and register managed properties.
(markdown-ts--treesit-settings): Use
'markdown-ts--fontify-delimiter' for delimiter nodes.
(require 'outline): Ensure outline faces are available so
headings are fontified correctly on first load.
* lisp/textmodes/page-ext.el (pages-directory-revert-function): New
function.
(pages-directory-list-all-headers-p, pages-directory-count-lines-p)
(pages-directory-regexp): New variables to store the page directory
style. (Bug#80319)
It is both simpler to code and marginally more general (allows
spaces in arguments).
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode-yamllint-options): Use
a list.
(yaml-ts-mode-flymake): Adjust accordingly.
* etc/NEWS: Announce the change.
* src/dispextern.h (struct glyph_row): Add
'extra_line_spacing_above' member.
(struct it): Add 'extra_line_spacing_above' member.
* src/frame.h (struct frame): Add 'extra_line_spacing_above'
member. Update comment for 'extra_line_spacing.'
* src/buffer.c (syms_of_buffer): Update the docstring of
'line-spacing' to describe the cons cell usage.
* src/buffer.h (struct buffer): Update comment for
'extra_line_spacing'.
* src/frame.c (gui_set_line_spacing): Handle cons cell value for
'line-spacing'. Calculate and set 'extra_line_spacing_above'
for both integer and float pairs.
* src/xdisp.c (init_iterator): Initialize 'extra_line_spacing_above'
from buffer or frame 'line-spacing', handling cons cells for both
integer and float values.
(gui_produce_glyphs): Use 'extra_line_spacing_above' to distribute
spacing between ascent and descent. Update 'max_extra_line_spacing'
calculation.
(resize_mini_window): Take line spacing into account when resizing the
mini window. Pass height of a single line to 'grow_mini_window' and
'shrink_mini_window'.
* src/window.c (grow_mini_window, shrink_mini_window): Add unit
argument which defines height of a single line.
* src/window.h (grow_mini_window, shrink_mini_window): Adjust function
prototypes accordingly with unit argument.
* lisp/subr.el (total-line-spacing): New function to calculate total
spacing from a number or cons cell.
(posn-col-row): Use total-line-spacing.
* lisp/simple.el (default-line-height): Use 'total-line-spacing'.
* lisp/textmodes/picture.el (picture-mouse-set-point): Use
'total-line-spacing'.
* lisp/window.el (window-default-line-height): Use
'total-line-spacing'.
(window--resize-mini-window): Take 'line-spacing' into account.
* test/lisp/subr-tests.el (total-line-spacing): New test.
* test/src/buffer-tests.el (test-line-spacing): New test.
* doc/emacs/display.texi (Display Custom): Document that
'line-spacing' can be a cons cell.
(Line Height): Document the new cons cell format for 'line-spacing'
to allow vertical centering.
Co-authored-by: Przemysław Alexander Kamiński <alexander@kaminski.se>
Co-authored-by: Daniel Mendler <mail@daniel-mendler.de>