diff options
| author | Stefan Kangas | 2023-03-05 06:30:15 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2023-03-05 06:30:15 +0100 |
| commit | 6fb8a4dff7ef22f96ebe1a775240617aabac6526 (patch) | |
| tree | b89b588cd0d76d698ffbc1e7556f28d31b7a45ce | |
| parent | 4b3ccf3092eaf5573b0f4968ee9a4515d04fd061 (diff) | |
| parent | 836044f329a0a96810f2d88471cb040b9d373cce (diff) | |
| download | emacs-6fb8a4dff7ef22f96ebe1a775240617aabac6526.tar.gz emacs-6fb8a4dff7ef22f96ebe1a775240617aabac6526.zip | |
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...
| -rw-r--r-- | doc/emacs/modes.texi | 9 | ||||
| -rw-r--r-- | doc/lispref/modes.texi | 6 | ||||
| -rw-r--r-- | lisp/files.el | 18 | ||||
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 54 | ||||
| -rw-r--r-- | lisp/progmodes/eglot.el | 7 | ||||
| -rw-r--r-- | lisp/progmodes/go-ts-mode.el | 5 | ||||
| -rw-r--r-- | lisp/progmodes/java-ts-mode.el | 20 | ||||
| -rw-r--r-- | lisp/progmodes/ruby-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/rust-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/progmodes/typescript-ts-mode.el | 2 | ||||
| -rw-r--r-- | lisp/subr.el | 5 | ||||
| -rw-r--r-- | lisp/treesit.el | 9 | ||||
| -rw-r--r-- | lisp/window.el | 4 | ||||
| -rw-r--r-- | src/window.c | 7 | ||||
| -rw-r--r-- | test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts | 34 | ||||
| -rw-r--r-- | test/lisp/progmodes/eglot-tests.el | 17 |
16 files changed, 145 insertions, 56 deletions
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 @@ specify which mode you prefer. | |||
| 473 | If you have changed the major mode of a buffer, you can return to | 473 | If you have changed the major mode of a buffer, you can return to |
| 474 | the major mode Emacs would have chosen automatically, by typing | 474 | the major mode Emacs would have chosen automatically, by typing |
| 475 | @kbd{M-x normal-mode}. This is the same function that | 475 | @kbd{M-x normal-mode}. This is the same function that |
| 476 | @code{find-file} calls to choose the major mode. It also processes | 476 | @code{find-file} calls to choose the major mode. If the buffer is |
| 477 | the file's @samp{-*-} line or local variables list (if any). | 477 | visiting a file, this command also processes the file's @samp{-*-} |
| 478 | @xref{File Variables}. | 478 | line and file-local variables list (if any). @xref{File Variables}. |
| 479 | If the buffer doesn't visit a file, the command processes only the | ||
| 480 | major mode specification, if any, in the @samp{-*-} line and in the | ||
| 481 | file-local variables list. | ||
| 479 | 482 | ||
| 480 | @vindex change-major-mode-with-file-name | 483 | @vindex change-major-mode-with-file-name |
| 481 | The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to | 484 | The commands @kbd{C-x C-w} and @code{set-visited-file-name} change to |
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 @@ This anchor is a function that is called with 3 arguments: @var{node}, | |||
| 5117 | @var{parent}, and @var{bol}, and returns the first non-whitespace | 5117 | @var{parent}, and @var{bol}, and returns the first non-whitespace |
| 5118 | character on the previous line. | 5118 | character on the previous line. |
| 5119 | 5119 | ||
| 5120 | @item point-min | 5120 | @item column-0 |
| 5121 | This anchor is a function that is called with 3 arguments: @var{node}, | 5121 | This anchor is a function that is called with 3 arguments: @var{node}, |
| 5122 | @var{parent}, and @var{bol}, and returns the beginning of the buffer. | 5122 | @var{parent}, and @var{bol}, and returns the beginning of the current |
| 5123 | This is useful as the beginning of the buffer is always at column 0. | 5123 | line, which is at column 0. |
| 5124 | 5124 | ||
| 5125 | @item comment-start | 5125 | @item comment-start |
| 5126 | This anchor is a function that is called with 3 arguments: @var{node}, | 5126 | This anchor is a function that is called with 3 arguments: @var{node}, |
diff --git a/lisp/files.el b/lisp/files.el index 387a3b5dc66..6f02aac33d3 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -2775,7 +2775,11 @@ not set local variables (though we do notice a mode specified with -*-.) | |||
| 2775 | 2775 | ||
| 2776 | `enable-local-variables' is ignored if you run `normal-mode' interactively, | 2776 | `enable-local-variables' is ignored if you run `normal-mode' interactively, |
| 2777 | or from Lisp without specifying the optional argument FIND-FILE; | 2777 | or from Lisp without specifying the optional argument FIND-FILE; |
| 2778 | in that case, this function acts as if `enable-local-variables' were t." | 2778 | in that case, this function acts as if `enable-local-variables' were t. |
| 2779 | |||
| 2780 | If invoked in a buffer that doesn't visit a file, this function | ||
| 2781 | processes only the major mode specification in the -*- line and | ||
| 2782 | the local variables spec." | ||
| 2779 | (interactive) | 2783 | (interactive) |
| 2780 | (kill-all-local-variables) | 2784 | (kill-all-local-variables) |
| 2781 | (unless delay-mode-hooks | 2785 | (unless delay-mode-hooks |
| @@ -3925,9 +3929,6 @@ variables. | |||
| 3925 | 3929 | ||
| 3926 | Uses `hack-local-variables-apply' to apply the variables. | 3930 | Uses `hack-local-variables-apply' to apply the variables. |
| 3927 | 3931 | ||
| 3928 | See `hack-local-variables--find-variables' for the meaning of | ||
| 3929 | HANDLE-MODE. | ||
| 3930 | |||
| 3931 | If `enable-local-variables' or `local-enable-local-variables' is | 3932 | If `enable-local-variables' or `local-enable-local-variables' is |
| 3932 | nil, or INHIBIT-LOCALS is non-nil, this function disregards all | 3933 | nil, or INHIBIT-LOCALS is non-nil, this function disregards all |
| 3933 | normal local variables. If `inhibit-local-variables-regexps' | 3934 | normal local variables. If `inhibit-local-variables-regexps' |
| @@ -3937,7 +3938,14 @@ applied. | |||
| 3937 | 3938 | ||
| 3938 | Variables present in `permanently-enabled-local-variables' will | 3939 | Variables present in `permanently-enabled-local-variables' will |
| 3939 | still be evaluated, even if local variables are otherwise | 3940 | still be evaluated, even if local variables are otherwise |
| 3940 | inhibited." | 3941 | inhibited. |
| 3942 | |||
| 3943 | If HANDLE-MODE is t, the function only checks whether a \"mode:\" | ||
| 3944 | is specified, and returns the corresponding mode symbol, or nil. | ||
| 3945 | In this case, try to ignore minor-modes, and return only a major-mode. | ||
| 3946 | If HANDLE-MODE is nil, the function gathers all the specified local | ||
| 3947 | variables. If HANDLE-MODE is neither nil nor t, the function gathers | ||
| 3948 | all the specified local variables, but ignores any settings of \"mode:\"." | ||
| 3941 | ;; We don't let inhibit-local-variables-p influence the value of | 3949 | ;; We don't let inhibit-local-variables-p influence the value of |
| 3942 | ;; enable-local-variables, because then it would affect dir-local | 3950 | ;; enable-local-variables, because then it would affect dir-local |
| 3943 | ;; variables. We don't want to search eg tar files for file local | 3951 | ;; variables. We don't want to search eg tar files for file local |
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 96d2615c1f7..132c44d330a 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -299,6 +299,23 @@ PARENT and BOL are like other anchor functions." | |||
| 299 | ;; prev-sibling doesn't have a child. | 299 | ;; prev-sibling doesn't have a child. |
| 300 | (treesit-node-start prev-sibling))) | 300 | (treesit-node-start prev-sibling))) |
| 301 | 301 | ||
| 302 | (defun c-ts-mode--standalone-parent-skip-preproc (_n parent &rest _) | ||
| 303 | "Like the standalone-parent anchor but skips preproc nodes. | ||
| 304 | PARENT is the same as other anchor functions." | ||
| 305 | (save-excursion | ||
| 306 | (treesit-node-start | ||
| 307 | (treesit-parent-until | ||
| 308 | ;; Use PARENT rather than NODE, to handle the case where NODE is | ||
| 309 | ;; nil. | ||
| 310 | parent (lambda (node) | ||
| 311 | (and node | ||
| 312 | (not (string-match "preproc" (treesit-node-type node))) | ||
| 313 | (progn | ||
| 314 | (goto-char (treesit-node-start node)) | ||
| 315 | (looking-back (rx bol (* whitespace)) | ||
| 316 | (line-beginning-position))))) | ||
| 317 | t)))) | ||
| 318 | |||
| 302 | (defun c-ts-mode--standalone-grandparent (_node parent bol &rest args) | 319 | (defun c-ts-mode--standalone-grandparent (_node parent bol &rest args) |
| 303 | "Like the standalone-parent anchor but pass it the grandparent. | 320 | "Like the standalone-parent anchor but pass it the grandparent. |
| 304 | PARENT, BOL, ARGS are the same as other anchor functions." | 321 | PARENT, BOL, ARGS are the same as other anchor functions." |
| @@ -309,8 +326,8 @@ PARENT, BOL, ARGS are the same as other anchor functions." | |||
| 309 | "Indent rules supported by `c-ts-mode'. | 326 | "Indent rules supported by `c-ts-mode'. |
| 310 | MODE is either `c' or `cpp'." | 327 | MODE is either `c' or `cpp'." |
| 311 | (let ((common | 328 | (let ((common |
| 312 | `(((parent-is "translation_unit") point-min 0) | 329 | `(((parent-is "translation_unit") column-0 0) |
| 313 | ((query "(ERROR (ERROR)) @indent") point-min 0) | 330 | ((query "(ERROR (ERROR)) @indent") column-0 0) |
| 314 | ((node-is ")") parent 1) | 331 | ((node-is ")") parent 1) |
| 315 | ((node-is "]") parent-bol 0) | 332 | ((node-is "]") parent-bol 0) |
| 316 | ((node-is "else") parent-bol 0) | 333 | ((node-is "else") parent-bol 0) |
| @@ -330,13 +347,28 @@ MODE is either `c' or `cpp'." | |||
| 330 | ((parent-is "labeled_statement") | 347 | ((parent-is "labeled_statement") |
| 331 | c-ts-mode--standalone-grandparent c-ts-mode-indent-offset) | 348 | c-ts-mode--standalone-grandparent c-ts-mode-indent-offset) |
| 332 | 349 | ||
| 333 | ((node-is "preproc") point-min 0) | 350 | ;; Preproc directives |
| 334 | ((node-is "#endif") point-min 0) | 351 | ((node-is "preproc") column-0 0) |
| 335 | ((match "preproc_call" "compound_statement") point-min 0) | 352 | ((node-is "#endif") column-0 0) |
| 336 | 353 | ((match "preproc_call" "compound_statement") column-0 0) | |
| 337 | ((n-p-gp nil "preproc" "translation_unit") point-min 0) | 354 | |
| 338 | ((n-p-gp nil "\n" "preproc") great-grand-parent c-ts-mode--preproc-offset) | 355 | ;; Top-level things under a preproc directive. Note that |
| 339 | ((parent-is "preproc") grand-parent c-ts-mode-indent-offset) | 356 | ;; "preproc" matches more than one type: it matches |
| 357 | ;; preproc_if, preproc_elif, etc. | ||
| 358 | ((n-p-gp nil "preproc" "translation_unit") column-0 0) | ||
| 359 | ;; Indent rule for an empty line after a preproc directive. | ||
| 360 | ((and no-node (parent-is ,(rx (or "\n" "preproc")))) | ||
| 361 | c-ts-mode--standalone-parent-skip-preproc c-ts-mode--preproc-offset) | ||
| 362 | ;; Statement under a preproc directive, the first statement | ||
| 363 | ;; indents against parent, the rest statements indent to | ||
| 364 | ;; their prev-sibling. | ||
| 365 | ((match nil ,(rx "preproc_" (or "if" "elif")) nil 3 3) | ||
| 366 | c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) | ||
| 367 | ((match nil "preproc_ifdef" nil 2 2) | ||
| 368 | c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) | ||
| 369 | ((match nil "preproc_else" nil 1 1) | ||
| 370 | c-ts-mode--standalone-parent-skip-preproc c-ts-mode-indent-offset) | ||
| 371 | ((parent-is "preproc") c-ts-mode--anchor-prev-sibling 0) | ||
| 340 | 372 | ||
| 341 | ((parent-is "function_definition") parent-bol 0) | 373 | ((parent-is "function_definition") parent-bol 0) |
| 342 | ((parent-is "conditional_expression") first-sibling 0) | 374 | ((parent-is "conditional_expression") first-sibling 0) |
| @@ -392,14 +424,14 @@ MODE is either `c' or `cpp'." | |||
| 392 | `((gnu | 424 | `((gnu |
| 393 | ;; Prepend rules to set highest priority | 425 | ;; Prepend rules to set highest priority |
| 394 | ((match "while" "do_statement") parent 0) | 426 | ((match "while" "do_statement") parent 0) |
| 395 | (c-ts-mode--top-level-label-matcher point-min 1) | 427 | (c-ts-mode--top-level-label-matcher column-0 1) |
| 396 | ,@common) | 428 | ,@common) |
| 397 | (k&r ,@common) | 429 | (k&r ,@common) |
| 398 | (linux | 430 | (linux |
| 399 | ;; Reference: | 431 | ;; Reference: |
| 400 | ;; https://www.kernel.org/doc/html/latest/process/coding-style.html, | 432 | ;; https://www.kernel.org/doc/html/latest/process/coding-style.html, |
| 401 | ;; and script/Lindent in Linux kernel repository. | 433 | ;; and script/Lindent in Linux kernel repository. |
| 402 | ((node-is "labeled_statement") point-min 0) | 434 | ((node-is "labeled_statement") column-0 0) |
| 403 | ,@common) | 435 | ,@common) |
| 404 | (bsd | 436 | (bsd |
| 405 | ((node-is "}") parent-bol 0) | 437 | ((node-is "}") parent-bol 0) |
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 13d30a67083..2f8d2002cd3 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -1079,7 +1079,8 @@ variable (which see) can query the value `eglot-lsp-context' to | |||
| 1079 | decide whether a given directory is a project containing a | 1079 | decide whether a given directory is a project containing a |
| 1080 | suitable root directory for a given LSP server's purposes." | 1080 | suitable root directory for a given LSP server's purposes." |
| 1081 | (let ((eglot-lsp-context t)) | 1081 | (let ((eglot-lsp-context t)) |
| 1082 | (or (project-current) `(transient . ,default-directory)))) | 1082 | (or (project-current) |
| 1083 | `(transient . ,(expand-file-name default-directory))))) | ||
| 1083 | 1084 | ||
| 1084 | ;;;###autoload | 1085 | ;;;###autoload |
| 1085 | (defun eglot (managed-major-mode project class contact language-id | 1086 | (defun eglot (managed-major-mode project class contact language-id |
| @@ -1922,6 +1923,7 @@ If it is activated, also signal textDocument/didOpen." | |||
| 1922 | (eglot--signal-textDocument/didOpen) | 1923 | (eglot--signal-textDocument/didOpen) |
| 1923 | ;; Run user hook after 'textDocument/didOpen' so server knows | 1924 | ;; Run user hook after 'textDocument/didOpen' so server knows |
| 1924 | ;; about the buffer. | 1925 | ;; about the buffer. |
| 1926 | (eglot-inlay-hints-mode 1) | ||
| 1925 | (run-hooks 'eglot-managed-mode-hook)))) | 1927 | (run-hooks 'eglot-managed-mode-hook)))) |
| 1926 | 1928 | ||
| 1927 | (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode) | 1929 | (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode) |
| @@ -3645,8 +3647,7 @@ If NOERROR, return predicate, else erroring function." | |||
| 3645 | (cond (eglot-inlay-hints-mode | 3647 | (cond (eglot-inlay-hints-mode |
| 3646 | (if (eglot--server-capable :inlayHintProvider) | 3648 | (if (eglot--server-capable :inlayHintProvider) |
| 3647 | (jit-lock-register #'eglot--update-hints 'contextual) | 3649 | (jit-lock-register #'eglot--update-hints 'contextual) |
| 3648 | (eglot--warn | 3650 | (eglot-inlay-hints-mode -1))) |
| 3649 | "No :inlayHintProvider support. Inlay hints will not work."))) | ||
| 3650 | (t | 3651 | (t |
| 3651 | (jit-lock-unregister #'eglot--update-hints) | 3652 | (jit-lock-unregister #'eglot--update-hints) |
| 3652 | (remove-overlays nil nil 'eglot--inlay-hint t)))) | 3653 | (remove-overlays nil nil 'eglot--inlay-hint t)))) |
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index ce77cc3973d..e6e8abd6445 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el | |||
| @@ -67,11 +67,12 @@ | |||
| 67 | 67 | ||
| 68 | (defvar go-ts-mode--indent-rules | 68 | (defvar go-ts-mode--indent-rules |
| 69 | `((go | 69 | `((go |
| 70 | ((parent-is "source_file") point-min 0) | 70 | ((parent-is "source_file") column-0 0) |
| 71 | ((node-is ")") parent-bol 0) | 71 | ((node-is ")") parent-bol 0) |
| 72 | ((node-is "]") parent-bol 0) | 72 | ((node-is "]") parent-bol 0) |
| 73 | ((node-is "}") parent-bol 0) | 73 | ((node-is "}") parent-bol 0) |
| 74 | ((node-is "labeled_statement") no-indent) | 74 | ((node-is "labeled_statement") no-indent 0) |
| 75 | ((parent-is "raw_string_literal") no-indent 0) | ||
| 75 | ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset) | 76 | ((parent-is "argument_list") parent-bol go-ts-mode-indent-offset) |
| 76 | ((parent-is "block") parent-bol go-ts-mode-indent-offset) | 77 | ((parent-is "block") parent-bol go-ts-mode-indent-offset) |
| 77 | ((parent-is "communication_case") parent-bol go-ts-mode-indent-offset) | 78 | ((parent-is "communication_case") parent-bol go-ts-mode-indent-offset) |
diff --git a/lisp/progmodes/java-ts-mode.el b/lisp/progmodes/java-ts-mode.el index d31d2d71c38..1115eadde7f 100644 --- a/lisp/progmodes/java-ts-mode.el +++ b/lisp/progmodes/java-ts-mode.el | |||
| @@ -69,10 +69,10 @@ | |||
| 69 | 69 | ||
| 70 | (defvar java-ts-mode--indent-rules | 70 | (defvar java-ts-mode--indent-rules |
| 71 | `((java | 71 | `((java |
| 72 | ((parent-is "program") point-min 0) | 72 | ((parent-is "program") column-0 0) |
| 73 | ((match "}" "element_value_array_initializer") | 73 | ((match "}" "element_value_array_initializer") |
| 74 | parent-bol 0) | 74 | parent-bol 0) |
| 75 | ((node-is "}") point-min c-ts-common-statement-offset) | 75 | ((node-is "}") column-0 c-ts-common-statement-offset) |
| 76 | ((node-is ")") parent-bol 0) | 76 | ((node-is ")") parent-bol 0) |
| 77 | ((node-is "else") parent-bol 0) | 77 | ((node-is "else") parent-bol 0) |
| 78 | ((node-is "]") parent-bol 0) | 78 | ((node-is "]") parent-bol 0) |
| @@ -80,15 +80,15 @@ | |||
| 80 | c-ts-common-comment-start-after-first-star -1) | 80 | c-ts-common-comment-start-after-first-star -1) |
| 81 | ((parent-is "comment") prev-adaptive-prefix 0) | 81 | ((parent-is "comment") prev-adaptive-prefix 0) |
| 82 | ((parent-is "text_block") no-indent) | 82 | ((parent-is "text_block") no-indent) |
| 83 | ((parent-is "class_body") point-min c-ts-common-statement-offset) | 83 | ((parent-is "class_body") column-0 c-ts-common-statement-offset) |
| 84 | ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) | 84 | ((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset) |
| 85 | ((parent-is "annotation_type_body") point-min c-ts-common-statement-offset) | 85 | ((parent-is "annotation_type_body") column-0 c-ts-common-statement-offset) |
| 86 | ((parent-is "interface_body") point-min c-ts-common-statement-offset) | 86 | ((parent-is "interface_body") column-0 c-ts-common-statement-offset) |
| 87 | ((parent-is "constructor_body") point-min c-ts-common-statement-offset) | 87 | ((parent-is "constructor_body") column-0 c-ts-common-statement-offset) |
| 88 | ((parent-is "enum_body_declarations") parent-bol 0) | 88 | ((parent-is "enum_body_declarations") parent-bol 0) |
| 89 | ((parent-is "enum_body") point-min c-ts-common-statement-offset) | 89 | ((parent-is "enum_body") column-0 c-ts-common-statement-offset) |
| 90 | ((parent-is "switch_block") point-min c-ts-common-statement-offset) | 90 | ((parent-is "switch_block") column-0 c-ts-common-statement-offset) |
| 91 | ((parent-is "record_declaration_body") point-min c-ts-common-statement-offset) | 91 | ((parent-is "record_declaration_body") column-0 c-ts-common-statement-offset) |
| 92 | ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) | 92 | ((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset) |
| 93 | ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) | 93 | ((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset) |
| 94 | ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) | 94 | ((parent-is "local_variable_declaration") parent-bol java-ts-mode-indent-offset) |
| @@ -121,7 +121,7 @@ | |||
| 121 | ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) | 121 | ((parent-is "case_statement") parent-bol java-ts-mode-indent-offset) |
| 122 | ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) | 122 | ((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset) |
| 123 | ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) | 123 | ((parent-is "do_statement") parent-bol java-ts-mode-indent-offset) |
| 124 | ((parent-is "block") point-min c-ts-common-statement-offset))) | 124 | ((parent-is "block") column-0 c-ts-common-statement-offset))) |
| 125 | "Tree-sitter indent rules.") | 125 | "Tree-sitter indent rules.") |
| 126 | 126 | ||
| 127 | (defvar java-ts-mode--keywords | 127 | (defvar java-ts-mode--keywords |
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el index 4530b162e6e..b2842c33d29 100644 --- a/lisp/progmodes/ruby-ts-mode.el +++ b/lisp/progmodes/ruby-ts-mode.el | |||
| @@ -557,7 +557,7 @@ a statement container is a node that matches | |||
| 557 | (let ((common | 557 | (let ((common |
| 558 | `( | 558 | `( |
| 559 | ;; Slam all top level nodes to the left margin | 559 | ;; Slam all top level nodes to the left margin |
| 560 | ((parent-is "program") point-min 0) | 560 | ((parent-is "program") column-0 0) |
| 561 | 561 | ||
| 562 | ;; Do not indent here docs or the end. Not sure why it | 562 | ;; Do not indent here docs or the end. Not sure why it |
| 563 | ;; takes the grand-parent but ok fine. | 563 | ;; takes the grand-parent but ok fine. |
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 @@ | |||
| 71 | 71 | ||
| 72 | (defvar rust-ts-mode--indent-rules | 72 | (defvar rust-ts-mode--indent-rules |
| 73 | `((rust | 73 | `((rust |
| 74 | ((parent-is "source_file") point-min 0) | 74 | ((parent-is "source_file") column-0 0) |
| 75 | ((node-is ")") parent-bol 0) | 75 | ((node-is ")") parent-bol 0) |
| 76 | ((node-is "]") parent-bol 0) | 76 | ((node-is "]") parent-bol 0) |
| 77 | ((node-is "}") (and parent parent-bol) 0) | 77 | ((node-is "}") (and parent parent-bol) 0) |
diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el index ca6fd2c09da..b21b1fd2cef 100644 --- a/lisp/progmodes/typescript-ts-mode.el +++ b/lisp/progmodes/typescript-ts-mode.el | |||
| @@ -69,7 +69,7 @@ | |||
| 69 | "Rules used for indentation. | 69 | "Rules used for indentation. |
| 70 | Argument LANGUAGE is either `typescript' or `tsx'." | 70 | Argument LANGUAGE is either `typescript' or `tsx'." |
| 71 | `((,language | 71 | `((,language |
| 72 | ((parent-is "program") point-min 0) | 72 | ((parent-is "program") column-0 0) |
| 73 | ((node-is "}") parent-bol 0) | 73 | ((node-is "}") parent-bol 0) |
| 74 | ((node-is ")") parent-bol 0) | 74 | ((node-is ")") parent-bol 0) |
| 75 | ((node-is "]") parent-bol 0) | 75 | ((node-is "]") parent-bol 0) |
diff --git a/lisp/subr.el b/lisp/subr.el index 2a8c51eb7c4..8ff3b868fab 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2441,8 +2441,9 @@ If the variable `delay-mode-hooks' is non-nil, does not do anything, | |||
| 2441 | just adds the HOOKS to the list `delayed-mode-hooks'. | 2441 | just adds the HOOKS to the list `delayed-mode-hooks'. |
| 2442 | Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', | 2442 | Otherwise, runs hooks in the sequence: `change-major-mode-after-body-hook', |
| 2443 | `delayed-mode-hooks' (in reverse order), HOOKS, then runs | 2443 | `delayed-mode-hooks' (in reverse order), HOOKS, then runs |
| 2444 | `hack-local-variables', runs the hook `after-change-major-mode-hook', and | 2444 | `hack-local-variables' (if the buffer is visiting a file), |
| 2445 | finally evaluates the functions in `delayed-after-hook-functions' (see | 2445 | runs the hook `after-change-major-mode-hook', and finally |
| 2446 | evaluates the functions in `delayed-after-hook-functions' (see | ||
| 2446 | `define-derived-mode'). | 2447 | `define-derived-mode'). |
| 2447 | 2448 | ||
| 2448 | Major mode functions should use this instead of `run-hooks' when | 2449 | Major mode functions should use this instead of `run-hooks' when |
diff --git a/lisp/treesit.el b/lisp/treesit.el index e7a8ad6104f..e680668a353 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el | |||
| @@ -1254,7 +1254,10 @@ See `treesit-simple-indent-presets'.") | |||
| 1254 | (goto-char bol) | 1254 | (goto-char bol) |
| 1255 | (forward-line -1) | 1255 | (forward-line -1) |
| 1256 | (skip-chars-forward " \t")))) | 1256 | (skip-chars-forward " \t")))) |
| 1257 | (cons 'point-min (lambda (&rest _) (point-min))) | 1257 | (cons 'column-0 (lambda (_n _p bol &rest _) |
| 1258 | (save-excursion | ||
| 1259 | (goto-char bol) | ||
| 1260 | (line-beginning-position)))) | ||
| 1258 | ;; TODO: Document. | 1261 | ;; TODO: Document. |
| 1259 | (cons 'and (lambda (&rest fns) | 1262 | (cons 'and (lambda (&rest fns) |
| 1260 | (lambda (node parent bol &rest _) | 1263 | (lambda (node parent bol &rest _) |
| @@ -1358,9 +1361,9 @@ prev-line | |||
| 1358 | 1361 | ||
| 1359 | Returns the first non-whitespace character on the previous line. | 1362 | Returns the first non-whitespace character on the previous line. |
| 1360 | 1363 | ||
| 1361 | point-min | 1364 | column-0 |
| 1362 | 1365 | ||
| 1363 | Returns the beginning of buffer, which is always at column 0. | 1366 | Returns the beginning of the current line, which is at column 0. |
| 1364 | 1367 | ||
| 1365 | comment-start | 1368 | comment-start |
| 1366 | 1369 | ||
diff --git a/lisp/window.el b/lisp/window.el index 576478eef88..08ce8498655 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -4143,6 +4143,10 @@ X and Y are FRAME-relative pixel coordinates. A coordinate on an | |||
| 4143 | edge shared by two windows is attributed to the window on the | 4143 | edge shared by two windows is attributed to the window on the |
| 4144 | right (or below). Return nil if no such window can be found. | 4144 | right (or below). Return nil if no such window can be found. |
| 4145 | 4145 | ||
| 4146 | Tool-bar and tab-bar pseudo-windows are ignored by this function: | ||
| 4147 | if the specified coordinates are in any of these two windows, this | ||
| 4148 | function returns nil. | ||
| 4149 | |||
| 4146 | Optional argument FRAME must specify a live frame and defaults to | 4150 | Optional argument FRAME must specify a live frame and defaults to |
| 4147 | the selected one. Optional argument NO-OTHER non-nil means to | 4151 | the selected one. Optional argument NO-OTHER non-nil means to |
| 4148 | return nil if the window located at the specified coordinates has | 4152 | return nil if the window located at the specified coordinates has |
diff --git a/src/window.c b/src/window.c index bf89261e79c..f4e09f49eae 100644 --- a/src/window.c +++ b/src/window.c | |||
| @@ -1729,8 +1729,11 @@ window_from_coordinates (struct frame *f, int x, int y, | |||
| 1729 | DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, | 1729 | DEFUN ("window-at", Fwindow_at, Swindow_at, 2, 3, 0, |
| 1730 | doc: /* Return window containing coordinates X and Y on FRAME. | 1730 | doc: /* Return window containing coordinates X and Y on FRAME. |
| 1731 | FRAME must be a live frame and defaults to the selected one. | 1731 | FRAME must be a live frame and defaults to the selected one. |
| 1732 | The top left corner of the frame is considered to be row 0, | 1732 | X and Y are measured in units of canonical columns and rows. |
| 1733 | column 0. */) | 1733 | The top left corner of the frame is considered to be column 0, row 0. |
| 1734 | Tool-bar and tab-bar pseudo-windows are ignored by this function: if | ||
| 1735 | the specified coordinates are in any of these two windows, this | ||
| 1736 | function returns nil. */) | ||
| 1734 | (Lisp_Object x, Lisp_Object y, Lisp_Object frame) | 1737 | (Lisp_Object x, Lisp_Object y, Lisp_Object frame) |
| 1735 | { | 1738 | { |
| 1736 | struct frame *f = decode_live_frame (frame); | 1739 | struct frame *f = decode_live_frame (frame); |
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 | |||
| 44 | /* */ | 44 | /* */ |
| 45 | static void | 45 | static void |
| 46 | =-=-= | 46 | =-=-= |
| 47 | |||
| 48 | Code: | ||
| 49 | (lambda () | ||
| 50 | (c-ts-mode) | ||
| 51 | (setq-local indent-tabs-mode nil) | ||
| 52 | (setq-local c-ts-mode-indent-offset 2) | ||
| 53 | (c-ts-mode-set-style 'gnu) | ||
| 54 | (indent-region (point-min) (point-max))) | ||
| 55 | |||
| 56 | Name: Prev-Sibling When Prev-Sibling is Preproc | ||
| 57 | |||
| 58 | =-= | ||
| 59 | static void | ||
| 60 | free_glyph_pool (struct glyph_pool *pool) | ||
| 61 | { | ||
| 62 | if (pool) | ||
| 63 | { | ||
| 64 | #if defined GLYPH_DEBUG | ||
| 65 | int c = 1; | ||
| 66 | #endif | ||
| 67 | int check_this = 3; | ||
| 68 | |||
| 69 | #ifdef stuff | ||
| 70 | int c = 1; | ||
| 71 | #elif defined stuff | ||
| 72 | int e = 5; | ||
| 73 | #else | ||
| 74 | int d = 11; | ||
| 75 | int f = 11; | ||
| 76 | #endif | ||
| 77 | int check_this = 3; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | =-=-= | ||
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 @@ then restored." | |||
| 103 | (set (car spec) (cadr spec))) | 103 | (set (car spec) (cadr spec))) |
| 104 | ((stringp (car spec)) (push spec file-specs)))) | 104 | ((stringp (car spec)) (push spec file-specs)))) |
| 105 | (unwind-protect | 105 | (unwind-protect |
| 106 | (let* ((home (getenv "HOME")) | 106 | (let* ((process-environment |
| 107 | (process-environment | ||
| 108 | (append | 107 | (append |
| 109 | `(;; Set XDF_CONFIG_HOME to /dev/null to prevent | 108 | `(;; Set XDF_CONFIG_HOME to /dev/null to prevent |
| 110 | ;; user-configuration to have an influence on | 109 | ;; user-configuration to have an influence on |
| 111 | ;; language servers. (See github#441) | 110 | ;; language servers. (See github#441) |
| 112 | "XDG_CONFIG_HOME=/dev/null" | 111 | "XDG_CONFIG_HOME=/dev/null" |
| 113 | ;; ... on the flip-side, a similar technique by | 112 | ;; ... on the flip-side, a similar technique by |
| 114 | ;; Emacs's test makefiles means that HOME is set to | 113 | ;; Emacs's test makefiles means that HOME is |
| 115 | ;; /nonexistent. This breaks some common | 114 | ;; spoofed to /nonexistent, or sometimes /tmp. |
| 116 | ;; installations for LSP servers like pylsp, making | 115 | ;; This breaks some common installations for LSP |
| 117 | ;; these tests mostly useless, so we hack around it | 116 | ;; servers like pylsp, rust-analyzer making these |
| 118 | ;; here with a great big hack. | 117 | ;; tests mostly useless, so we hack around it here |
| 118 | ;; with a great big hack. | ||
| 119 | ,(format "HOME=%s" | 119 | ,(format "HOME=%s" |
| 120 | (if (file-exists-p home) home | 120 | (expand-file-name (format "~%s" (user-login-name))))) |
| 121 | (format "/home/%s" (getenv "USER"))))) | ||
| 122 | process-environment)) | 121 | process-environment)) |
| 123 | ;; Prevent "Can't guess python-indent-offset ..." messages. | 122 | ;; Prevent "Can't guess python-indent-offset ..." messages. |
| 124 | (python-indent-guess-indent-offset-verbose . nil) | 123 | (python-indent-guess-indent-offset-verbose . nil) |