mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2026-09-10 07:46:51 -04:00
Merge from origin/emacs-29
67bc96c9d9Remove treesit-defun-prefer-top-level and friends4f9bccef55Add yaml-ts-mode (Bug#60105)f9cb144d45Fix indentation in json-ts-mode (bug#60123)3d348c46e7; Handle nil ARG in treesit-beginning/end-of-defun1a66435ddaNew input method 'cyrillic-chuvash'b9227c502d; Improve wording of 'format' doc string
This commit is contained in:
commit
690724f0f1
|
|
@ -18,6 +18,7 @@ languages=(
|
|||
'toml'
|
||||
'tsx'
|
||||
'typescript'
|
||||
'yaml'
|
||||
)
|
||||
|
||||
for language in "${languages[@]}"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ case "${lang}" in
|
|||
sourcedir="tree-sitter-typescript/tsx/src"
|
||||
grammardir="tree-sitter-typescript/tsx"
|
||||
;;
|
||||
"yaml")
|
||||
org="ikatyang"
|
||||
;;
|
||||
esac
|
||||
|
||||
git clone "https://github.com/${org}/${repo}.git" \
|
||||
|
|
|
|||
10
etc/NEWS
10
etc/NEWS
|
|
@ -38,6 +38,11 @@ connection.
|
|||
|
||||
* Editing Changes in Emacs 30.1
|
||||
|
||||
---
|
||||
*** New input method 'cyrillic-chuvash'.
|
||||
This input method is based on the russian-computer, and is intended
|
||||
for the Chuvash language written in the Cyrillic script.
|
||||
|
||||
|
||||
* Changes in Specialized Modes and Packages in Emacs 30.1
|
||||
---
|
||||
|
|
@ -99,6 +104,11 @@ point is not in a comment or a string. It is by default bound to
|
|||
|
||||
* Incompatible Lisp Changes in Emacs 30.1
|
||||
|
||||
*** New major mode 'yaml-ts-mode'.
|
||||
A major mode based on the tree-sitter library for editing files
|
||||
written in YAML. It is auto-enabled for files with the ".yaml" or
|
||||
".yml" extensions.
|
||||
|
||||
|
||||
* Lisp Changes in Emacs 30.1
|
||||
|
||||
|
|
|
|||
|
|
@ -1712,6 +1712,138 @@ as follows.
|
|||
("/T" ?Ө)
|
||||
("/Y" ?Ү))
|
||||
|
||||
|
||||
;; Chuvash layout based on russian-computer.
|
||||
(quail-define-package
|
||||
"cyrillic-chuvash" "Chuvash" "CV" t
|
||||
"Input method for cyrillic Chuvash with a postfix modifier.
|
||||
|
||||
А* -> Ӑ
|
||||
а* -> ӑ
|
||||
Е* -> Ӗ
|
||||
Е* -> ӗ
|
||||
С* -> Ҫ
|
||||
с* -> ҫ
|
||||
У* -> Ӳ
|
||||
у* -> ӳ
|
||||
|
||||
Doubling the postfix separates the letter and postfix
|
||||
"
|
||||
nil t nil nil nil nil nil nil nil nil t)
|
||||
|
||||
(quail-define-rules
|
||||
("1" ?1)
|
||||
("2" ?2)
|
||||
("3" ?3)
|
||||
("4" ?4)
|
||||
("5" ?5)
|
||||
("6" ?6)
|
||||
("7" ?7)
|
||||
("8" ?8)
|
||||
("9" ?9)
|
||||
("0" ?0)
|
||||
("-" ?-)
|
||||
("=" ?=)
|
||||
("|" ?/)
|
||||
("`" ?ё)
|
||||
("q" ?й)
|
||||
("w" ?ц)
|
||||
("e" ?у)
|
||||
("r" ?к)
|
||||
("t" ?е)
|
||||
("y" ?н)
|
||||
("u" ?г)
|
||||
("i" ?ш)
|
||||
("o" ?щ)
|
||||
("p" ?з)
|
||||
("[" ?х)
|
||||
("]" ?ъ)
|
||||
("a" ?ф)
|
||||
("s" ?ы)
|
||||
("d" ?в)
|
||||
("f" ?а)
|
||||
("g" ?п)
|
||||
("h" ?р)
|
||||
("j" ?о)
|
||||
("k" ?л)
|
||||
("l" ?д)
|
||||
(";" ?ж)
|
||||
("'" ?э)
|
||||
("\\" ?\\)
|
||||
("z" ?я)
|
||||
("x" ?ч)
|
||||
("c" ?с)
|
||||
("v" ?м)
|
||||
("b" ?и)
|
||||
("n" ?т)
|
||||
("m" ?ь)
|
||||
("," ?б)
|
||||
("." ?ю)
|
||||
("/" ?.)
|
||||
("!" ?!)
|
||||
("@" ?\")
|
||||
("#" ?№)
|
||||
("$" ?\;)
|
||||
("%" ?%)
|
||||
("^" ?:)
|
||||
("&" ??)
|
||||
("*" ?*)
|
||||
("(" ?\()
|
||||
(")" ?\))
|
||||
("_" ?_)
|
||||
("+" ?+)
|
||||
("~" ?Ё)
|
||||
("Q" ?Й)
|
||||
("W" ?Ц)
|
||||
("E" ?У)
|
||||
("R" ?К)
|
||||
("T" ?Е)
|
||||
("Y" ?Н)
|
||||
("U" ?Г)
|
||||
("I" ?Ш)
|
||||
("O" ?Щ)
|
||||
("P" ?З)
|
||||
("{" ?Х)
|
||||
("}" ?Ъ)
|
||||
("A" ?Ф)
|
||||
("S" ?Ы)
|
||||
("D" ?В)
|
||||
("F" ?А)
|
||||
("G" ?П)
|
||||
("H" ?Р)
|
||||
("J" ?О)
|
||||
("K" ?Л)
|
||||
("L" ?Д)
|
||||
(":" ?Ж)
|
||||
("\"" ?Э)
|
||||
("|" ?|)
|
||||
("Z" ?Я)
|
||||
("X" ?Ч)
|
||||
("C" ?С)
|
||||
("V" ?М)
|
||||
("B" ?И)
|
||||
("N" ?Т)
|
||||
("M" ?Ь)
|
||||
("<" ?Б)
|
||||
(">" ?Ю)
|
||||
("?" ?,)
|
||||
("F*" ?Ӑ)
|
||||
("f*" ?ӑ)
|
||||
("T*" ?Ӗ)
|
||||
("t*" ?ӗ)
|
||||
("C*" ?Ҫ)
|
||||
("c*" ?ҫ)
|
||||
("E*" ?Ӳ)
|
||||
("e*" ?ӳ)
|
||||
("F**" ["А*"])
|
||||
("f**" ["а*"])
|
||||
("T**" ["Е*"])
|
||||
("t**" ["е*"])
|
||||
("C**" ["С*"])
|
||||
("c**" ["с*"])
|
||||
("E**" ["У*"])
|
||||
("e**" ["у*"]))
|
||||
|
||||
;; Local Variables:
|
||||
;; coding: utf-8
|
||||
;; End:
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ chosen (interactively or automatically)."
|
|||
((tex-mode context-mode texinfo-mode bibtex-mode)
|
||||
. ,(eglot-alternatives '("digestif" "texlab")))
|
||||
(erlang-mode . ("erlang_ls" "--transport" "stdio"))
|
||||
(yaml-mode . ("yaml-language-server" "--stdio"))
|
||||
((yaml-ts-mode yaml-mode) . ("yaml-language-server" "--stdio"))
|
||||
(nix-mode . ,(eglot-alternatives '("nil" "rnix-lsp")))
|
||||
(gdscript-mode . ("localhost" 6008))
|
||||
((fortran-mode f90-mode) . ("fortls"))
|
||||
|
|
|
|||
|
|
@ -70,7 +70,8 @@
|
|||
((node-is "}") parent-bol 0)
|
||||
((node-is ")") parent-bol 0)
|
||||
((node-is "]") parent-bol 0)
|
||||
((parent-is "object") parent-bol json-ts-mode-indent-offset))))
|
||||
((parent-is "object") parent-bol json-ts-mode-indent-offset)
|
||||
((parent-is "array") parent-bol json-ts-mode-indent-offset))))
|
||||
|
||||
(defvar json-ts-mode--font-lock-settings
|
||||
(treesit-font-lock-rules
|
||||
|
|
|
|||
151
lisp/textmodes/yaml-ts-mode.el
Normal file
151
lisp/textmodes/yaml-ts-mode.el
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
;;; yaml-ts-mode.el --- tree-sitter support for YAML -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
|
||||
;; Author : Randy Taylor <dev@rjt.dev>
|
||||
;; Maintainer : Randy Taylor <dev@rjt.dev>
|
||||
;; Created : December 2022
|
||||
;; Keywords : yaml languages tree-sitter
|
||||
|
||||
;; This file is part of GNU Emacs.
|
||||
|
||||
;; GNU Emacs is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
;; the Free Software Foundation, either version 3 of the License, or
|
||||
;; (at your option) any later version.
|
||||
|
||||
;; GNU Emacs is distributed in the hope that it will be useful,
|
||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'treesit)
|
||||
|
||||
(declare-function treesit-parser-create "treesit.c")
|
||||
|
||||
(defvar yaml-ts-mode--syntax-table
|
||||
(let ((table (make-syntax-table)))
|
||||
(modify-syntax-entry ?# "<" table)
|
||||
(modify-syntax-entry ?\n ">" table)
|
||||
(modify-syntax-entry ?& "." table)
|
||||
(modify-syntax-entry ?* "." table)
|
||||
(modify-syntax-entry ?\( "." table)
|
||||
(modify-syntax-entry ?\) "." table)
|
||||
(modify-syntax-entry ?\' "\"" table)
|
||||
table)
|
||||
"Syntax table for `yaml-ts-mode'.")
|
||||
|
||||
(defvar yaml-ts-mode--font-lock-settings
|
||||
(treesit-font-lock-rules
|
||||
:language 'yaml
|
||||
:feature 'bracket
|
||||
'((["[" "]" "{" "}"]) @font-lock-bracket-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'comment
|
||||
'((comment) @font-lock-comment-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'constant
|
||||
'([(boolean_scalar)
|
||||
(null_scalar)
|
||||
(reserved_directive)
|
||||
(tag_directive)
|
||||
(yaml_directive)] @font-lock-constant-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'delimiter
|
||||
'((["," ":" "-" ">" "?" "|"]) @font-lock-delimiter-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'misc-punctuation
|
||||
'((["---" "..." "&" "*"]) @font-lock-misc-punctuation-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'number
|
||||
'([(float_scalar) (integer_scalar)] @font-lock-number-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'type
|
||||
'([(alias_name) (anchor_name) (tag)] @font-lock-type-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'string
|
||||
:override t
|
||||
'([(block_scalar)
|
||||
(double_quote_scalar)
|
||||
(single_quote_scalar)
|
||||
(string_scalar)] @font-lock-string-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'escape-sequence
|
||||
:override t
|
||||
'((escape_sequence) @font-lock-escape-face)
|
||||
|
||||
:language 'yaml
|
||||
:feature 'property
|
||||
:override t
|
||||
'((block_mapping_pair
|
||||
key: (flow_node (plain_scalar (string_scalar) @font-lock-property-face)))
|
||||
(block_mapping_pair
|
||||
key: (flow_node
|
||||
[(double_quote_scalar) (single_quote_scalar)] @font-lock-property-face))
|
||||
(flow_mapping
|
||||
(_ key: (flow_node (plain_scalar (string_scalar) @font-lock-property-face))))
|
||||
(flow_mapping
|
||||
(_ key:
|
||||
(flow_node
|
||||
[(double_quote_scalar) (single_quote_scalar)] @font-lock-property-face)))
|
||||
(flow_sequence
|
||||
(_ key: (flow_node (plain_scalar (string_scalar) @font-lock-property-face))))
|
||||
(flow_sequence
|
||||
(_ key:
|
||||
(flow_node
|
||||
[(double_quote_scalar) (single_quote_scalar)] @font-lock-property-face))))
|
||||
|
||||
:language 'yaml
|
||||
:feature 'error
|
||||
:override t
|
||||
'((ERROR) @font-lock-warning-face))
|
||||
"Tree-sitter font-lock settings for `yaml-ts-mode'.")
|
||||
|
||||
;;;###autoload
|
||||
(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-ts-mode))
|
||||
|
||||
;;;###autoload
|
||||
(define-derived-mode yaml-ts-mode text-mode "YAML"
|
||||
"Major mode for editing YAML, powered by tree-sitter."
|
||||
:group 'yaml
|
||||
:syntax-table yaml-ts-mode--syntax-table
|
||||
|
||||
(when (treesit-ready-p 'yaml)
|
||||
(treesit-parser-create 'yaml)
|
||||
|
||||
;; Comments.
|
||||
(setq-local comment-start "# ")
|
||||
(setq-local comment-end "")
|
||||
|
||||
;; Indentation.
|
||||
(setq-local indent-tabs-mode nil)
|
||||
|
||||
;; Font-lock.
|
||||
(setq-local treesit-font-lock-settings yaml-ts-mode--font-lock-settings)
|
||||
(setq-local treesit-font-lock-feature-list
|
||||
'((comment)
|
||||
(string type)
|
||||
(constant escape-sequence number property)
|
||||
(bracket delimiter error misc-punctuation)))
|
||||
|
||||
(treesit-major-mode-setup)))
|
||||
|
||||
(provide 'yaml-ts-mode)
|
||||
|
||||
;;; yaml-ts-mode.el ends here
|
||||
|
|
@ -1591,38 +1591,6 @@ newline after a defun, or the beginning of a defun.
|
|||
|
||||
If the value is nil, no skipping is performed.")
|
||||
|
||||
(defvar-local treesit-defun-prefer-top-level nil
|
||||
"When non-nil, Emacs prefers top-level defun.
|
||||
|
||||
In some languages, a defun could be nested in another one.
|
||||
Normally Emacs stops at the first defun it encounters. If this
|
||||
variable's value is t, Emacs tries to find the top-level defun,
|
||||
and ignores nested ones.
|
||||
|
||||
This variable can also be a list of cons cells of the
|
||||
form (FROM . TO), where FROM and TO are tree-sitter node type
|
||||
regexps. When Emacs finds a defun node whose type matches any of
|
||||
the FROM regexps in the list, it then tries to find a
|
||||
higher-level node matching the corresponding TO regexp.")
|
||||
|
||||
(defun treesit--defun-maybe-top-level (node)
|
||||
"Maybe return the top-level equivalent of NODE.
|
||||
For the detailed semantic see `treesit-defun-prefer-top-level'."
|
||||
(pcase treesit-defun-prefer-top-level
|
||||
('nil node)
|
||||
('t (or (treesit-node-top-level
|
||||
node treesit-defun-type-regexp)
|
||||
node))
|
||||
((pred consp)
|
||||
(cl-loop
|
||||
for con in treesit-defun-prefer-top-level
|
||||
for from = (car con)
|
||||
for to = (cdr con)
|
||||
if (string-match-p from (treesit-node-type node))
|
||||
return (or (treesit-node-top-level node to)
|
||||
node)
|
||||
finally return node))))
|
||||
|
||||
(defun treesit-beginning-of-defun (&optional arg)
|
||||
"Move backward to the beginning of a defun.
|
||||
|
||||
|
|
@ -1635,7 +1603,8 @@ This is a tree-sitter equivalent of `beginning-of-defun'.
|
|||
Behavior of this function depends on `treesit-defun-type-regexp'
|
||||
and `treesit-defun-skipper'."
|
||||
(interactive "^p")
|
||||
(when-let ((dest (treesit--navigate-defun (point) (- arg) 'beg)))
|
||||
(when-let* ((arg (or arg 1))
|
||||
(dest (treesit--navigate-defun (point) (- arg) 'beg)))
|
||||
(goto-char dest)
|
||||
(when treesit-defun-skipper
|
||||
(funcall treesit-defun-skipper))
|
||||
|
|
@ -1651,7 +1620,8 @@ This is a tree-sitter equivalent of `end-of-defun'. Behavior of
|
|||
this function depends on `treesit-defun-type-regexp' and
|
||||
`treesit-defun-skipper'."
|
||||
(interactive "^p\nd")
|
||||
(when-let ((dest (treesit--navigate-defun (point) arg 'end)))
|
||||
(when-let* ((arg (or arg 1))
|
||||
(dest (treesit--navigate-defun (point) arg 'end)))
|
||||
(goto-char dest)
|
||||
(when treesit-defun-skipper
|
||||
(funcall treesit-defun-skipper))))
|
||||
|
|
|
|||
|
|
@ -3279,18 +3279,18 @@ The other arguments are substituted into it to make the result, a string.
|
|||
The format control string may contain %-sequences meaning to substitute
|
||||
the next available argument, or the argument explicitly specified:
|
||||
|
||||
%s means print a string argument. Actually, prints any object, with `princ'.
|
||||
%d means print as signed number in decimal.
|
||||
%o means print a number in octal.
|
||||
%x means print a number in hex.
|
||||
%s means produce a string argument. Actually, produces any object with `princ'.
|
||||
%d means produce as signed number in decimal.
|
||||
%o means produce a number in octal.
|
||||
%x means produce a number in hex.
|
||||
%X is like %x, but uses upper case.
|
||||
%e means print a number in exponential notation.
|
||||
%f means print a number in decimal-point notation.
|
||||
%g means print a number in exponential notation if the exponent would be
|
||||
%e means produce a number in exponential notation.
|
||||
%f means produce a number in decimal-point notation.
|
||||
%g means produce a number in exponential notation if the exponent would be
|
||||
less than -4 or greater than or equal to the precision (default: 6);
|
||||
otherwise it prints in decimal-point notation.
|
||||
%c means print a number as a single character.
|
||||
%S means print any object as an s-expression (using `prin1').
|
||||
otherwise it produces in decimal-point notation.
|
||||
%c means produce a number as a single character.
|
||||
%S means produce any object as an s-expression (using `prin1').
|
||||
|
||||
The argument used for %d, %o, %x, %e, %f, %g or %c must be a number.
|
||||
%o, %x, and %X treat arguments as unsigned if `binary-as-unsigned' is t
|
||||
|
|
@ -3325,7 +3325,7 @@ included even if the precision is zero, and also forces trailing
|
|||
zeros after the decimal point to be left in place.
|
||||
|
||||
The width specifier supplies a lower limit for the length of the
|
||||
printed representation. The padding, if any, normally goes on the
|
||||
produced representation. The padding, if any, normally goes on the
|
||||
left, but it goes on the right if the - flag is present. The padding
|
||||
character is normally a space, but it is 0 if the 0 flag is present.
|
||||
The 0 flag is ignored if the - flag is present, or the format sequence
|
||||
|
|
@ -3334,7 +3334,7 @@ is something other than %d, %o, %x, %e, %f, and %g.
|
|||
For %e and %f sequences, the number after the "." in the precision
|
||||
specifier says how many decimal places to show; if zero, the decimal
|
||||
point itself is omitted. For %g, the precision specifies how many
|
||||
significant digits to print; zero or omitted are treated as 1.
|
||||
significant digits to produce; zero or omitted are treated as 1.
|
||||
For %s and %S, the precision specifier truncates the string to the
|
||||
given width.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue