From: Eli Zaretskii Date: Wed, 25 Dec 2024 18:52:45 +0000 (+0200) Subject: ; Fix documentation of recent additions to treesit.el X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=130c174d6562498b65bc8b0ef5ebc0bbadde7dc7;p=emacs.git ; 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. (cherry picked from commit e96727f0ea0986bffe7ff235e5abc5354e63a64d) --- diff --git a/etc/NEWS b/etc/NEWS index 4882689aba8..c3bbc825030 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -834,10 +834,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' diff --git a/lisp/treesit.el b/lisp/treesit.el index b18e8e281ce..d29b84be739 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -850,17 +850,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))))