commit 6fb8a4dff7ef22f96ebe1a775240617aabac6526 (HEAD, refs/remotes/origin/master) Merge: 4b3ccf3092e 836044f329a Author: Stefan Kangas Date: Sun Mar 5 06:30:15 2023 +0100 Merge from origin/emacs-29 836044f329a Fix c-ts-mode preproc directive indentation 64980a59b65 ; * lisp/files.el (hack-local-variables): Fix typo in the... a7cd125d490 More robustly unspoof HOME in Eglot tests (bug#61637) 6c66dbd02c7 Turn on Eglot inlay hints by default 246f5b541c5 Update ts modes missed in 4c16fd3a512 to use column-0 0bfba49ca7c Robustify Eglot for "transient" projects ea5fd375bb2 Fix documentation of 'normal-mode' in buffers that don't ... 4c16fd3a512 Change tree-sitter indent anchor 'point-min' to 'column-0' f47b3930158 Fix go-ts-mode multi-line string indentation (bug#61923) e0bf2da3db6 ; More accurate doc strings for 'window-at' and 'window-a... commit 836044f329a0a96810f2d88471cb040b9d373cce Author: Yuan Fu Date: Sat Mar 4 14:39:44 2023 -0800 Fix c-ts-mode preproc directive indentation Mentioned in bug#61893, although not the subject of that report. This change fixes indentation for nested directives. For example, when the directive involves elif and the like, the elif is nested in the if directive, so simply using grand-parent and great-grand-parent for anchor is insufficient, because the nesting can grow arbitrarily. The test added also covers the last preproc fix. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--standalone-parent-skip-preproc): New function. (c-ts-mode--indent-styles): New rules. * test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: New test. diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 05c471e6fb4..f40bbc57eb5 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -299,6 +299,23 @@ c-ts-mode--anchor-prev-sibling ;; prev-sibling doesn't have a child. (treesit-node-start prev-sibling))) +(defun c-ts-mode--standalone-parent-skip-preproc (_n parent &rest _) + "Like the standalone-parent anchor but skips preproc nodes. +PARENT is the same as other anchor functions." + (save-excursion + (treesit-node-start + (treesit-parent-until + ;; Use PARENT rather than NODE, to handle the case where NODE is + ;; nil. + parent (lambda (node) + (and node + (not (string-match "preproc" (treesit-node-type node))) + (progn + (goto-char (treesit-node-start node)) + (looking-back (rx bol (* whitespace)) + (line-beginning-position))))) + t)))) + (defun c-ts-mode--standalone-grandparent (_node parent bol &rest args) "Like the standalone-parent anchor but pass it the grandparent. PARENT, BOL, ARGS are the same as other anchor functions." @@ -330,13 +347,28 @@ c-ts-mode--indent-styles ((parent-is "labeled_statement") c-ts-mode--standalone-grandparent c-ts-mode-indent-offset) + ;; Preproc directives ((node-is "preproc") column-0 0) ((node-is "#endif") column-0 0) ((match "preproc_call" "compound_statement") column-0 0) + ;; Top-level things under a preproc directive. Note that + ;; "preproc" matches more than one type: it matches + ;; preproc_if, preproc_elif, etc. ((n-p-gp nil "preproc" "translation_unit") column-0 0) - ((n-p-gp nil "\n" "preproc") great-grand-parent c-ts-mode--preproc-offset) - ((parent-is "preproc") grand-parent c-ts-mode-indent-offset) + ;; Indent rule for an empty line after a preproc directive. + ((and no-node (parent-is ,(rx (or "\n" "preproc")))) + c-ts-mode--standalone-parent-skip-preproc c-ts-mode--preproc-offset) + ;; Statement under a preproc directive, the first statement + ;; indents against parent, the rest statements indent to + ;; their prev-sibling. + ((match nil ,(rx "preproc_" (or "if" "elif")) nil 3 3) + c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) + ((match nil "preproc_ifdef" nil 2 2) + c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) + ((match nil "preproc_else" nil 1 1) + c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) + ((parent-is "preproc") c-ts-mode--anchor-prev-sibling 0) ((parent-is "function_definition") parent-bol 0) ((parent-is "conditional_expression") first-sibling 0) diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts b/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts index 57610b5483e..0f9256ad984 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts @@ -44,3 +44,37 @@ static void /* */ static void =-=-= + +Code: + (lambda () + (c-ts-mode) + (setq-local indent-tabs-mode nil) + (setq-local c-ts-mode-indent-offset 2) + (c-ts-mode-set-style 'gnu) + (indent-region (point-min) (point-max))) + +Name: Prev-Sibling When Prev-Sibling is Preproc + +=-= +static void +free_glyph_pool (struct glyph_pool *pool) +{ + if (pool) + { +#if defined GLYPH_DEBUG + int c = 1; +#endif + int check_this = 3; + +#ifdef stuff + int c = 1; +#elif defined stuff + int e = 5; +#else + int d = 11; + int f = 11; +#endif + int check_this = 3; + } +} +=-=-= commit 64980a59b65245c450fedefa38c8140780d1a526 Author: Eli Zaretskii Date: Sat Mar 4 22:03:14 2023 +0200 ; * lisp/files.el (hack-local-variables): Fix typo in the doc string. diff --git a/lisp/files.el b/lisp/files.el index 63ad2806ca3..d325729bf4d 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -3944,7 +3944,7 @@ hack-local-variables is specified, and returns the corresponding mode symbol, or nil. In this case, try to ignore minor-modes, and return only a major-mode. If HANDLE-MODE is nil, the function gathers all the specified local -variables. If HANDLE-MODE is neither nil nor t, the functions gathers +variables. If HANDLE-MODE is neither nil nor t, the function gathers all the specified local variables, but ignores any settings of \"mode:\"." ;; We don't let inhibit-local-variables-p influence the value of ;; enable-local-variables, because then it would affect dir-local commit a7cd125d490295eb24edf43119f3d3511c3dfddd Author: João Távora Date: Sat Mar 4 19:14:48 2023 +0000 More robustly unspoof HOME in Eglot tests (bug#61637) A fair number of LSP servers allow user-local installations instead of system wide installations. Emacs's technique of spoofing the HOME env var to some non-existent or non-home directory during 'make check' breaks these tests. That's because the executables are still found by executable-find, but their invocation will rarely be successful as HOME isn't what they expect it to be. Eglot tests already had a technique for dealing with this, "unspoffing" HOME just for the invocations of LSP server but it stopped working a while back. So make it more robust. Eventually, we'll want to decide wether these local servers should be considered in 'make check' runs at all, or whether there is a way to use them with a spoofed HOME. * test/lisp/progmodes/eglot-tests.el (eglot--call-with-fixture): More robustly unspoof HOME. diff --git a/test/lisp/progmodes/eglot-tests.el b/test/lisp/progmodes/eglot-tests.el index 5d5de59a19a..7a90d68d213 100644 --- a/test/lisp/progmodes/eglot-tests.el +++ b/test/lisp/progmodes/eglot-tests.el @@ -103,22 +103,21 @@ eglot--call-with-fixture (set (car spec) (cadr spec))) ((stringp (car spec)) (push spec file-specs)))) (unwind-protect - (let* ((home (getenv "HOME")) - (process-environment + (let* ((process-environment (append `(;; Set XDF_CONFIG_HOME to /dev/null to prevent ;; user-configuration to have an influence on ;; language servers. (See github#441) "XDG_CONFIG_HOME=/dev/null" ;; ... on the flip-side, a similar technique by - ;; Emacs's test makefiles means that HOME is set to - ;; /nonexistent. This breaks some common - ;; installations for LSP servers like pylsp, making - ;; these tests mostly useless, so we hack around it - ;; here with a great big hack. + ;; Emacs's test makefiles means that HOME is + ;; spoofed to /nonexistent, or sometimes /tmp. + ;; This breaks some common installations for LSP + ;; servers like pylsp, rust-analyzer making these + ;; tests mostly useless, so we hack around it here + ;; with a great big hack. ,(format "HOME=%s" - (if (file-exists-p home) home - (format "/home/%s" (getenv "USER"))))) + (expand-file-name (format "~%s" (user-login-name))))) process-environment)) ;; Prevent "Can't guess python-indent-offset ..." messages. (python-indent-guess-indent-offset-verbose . nil) commit 6c66dbd02c7773a4347583b35b8caa219df30807 Author: João Távora Date: Sat Mar 4 15:05:15 2023 +0000 Turn on Eglot inlay hints by default This is like any other server-provided feature, and may be turned off client-side by setting eglot-ignored-server-capabilities like (add-to-list 'eglot-ignored-server-capabilities :inlayHintProvider) * lisp/progmodes/eglot.el (eglot--maybe-activate-editing-mode): Activate eglot-inlay-hints-mode. (eglot-inlay-hints-mode): Instead of warning about missing :inlayHintProvider, turn off eglot-inlay-hints-mode. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 1f213d4e254..2491c86ea5b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1923,6 +1923,7 @@ eglot--maybe-activate-editing-mode (eglot--signal-textDocument/didOpen) ;; Run user hook after 'textDocument/didOpen' so server knows ;; about the buffer. + (eglot-inlay-hints-mode 1) (run-hooks 'eglot-managed-mode-hook)))) (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode) @@ -3646,8 +3647,7 @@ eglot-inlay-hints-mode (cond (eglot-inlay-hints-mode (if (eglot--server-capable :inlayHintProvider) (jit-lock-register #'eglot--update-hints 'contextual) - (eglot--warn - "No :inlayHintProvider support. Inlay hints will not work."))) + (eglot-inlay-hints-mode -1))) (t (jit-lock-unregister #'eglot--update-hints) (remove-overlays nil nil 'eglot--inlay-hint t)))) commit 246f5b541c50b28c4303a365f8d8cd384f0aa6c9 Author: Dmitry Gutov Date: Sat Mar 4 19:45:39 2023 +0200 Update ts modes missed in 4c16fd3a512 to use column-0 * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): * lisp/progmodes/go-ts-mode.el (go-ts-mode--indent-rules): Change point-min anchor to column-0. diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index c0ec2822b57..77c97ffac11 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -66,7 +66,7 @@ go-ts-mode--syntax-table (defvar go-ts-mode--indent-rules `((go - ((parent-is "source_file") point-min 0) + ((parent-is "source_file") column-0 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is "}") parent-bol 0) diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index fa1d8626f14..750642420e3 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el @@ -557,7 +557,7 @@ ruby-ts--indent-rules (let ((common `( ;; Slam all top level nodes to the left margin - ((parent-is "program") point-min 0) + ((parent-is "program") column-0 0) ;; Do not indent here docs or the end. Not sure why it ;; takes the grand-parent but ok fine. commit 4b3ccf3092eaf5573b0f4968ee9a4515d04fd061 Author: Eli Zaretskii Date: Sat Mar 4 17:01:16 2023 +0200 Unbreak the unexec build * src/alloc.c (BLOCK_ALIGN) [HAVE_UNEXEC]: Reset back to 1024. (Bug#61960) diff --git a/src/alloc.c b/src/alloc.c index 5450586b533..d09fc41dec6 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1083,7 +1083,11 @@ lisp_free (void *block) BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ /* Byte alignment of storage blocks. */ -#define BLOCK_ALIGN (1 << 15) +#ifdef HAVE_UNEXEC +# define BLOCK_ALIGN (1 << 10) +#else /* !HAVE_UNEXEC */ +# define BLOCK_ALIGN (1 << 15) +#endif verify (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. commit 0bfba49ca7cf90e841c076d6db9bb3826e7b6a57 Author: João Távora Date: Sat Mar 4 12:49:00 2023 +0000 Robustify Eglot for "transient" projects When Eglot needs to synthesize a "transient" project for default-directory sometimes the value of that variable is set to an unexpanded value, sometimes not. This can cause simple invocations like. Emacs -Q ~/path/to-some-python-file.py -f eglot to fail, because eglot--current-server will be looking for a project in the registry called (transient . "~/path") where in reality it is stored there as (transient . "/home/someuser/path") The fix is to always expand default-directory in eglot--current-project. * lisp/progmodes/eglot.el (eglot--current-project): Use expand-file-name. diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index c74b13d3380..1f213d4e254 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1079,7 +1079,8 @@ eglot--current-project decide whether a given directory is a project containing a suitable root directory for a given LSP server's purposes." (let ((eglot-lsp-context t)) - (or (project-current) `(transient . ,default-directory)))) + (or (project-current) + `(transient . ,(expand-file-name default-directory))))) ;;;###autoload (defun eglot (managed-major-mode project class contact language-id commit 396f46d904ab7509476b0d824ec2e4d9a231a2df Author: Konstantin Kharlamov Date: Thu Feb 16 18:07:55 2023 +0300 bug#61489: Increase BLOCK_ALIGN from 1024 to 32768 Originally discovered by Tyler Dodge in his article "Significant Garbage Collection Improvement For Emacs". While testing this change on Archlinux system with Intel i5-7200U CPU, average time of garbage collection gets reduced by ≈25%. Other users report improvements up to 50%. While monitoring PSS of emacs with and without customizations loaded before and after the patch, no statistically significant differences were discovered. So overall, this change is a win. * src/alloc.c (BLOCK_ALIGN): increase from 1024 to 32768. diff --git a/src/alloc.c b/src/alloc.c index 6a7037b6bb0..5450586b533 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -1083,7 +1083,7 @@ lisp_free (void *block) BLOCK_BYTES and guarantees they are aligned on a BLOCK_ALIGN boundary. */ /* Byte alignment of storage blocks. */ -#define BLOCK_ALIGN (1 << 10) +#define BLOCK_ALIGN (1 << 15) verify (POWER_OF_2 (BLOCK_ALIGN)); /* Use aligned_alloc if it or a simple substitute is available. commit ea5fd375bb2656562f57325b3d5c6fd17f6b2e72 Author: Eli Zaretskii Date: Sat Mar 4 12:16:51 2023 +0200 Fix documentation of 'normal-mode' in buffers that don't visit files * lisp/files.el (normal-mode): * lisp/subr.el (run-mode-hooks): * doc/emacs/modes.texi (Choosing Modes): Mention the caveat with 'normal-mode' in buffers not visiting files. (Bug#61925) * lisp/files.el (hack-local-variables): Doc fix. diff --git a/doc/emacs/modes.texi b/doc/emacs/modes.texi index 0e4b15fb514..d2f96af0b55 100644 --- a/doc/emacs/modes.texi +++ b/doc/emacs/modes.texi @@ -473,9 +473,12 @@ Choosing Modes If you have changed the major mode of a buffer, you can return to the major mode Emacs would have chosen automatically, by typing @kbd{M-x normal-mode}. This is the same function that -@code{find-file} calls to choose the major mode. It also processes -the file's @samp{-*-} line or local variables list (if any). -@xref{File Variables}. +@code{find-file} calls to choose the major mode. If the buffer is +visiting a file, this command also processes the file's @samp{-*-} +line and file-local variables list (if any). @xref{File Variables}. +If the buffer doesn't visit a file, the command processes only the +major mode specification, if any, in the @samp{-*-} line and in the +file-local variables list. @vindex change-major-mode-with-file-name The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to diff --git a/lisp/files.el b/lisp/files.el index db3f348c4b5..63ad2806ca3 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -2775,7 +2775,11 @@ normal-mode `enable-local-variables' is ignored if you run `normal-mode' interactively, or from Lisp without specifying the optional argument FIND-FILE; -in that case, this function acts as if `enable-local-variables' were t." +in that case, this function acts as if `enable-local-variables' were t. + +If invoked in a buffer that doesn't visit a file, this function +processes only the major mode specification in the -*- line and +the local variables spec." (interactive) (kill-all-local-variables) (unless delay-mode-hooks @@ -3925,9 +3929,6 @@ hack-local-variables Uses `hack-local-variables-apply' to apply the variables. -See `hack-local-variables--find-variables' for the meaning of -HANDLE-MODE. - If `enable-local-variables' or `local-enable-local-variables' is nil, or INHIBIT-LOCALS is non-nil, this function disregards all normal local variables. If `inhibit-local-variables-regexps' @@ -3937,7 +3938,14 @@ hack-local-variables Variables present in `permanently-enabled-local-variables' will still be evaluated, even if local variables are otherwise -inhibited." +inhibited. + +If HANDLE-MODE is t, the function only checks whether a \"mode:\" +is specified, and returns the corresponding mode symbol, or nil. +In this case, try to ignore minor-modes, and return only a major-mode. +If HANDLE-MODE is nil, the function gathers all the specified local +variables. If HANDLE-MODE is neither nil nor t, the functions gathers +all the specified local variables, but ignores any settings of \"mode:\"." ;; We don't let inhibit-local-variables-p influence the value of ;; enable-local-variables, because then it would affect dir-local ;; variables. We don't want to search eg tar files for file local diff --git a/lisp/subr.el b/lisp/subr.el index a0a22072a18..b8bda0efd3d 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2406,8 +2406,9 @@ run-mode-hooks just adds the HOOKS to the list `delayed-mode-hooks'. Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', `delayed-mode-hooks' (in reverse order), HOOKS, then runs -`hack-local-variables', runs the hook `after-change-major-mode-hook', and -finally evaluates the functions in `delayed-after-hook-functions' (see +`hack-local-variables' (if the buffer is visiting a file), +runs the hook `after-change-major-mode-hook', and finally +evaluates the functions in `delayed-after-hook-functions' (see `define-derived-mode'). Major mode functions should use this instead of `run-hooks' when commit 4c16fd3a51286e1b1685bfb28e0cd6ae2358c37d Author: Yuan Fu Date: Sat Mar 4 01:09:00 2023 -0800 Change tree-sitter indent anchor 'point-min' to 'column-0' Point-min isn't necessarily at column 0, using line-beginning-position is better. column-0 is also more intuitive. * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--indent-rules): * lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode--indent-rules): Change point-min to column-0. * lisp/treesit.el (treesit-simple-indent-presets): Change point-min to column-0. diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index fedb2804f26..c12224230fc 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -5117,10 +5117,10 @@ Parser-based Indentation @var{parent}, and @var{bol}, and returns the first non-whitespace character on the previous line. -@item point-min +@item column-0 This anchor is a function that is called with 3 arguments: @var{node}, -@var{parent}, and @var{bol}, and returns the beginning of the buffer. -This is useful as the beginning of the buffer is always at column 0. +@var{parent}, and @var{bol}, and returns the beginning of the current +line, which is at column 0. @item comment-start This anchor is a function that is called with 3 arguments: @var{node}, diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index eb07eb74676..05c471e6fb4 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -309,8 +309,8 @@ c-ts-mode--indent-styles "Indent rules supported by `c-ts-mode'. MODE is either `c' or `cpp'." (let ((common - `(((parent-is "translation_unit") point-min 0) - ((query "(ERROR (ERROR)) @indent") point-min 0) + `(((parent-is "translation_unit") column-0 0) + ((query "(ERROR (ERROR)) @indent") column-0 0) ((node-is ")") parent 1) ((node-is "]") parent-bol 0) ((node-is "else") parent-bol 0) @@ -330,11 +330,11 @@ c-ts-mode--indent-styles ((parent-is "labeled_statement") c-ts-mode--standalone-grandparent c-ts-mode-indent-offset) - ((node-is "preproc") point-min 0) - ((node-is "#endif") point-min 0) - ((match "preproc_call" "compound_statement") point-min 0) + ((node-is "preproc") column-0 0) + ((node-is "#endif") column-0 0) + ((match "preproc_call" "compound_statement") column-0 0) - ((n-p-gp nil "preproc" "translation_unit") point-min 0) + ((n-p-gp nil "preproc" "translation_unit") column-0 0) ((n-p-gp nil "\n" "preproc") great-grand-parent c-ts-mode--preproc-offset) ((parent-is "preproc") grand-parent c-ts-mode-indent-offset) @@ -392,14 +392,14 @@ c-ts-mode--indent-styles `((gnu ;; Prepend rules to set highest priority ((match "while" "do_statement") parent 0) - (c-ts-mode--top-level-label-matcher point-min 1) + (c-ts-mode--top-level-label-matcher column-0 1) ,@common) (k&r ,@common) (linux ;; Reference: ;; https://www.kernel.org/doc/html/latest/process/coding-style.html, ;; and script/Lindent in Linux kernel repository. - ((node-is "labeled_statement") point-min 0) + ((node-is "labeled_statement") column-0 0) ,@common) (bsd ((node-is "}") parent-bol 0) diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index 827d38e30c2..5cd4acd301d 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el @@ -69,10 +69,10 @@ java-ts-mode--syntax-table (defvar java-ts-mode--indent-rules `((java - ((parent-is "program") point-min 0) + ((parent-is "program") column-0 0) ((match "}" "element_value_array_initializer") parent-bol 0) - ((node-is "}") point-min c-ts-common-statement-offset) + ((node-is "}") column-0 c-ts-common-statement-offset) ((node-is ")") parent-bol 0) ((node-is "else") parent-bol 0) ((node-is "]") parent-bol 0) @@ -80,15 +80,15 @@ java-ts-mode--indent-rules c-ts-common-comment-start-after-first-star -1) ((parent-is "comment") prev-adaptive-prefix 0) ((parent-is "text_block") no-indent) - ((parent-is "class_body") point-min c-ts-common-statement-offset) + ((parent-is "class_body") column-0 c-ts-common-statement-offset) ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) - ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) - ((parent-is "interface_body") point-min c-ts-common-statement-offset) - ((parent-is "constructor_body") point-min c-ts-common-statement-offset) + ((parent-is "annotation_type_body") column-0 c-ts-common-statement-offset) + ((parent-is "interface_body") column-0 c-ts-common-statement-offset) + ((parent-is "constructor_body") column-0 c-ts-common-statement-offset) ((parent-is "enum_body_declarations") parent-bol 0) - ((parent-is "enum_body") point-min c-ts-common-statement-offset) - ((parent-is "switch_block") point-min c-ts-common-statement-offset) - ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) + ((parent-is "enum_body") column-0 c-ts-common-statement-offset) + ((parent-is "switch_block") column-0 c-ts-common-statement-offset) + ((parent-is "record_declaration_body") column-0 c-ts-common-statement-offset) ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) @@ -121,7 +121,7 @@ java-ts-mode--indent-rules ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) - ((parent-is "block") point-min c-ts-common-statement-offset))) + ((parent-is "block") column-0 c-ts-common-statement-offset))) "Tree-sitter indent rules.") (defvar java-ts-mode--keywords diff --git a/lisp/progmodes/rust-ts-mode.el b/lisp/progmodes/rust-ts-mode.el index 2d5c3211c1a..696c2633231 100644 --- a/lisp/progmodes/rust-ts-mode.el +++ b/lisp/progmodes/rust-ts-mode.el @@ -71,7 +71,7 @@ rust-ts-mode--syntax-table (defvar rust-ts-mode--indent-rules `((rust - ((parent-is "source_file") point-min 0) + ((parent-is "source_file") column-0 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is "}") (and parent parent-bol) 0) diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index 65fba72373c..a9ca85d5d35 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el @@ -69,7 +69,7 @@ typescript-ts-mode--indent-rules "Rules used for indentation. Argument LANGUAGE is either `typescript' or `tsx'." `((,language - ((parent-is "program") point-min 0) + ((parent-is "program") column-0 0) ((node-is "}") parent-bol 0) ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) diff --git a/lisp/treesit.el b/lisp/treesit.el index dbd102d00b3..19484ceb0c2 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -1254,7 +1254,10 @@ treesit-simple-indent-presets (goto-char bol) (forward-line -1) (skip-chars-forward " \t")))) - (cons 'point-min (lambda (&rest _) (point-min))) + (cons 'column-0 (lambda (_n _p bol &rest _) + (save-excursion + (goto-char bol) + (line-beginning-position)))) ;; TODO: Document. (cons 'and (lambda (&rest fns) (lambda (node parent bol &rest _) @@ -1358,9 +1361,9 @@ treesit-simple-indent-presets Returns the first non-whitespace character on the previous line. -point-min +column-0 - Returns the beginning of buffer, which is always at column 0. + Returns the beginning of the current line, which is at column 0. comment-start commit f47b39301589feb2cb846a3c62f94411d993be78 Author: Yuan Fu Date: Sat Mar 4 00:37:03 2023 -0800 Fix go-ts-mode multi-line string indentation (bug#61923) * lisp/progmodes/go-ts-mode.el: (go-ts-mode--indent-rules): Add indent rule for multi-line sting. diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index e8f93d14744..c0ec2822b57 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -70,7 +70,8 @@ go-ts-mode--indent-rules ((node-is ")") parent-bol 0) ((node-is "]") parent-bol 0) ((node-is "}") parent-bol 0) - ((node-is "labeled_statement") no-indent) + ((node-is "labeled_statement") no-indent 0) + ((parent-is "raw_string_literal") no-indent 0) ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset) ((parent-is "block") parent-bol go-ts-mode-indent-offset) ((parent-is "communication_case") parent-bol go-ts-mode-indent-offset) commit e0bf2da3db69d074e16ceda3f2b5323f2d22d34b Author: Eli Zaretskii Date: Sat Mar 4 10:43:25 2023 +0200 ; More accurate doc strings for 'window-at' and 'window-at-x-y'. * lisp/window.el (window-at-x-y): * src/window.c (Fwindow_at): Doc fix. (Bug#61948) diff --git a/lisp/window.el b/lisp/window.el index 083fa9bfd2f..f6ddae854ad 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -4134,6 +4134,10 @@ window-at-x-y edge shared by two windows is attributed to the window on the right (or below). Return nil if no such window can be found. +Tool-bar and tab-bar pseudo-windows are ignored by this function: +if the specified coordinates are in any of these two windows, this +function returns nil. + Optional argument FRAME must specify a live frame and defaults to the selected one. Optional argument NO-OTHER non-nil means to return nil if the window located at the specified coordinates has diff --git a/src/window.c b/src/window.c index a94e1d611c7..0efd6813f8d 100644 --- a/src/window.c +++ b/src/window.c @@ -1729,8 +1729,11 @@ window_from_coordinates (struct frame *f, int x, int y, DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, doc: /* Return window containing coordinates X and Y on FRAME. FRAME must be a live frame and defaults to the selected one. -The top left corner of the frame is considered to be row 0, -column 0. */) +X and Y are measured in units of canonical columns and rows. +The top left corner of the frame is considered to be column 0, row 0. +Tool-bar and tab-bar pseudo-windows are ignored by this function: if +the specified coordinates are in any of these two windows, this +function returns nil. */) (Lisp_Object x, Lisp_Object y, Lisp_Object frame) { struct frame *f = decode_live_frame (frame);