aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2024-12-25 20:52:45 +0200
committerEli Zaretskii2024-12-25 20:52:45 +0200
commite96727f0ea0986bffe7ff235e5abc5354e63a64d (patch)
treef5169cef94b272dd43320b86a7de92ebf9978cd5
parentd70ef80868996b9119f032cd13911c600436e29f (diff)
downloademacs-e96727f0ea0986bffe7ff235e5abc5354e63a64d.tar.gz
emacs-e96727f0ea0986bffe7ff235e5abc5354e63a64d.zip
; 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.
-rw-r--r--etc/NEWS8
-rw-r--r--lisp/treesit.el15
2 files changed, 12 insertions, 11 deletions
diff --git a/etc/NEWS b/etc/NEWS
index ca107bb4938..8adead78a32 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -994,10 +994,10 @@ it uses `forward-sexp-default-function'.
994 994
995+++ 995+++
996*** New function 'treesit-language-display-name'. 996*** New function 'treesit-language-display-name'.
997New function that returns the display name given the language symbol. 997This new function returns the display name of a language given the
998For example, 'cpp' is translated to "C++". Also adds a new variable 998language symbol. For example, 'cpp' is translated to "C++". A new
999'treesit-language-display-name-alist' that the function uses to 999variable 'treesit-language-display-name-alist' holds the translations of
1000translate display names. 1000language symbols where that translation is not trivial.
1001 1001
1002+++ 1002+++
1003*** New command 'treesit-explore' 1003*** New command 'treesit-explore'
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 2616d16e800..eb3e26fff7e 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -851,17 +851,18 @@ omitted, default END to BEG."
851 ) 851 )
852 "An alist mapping language symbols to their display names. 852 "An alist mapping language symbols to their display names.
853 853
854Used by `treesit-language-display-name'. If there's no mapping in this 854Used by `treesit-language-display-name'. If there's no mapping for a
855alist, `treesit-language-display-name' converts the symbol to display 855lamguage in this alist, `treesit-language-display-name' converts the
856name by capitalizing the first letter. So languages like Java, 856symbol to the display name by capitalizing the first letter of the
857Javascript, Rust don't need an entry in this variable.") 857symbol's name. Thus, languages like Java, Javascript, Rust don't need
858an entry in this variable.")
858 859
859(defun treesit-language-display-name (language) 860(defun treesit-language-display-name (language)
860 "Returns the display name (a string) of LANGUAGE. 861 "Return the display name (a string) of LANGUAGE (a symbol).
861 862
862If LANGUAGE has an entry in `treesit-language-display-name-alist', use 863If LANGUAGE has an entry in `treesit-language-display-name-alist', use
863the display name in their. Otherwise, capitalize the first letter of 864the display name from there. Otherwise, capitalize the first letter of
864LANGUAGE and return the string." 865LANGUAGE's name and return the resulting string."
865 (or (alist-get language treesit-language-display-name-alist) 866 (or (alist-get language treesit-language-display-name-alist)
866 (capitalize (symbol-name language)))) 867 (capitalize (symbol-name language))))
867 868