; Fix documentation of recent additions to treesit.el

* lisp/treesit.el (treesit-language-display-name-alist)
(treesit-language-display-name): Doc fixes.

* etc/NEWS: Fix wording of entry announcing the above.
This commit is contained in:
Eli Zaretskii 2024-12-25 20:52:45 +02:00
parent d70ef80868
commit e96727f0ea
2 changed files with 12 additions and 11 deletions

View file

@ -994,10 +994,10 @@ it uses `forward-sexp-default-function'.
+++
*** New function 'treesit-language-display-name'.
New function that returns the display name given the language symbol.
For example, 'cpp' is translated to "C++". Also adds a new variable
'treesit-language-display-name-alist' that the function uses to
translate display names.
This new function returns the display name of a language given the
language symbol. For example, 'cpp' is translated to "C++". A new
variable 'treesit-language-display-name-alist' holds the translations of
language symbols where that translation is not trivial.
+++
*** New command 'treesit-explore'

View file

@ -851,17 +851,18 @@ omitted, default END to BEG."
)
"An alist mapping language symbols to their display names.
Used by `treesit-language-display-name'. If there's no mapping in this
alist, `treesit-language-display-name' converts the symbol to display
name by capitalizing the first letter. So languages like Java,
Javascript, Rust don't need an entry in this variable.")
Used by `treesit-language-display-name'. If there's no mapping for a
lamguage in this alist, `treesit-language-display-name' converts the
symbol to the display name by capitalizing the first letter of the
symbol's name. Thus, languages like Java, Javascript, Rust don't need
an entry in this variable.")
(defun treesit-language-display-name (language)
"Returns the display name (a string) of LANGUAGE.
"Return the display name (a string) of LANGUAGE (a symbol).
If LANGUAGE has an entry in `treesit-language-display-name-alist', use
the display name in their. Otherwise, capitalize the first letter of
LANGUAGE and return the string."
the display name from there. Otherwise, capitalize the first letter of
LANGUAGE's name and return the resulting string."
(or (alist-get language treesit-language-display-name-alist)
(capitalize (symbol-name language))))