commit 24488bc4b275109d7132689a0714cfb11d05e512 (HEAD, refs/remotes/origin/master) Author: Eli Zaretskii Date: Sat Dec 31 09:24:32 2022 +0200 Fix the build broken by latest GnuTLS-related changes * src/gnutls.c (key_file2_aux): Don't use GNUTLS_PKCS_PBES2_* constants that are defined only in latest versions of GnuTLS. (Bug#50507) (Fgnutls_boot): Mention in the doc string that some flags of 'gnutls_certificate_set_x509_key_file2' are only supported since GnuTLS 3.6.3. diff --git a/src/gnutls.c b/src/gnutls.c index ab50128b81c..e58322934de 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -1822,18 +1822,30 @@ key_file2_aux (Lisp_Object flags) rv |= GNUTLS_PKCS_NULL_PASSWORD; else if (EQ (flag, Qgnutls_pkcs_pbes2_des)) rv |= GNUTLS_PKCS_PBES2_DES; +#ifdef GNUTLS_PKCS_PBES1_DES_MD5 else if (EQ (flag, Qgnutls_pkcs_pbes1_des_md5)) rv |= GNUTLS_PKCS_PBES1_DES_MD5; +#endif +#ifdef GNUTLS_PKCS_PBES2_GOST_TC26Z else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_tc26z)) rv |= GNUTLS_PKCS_PBES2_GOST_TC26Z; +#endif +#ifdef GNUTLS_PKCS_PBES2_GOST_CPA else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpa)) rv |= GNUTLS_PKCS_PBES2_GOST_CPA; +#endif +#ifdef GNUTLS_PKCS_PBES2_GOST_CPB else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpb)) rv |= GNUTLS_PKCS_PBES2_GOST_CPB; +#endif +#ifdef GNUTLS_PKCS_PBES2_GOST_CPC else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpc)) rv |= GNUTLS_PKCS_PBES2_GOST_CPC; +#endif +#ifdef GNUTLS_PKCS_PBES2_GOST_CPD else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpd)) rv |= GNUTLS_PKCS_PBES2_GOST_CPD; +#endif } return rv; } @@ -1893,6 +1905,7 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, GNUTLS_PKCS_PBES2_GOST_CPA, GNUTLS_PKCS_PBES2_GOST_CPB, GNUTLS_PKCS_PBES2_GOST_CPC, GNUTLS_PKCS_PBES2_GOST_CPD. If not specified, or if nil, the bitflag with value 0 is used. +Note that some of these are only supported since GnuTLS 3.6.3. The debug level will be set for this process AND globally for GnuTLS. So if you set it higher or lower at any point, it affects global commit 2ec4e187c9c4592f9fbd86b67854110252b80140 Merge: 57e363a4514 ab1f245f1a1 Author: Stefan Kangas Date: Sat Dec 31 06:30:21 2022 +0100 Merge from origin/emacs-29 ab1f245f1a1 Show tree-sitter query source when signaling query error 0b58ea0e602 ; * lisp/treesit.el (treesit--install-language-grammar-1)... 724da28763c Add version tags and mention the new options in NEWS 8675f4136c7 Add new options for Ruby code indentation 4922de626f0 ; Fix doc strings of 'treesit-install-language-grammar' 69b2aaaaded ; Fix recently modified docs of 'set-face-attribute' (bug... 0248fc9e1ac Add treesit-install-language-grammar 0237c5927e9 Add treesit-language-abi-version 312f82d36f0 Change "language definition" to "language grammar" in man... fba35657da5 ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragrap... dec1b37a32b ; * doc/lispref/parsing.texi (Accessing Node Information)... 39265abf0cc * test/lisp/net/tramp-tests.el (tramp-test32-shell-comman... ebf65c7e7e3 * lisp/eshell/em-tramp.el (tramp): Require also at runtim... # Conflicts: # etc/NEWS commit 57e363a4514bddc443414aec1528fd9501d85034 Author: Po Lu Date: Sat Dec 31 09:10:36 2022 +0800 ; * src/gnutls.c (Fgnutls_boot): Fix typo. diff --git a/src/gnutls.c b/src/gnutls.c index eb231810fae..ab50128b81c 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -1941,7 +1941,7 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, Lisp_Object prime_bits; #ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 unsigned int aux_key_file; -#endiif +#endif struct Lisp_Process *p = XPROCESS (proc); CHECK_PROCESS (proc); commit e645bcc26d468ab6b8e16b6160c203c5db70ec6b Author: Po Lu Date: Sat Dec 31 09:10:23 2022 +0800 Fix last change in gnutls.c * src/gnutls.c (Fgnutls_boot): Pacify --enable-check-lisp-object-type and Haiku GCC warning involving `key_file2_aux'. diff --git a/src/gnutls.c b/src/gnutls.c index 571f141b2ac..eb231810fae 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -1792,9 +1792,8 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist) The key :flags receives a list of symbols, each of which corresponds to a GnuTLS C flag, the ORed result is to be passed to - the function gnutls_certificate_set_x509_key_file2() as its last - argument. -*/ + the function `gnutls_certificate_set_x509_key_file2' as its last + argument. */ static unsigned int key_file2_aux (Lisp_Object flags) { @@ -1940,6 +1939,9 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, Lisp_Object loglevel; Lisp_Object hostname; Lisp_Object prime_bits; +#ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 + unsigned int aux_key_file; +#endiif struct Lisp_Process *p = XPROCESS (proc); CHECK_PROCESS (proc); @@ -2134,10 +2136,17 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, certfile = ansi_encode_filename (certfile); # endif # ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 - if (plist_member (proplist, QCpass)) - ret = gnutls_certificate_set_x509_key_file2 - (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format, - c_pass, key_file2_aux (flags)); + if (!NILP (plist_member (proplist, QCpass))) + { + aux_key_file = key_file2_aux (flags); + ret + = gnutls_certificate_set_x509_key_file2 (x509_cred, + SSDATA (certfile), + SSDATA (keyfile), + file_format, + c_pass, + aux_key_file); + } else # endif ret = gnutls_certificate_set_x509_key_file commit ab1f245f1a1b36bae9a3051b6cb93ecd5b78dd7a (refs/remotes/origin/emacs-29) Author: Yuan Fu Date: Fri Dec 30 16:57:45 2022 -0800 Show tree-sitter query source when signaling query error * src/treesit.c (treesit_compose_query_signal_data): Add QUERY_SOURCE parameter. (treesit_ensure_query_compiled) (Ftreesit_query_capture): Add query source. diff --git a/src/treesit.c b/src/treesit.c index a9bfcb3d9e9..974d2fc4517 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -1194,10 +1194,12 @@ treesit_query_error_to_string (TSQueryError error) static Lisp_Object treesit_compose_query_signal_data (uint32_t error_offset, - TSQueryError error_type) + TSQueryError error_type, + Lisp_Object query_source) { - return list3 (build_string (treesit_query_error_to_string (error_type)), + return list4 (build_string (treesit_query_error_to_string (error_type)), make_fixnum (error_offset + 1), + query_source, build_pure_c_string ("Debug the query with `treesit-query-validate'")); } @@ -1239,7 +1241,8 @@ treesit_ensure_query_compiled (Lisp_Object query, Lisp_Object *signal_symbol, { *signal_symbol = Qtreesit_query_error; *signal_data = treesit_compose_query_signal_data (error_offset, - error_type); + error_type, + source); } XTS_COMPILED_QUERY (query)->query = treesit_query; return treesit_query; @@ -2627,7 +2630,7 @@ DEFUN ("treesit-query-capture", if (treesit_query == NULL) xsignal (Qtreesit_query_error, treesit_compose_query_signal_data (error_offset, - error_type)); + error_type, query)); cursor = ts_query_cursor_new (); needs_to_free_query_and_cursor = true; } commit 0b58ea0e6025fa815f8afb217f4605a680e4015c Author: Yuan Fu Date: Fri Dec 30 16:23:39 2022 -0800 ; * lisp/treesit.el (treesit--install-language-grammar-1): Minor fix. diff --git a/lisp/treesit.el b/lisp/treesit.el index d12c19dde85..56f9b681e80 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -36,6 +36,7 @@ (eval-when-compile (require 'subr-x)) ; For `string-join'. (require 'cl-seq) (require 'font-lock) +(require 'seq) ;;; Function declarations @@ -2684,27 +2685,30 @@ treesit--install-language-grammar-1 (out-dir lang url &optional source-dir grammar-dir cc c++) "Install and compile a tree-sitter language grammar library. -OUT-DIR is the directory to put the compiled library file, it -defaults to ~/.emacs.d/tree-sitter. +OUT-DIR is the directory to put the compiled library file. If it +is nil, the \"tree-sitter\" directory under user's Emacs +configuration directory is used (and automatically created if not +exist). For LANG, URL, SOURCE-DIR, GRAMMAR-DIR, CC, C++, see `treesit-language-source-alist'. If anything goes wrong, this function signals an error." (let* ((lang (symbol-name lang)) - (default-directory "/tmp") - (workdir (expand-file-name "treesit-workdir-00893133134")) + (default-directory (make-temp-file "treesit-workdir" t)) + (workdir (expand-file-name "repo")) (source-dir (expand-file-name (or source-dir "src") workdir)) (grammar-dir (expand-file-name (or grammar-dir "") workdir)) - (cc (or cc "cc")) - (c++ (or c++ "c++")) - (soext (pcase system-type - ('darwin "dylib") - ((or 'ms-dos 'cywin 'windows-nt) "dll") - (_ "so"))) + (cc (or cc (seq-find #'executable-find '("cc" "gcc" "c99")) + ;; If no C compiler found, just use cc and let + ;; `call-process' signal the error. + "cc")) + (c++ (or c++ (seq-find #'executable-find '("c++" "g++")) + "c++")) + (soext (or (car dynamic-library-suffixes) + (signal 'treesit-error '("Emacs cannot figure out the file extension for dynamic libraries for this system, because `dynamic-library-suffixes' is nil")))) (out-dir (or (and out-dir (expand-file-name out-dir)) - (expand-file-name - "tree-sitter" user-emacs-directory))) - (lib-name (format "libtree-sitter-%s.%s" lang soext))) + (locate-user-emacs-file "tree-sitter"))) + (lib-name (concat "libtree-sitter-" lang soext))) (unwind-protect (with-temp-buffer (message "Cloning repository") @@ -2713,8 +2717,9 @@ treesit--install-language-grammar-1 "git" nil t nil "clone" url "--depth" "1" "--quiet" workdir) ;; cp "${grammardir}"/grammar.js "${sourcedir}" - (copy-file (concat grammar-dir "/grammar.js") - (concat source-dir "/grammar.js")) + (copy-file (expand-file-name "grammar.js" grammar-dir) + (expand-file-name "grammar.js" source-dir) + t t) ;; cd "${sourcedir}" (setq default-directory source-dir) (message "Compiling library") @@ -2739,7 +2744,7 @@ treesit--install-language-grammar-1 (rx bos (+ anychar) ".o" eos)) "-o" ,lib-name)) ;; Copy out. - (copy-file lib-name (concat out-dir "/") t) + (copy-file lib-name (file-name-as-directory out-dir) t t) (message "Library installed to %s/%s" out-dir lib-name)) (when (file-exists-p workdir) (delete-directory workdir t))))) commit 724da28763c25f5dcd210b70e71f98bf5cbf5023 Author: Dmitry Gutov Date: Sat Dec 31 00:12:51 2022 +0200 Add version tags and mention the new options in NEWS * etc/NEWS: Mention the new options (bug#60186). * lisp/progmodes/ruby-mode.el (ruby-block-indent) (ruby-after-operator-indent, ruby-method-call-indent) (ruby-parenless-call-arguments-indent): Add version tags. diff --git a/etc/NEWS b/etc/NEWS index d2e11e5adf4..38b7865626d 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2832,7 +2832,11 @@ project-dedicated or global) is specified by the new *** Support for endless methods. --- -*** New user option 'ruby-method-params-indent'. +*** New user options that determine indentation logic. +'ruby-method-params-indent', 'ruby-block-indent', +'ruby-after-operator-indent', 'ruby-method-call-indent', +'ruby-parenless-call-arguments-indent'. See the docstrings for +explanations and examples. ** Eshell diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index 021dda1a3e1..3a86093941b 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -306,7 +306,8 @@ ruby-block-indent Only has effect when `ruby-use-smie' is t." :type 'boolean - :safe 'booleanp) + :safe 'booleanp + :version "29.1") (defcustom ruby-after-operator-indent t "Non-nil to use structural indentation after binary operators. @@ -326,7 +327,8 @@ ruby-after-operator-indent Only has effect when `ruby-use-smie' is t." :type 'boolean - :safe 'booleanp) + :safe 'booleanp + :version "29.1") (defcustom ruby-method-call-indent t "Non-nil to use the structural indentation algorithm. @@ -348,7 +350,8 @@ ruby-method-call-indent Only has effect when `ruby-use-smie' is t." :type 'boolean - :safe 'booleanp) + :safe 'booleanp + :version "29.1") (defcustom ruby-parenless-call-arguments-indent t "Non-nil to align arguments in a parenless call vertically. @@ -369,7 +372,8 @@ ruby-parenless-call-arguments-indent Only has effect when `ruby-use-smie' is t." :type 'boolean - :safe 'booleanp) + :safe 'booleanp + :version "29.1") (defcustom ruby-deep-arglist t "Deep indent lists in parenthesis when non-nil. commit 8675f4136c7da7356e5578cf1eabda2f37a597e5 Author: Dmitry Gutov Date: Fri Dec 30 23:58:26 2022 +0200 Add new options for Ruby code indentation * lisp/progmodes/ruby-mode.el (ruby-block-indent) (ruby-after-operator-indent, ruby-method-call-indent) (ruby-parenless-call-arguments-indent): New options (bug#60186). (ruby-smie-grammar): Specify associativity for "?". (ruby-smie--indent-to-stmt): Add optional argument. * test/lisp/progmodes/ruby-mode-resources/ruby.rb: New cases. * test/lisp/progmodes/ruby-mode-resources/ruby-method-call-indent.rb: * test/lisp/progmodes/ruby-mode-resources/ruby-block-indent.rb: * test/lisp/progmodes/ruby-mode-resources/ruby-after-operator-indent.rb: * test/lisp/progmodes/ruby-mode-resources/ ruby-parenless-call-arguments-indent.rb: New files. * test/lisp/progmodes/ruby-mode-tests.el: Add indentation tests for new files. diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el index a4aa61905e4..021dda1a3e1 100644 --- a/lisp/progmodes/ruby-mode.el +++ b/lisp/progmodes/ruby-mode.el @@ -285,6 +285,92 @@ ruby-method-params-indent :safe (lambda (val) (or (memq val '(t nil)) (numberp val))) :version "29.1") +(defcustom ruby-block-indent t + "Non-nil to align the body of a block to the statement's start. + +The body and the closer will be aligned to the column where the +statement containing the block starts. Example: + + foo.bar + .each do + baz + end + +If nil, it will be aligned instead to the beginning of the line +containing the block's opener: + + foo.bar + .each do + baz + end + +Only has effect when `ruby-use-smie' is t." + :type 'boolean + :safe 'booleanp) + +(defcustom ruby-after-operator-indent t + "Non-nil to use structural indentation after binary operators. + +The code will be aligned to the implicit parent expression, +according to the operator precedence: + + qux = 4 + 5 * + 6 + + 7 + +Set it to nil to align to the beginning of the statement: + + qux = 4 + 5 * + 6 + + 7 + +Only has effect when `ruby-use-smie' is t." + :type 'boolean + :safe 'booleanp) + +(defcustom ruby-method-call-indent t + "Non-nil to use the structural indentation algorithm. + +The method call will be aligned to the implicit parent +expression, according to the operator precedence: + + foo = subject + .update( + 1 + ) + +Set it to nil to align to the beginning of the statement: + + foo = subject + .update( + 1 + ) + +Only has effect when `ruby-use-smie' is t." + :type 'boolean + :safe 'booleanp) + +(defcustom ruby-parenless-call-arguments-indent t + "Non-nil to align arguments in a parenless call vertically. + +Example: + + qux :+, + bar, + :[]=, + bar + +Set it to nil to align to the beginning of the statement: + + qux :+, + bar, + :[]=, + bar + +Only has effect when `ruby-use-smie' is t." + :type 'boolean + :safe 'booleanp) + (defcustom ruby-deep-arglist t "Deep indent lists in parenthesis when non-nil. Also ignores spaces after parenthesis when `space'. @@ -416,6 +502,7 @@ ruby-smie-grammar '((right "=") (right "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "<<=" ">>=" "&&=" "||=") + (right "?") (nonassoc ".." "...") (left "&&" "||") (nonassoc "<=>") @@ -608,10 +695,10 @@ ruby-smie--backward-token "def=") (t tok))))))) -(defun ruby-smie--indent-to-stmt () +(defun ruby-smie--indent-to-stmt (&optional offset) (save-excursion (smie-backward-sexp ";") - (cons 'column (smie-indent-virtual)))) + (cons 'column (+ (smie-indent-virtual) (or offset 0))))) (defun ruby-smie--indent-to-stmt-p (keyword) (or (eq t ruby-align-to-stmt-keywords) @@ -642,7 +729,9 @@ ruby-smie-rules (forward-comment -1) (not (eq (preceding-char) ?:)))) ;; Curly block opener. - (ruby-smie--indent-to-stmt)) + (if ruby-block-indent + (ruby-smie--indent-to-stmt) + (cons 'column (current-indentation)))) ((smie-rule-hanging-p) ;; Treat purely syntactic block-constructs as being part of their parent, ;; when the opening token is hanging and the parent is not an @@ -677,13 +766,20 @@ ruby-smie-rules (unless (or (eolp) (forward-comment 1)) (cons 'column (current-column))))) ('(:before . " @ ") - (if (or (eq ruby-method-params-indent t) - (not (smie-rule-parent-p "def" "def="))) - (save-excursion - (skip-chars-forward " \t") - (cons 'column (current-column))) - (smie-rule-parent (or ruby-method-params-indent 0)))) - ('(:before . "do") (ruby-smie--indent-to-stmt)) + (cond + ((and (not ruby-parenless-call-arguments-indent) + (not (smie-rule-parent-p "def" "def="))) + (ruby-smie--indent-to-stmt ruby-indent-level)) + ((or (eq ruby-method-params-indent t) + (not (smie-rule-parent-p "def" "def="))) + (save-excursion + (skip-chars-forward " \t") + (cons 'column (current-column)))) + (t (smie-rule-parent (or ruby-method-params-indent 0))))) + ('(:before . "do") + (if ruby-block-indent + (ruby-smie--indent-to-stmt) + (cons 'column (current-indentation)))) ('(:before . ".") (if (smie-rule-sibling-p) (when ruby-align-chained-calls @@ -696,8 +792,10 @@ ruby-smie-rules (not (smie-rule-bolp))))) (cons 'column (current-column))) (smie-backward-sexp ".") - (cons 'column (+ (current-column) - ruby-indent-level)))) + (if ruby-method-call-indent + (cons 'column (+ (current-column) + ruby-indent-level)) + (ruby-smie--indent-to-stmt ruby-indent-level)))) (`(:before . ,(or "else" "then" "elsif" "rescue" "ensure")) (smie-rule-parent)) (`(:before . ,(or "when" "in")) @@ -708,16 +806,22 @@ ruby-smie-rules "<=>" ">" "<" ">=" "<=" "==" "===" "!=" "<<" ">>" "+=" "-=" "*=" "/=" "%=" "**=" "&=" "|=" "^=" "|" "<<=" ">>=" "&&=" "||=" "and" "or")) - (and (smie-rule-parent-p ";" nil) - (smie-indent--hanging-p) - ruby-indent-level)) + (cond + ((not ruby-after-operator-indent) + (ruby-smie--indent-to-stmt ruby-indent-level)) + ((and (smie-rule-parent-p ";" nil) + (smie-indent--hanging-p)) + ruby-indent-level))) (`(:before . "=") (save-excursion (and (smie-rule-parent-p " @ ") (goto-char (nth 1 (smie-indent--parent))) (smie-rule-prev-p "def=") (cons 'column (+ (current-column) ruby-indent-level -3))))) - (`(:after . ,(or "?" ":")) ruby-indent-level) + (`(:after . ,(or "?" ":")) + (if ruby-after-operator-indent + ruby-indent-level + (ruby-smie--indent-to-stmt ruby-indent-level))) (`(:before . ,(guard (memq (intern-soft token) ruby-alignable-keywords))) (when (not (ruby--at-indentation-p)) (if (ruby-smie--indent-to-stmt-p token) @@ -725,7 +829,10 @@ ruby-smie-rules (cons 'column (current-column))))) ('(:before . "iuwu-mod") (smie-rule-parent ruby-indent-level)) - )) + (`(:before . ",") + (and (not ruby-parenless-call-arguments-indent) + (smie-rule-parent-p " @ ") + (ruby-smie--indent-to-stmt ruby-indent-level))))) (defun ruby--at-indentation-p (&optional point) (save-excursion diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-after-operator-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-after-operator-indent.rb new file mode 100644 index 00000000000..25cd8736f97 --- /dev/null +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-after-operator-indent.rb @@ -0,0 +1,29 @@ +4 + + 5 + + 6 + + 7 + +qux = 4 + 5 * + 6 + + 7 + +foo = obj.bar { |m| tee(m) } + + obj.qux { |m| hum(m) } + +foo. + bar + .baz + +qux = foo.fee ? + bar : + tee + +# Endless methods. +class Bar + def foo(abc) = bar + + baz +end + +# Local Variables: +# ruby-after-operator-indent: nil +# End: diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-block-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-block-indent.rb new file mode 100644 index 00000000000..32882814b7e --- /dev/null +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-block-indent.rb @@ -0,0 +1,33 @@ +foo + .asdasd + .proc do |**args| + p(**args) + end + +foo + .asdasd + .proc { |**args| + p(**args) + } + +bar.foo do + bar +end + +bar.foo(tee) do + bar +end + +bar.foo(tee) { + bar +} + +x.foo do + foo +end.bar do + bar +end + +# Local Variables: +# ruby-block-indent: nil +# End: diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-method-call-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-method-call-indent.rb new file mode 100644 index 00000000000..1a8285ee919 --- /dev/null +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-method-call-indent.rb @@ -0,0 +1,15 @@ +foo2 = + subject. + update( + 2 + ) + +foo3 = + subject + .update( + 2 + ) + +# Local Variables: +# ruby-method-call-indent: nil +# End: diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby-parenless-call-arguments-indent.rb b/test/lisp/progmodes/ruby-mode-resources/ruby-parenless-call-arguments-indent.rb new file mode 100644 index 00000000000..58e08810c4c --- /dev/null +++ b/test/lisp/progmodes/ruby-mode-resources/ruby-parenless-call-arguments-indent.rb @@ -0,0 +1,23 @@ +method arg1, + method2 arg2, + arg3, [ + arg4, + arg5 + ] + +zzz = method (a + b), + c, :d => :e, + f: g + +return render json: { + errors: { base: [message] }, + copying: copying + }, + status: 400 + +foo(a, + b) + +# Local Variables: +# ruby-parenless-call-arguments-indent: nil +# End: diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb index 6a69d9db78a..bfae948b259 100644 --- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb +++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb @@ -226,6 +226,7 @@ def begin foo. bar + .baz # https://github.com/rails/rails/blob/17f5d8e062909f1fcae25351834d8e89967b645e/activesupport/lib/active_support/time_with_zone.rb#L206 foo # comment intended to confuse the tokenizer @@ -380,6 +381,18 @@ def bar i + 1 end +m1 = foo + .asdasd + .proc do |**args| + p(**args) +end + +m2 = foo + .asdasd + .proc { |**args| + p(**args) +} + bar.foo do bar end @@ -398,6 +411,12 @@ def bar end end +x.foo do + foo +end.bar do + bar +end + foo | bar @@ -540,5 +559,9 @@ def baz.full_name = "#{bar} 3" end # Local Variables: +# ruby-after-operator-indent: t +# ruby-block-indent: t +# ruby-method-call-indent: t # ruby-method-params-indent: t +# ruby-parenless-call-arguments-indent: t # End: diff --git a/test/lisp/progmodes/ruby-mode-tests.el b/test/lisp/progmodes/ruby-mode-tests.el index 560f780285a..5c81cc31cc1 100644 --- a/test/lisp/progmodes/ruby-mode-tests.el +++ b/test/lisp/progmodes/ruby-mode-tests.el @@ -956,7 +956,11 @@ ruby-deftest-indent (kill-buffer buf))))) (ruby-deftest-indent "ruby.rb") +(ruby-deftest-indent "ruby-after-operator-indent.rb") +(ruby-deftest-indent "ruby-block-indent.rb") +(ruby-deftest-indent "ruby-method-call-indent.rb") (ruby-deftest-indent "ruby-method-params-indent.rb") +(ruby-deftest-indent "ruby-parenless-call-arguments-indent.rb") (ert-deftest ruby--test-chained-indentation () (with-temp-buffer commit 9d0f5909afc562dc2bdda04a95f64ee25a628185 Author: Mattias Engdegård Date: Fri Dec 30 13:48:47 2022 +0100 Correct suppression of suspicious eq type warning * lisp/emacs-lisp/byte-run.el (with-suppressed-warnings): * lisp/emacs-lisp/bytecomp.el (bytecomp--warn-dodgy-eq-arg): Suppress warning using (suspicious FUNCTION), where FUNCTION is not always `eq`. diff --git a/lisp/emacs-lisp/byte-run.el b/lisp/emacs-lisp/byte-run.el index d909395e973..697d1d3ee74 100644 --- a/lisp/emacs-lisp/byte-run.el +++ b/lisp/emacs-lisp/byte-run.el @@ -653,8 +653,7 @@ with-suppressed-warnings `suspicious' and `empty-body'. For the `mapcar' case, only the `mapcar' function can be used in -the symbol list. For `suspicious', only `set-buffer', `lsh' and `eq' -can be used." +the symbol list." ;; Note: during compilation, this definition is overridden by the one in ;; byte-compile-initial-macro-environment. (declare (debug (sexp body)) (indent 1)) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index a41e076f9b0..e314976fc1a 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -5526,7 +5526,7 @@ bytecomp--warn-dodgy-eq-arg (macroexp-warn-and-return (format "`%s' called with literal %s that may never match (%s)" (car form) type parenthesis) - form '(suspicious eq) t)) + form (list 'suspicious (car form)) t)) (defun bytecomp--check-eq-args (form &optional a b &rest _ignore) (let* ((number-ok (eq (car form) 'eql)) commit a77204c64659147794b1c9f4114091a257205a49 Author: Jim Porter Date: Fri Dec 30 10:40:08 2022 -0800 ; Fix Eshell tests on macOS * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/if-statement-pipe) (esh-cmd-test/if-else-statement-pipe): * test/lisp/eshell/esh-io-tests.el (esh-io-test/pipeline/subcommands): Allow trailing newlines in the output. diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index cc40dde3552..42d24967ff8 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -274,24 +274,26 @@ esh-cmd-test/if-else-statement-ext-cmd (ert-deftest esh-cmd-test/if-statement-pipe () "Test invocation of an if statement piped to another command." (skip-unless (executable-find "rev")) - (let ((eshell-test-value t)) - (eshell-command-result-equal "if $eshell-test-value {echo yes} | rev" - "sey")) - (let ((eshell-test-value nil)) - (eshell-command-result-equal "if $eshell-test-value {echo yes} | rev" - nil))) + (with-temp-eshell + (let ((eshell-test-value t)) + (eshell-match-command-output "if $eshell-test-value {echo yes} | rev" + "\\`sey\n?")) + (let ((eshell-test-value nil)) + (eshell-match-command-output "if $eshell-test-value {echo yes} | rev" + "\\`\n?")))) (ert-deftest esh-cmd-test/if-else-statement-pipe () "Test invocation of an if/else statement piped to another command." (skip-unless (executable-find "rev")) - (let ((eshell-test-value t)) - (eshell-command-result-equal - "if $eshell-test-value {echo yes} {echo no} | rev" - "sey")) - (let ((eshell-test-value nil)) - (eshell-command-result-equal - "if $eshell-test-value {echo yes} {echo no} | rev" - "on"))) + (with-temp-eshell + (let ((eshell-test-value t)) + (eshell-match-command-output + "if $eshell-test-value {echo yes} {echo no} | rev" + "\\`sey\n?")) + (let ((eshell-test-value nil)) + (eshell-match-command-output + "if $eshell-test-value {echo yes} {echo no} | rev" + "\\`on\n?")))) (ert-deftest esh-cmd-test/unless-statement () "Test invocation of an unless statement." diff --git a/test/lisp/eshell/esh-io-tests.el b/test/lisp/eshell/esh-io-tests.el index 0f09afa19e4..52501f5bb70 100644 --- a/test/lisp/eshell/esh-io-tests.el +++ b/test/lisp/eshell/esh-io-tests.el @@ -320,8 +320,9 @@ esh-io-test/pipeline/all (ert-deftest esh-io-test/pipeline/subcommands () "Chek that all commands in a subcommand are properly piped." (skip-unless (executable-find "rev")) - (eshell-command-result-equal "{echo foo; echo bar} | rev" - "raboof")) + (with-temp-eshell + (eshell-match-command-output "{echo foo; echo bar} | rev" + "\\`raboof\n?"))) ;; Virtual targets commit e9983b1b635cbbc5402279dbbe42878902b151db Author: Nikolaos Chatzikonstantinou Date: Mon Sep 26 11:08:18 2022 -0400 Add :pass and :flags to gnutls-boot for :keylist * lisp/net/gnutls.el (gnutls-boot-parameters): Add the keys :pass and :flags, and update the documentation. * src/gnutls.c (gnutls-boot): Add the keys :pass and :flags, and update the documentation. (syms_of_gnutls): Add the symbols :pass, :flags, and the symbols that correspond to the enumeration constants of the GnuTLS enum `gnutls_pkcs_encrypt_flags_t'. (key_file2_aux): Private helper function that translates a list of symbols to its corresponding `unsigned int' value of the GnuTLS C enum `gnutls_pkcs_encrypt_flags_t'. (Bug#50507) diff --git a/lisp/net/gnutls.el b/lisp/net/gnutls.el index 9f14df08a79..f828ccfc1b0 100644 --- a/lisp/net/gnutls.el +++ b/lisp/net/gnutls.el @@ -262,6 +262,7 @@ gnutls-boot-parameters &key type hostname priority-string trustfiles crlfiles keylist min-prime-bits verify-flags verify-error verify-hostname-error + pass flags &allow-other-keys) "Return a keyword list of parameters suitable for passing to `gnutls-boot'. @@ -278,6 +279,13 @@ gnutls-boot-parameters VERIFY-HOSTNAME-ERROR is a backwards compatibility option for putting `:hostname' in VERIFY-ERROR. +PASS is a string, the password of the key. It may also be nil, +for a NULL password. + +FLAGS is a list of symbols corresponding to the equivalent ORed +bitflag of the gnutls_pkcs_encrypt_flags_t enum of GnuTLS. The +empty list corresponds to the bitflag with value 0. + When VERIFY-ERROR is t or a list containing `:trustfiles', an error will be raised when the peer certificate verification fails as per GnuTLS' gnutls_certificate_verify_peers2. Otherwise, only @@ -355,6 +363,8 @@ gnutls-boot-parameters :keylist ,keylist :verify-flags ,verify-flags :verify-error ,verify-error + :pass ,pass + :flags ,flags :callbacks nil))) (defun gnutls--get-files (files) diff --git a/src/gnutls.c b/src/gnutls.c index 4093865cae5..571f141b2ac 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -34,6 +34,7 @@ # endif # if GNUTLS_VERSION_NUMBER >= 0x030200 +# define HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 # define HAVE_GNUTLS_CIPHER_GET_IV_SIZE # endif @@ -121,6 +122,11 @@ DEF_DLL_FN (int, gnutls_certificate_set_x509_crl_file, DEF_DLL_FN (int, gnutls_certificate_set_x509_key_file, (gnutls_certificate_credentials_t, const char *, const char *, gnutls_x509_crt_fmt_t)); +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 +DEF_DLL_FN (int, gnutls_certificate_set_x509_key_file2, + (gnutls_certificate_credentials_t, const char *, const char *, + gnutls_x509_crt_fmt_t, const char *, unsigned int)); +# endif # ifdef HAVE_GNUTLS_X509_SYSTEM_TRUST DEF_DLL_FN (int, gnutls_certificate_set_x509_system_trust, (gnutls_certificate_credentials_t)); @@ -314,6 +320,9 @@ init_gnutls_functions (void) LOAD_DLL_FN (library, gnutls_certificate_set_verify_flags); LOAD_DLL_FN (library, gnutls_certificate_set_x509_crl_file); LOAD_DLL_FN (library, gnutls_certificate_set_x509_key_file); +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 + LOAD_DLL_FN (library, gnutls_certificate_set_x509_key_file2); +# endif # ifdef HAVE_GNUTLS_X509_SYSTEM_TRUST LOAD_DLL_FN (library, gnutls_certificate_set_x509_system_trust); # endif @@ -455,6 +464,9 @@ init_gnutls_functions (void) # define gnutls_certificate_set_verify_flags fn_gnutls_certificate_set_verify_flags # define gnutls_certificate_set_x509_crl_file fn_gnutls_certificate_set_x509_crl_file # define gnutls_certificate_set_x509_key_file fn_gnutls_certificate_set_x509_key_file +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 +# define gnutls_certificate_set_x509_key_file2 fn_gnutls_certificate_set_x509_key_file2 +# endif # define gnutls_certificate_set_x509_system_trust fn_gnutls_certificate_set_x509_system_trust # define gnutls_certificate_set_x509_trust_file fn_gnutls_certificate_set_x509_trust_file # define gnutls_certificate_type_get fn_gnutls_certificate_type_get @@ -1774,6 +1786,61 @@ gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist) return gnutls_make_error (ret); } +#ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 + +/* Helper function for gnutls-boot. + + The key :flags receives a list of symbols, each of which + corresponds to a GnuTLS C flag, the ORed result is to be passed to + the function gnutls_certificate_set_x509_key_file2() as its last + argument. +*/ +static unsigned int +key_file2_aux (Lisp_Object flags) +{ + unsigned int rv = 0; + Lisp_Object tail = flags; + FOR_EACH_TAIL_SAFE (tail) + { + Lisp_Object flag = XCAR (tail); + if (EQ (flag, Qgnutls_pkcs_plain)) + rv |= GNUTLS_PKCS_PLAIN; + else if (EQ (flag, Qgnutls_pkcs_pkcs12_3des)) + rv |= GNUTLS_PKCS_PKCS12_3DES; + else if (EQ (flag, Qgnutls_pkcs_pkcs12_arcfour)) + rv |= GNUTLS_PKCS_PKCS12_ARCFOUR; + else if (EQ (flag, Qgnutls_pkcs_pkcs12_rc2_40)) + rv |= GNUTLS_PKCS_PKCS12_RC2_40; + else if (EQ (flag, Qgnutls_pkcs_pbes2_3des)) + rv |= GNUTLS_PKCS_PBES2_3DES; + else if (EQ (flag, Qgnutls_pkcs_pbes2_aes_128)) + rv |= GNUTLS_PKCS_PBES2_AES_128; + else if (EQ (flag, Qgnutls_pkcs_pbes2_aes_192)) + rv |= GNUTLS_PKCS_PBES2_AES_192; + else if (EQ (flag, Qgnutls_pkcs_pbes2_aes_256)) + rv |= GNUTLS_PKCS_PBES2_AES_256; + else if (EQ (flag, Qgnutls_pkcs_null_password)) + rv |= GNUTLS_PKCS_NULL_PASSWORD; + else if (EQ (flag, Qgnutls_pkcs_pbes2_des)) + rv |= GNUTLS_PKCS_PBES2_DES; + else if (EQ (flag, Qgnutls_pkcs_pbes1_des_md5)) + rv |= GNUTLS_PKCS_PBES1_DES_MD5; + else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_tc26z)) + rv |= GNUTLS_PKCS_PBES2_GOST_TC26Z; + else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpa)) + rv |= GNUTLS_PKCS_PBES2_GOST_CPA; + else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpb)) + rv |= GNUTLS_PKCS_PBES2_GOST_CPB; + else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpc)) + rv |= GNUTLS_PKCS_PBES2_GOST_CPC; + else if (EQ (flag, Qgnutls_pkcs_pbes2_gost_cpd)) + rv |= GNUTLS_PKCS_PBES2_GOST_CPD; + } + return rv; +} + +#endif /* HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 */ + DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, doc: /* Initialize GnuTLS client for process PROC with TYPE+PROPLIST. Currently only client mode is supported. Return a success/failure @@ -1813,6 +1880,21 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, :complete-negotiation, if non-nil, will make negotiation complete before returning even on non-blocking sockets. +:pass, the password of the private key as per GnuTLS' +gnutls_certificate_set_x509_key_file2. Specify as nil to have a NULL +password. + +:flags, a list of symbols relating to :pass, each specifying a flag: +GNUTLS_PKCS_PLAIN, GNUTLS_PKCS_PKCS12_3DES, +GNUTLS_PKCS_PKCS12_ARCFOUR, GNUTLS_PKCS_PKCS12_RC2_40, +GNUTLS_PKCS_PBES2_3DES, GNUTLS_PKCS_PBES2_AES_128, +GNUTLS_PKCS_PBES2_AES_192, GNUTLS_PKCS_PBES2_AES_256, +GNUTLS_PKCS_NULL_PASSWORD, GNUTLS_PKCS_PBES2_DES, +GNUTLS_PKCS_PBES2_DES_MD5, GNUTLS_PKCS_PBES2_GOST_TC26Z, +GNUTLS_PKCS_PBES2_GOST_CPA, GNUTLS_PKCS_PBES2_GOST_CPB, +GNUTLS_PKCS_PBES2_GOST_CPC, GNUTLS_PKCS_PBES2_GOST_CPD. If not +specified, or if nil, the bitflag with value 0 is used. + The debug level will be set for this process AND globally for GnuTLS. So if you set it higher or lower at any point, it affects global debugging. @@ -1825,6 +1907,9 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, functions are used. This function allocates resources which can only be deallocated by calling `gnutls-deinit' or by calling it again. +The :pass and :flags keys are ignored with old versions of GnuTLS, and +:flags is ignored if :pass is not specified. + The callbacks alist can have a `verify' key, associated with a verification function (UNUSED). @@ -1842,12 +1927,15 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, Lisp_Object global_init; char const *priority_string_ptr = "NORMAL"; /* default priority string. */ char *c_hostname; + const char *c_pass; /* Placeholders for the property list elements. */ Lisp_Object priority_string; Lisp_Object trustfiles; Lisp_Object crlfiles; Lisp_Object keylist; + Lisp_Object pass; + Lisp_Object flags; /* Lisp_Object callbacks; */ Lisp_Object loglevel; Lisp_Object hostname; @@ -1877,6 +1965,13 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, crlfiles = plist_get (proplist, QCcrlfiles); loglevel = plist_get (proplist, QCloglevel); prime_bits = plist_get (proplist, QCmin_prime_bits); + pass = plist_get (proplist, QCpass); + flags = plist_get (proplist, QCflags); + + if (STRINGP (pass)) + c_pass = SSDATA (pass); + else + c_pass = NULL; if (!STRINGP (hostname)) { @@ -2037,6 +2132,13 @@ DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 3, 0, # ifdef WINDOWSNT keyfile = ansi_encode_filename (keyfile); certfile = ansi_encode_filename (certfile); +# endif +# ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_KEY_FILE2 + if (plist_member (proplist, QCpass)) + ret = gnutls_certificate_set_x509_key_file2 + (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format, + c_pass, key_file2_aux (flags)); + else # endif ret = gnutls_certificate_set_x509_key_file (x509_cred, SSDATA (certfile), SSDATA (keyfile), file_format); @@ -2862,8 +2964,26 @@ syms_of_gnutls (void) DEFSYM (QCmin_prime_bits, ":min-prime-bits"); DEFSYM (QCloglevel, ":loglevel"); DEFSYM (QCcomplete_negotiation, ":complete-negotiation"); + DEFSYM (QCpass, ":pass"); + DEFSYM (QCflags, ":flags"); DEFSYM (QCverify_flags, ":verify-flags"); DEFSYM (QCverify_error, ":verify-error"); + DEFSYM (Qgnutls_pkcs_plain, "GNUTLS_PKCS_PLAIN"); + DEFSYM (Qgnutls_pkcs_pkcs12_3des, "GNUTLS_PKCS_PKCS12_3DES"); + DEFSYM (Qgnutls_pkcs_pkcs12_arcfour, "GNUTLS_PKCS_PKCS12_ARCFOUR"); + DEFSYM (Qgnutls_pkcs_pkcs12_rc2_40, "GNUTLS_PKCS_PKCS12_RC2_40"); + DEFSYM (Qgnutls_pkcs_pbes2_3des, "GNUTLS_PKCS_PBES2_3DES"); + DEFSYM (Qgnutls_pkcs_pbes2_aes_128, "GNUTLS_PKCS_PBES2_AES_128"); + DEFSYM (Qgnutls_pkcs_pbes2_aes_192, "GNUTLS_PKCS_PBES2_AES_192"); + DEFSYM (Qgnutls_pkcs_pbes2_aes_256, "GNUTLS_PKCS_PBES2_AES_256"); + DEFSYM (Qgnutls_pkcs_null_password, "GNUTLS_PKCS_NULL_PASSWORD"); + DEFSYM (Qgnutls_pkcs_pbes2_des, "GNUTLS_PKCS_PBES2_DES"); + DEFSYM (Qgnutls_pkcs_pbes1_des_md5, "GNUTLS_PKCS_PBES1_DES_MD5"); + DEFSYM (Qgnutls_pkcs_pbes2_gost_tc26z, "GNUTLS_PKCS_PBES2_GOST_TC26Z"); + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpa, "GNUTLS_PKCS_PBES2_GOST_CPA"); + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpb, "GNUTLS_PKCS_PBES2_GOST_CPB"); + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpc, "GNUTLS_PKCS_PBES2_GOST_CPC"); + DEFSYM (Qgnutls_pkcs_pbes2_gost_cpd, "GNUTLS_PKCS_PBES2_GOST_CPD"); DEFSYM (QCcipher_id, ":cipher-id"); DEFSYM (QCcipher_aead_capable, ":cipher-aead-capable"); commit 4922de626f05f0c26bc732b082c30c5c18a88416 Author: Eli Zaretskii Date: Fri Dec 30 17:10:22 2022 +0200 ; Fix doc strings of 'treesit-install-language-grammar' * lisp/treesit.el (treesit-install-language-grammar) (treesit--install-language-grammar-1): Doc fixes. diff --git a/lisp/treesit.el b/lisp/treesit.el index b120ca68c5c..d12c19dde85 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2632,14 +2632,14 @@ treesit-language-source-alist \"c++\", respectively.") (defun treesit-install-language-grammar (lang) - "Install language grammar for LANG. + "Build and install the tree-sitter language grammar library for LANG. -This command requires git, a C compiler and (sometimes) a C++ -compiler to exist and locatable in the executable paths. It also -requires that the recipe for LANG exists in -`treesit-language-source-alist'. +This command requires Git, a C compiler and (sometimes) a C++ compiler, +and the linker to be installed and on PATH. It also requires that the +recipe for LANG exists in `treesit-language-source-alist'. -Current executable paths can be checked by calling `exec-path'." +See `exec-path' for the current path where Emacs looks for +executable programs, such as the C/C++ compiler and linker." (interactive (list (intern (completing-read "Language: " @@ -2682,10 +2682,10 @@ treesit--call-process-signal (defun treesit--install-language-grammar-1 (out-dir lang url &optional source-dir grammar-dir cc c++) - "Install and compile a tree-sitter language grammar. + "Install and compile a tree-sitter language grammar library. -OUT-DIR is the direcotory to put the compiled library file, -default to ~/.emacs.d/tree-sitter. +OUT-DIR is the directory to put the compiled library file, it +defaults to ~/.emacs.d/tree-sitter. For LANG, URL, SOURCE-DIR, GRAMMAR-DIR, CC, C++, see `treesit-language-source-alist'. If anything goes wrong, this commit 69b2aaaaded71b05b41b52ee5072d4d8babe33b6 Author: Eli Zaretskii Date: Fri Dec 30 16:43:38 2022 +0200 ; Fix recently modified docs of 'set-face-attribute' (bug#52493) * doc/lispref/display.texi (Attribute Functions): Clarify wording and restore removed information about resetting attributes to 'unspecified' for future frames. * lisp/faces.el (set-face-attribute): Minor copyedit of doc string. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 5397489e44f..604d5bd1a23 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -3059,16 +3059,23 @@ Attribute Functions this function sets the attributes for all existing frames, as well as for newly created frames. -To @emph{unset} the value of an attribute, that is, to indicate that -the face doesn't by itself specify a value for the attribute, the -special value @code{unspecified} (@emph{not} @code{nil}!@:) must be -used. +To @emph{reset} the value of an attribute, that is, to indicate that +the face doesn't by itself specify a value for the attribute, use the +special value @code{unspecified} (@emph{not} @code{nil}!@:) for the +attribute, and set the @var{frame} argument to @code{t}, in addition +to the call with @var{frame} set to @code{nil}. This is because the +default attributes for newly created frames are merged with the face's +spec in @code{defface} when a new frame is created, and so having +@code{unspecified} in the default attributes for new frames will be +unable to override @code{defface}; the special call to this function +as described above will arrange for @code{defface} to be overridden. Note that the attribute-value pairs are evaluated in the order they -are specified, except the @code{:family} and @code{:foundry} -attributes, which are evaluated first. This means both that only the -last value of a given attribute will be used, and that in some cases a -different order will give different results. For example, when +are specified, with the exception of the @code{:family} and +@code{:foundry} attributes, which are evaluated first. This means +that if a certain attribute is specified more than once, only the last +value will be used. It also means that in some cases a different +order of attributes will produce different results. For example, when @code{:weight} is placed before @code{:font}, the weight value is applied to the current font of the face, and might be rounded to the closest available weight of that font, whereas when @code{:font} is diff --git a/lisp/faces.el b/lisp/faces.el index fe683e437f5..0dd89be4738 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -691,8 +691,8 @@ set-face-attribute t and the ATTRIBUTE's value set to `unspecified'. Note that the ATTRIBUTE VALUE pairs are evaluated in the order -they are specified, except the `:family' and `:foundry' -attributes which are evaluated first. +they are specified, except that the `:family' and `:foundry' +attributes are evaluated first. The following attributes are recognized: commit 0248fc9e1ac6aa0b802a334ace77c9cf0709e2c3 Author: Yuan Fu Date: Fri Dec 30 02:56:26 2022 -0800 Add treesit-install-language-grammar Per discussion on emacs-devel, I added function to install and compile language grammars. * lisp/treesit.el (treesit-language-source-alist): New variable. (treesit-install-language-grammar) (treesit--call-process-signal) (treesit--install-language-grammar-1): New functions. diff --git a/lisp/treesit.el b/lisp/treesit.el index f3ca1afa139..b120ca68c5c 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2611,6 +2611,139 @@ treesit-explore-mode #'treesit--explorer-post-command t) (kill-buffer treesit--explorer-buffer))) +;;; Install & build language grammar + +(defvar treesit-language-source-alist nil + "Configures how to download tree-sitter language grammars. +This should be an alist of + + (LANG . (URL SOURCE-DIR GRAMMAR-DIR CC C++)) + +Only LANG and URL are mandatory. LANG is the language symbol. +URL is the repository's url. + +SOURCE-DIR is the relative directory in the repository in which +the grammar.c file resides, default to \"src\". + +GRAMMAR-DIR is the relative grammar directory in the repository +in which the grammar.js file resides, default to \"\". + +CC and C++ are C and C++ compilers, default to \"cc\" and +\"c++\", respectively.") + +(defun treesit-install-language-grammar (lang) + "Install language grammar for LANG. + +This command requires git, a C compiler and (sometimes) a C++ +compiler to exist and locatable in the executable paths. It also +requires that the recipe for LANG exists in +`treesit-language-source-alist'. + +Current executable paths can be checked by calling `exec-path'." + (interactive (list (intern + (completing-read + "Language: " + (mapcar #'car treesit-language-source-alist) + nil t)))) + (condition-case err + (apply #'treesit--install-language-grammar-1 + ;; The nil is OUT-DIR. + (cons nil (assoc lang treesit-language-source-alist))) + (error + (display-warning + 'treesit + (format "Error encountered when installing language grammar: %s" + err)))) + ;; Check that the installed language grammar is loadable. + (pcase-let ((`(,available . ,err) + (treesit-language-available-p lang t))) + (when (not available) + (display-warning + 'treesit + (format "The installed language grammar for %s cannot be located or has problems (%s): %s" + lang (nth 0 err) + (string-join + (mapcar (lambda (x) (format "%s" x)) + (cdr err)) + " ")))))) + +(defun treesit--call-process-signal (&rest args) + "Run `call-process' with ARGS. +If it returns anything but 0, signal an error. Use the buffer +content as signal data, and erase buffer afterwards." + (unless (eq 0 (apply #'call-process args)) + (signal 'treesit-error (list "Command:" + (string-join (cons (car args) + (nthcdr 4 args)) + " ") + "Error output:" + (buffer-string))) + (erase-buffer))) + +(defun treesit--install-language-grammar-1 + (out-dir lang url &optional source-dir grammar-dir cc c++) + "Install and compile a tree-sitter language grammar. + +OUT-DIR is the direcotory to put the compiled library file, +default to ~/.emacs.d/tree-sitter. + +For LANG, URL, SOURCE-DIR, GRAMMAR-DIR, CC, C++, see +`treesit-language-source-alist'. If anything goes wrong, this +function signals an error." + (let* ((lang (symbol-name lang)) + (default-directory "/tmp") + (workdir (expand-file-name "treesit-workdir-00893133134")) + (source-dir (expand-file-name (or source-dir "src") workdir)) + (grammar-dir (expand-file-name (or grammar-dir "") workdir)) + (cc (or cc "cc")) + (c++ (or c++ "c++")) + (soext (pcase system-type + ('darwin "dylib") + ((or 'ms-dos 'cywin 'windows-nt) "dll") + (_ "so"))) + (out-dir (or (and out-dir (expand-file-name out-dir)) + (expand-file-name + "tree-sitter" user-emacs-directory))) + (lib-name (format "libtree-sitter-%s.%s" lang soext))) + (unwind-protect + (with-temp-buffer + (message "Cloning repository") + ;; git clone xxx --depth 1 --quiet workdir + (treesit--call-process-signal + "git" nil t nil "clone" url "--depth" "1" "--quiet" + workdir) + ;; cp "${grammardir}"/grammar.js "${sourcedir}" + (copy-file (concat grammar-dir "/grammar.js") + (concat source-dir "/grammar.js")) + ;; cd "${sourcedir}" + (setq default-directory source-dir) + (message "Compiling library") + ;; cc -fPIC -c -I. parser.c + (treesit--call-process-signal + cc nil t nil "-fPIC" "-c" "-I." "parser.c") + ;; cc -fPIC -c -I. scanner.c + (when (file-exists-p "scanner.c") + (treesit--call-process-signal + cc nil t nil "-fPIC" "-c" "-I." "scanner.c")) + ;; c++ -fPIC -I. -c scanner.cc + (when (file-exists-p "scanner.cc") + (treesit--call-process-signal + c++ nil t nil "-fPIC" "-c" "-I." "scanner.cc")) + ;; cc/c++ -fPIC -shared *.o -o "libtree-sitter-${lang}.${soext}" + (apply #'treesit--call-process-signal + (if (file-exists-p "scanner.cc") c++ cc) + nil t nil + `("-fPIC" "-shared" + ,@(directory-files + default-directory nil + (rx bos (+ anychar) ".o" eos)) + "-o" ,lib-name)) + ;; Copy out. + (copy-file lib-name (concat out-dir "/") t) + (message "Library installed to %s/%s" out-dir lib-name)) + (when (file-exists-p workdir) + (delete-directory workdir t))))) + ;;; Etc (declare-function find-library-name "find-func.el") commit 0237c5927e9a741083e4d177bd9a8e9c876cc662 Author: Yuan Fu Date: Fri Dec 30 02:54:13 2022 -0800 Add treesit-language-abi-version Also rename treesit-language-version to treesit-library-abi-version, because the old name is somewhat misleading. * doc/lispref/parsing.texi (Language Grammar): Update. * src/treesit.c (Ftreesit_library_abi_version): Rename. (Ftreesit_language_abi_version): New function. diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 5411987b5e8..8803991b725 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -141,7 +141,7 @@ Language Grammar conventions. @cindex language grammar version, compatibility -@defun treesit-language-version &optional min-compatible +@defun treesit-library-abi-version &optional min-compatible This function returns the version of the language grammar Application Binary Interface (@acronym{ABI}) supported by the tree-sitter library. By default, it returns the latest ABI version @@ -153,6 +153,12 @@ Language Grammar them. @end defun +@defun treesit-language-abi-version language +This function returns the language grammar @acronym{ABI} version of +language grammar for @var{language} loaded by Emacs. If +@var{language} is unavailable, this function returns @code{nil}. +@end defun + @heading Concrete syntax tree @cindex syntax tree, concrete diff --git a/src/treesit.c b/src/treesit.c index eaa563a54c4..a9bfcb3d9e9 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -662,9 +662,8 @@ DEFUN ("treesit-language-available-p", Ftreesit_langauge_available_p, } } -DEFUN ("treesit-language-version", - Ftreesit_language_version, - Streesit_language_version, +DEFUN ("treesit-library-abi-version", Ftreesit_library_abi_version, + Streesit_library_abi_version, 0, 1, 0, doc: /* Return the language ABI version of the tree-sitter library. @@ -680,6 +679,29 @@ DEFUN ("treesit-language-version", return make_fixnum (TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION); } +DEFUN ("treesit-language-version", Ftreesit_language_abi_version, + Streesit_language_abi_version, + 0, 1, 0, + doc: /* Return the language ABI version of the tree-sitter LANGUAGE. +Return nil if LANGUAGE is not available. */) + (Lisp_Object language) +{ + if (NILP (Ftreesit_langauge_available_p (language, Qnil))) + return Qnil; + else + { + Lisp_Object signal_symbol = Qnil; + Lisp_Object signal_data = Qnil; + TSLanguage *ts_language = treesit_load_language (language, + &signal_symbol, + &signal_data); + if (ts_language == NULL) + return Qnil; + uint32_t version = ts_language_version (ts_language); + return make_fixnum((ptrdiff_t) version); + } +} + /*** Parsing functions */ static void @@ -3345,7 +3367,8 @@ syms_of_treesit (void) Vtreesit_extra_load_path = Qnil; defsubr (&Streesit_language_available_p); - defsubr (&Streesit_language_version); + defsubr (&Streesit_library_abi_version); + defsubr (&Streesit_language_abi_version); defsubr (&Streesit_parser_p); defsubr (&Streesit_node_p); commit 7493b4026fc74a51c76c5b614bc83b864af9bc31 Author: Mattias Engdegård Date: Fri Dec 30 11:30:23 2022 +0100 ; fix misplaced bracketing of `and` inside `when` diff --git a/lisp/help-fns.el b/lisp/help-fns.el index e29f763dabc..3307771ef68 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -2004,8 +2004,8 @@ help-fns-find-keymap-name (mapatoms (lambda (symb) (when (and (boundp symb) (eq (symbol-value symb) keymap) - (not (eq symb 'keymap)) - (throw 'found-keymap symb))))) + (not (eq symb 'keymap))) + (throw 'found-keymap symb)))) nil))) ;; Follow aliasing. (or (ignore-errors (indirect-variable name)) name)))) commit c34230f12aa966df091dd7b3cb2e32ce43ad811d Author: Mattias Engdegård Date: Fri Dec 30 11:11:14 2022 +0100 ; remove incorrect quoting of condition names diff --git a/lisp/abbrev.el b/lisp/abbrev.el index 2ca8e25dac7..26c2b097929 100644 --- a/lisp/abbrev.el +++ b/lisp/abbrev.el @@ -501,7 +501,7 @@ make-abbrev-table (defun abbrev-table-p (object) "Return non-nil if OBJECT is an abbrev table." (and (obarrayp object) - (numberp (ignore-error 'wrong-type-argument + (numberp (ignore-error wrong-type-argument (abbrev-table-get object :abbrev-table-modiff))))) (defun abbrev-table-empty-p (object &optional ignore-system) diff --git a/lisp/desktop.el b/lisp/desktop.el index ef73bc596df..d55739bb6f8 100644 --- a/lisp/desktop.el +++ b/lisp/desktop.el @@ -828,7 +828,7 @@ desktop--on-kill ;; If we own it, we don't anymore. (when (eq (emacs-pid) (desktop-owner)) ;; Allow exiting Emacs even if we can't delete the desktop file. - (ignore-error 'file-error + (ignore-error file-error (desktop-release-lock)))) ;; ---------------------------------------------------------------------------- diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index 950922ea7f8..c56278aad02 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -467,7 +467,7 @@ eshell-sentinel (if (process-get proc :eshell-busy) (run-at-time 0 nil finish-io) (when data - (ignore-error 'eshell-pipe-broken + (ignore-error eshell-pipe-broken (eshell-output-object data index handles))) (eshell-close-handles diff --git a/lisp/gnus/gnus-registry.el b/lisp/gnus/gnus-registry.el index cf5ca628cff..c5cd4d7d6be 100644 --- a/lisp/gnus/gnus-registry.el +++ b/lisp/gnus/gnus-registry.el @@ -394,7 +394,7 @@ gnus-registry-read (with-no-warnings (eieio-persistent-read file 'registry-db)) ;; Older EIEIO versions do not check the class name. - ('wrong-number-of-arguments + (wrong-number-of-arguments (eieio-persistent-read file))))) (gnus-message 5 "Reading Gnus registry from %s...done" file)) diff --git a/lisp/image-mode.el b/lisp/image-mode.el index bd208fbad46..10af8c6cab9 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -1086,7 +1086,7 @@ image-fit-to-window (unwind-protect (progn (setq-local image-fit-to-window-lock t) - (ignore-error 'remote-file-error + (ignore-error remote-file-error (image-toggle-display-image))) (setq image-fit-to-window-lock nil))))))))))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index e39c9ccc31a..acbd50dc0fb 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -5439,7 +5439,7 @@ tramp-action-show-and-confirm-message ;; Hide message in buffer. (narrow-to-region (point-max) (point-max)) ;; Wait for new output. - (while (not (tramp-compat-ignore-error 'file-error + (while (not (tramp-compat-ignore-error file-error (tramp-wait-for-regexp proc 0.1 tramp-security-key-confirmed-regexp))) (when (tramp-check-for-regexp proc tramp-security-key-timeout-regexp) diff --git a/lisp/startup.el b/lisp/startup.el index 6270de2ace6..5a383630774 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2921,7 +2921,7 @@ command-line--eval-script (when (looking-at "#!") (forward-line)) (let (value form) - (while (ignore-error 'end-of-file + (while (ignore-error end-of-file (setq form (read (current-buffer)))) (setq value (eval form t))) (kill-emacs (if (numberp value) diff --git a/test/lisp/emacs-lisp/multisession-tests.el b/test/lisp/emacs-lisp/multisession-tests.el index 5807c27bd20..68d9c9646ff 100644 --- a/test/lisp/emacs-lisp/multisession-tests.el +++ b/test/lisp/emacs-lisp/multisession-tests.el @@ -94,7 +94,7 @@ multi-test-sqlite-busy (dotimes (i 100) (cl-incf (multisession-value multisession--bar)))))))) (while (process-live-p proc) - (ignore-error 'sqlite-locked-error + (ignore-error sqlite-locked-error (message "multisession--bar %s" (multisession-value multisession--bar)) ;;(cl-incf (multisession-value multisession--bar)) ) diff --git a/test/src/process-tests.el b/test/src/process-tests.el index 7d3d9eb72b8..f0b9dc0fb92 100644 --- a/test/src/process-tests.el +++ b/test/src/process-tests.el @@ -830,7 +830,7 @@ process-tests--EMFILE-message (when (eq process-tests--EMFILE-message :unknown) (setq process-tests--EMFILE-message (with-temp-buffer - (when (eql (ignore-error 'file-error + (when (eql (ignore-error file-error (call-process "errno" nil t nil "EMFILE")) 0) (goto-char (point-min)) diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el index b323f592dca..977b2f63715 100644 --- a/test/src/regex-emacs-tests.el +++ b/test/src/regex-emacs-tests.el @@ -273,7 +273,7 @@ regex-tests-match string (condition-case nil (if (string-match pattern string) nil 'search-failed) - ('invalid-regexp 'compilation-failed)) + (invalid-regexp 'compilation-failed)) bounds-ref substring-ref))) @@ -518,7 +518,7 @@ regex-tests-PCRE what-failed (condition-case nil (if (string-match pattern string) nil 'search-failed) - ('invalid-regexp 'compilation-failed)) + (invalid-regexp 'compilation-failed)) matches-observed (cl-loop for x from 0 to 20 commit 312f82d36f0f8a68e70a7fbcddc398670680b5b6 Author: Yuan Fu Date: Fri Dec 30 00:47:22 2022 -0800 Change "language definition" to "language grammar" in manual. "Language grammar" is apparently the more widely used term among people talking about tree-sitter. To avoid confusion, I think it's good to use that rather than "language definition", which is a term that I made up :-) Feel free to revert this if it is too much change. * doc/lispref/elisp.texi: * doc/lispref/modes.texi: * doc/lispref/parsing.texi: * lisp/treesit.el: Change "language definition" to "language grammar". diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi index b1bbe5e0a96..fa4bc36b255 100644 --- a/doc/lispref/elisp.texi +++ b/doc/lispref/elisp.texi @@ -1364,7 +1364,7 @@ Top Parsing Program Source -* Language Definitions:: Loading tree-sitter language definitions. +* Language Grammar:: Loading tree-sitter language grammar. * Using Parser:: Introduction to parsers. * Retrieving Nodes:: Retrieving nodes from a syntax tree. * Accessing Node Information:: Accessing node information. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index de17969566d..9eb4f120f35 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -5082,7 +5082,7 @@ Parser-based Indentation @end defun It is also helpful to use @code{treesit-inspect-mode} (@pxref{Language -Definitions}) when writing indentation rules. +Grammar}) when writing indentation rules. @node Desktop Save Mode @section Desktop Save Mode diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index bbe498ad9ec..5411987b5e8 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -30,7 +30,7 @@ Parsing Program Source To be able to parse the program source using the tree-sitter library and access the syntax tree of the program, a Lisp program needs to -load a language definition library, and create a parser for that +load a language grammar library, and create a parser for that language and the current buffer. After that, the Lisp program can query the parser about specific nodes of the syntax tree. Then, it can access various kinds of information about each node, and search @@ -39,7 +39,7 @@ Parsing Program Source source files that mix multiple programming languages. @menu -* Language Definitions:: Loading tree-sitter language definitions. +* Language Grammar:: Loading tree-sitter language grammar. * Using Parser:: Introduction to parsers. * Retrieving Nodes:: Retrieving nodes from a syntax tree. * Accessing Node Information:: Accessing node information. @@ -49,27 +49,27 @@ Parsing Program Source * Tree-sitter C API:: Compare the C API and the ELisp API. @end menu -@node Language Definitions -@section Tree-sitter Language Definitions -@cindex language definitions, for tree-sitter +@node Language Grammar +@section Tree-sitter Language Grammar +@cindex language grammar, for tree-sitter -@heading Loading a language definition -@cindex loading language definition for tree-sitter +@heading Loading a language grammar +@cindex loading language grammar for tree-sitter @cindex language argument, for tree-sitter -Tree-sitter relies on language definitions to parse text in that -language. In Emacs, a language definition is represented by a symbol. -For example, the C language definition is represented as the symbol +Tree-sitter relies on language grammar to parse text in that +language. In Emacs, a language grammar is represented by a symbol. +For example, the C language grammar is represented as the symbol @code{c}, and @code{c} can be passed to tree-sitter functions as the @var{language} argument. @vindex treesit-extra-load-path @vindex treesit-load-language-error @vindex treesit-load-suffixes -Tree-sitter language definitions are distributed as dynamic libraries. -In order to use a language definition in Emacs, you need to make sure +Tree-sitter language grammar are distributed as dynamic libraries. +In order to use a language grammar in Emacs, you need to make sure that the dynamic library is installed on the system. Emacs looks for -language definitions in several places, in the following order: +language grammar in several places, in the following order: @itemize @bullet @item @@ -91,12 +91,12 @@ Language Definitions @table @code @item (not-found @var{error-msg} @dots{}) -This means that Emacs could not find the language definition library. +This means that Emacs could not find the language grammar library. @item (symbol-error @var{error-msg}) This means that Emacs could not find in the library the expected function -that every language definition library should export. +that every language grammar library should export. @item (version-mismatch @var{error-msg}) -This means that the version of language definition library is incompatible +This means that the version of language grammar library is incompatible with that of the tree-sitter library. @end table @@ -105,7 +105,7 @@ Language Definitions details about the failure. @defun treesit-language-available-p language &optional detail -This function returns non-@code{nil} if the language definitions for +This function returns non-@code{nil} if the language grammar for @var{language} exist and can be loaded. If @var{detail} is non-@code{nil}, return @code{(t . nil)} when @@ -119,7 +119,7 @@ Language Definitions @file{libtree-sitter-@var{language}.@var{ext}}, where @var{ext} is the system-specific extension for dynamic libraries. Also by convention, the function provided by that library is named -@code{tree_sitter_@var{language}}. If a language definition library +@code{tree_sitter_@var{language}}. If a language grammar library doesn't follow this convention, you should add an entry @example @@ -140,14 +140,14 @@ Language Definitions for a language that considers itself too ``cool'' to abide by conventions. -@cindex language-definition version, compatibility +@cindex language grammar version, compatibility @defun treesit-language-version &optional min-compatible -This function returns the version of the language-definition +This function returns the version of the language grammar Application Binary Interface (@acronym{ABI}) supported by the tree-sitter library. By default, it returns the latest ABI version supported by the library, but if @var{min-compatible} is non-@code{nil}, it returns the oldest ABI version which the library -still can support. Language definition libraries must be built for +still can support. language grammar libraries must be built for ABI versions between the oldest and the latest versions supported by the tree-sitter library, otherwise the library will be unable to load them. @@ -210,7 +210,7 @@ Language Definitions @cindex field name, tree-sitter @cindex tree-sitter node field name @anchor{tree-sitter node field name} -To make the syntax tree easier to analyze, many language definitions +To make the syntax tree easier to analyze, many language grammar assign @dfn{field names} to child nodes. For example, a @code{function_definition} node could have a @code{declarator} and a @code{body}: @@ -266,13 +266,13 @@ Language Definitions @heading Reading the grammar definition @cindex reading grammar definition, tree-sitter -Authors of language definitions define the @dfn{grammar} of a +Authors of language grammar define the @dfn{grammar} of a programming language, which determines how a parser constructs a concrete syntax tree out of the program text. In order to use the syntax tree effectively, you need to consult the @dfn{grammar file}. The grammar file is usually @file{grammar.js} in a language -definition's project repository. The link to a language definition's +grammar's project repository. The link to a language grammar's home page can be found on @uref{https://tree-sitter.github.io/tree-sitter, tree-sitter's homepage}. @@ -350,7 +350,7 @@ Language Definitions @end table Below are grammar functions of lesser importance for reading a -language definition. +language grammar. @table @code @item token(@var{rule}) @@ -397,7 +397,7 @@ Using Parser @cindex tree-sitter parser, creating @defun treesit-parser-create language &optional buffer no-reuse Create a parser for the specified @var{buffer} and @var{language} -(@pxref{Language Definitions}). If @var{buffer} is omitted or +(@pxref{Language Grammar}). If @var{buffer} is omitted or @code{nil}, it stands for the current buffer. By default, this function reuses a parser if one already exists for @@ -685,7 +685,7 @@ Retrieving Nodes @cindex nodes, by field name @cindex syntax tree nodes, by field name -To make the syntax tree easier to analyze, many language definitions +To make the syntax tree easier to analyze, many language grammar assign @dfn{field names} to child nodes (@pxref{tree-sitter node field name, field name}). For example, a @code{function_definition} node could have a @code{declarator} node and a @code{body} node. @@ -929,7 +929,7 @@ Accessing Node Information In general, nodes in a concrete syntax tree fall into two categories: @dfn{named nodes} and @dfn{anonymous nodes}. Whether a node is named -or anonymous is determined by the language definition +or anonymous is determined by the language grammar (@pxref{tree-sitter named node, named node}). @cindex tree-sitter missing node @@ -1704,8 +1704,8 @@ Tree-sitter major modes This function checks for conditions for activating tree-sitter. It checks whether Emacs was built with tree-sitter, whether the buffer's size is not too large for tree-sitter to handle it, and whether the -language definition for @var{language} is available on the system -(@pxref{Language Definitions}). +language grammar for @var{language} is available on the system +(@pxref{Language Grammar}). This function emits a warning if tree-sitter cannot be activated. If @var{quiet} is @code{message}, the warning is turned into a message; @@ -1826,7 +1826,7 @@ Tree-sitter C API Updating a node with changes. (In Emacs, retrieve a new node instead of updating the existing one.) @item -Querying statics of a language definition. +Querying statics of a language grammar. @end itemize In addition, Emacs makes some changes to the C API to make the API more diff --git a/lisp/treesit.el b/lisp/treesit.el index 0ba4395a6b4..f3ca1afa139 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -2128,7 +2128,7 @@ treesit-ready-p (pcase-let ((`(,available . ,err) (treesit-language-available-p lang t))) (when (not available) - (setq msg (format "language definition for %s is unavailable (%s): %s" + (setq msg (format "language grammar for %s is unavailable (%s): %s" lang (nth 0 err) (string-join (mapcar (lambda (x) (format "%s" x)) @@ -2272,7 +2272,7 @@ treesit-inspect-mode where NODE, CHILD, etc, are nodes which begin at point. PARENT is the parent of NODE. NODE is displayed in bold typeface. FIELD-NAMEs are field names of NODE and CHILD, etc (see Info -node `(elisp)Language Definitions', heading \"Field names\"). +node `(elisp)Language Grammar', heading \"Field names\"). If no node starts at point, i.e., point is in the middle of a node, then the mode line displays the earliest node that spans point, commit fba35657da5697f3dd55cbbd3a60e36c7561f94b Author: Yuan Fu Date: Fri Dec 30 00:34:42 2022 -0800 ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragraph): Fix. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 82458ba5adb..82a13e97625 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -595,7 +595,9 @@ c-ts-mode--fill-paragraph (start-marker nil) (end-marker nil) (end-len 0)) - (when (equal (treesit-node-type node) "comment") + ;; These covers C/C++, Java, JavaScript, TypeScript, Rust, C#. + (when (member (treesit-node-type node) + '("comment" "line_comment" "block_comment")) ;; We mask "/*" and the space before "*/" like ;; `c-fill-paragraph' does. (atomic-change-group commit dec1b37a32b5ea4102cc5dcd803ac73774f2574c Author: Yuan Fu Date: Thu Dec 29 20:54:42 2022 -0800 ; * doc/lispref/parsing.texi (Accessing Node Information): Fix typo. diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 86b3bd54e7c..bbe498ad9ec 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi @@ -968,7 +968,7 @@ Accessing Node Information For example, a named node can be a @code{string_literal} node, where @code{string_literal} is its type. The type of an anonymous node is just the text that the node represents; e.g., the type of a @samp{,} -node 480is just @samp{,}. +node is just @samp{,}. This function returns @var{node}'s type as a string. @end defun commit 39265abf0ccdfa9a91dbe42f1e0a26e64cd50835 Author: Michael Albinus Date: Fri Dec 30 09:26:56 2022 +0100 * test/lisp/net/tramp-tests.el (tramp-test32-shell-command): Fix test. diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 79b2fc803d6..8d63bb3de9b 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5503,15 +5503,11 @@ tramp-test32-shell-command ;; String to be sent. (format "%s\n" (file-name-nondirectory tmp-name))) (should - (string-equal - ;; tramp-adb.el echoes, so we must add the string. - (if (and (tramp--test-adb-p) - (not (tramp-direct-async-process-p))) - (format - "%s\n%s\n" - (file-name-nondirectory tmp-name) - (file-name-nondirectory tmp-name)) - (format "%s\n" (file-name-nondirectory tmp-name))) + (string-match-p + ;; Some shells echo, for example the "adb" or "docker" methods. + (tramp-compat-rx + bos (** 1 2 (literal (file-name-nondirectory tmp-name)) "\n") + eos) (buffer-string)))) ;; Cleanup. commit ebf65c7e7e3872685e5c58e0618ed33ea570520f Author: Michael Albinus Date: Fri Dec 30 09:26:41 2022 +0100 * lisp/eshell/em-tramp.el (tramp): Require also at runtime. (Bug#60402) diff --git a/lisp/eshell/em-tramp.el b/lisp/eshell/em-tramp.el index 499deaa7fc5..2453af1bacc 100644 --- a/lisp/eshell/em-tramp.el +++ b/lisp/eshell/em-tramp.el @@ -30,8 +30,9 @@ (eval-when-compile (require 'esh-mode) - (require 'eshell) - (require 'tramp)) + (require 'eshell)) + +(require 'tramp) ;; There are no items in this custom group, but eshell modules (ab)use ;; custom groups.