summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix c-ts-mode preproc directive indentationYuan Fu2023-03-041-0/+34
| | | | | | | | | | | | | | | 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.
* More robustly unspoof HOME in Eglot tests (bug#61637)João Távora2023-03-041-9/+8
| | | | | | | | | | | | | | | | | | | | 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.
* Fix c-ts-mode empty line indentation (bug#61893)Yuan Fu2023-03-011-8/+25
| | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Make the "rest sibling" matchers catch the case where NODE is nil, when indenting an empty line. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
* ruby-mode: Fix method call indentation in rhs of multiple assignmentDmitry Gutov2023-02-281-0/+5
| | | | | | | * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Special-case assignment that follows a comma-separated list (bug#61871). * test/lisp/progmodes/ruby-mode-resources/ruby.rb: Add case.
* ruby-smie-rules: Fix misindentation of a method call after assignmentDmitry Gutov2023-02-271-0/+4
| | | | | | | | | * lisp/progmodes/ruby-mode.el (ruby-smie-rules): Fix indentation of a method call after assignment with ruby-after-operator-indent=nil (bug#61822). * test/lisp/progmodes/ruby-mode-resources/ruby-after-operator-indent.rb: Add corresponding example.
* Eglot: rename and redocument encoding-related functions (bug#61726)João Távora2023-02-261-5/+5
| | | | | | | | | | | | | | | | | | | | | | * lisp/progmodes/eglot.el (eglot-current-column): Obsolete. (eglot-lsp-abiding-column): Obsolete. (eglot-current-column-function): Obsolete. (eglot-current-linepos-function): Rename from eglot-current-column-function. (eglot-utf-8-linepos): Rename from eglot-bytewise-column. (eglot-utf-16-linepos): Rename from eglot-lsp-abiding-column. (eglot-utf-32-linepos): Rename from eglot-current-column. (eglot-move-to-current-column): Obsolete. (eglot-move-to-lsp-abiding-column): Obsolete. (eglot-move-to-column-function): Obsolete. (eglot-move-to-linepos-function): Rename from eglot-move-to-column-function. (eglot-move-to-utf-8-linepos): Rename from eglot-move-to-bytewise-column. (eglot-move-to-utf-16-linepos): Rename from eglot-move-to-lsp-abiding-column. (eglot-move-to-utf-32-linepos): Rename from eglot-move-to-current-column. (eglot--managed-mode): Adjust. (eglot-client-capabilities): Trim whitespace. * test/lisp/progmodes/eglot-tests.el (eglot-test-lsp-abiding-column) (eglot-test-lsp-abiding-column-1): Use new function/variable names.
* ; Set indent-tabs-mode to nil in c-ts-mode indent preproc testYuan Fu2023-02-241-0/+1
| | | | | * test/lisp/progmodes/c-ts-mode-resources/indent-preproc.erts: Set indent-tabs-mode to nil.
* Add declaration_list to c-ts-common-indent-type-regexp-alistDaniel Martín2023-02-201-0/+16
| | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Consider a "declaration_list" a block. (Bug#61635) * test/lisp/progmodes/c-ts-mode-resources/indent.erts (Code): Add a test case.
* Improve tree-sitter indent anchor prev-adaptive-prefix (bug#61314)Yuan Fu2023-02-191-0/+15
| | | | | | | | | | | | | | | | | | | | | | Now prev-adaptive-prefix looks at the current line and checks if it begins with a prefix itself. If it does, prev-adaptive-prefix tries to place the anchor before the prefix on the previous line, rather than after it. - prev line - this line -> This line starts with a "-", i.e., begins with a prefix, so we place the anchor at the beginning of the "-" of the previous line, rather than after it - prev line this line -> This line doesn't start with a prefix, so the anchor is placed after the previous line's "-". * doc/lispref/modes.texi (Parser-based Indentation): Update manual. * lisp/treesit.el: (treesit-simple-indent-presets): Add local variable this-line-has-prefix, base what anchor to return on the value of this-line-has-prefix and whether the prev line has a prefix.
* Cleanup preproc indent for c-ts-mode (bug#61558)Theodor Thornhill2023-02-192-0/+49
| | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Make sure we indent to great-grand-parent if inside an #ifdef...#endif block. If grand-parent is root node, then don't indent one step. (c-ts-mode--preproc-offset): New helper anchor function to calculate indent offset.
* Fix point moving when calling python-shell-send-regionkobarity2023-02-181-18/+44
| | | | | | | | | | * lisp/progmodes/python.el (python-shell-buffer-substring): Add `save-excursion' to prevent the point from moving. * test/lisp/progmodes/python-tests.el (python-tests-should-not-move): New helper function to assert that point does not move while calling a function. (python-shell-buffer-substring-*): Use `python-tests-should-not-move'. (Bug#61463)
* Fix indentation for closing bracket in c-ts-mode (bug#61398)Yuan Fu2023-02-121-0/+27
| | | | | | | * lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Move the rule earlier. (c-ts-base-mode): Add move block type. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.
* ruby-ts-mode: Fix indentation inside empty if/unless/case/defDmitry Gutov2023-02-091-0/+16
| | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Add new rule. * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-indent-empty-if-else): New test.
* Fix c-ts-mode indentationYuan Fu2023-02-061-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sign, ok, there's another edge case: else if statements. Because "else if" is usually implemented as just another if statement nested in the else branch, this creates additional levels that indentation needs to ignore. I converted c-ts-common-indent-block-type-regexp + c-ts-common-indent-bracketless-type-regexp into a new, more flexible variable, c-ts-common-indent-type-regexp-alist, to avoid adding yet more variables in order to recognize else and if statements. * lisp/progmodes/c-ts-common.el: (c-ts-common-indent-type-regexp-alist): New variable. (c-ts-common-indent-block-type-regexp) (c-ts-common-indent-bracketless-type-regexp): Remove variables. (c-ts-common--node-is): New function. (c-ts-common-statement-offset): Use the new variable, and add the "else if" special case. Also merge the code of c-ts-mode--fix-bracketless-indent, because now the code is much more succinct. (c-ts-mode--fix-bracketless-indent): Merge into c-ts-common-statement-offset. * lisp/progmodes/c-ts-mode.el: (c-ts-base-mode): Setup c-ts-common-indent-type-regexp-alist. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
* Fix c-ts-mode indentationYuan Fu2023-02-061-0/+14
| | | | | | | | Turns out I shouldn't have removed the explicit rules. Anyway, now it indents properly. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add rules. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add tests
* Fix c-ts-mode indentation (bug#61291)Yuan Fu2023-02-061-0/+11
| | | | | | | | | | Fix indentation for the semicolon in while (str_a[i++] == str_b[j++]) ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New rule. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
* Use c-ts-common-statement-offset in java-ts-mode (bug#61142)Theodor Thornhill2023-02-061-0/+45
| | | | | | | | | | | | | | | * lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Add new matchers to enable c-ts-common machinery. (java-ts-mode): Add regexps. * lisp/progmodes/c-ts-common.el (c-ts-common-statement-offset): Fix typo in documentation and use the new if statement helpers. (c-ts-common-if-statement-regexp): New defvar. (c-ts-common-nestable-if-statement-p): New defvar. (c-ts-common--fix-nestable-if-statement): New helper. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add test for complicated bracket matching indentation. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Add indent rules for bracketless statements.
* Make c-ts-mode-set-style's effect local (bug#61245)Yuan Fu2023-02-042-3/+3
| | | | | | | | | | | | | | | | Now c-ts-mode-set-style's effect is local, and there is a new function c-ts-mode-set-global-style that changes the global setting. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-style-setter): Use c-ts-mode-set-style. (c-ts-mode-indent-style) (c-ts-mode--prompt-for-style): Minor change in docstring. (c-ts-mode-set-global-style): New function (from c-ts-mode-set-style). (c-ts-mode-set-local-style): Remove function (became c-ts-mode-set-style). (c-ts-mode-set-style): Renamed from c-ts-mode-set-local-style. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Use c-ts-mode-set-style.
* Fix switch statement indentation for go-ts-mode (bug#61238)Davide Masserut2023-02-042-0/+78
| | | | | | | | | | * lisp/progmodes/go-ts-mode.el (go-ts-mode--indent-rules): Add indentation for type switch and select case blocks * test/lisp/progmodes/go-ts-mode-resources/indent.erts: New .erts file to test indentation of Go constructs and prevent regression of bug fixes. * test/lisp/progmodes/go-ts-mode-tests.el: New file with go-ts-mode tests.
* Add tests for compilation support for TypeScript (bug#61104)Theodor Thornhill2023-02-041-1/+5
| | | | | | * test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data): Add new test-cases. (compile-test-error-regexps): Increase expected errors
* ; Fix c-ts-mode indent testYuan Fu2023-02-021-26/+26
| | | | | * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Move the linux style test case down.
* Make c-ts-mode indent tests side-effect-freeYuan Fu2023-02-022-9/+9
| | | | | | | | | | | | | | | | | | Running indent tests changes the global value of c-ts-mode-indent-style. That's not good. This change fixes that. I also refactored the indent style functions a bit. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--prompt-for-style): New function. (c-ts-mode-set-local-style): New function. (c-ts-mode-set-style): Use c-ts-mode--prompt-for-style. Use derived-mode-p when testing for major mode. Remove check of current buffer's major mode since it doesn't matter. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Use c-ts-mode-set-local-style to set the indent style locally.
* Move c-ts-mode--statement-offset to c-ts-common.elYuan Fu2023-01-291-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | Now it can be used by other C-like languages. * lisp/progmodes/c-ts-common.el (c-ts-common-indent-offset): (c-ts-common-indent-block-type-regexp): (c-ts-common-indent-bracketless-type-regexp): New variables. (c-ts-common-statement-offset): (c-ts-mode--fix-bracketless-indent): (c-ts-mode--close-bracket-offset): New functions. * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Change c-ts-mode--statement-offset to c-ts-common-statement-offset. The (parent-is "if_statement") rules are now handled by (node-is "compound_statement"). (c-ts-mode--statement-offset-post-processr): (c-ts-mode--statement-offset): (c-ts-mode--fix-bracketless-indent): Move to c-ts-common.el. (c-ts-base-mode): Setup c-ts-common stuff. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Make the test more challenging.
* Make project-current not error out inside non-existent dirsDmitry Gutov2023-01-281-0/+10
| | | | | | | | * lisp/progmodes/project.el (project-try-vc): Use condition-case to catch 'file-missing' (bug#61107). * test/lisp/progmodes/project-tests.el (project-vc-nonexistent-directory-no-error): New test.
* Fix indentation for c-ts-mode (bug#61026)Yuan Fu2023-01-251-0/+52
| | | | | | | | | | | | | | | | | | | Fix indentation for things like while (true) if (true) { puts ("Hello"); } Note that the outer while loop omits brackets. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--statement-offset-post-processr): New variable. (c-ts-mode--statement-offset): Use the new function. (c-ts-mode--fix-bracketless-indent): New function. (c-ts-base-mode): Use the new function. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.
* Tweak BSD style indentation (bug#60984)Theodor Thornhill2023-01-222-0/+97
| | | | | | | | | * lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Simplify rules. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: New testfile with bsd style indentation examples. * test/lisp/progmodes/c-ts-mode-tests.el (c-ts-mode-test-indentation-bsd): Add a test for the new style.
* ruby-ts-mode: Fix two additional cases with ruby-method-call-indent=nilDmitry Gutov2023-01-221-0/+9
| | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Fix two additional cases with ruby-method-call-indent=nil. * test/lisp/progmodes/ruby-mode-resources/ruby-method-call-indent.rb: Add examples.
* Fix c-ts-mode indent (bug#60873)Yuan Fu2023-01-191-0/+13
| | | | | | * lisp/progmodes/c-ts-mode.el: (c-ts-mode--statement-offset): Handle the edge case. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: Add a test.
* (ruby-ts--indent-rules): Indent inside empty parens properlyDmitry Gutov2023-01-191-0/+12
| | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Consider the case when there are no arguments inside the call yet. * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-indent-call-no-args): Add test.
* (ruby-ts--indent-rules): Add a rule for continuation of a hash pairDmitry Gutov2023-01-191-0/+6
| | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Add a rule for continuation of a hash pair. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Add examples.
* (ruby-ts--parent-call-or-bol): Handle more cases with nested literalsDmitry Gutov2023-01-191-0/+17
| | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--parent-call-or-bol): Handle more cases with nested literals. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Add examples.
* (ruby-ts--statement-container-regexp): Remove "parenthesized_statements"Dmitry Gutov2023-01-191-0/+8
| | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--statement-container-regexp): Remove "parenthesized_statements", it's not really a statement container, not one we'd use for indentation alignment anyway. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Add examples.
* ruby-ts-mode: Handle indent in parenless calls much closer to ruby-modeDmitry Gutov2023-01-191-0/+1
| | | | | | | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--parent-call-or-bol): New function. (ruby-ts--indent-rules): Use it for cases which need special anchoring logic when inside a parenless method call. Remove the ad-hoc handling of pair-hash-pair etc indentation, which was there only for the parenless cases, apparently. Have "No paren, ruby-parenless-call-arguments-indent is nil" case align to the statement, if only because ruby-mode does that. * test/lisp/progmodes/ruby-ts-mode-tests.el: Run indent test for ruby-parenless-call-arguments-indent.rb.
* ruby-ts-mode: Obey the option ruby-method-call-indentDmitry Gutov2023-01-182-0/+2
| | | | | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--method-call-indent-p): New function. (ruby-ts--indent-rules): Use it. * test/lisp/progmodes/ruby-ts-mode-tests.el: Run indent test for ruby-method-call-indent.rb. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Add explicit value for ruby-method-call-indent.
* ruby-ts-mode: Obey the option ruby-after-operator-indentDmitry Gutov2023-01-182-1/+5
| | | | | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--after-op-indent-p): New function. (ruby-ts--indent-rules): Use it. * test/lisp/progmodes/ruby-ts-mode-tests.el: Run indent test for ruby-after-operator-indent.rb. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Make sure indentation vars are at their default values.
* ruby-ts-mode: Fix indent after operator or conditionalDmitry Gutov2023-01-181-0/+13
| | | | | | | | | | | | | | Make it match ruby-mode's indentation behavior. * lisp/progmodes/ruby-ts-mode.el (ruby-ts--binary-indent-anchor): New function. (ruby-ts--indent-rules): Use it instead of a composite matcher. Add a rule for 'conditional'. (ruby-ts--assignment-ancestor, ruby-ts--is-in-condition) (ruby-ts--endless-method): Remove. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: Add examples.
* ruby-ts-mode: Fix/change indentation of a continuation method callDmitry Gutov2023-01-181-0/+13
| | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Fix/change indentation of a continuation method call. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: New examples.
* ruby-ts-mode: Fix indent inside parenthesized_expr and else/end after unlessDmitry Gutov2023-01-181-0/+10
| | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Fix indentation for parenthesized_expression and else/end after 'unless'. * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: New examples.
* ruby-ts-mode: Fix the rules for hanging arrays and hashesDmitry Gutov2023-01-182-0/+24
| | | | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--indent-rules): Fix the rules for hanging arrays and hashes (to line up to parent-bol instead of the opening brace). * test/lisp/progmodes/ruby-mode-resources/ruby-ts.rb: New file with examples. * test/lisp/progmodes/ruby-ts-mode-tests.el: Use it here.
* Fix tree-sitter indent preset function (bug#60270)Yuan Fu2023-01-161-0/+14
| | | | | | | * lisp/treesit.el (treesit-simple-indent-presets): Fix prev-adaptive-prefix so it doesn't return nil if the previous line has no prefix. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
* ruby-ts-mode: Support the option ruby-block-indentDmitry Gutov2023-01-161-0/+1
| | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts--block-indent-anchor): New function. (ruby-ts--indent-rules): Use it. * test/lisp/progmodes/ruby-ts-mode-tests.el: Run indent test for ruby-block-indent.rb.
* ; Add more c-ts-mode indent and filling testsYuan Fu2023-01-153-1/+322
| | | | | | | * test/lisp/progmodes/c-ts-mode-resources/filling.erts: New file. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: More tests. * test/lisp/progmodes/c-ts-mode-tests.el: (c-ts-mode-test-filling): new test.
* Add c-ts-mode testsDaniel Martín2023-01-132-0/+75
| | | | | | | | * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New .erts file to test indentation of typical C constructs and prevent regression of bug fixes. * test/lisp/progmodes/c-ts-mode-tests.el: New file with c-ts-mode tests.
* ; ruby.rb: Fix pattern matching syntax and extend the exampleDmitry Gutov2023-01-091-1/+1
|
* Fix 'python-shell-buffer-substring' when START is in middle of 1st linekobarity2023-01-071-0/+10
| | | | | | | | * lisp/progmodes/python.el (python-shell-buffer-substring): Instead of checking whether START is point-min, check whether START is in the first line. (Bug#60466) * test/lisp/progmodes/python-tests.el (python-shell-buffer-substring-18): New test.
* (ruby-ts-add-log-current-function): Fix when between two methodsDmitry Gutov2023-01-042-0/+6
| | | | | | | | | | | | | | | | * lisp/progmodes/ruby-ts-mode.el (ruby-ts-add-log-current-function): Fix the case when point is between two methods. 'treesit-node-at' returs the 'def' node of the method after point in such case, so it behaved like point was inside the method below. * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-add-log-current-method-outside-of-method): Update the test case. * test/lisp/progmodes/ruby-mode-tests.el (ruby-add-log-current-method-outside-of-method): Mirror that change.
* ; Skip ruby-ts tests if grammar is not availableStefan Kangas2023-01-021-12/+12
| | | | | * test/lisp/progmodes/ruby-ts-mode-tests.el: Properly skip tests if there is no grammar for ruby.
* Add ruby-ts-modePerry Smith2023-01-021-0/+254
| | | | | | | | | | | | | * etc/NEWS: Mention the new mode. * lisp/progmodes/ruby-ts-mode.el: New file. * test/lisp/progmodes/ruby-ts-mode-tests.el: New file. * lisp/progmodes/eglot.el (eglot-server-programs): Add ruby-ts-mode to the Ruby entry. Co-authored-by: Dmitry Gutov <dgutov@yandex.ru>
* ; Add 2023 to copyright years.Eli Zaretskii2023-01-0132-32/+32
|
* Fix python-shell-buffer-substring when retrieving a single statementkobarity2022-12-311-0/+64
| | | | | | | | | | | * lisp/progmodes/python.el (python-shell-buffer-substring): Do not add "if True:" line when retrieving a single statement. (python-shell-send-region): Add a reference to `python-shell-buffer-substring' in docstring. * test/lisp/progmodes/python-tests.el (python-shell-buffer-substring-13) (python-shell-buffer-substring-14, python-shell-buffer-substring-15) (python-shell-buffer-substring-16, python-shell-buffer-substring-17): New tests. (Bug#60142)