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.
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 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.
* 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.
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.
* 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.
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.
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.
* 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 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.
* test/lisp/erc/erc-scenarios-base-compat-rename-bouncer.el: Fix file
name in prop line and footer.
* test/lisp/erc/erc-scenarios-base-local-modules.el: Fix file name in
prop line and footer.
* test/lisp/erc/erc-scenarios-base-netid-samenet.el: Fix file name in
prop line and footer.
* test/lisp/erc/erc-scenarios-base-upstream-recon-soju.el: Fix file
name in prop line and footer.
* test/lisp/erc/erc-scenarios-base-upstream-recon-znc.el: Fix file
name in prop line and footer.
Tramp currently isn't able to handle this, so the result will just
produce an error (bug#61024).
* lisp/eshell/esh-proc.el (eshell-gather-process-output): Check for a
remote 'default-directory' before trying to make a pipe process.
* test/lisp/eshell/esh-proc-tests.el
(esh-var-test/output/remote-redirect): New test.
* 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.
It still doesn't work for an AFTER that's a key, though, since
`key-parse' produces vectors, and keymaps contain integers.
* lisp/keymap.el (keymap-set-after): Only parse AFTER as a key if it's
a string. For consistency, use `key-parse' on the definition if it's
a string, just like `keymap-set'.
* test/src/keymap-tests.el (keymap-tests--command-3): New dummy command.
(keymap-set-after-menus): New test. Check that we can insert a menu
item after a specific entry.
It's stricter than `kbd', and doesn't try to do anything with key
sequences that look like macros.
* lisp/keymap.el (keymap-lookup): Use `key-parse' instead of `kbd'.
* test/src/keymap-tests.el (keymap-set-after-menus): Test the
`keymap-set-after' API.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
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.
* 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.
* 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.
* 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.
* lisp/erc/erc-common.el (define-erc-module): Add symbol property
`erc-module' to minor modes defined as part of a module.
* lisp/erc/erc.el (erc--merge-local-modes): Be more conservative when
persisting local minor-mode state across ERC sessions. User and
third-party modes that were not defined via `define-erc-modules'
should be left alone.
(erc-open): Run major-mode hooks and enable minor modes after prompt
has been set up. This ensures that module-setup code can access a
fully initialized `erc-input-marker'.
* test/lisp/erc/erc-tests.el (erc--merge-local-modes): Add mocks for
`erc-module' symbol property and a test case covering some foreign ERC
mode.
(define-erc-module--global, define-erc-module--local): Expect the
`erc-module' symbol property to be defined for mode symbols and
aliases. (Bug#60784.)
* lisp/erc/erc.el (erc--target-priors): New internal variable to do
for target buffers what `erc--server-reconnecting' does for server
buffers.
(erc-open): Source the state of a local module's mode variable from
its actual buffer rather than its server buffer. Additionally, make
all local variables from a prior session available to
module-activation functions and `erc-mode' hooks, even when
`erc-reuse-buffers' is nil. This bug arrived with the introduction of
"local-modules" (bug#57955).
* test/lisp/erc/erc-scenarios-base-local-modules.el
(erc-scenarios-base-local-modules--toggle-helpers): Remove useless
`with-current-buffer'.
(erc-scenarios-base-local-modules--local-var, erc--phony-sblm--enable,
erc--phony-sblm--disable, erc--phony-sblm--mode): Add fake local
module and data var for test scenario.
(erc-scenarios-base-local-modules--var-persistence) Add slightly hacky
test case with promise to improve later when splitting the file.
Fmake_indirect_buffer can be told whether to run buffer hooks since
bug#49160, but until now it ran buffer-list-update-hook irrespective
of this.
* src/buffer.c (Fmake_indirect_buffer): Don't run
buffer-list-update-hook when called with a non-nil
INHIBIT-BUFFER-HOOKS argument.
(run_buffer_list_update_hook): Don't special-case NULL argument, as
no such callers remain.
* test/src/buffer-tests.el
(buffer-tests-inhibit-buffer-hooks-indirect): Test whether indirect
buffer hooks are run regardless of whether base buffer hooks are
inhibited. Check that all three buffer hooks, not just
kill-buffer-query-functions, are inhibited.
* 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.
* 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.
* 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.
* lisp/simple.el (first-completion): Add the text-property 'first-completion'
when the first completion is at the beginning of the buffer.
* test/lisp/minibuffer-tests.el (completions-header-format-test):
Revert the recent change.
* 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.
* src/coding.c (encode_coding_utf_8): Fix encoding with
'utf-8-auto': it should produce BOM, per the documentation of
the :bom attribute. (Bug#60750)
* lisp/international/mule.el (define-coding-system): Doc fix.
* test/src/coding-tests.el (coding-tests): Use
'with-coding-priority' instead of 'prefer-coding-system', as the
latter has global persistent effect and affects further tests.
* lisp/erc/erc-networks.el
(erc-networks--copy-server-buffer-functions): New internal hook
through which modules can perform housekeeping when server buffers
belonging to the same network context are merged.
(erc-networks--copy-over-server-buffer-contents): Run new internal
hook `erc-networks--copy-server-buffer-functions'.
* lisp/erc/erc-track.el (erc-track-enable, erc-track-disable): Manage
membership in `erc-networks--copy-server-buffer-functions' hook.
(erc-track--replace-killed-buffer): New function to replace server
buffer being killed in `erc-modified-channels-alist'.
* test/lisp/erc/erc-scenarios-base-association.el
(erc-scenarios-networks-merge-server-track): New test.
* test/lisp/erc/resources/networks/merge-server/track.eld: New test
data. (Bug#60560.)
* test/lisp/erc/erc-services-tests.el
(erc--auth-source-search--plstore-standard,
erc--auth-source-search--plstore-announced,
erc--auth-source-search--plstore-overrides): Kill buffer renamed by
plstore. In the future, try using the `:buffer' keyword introduced in
Emacs 29.
* test/lisp/erc/resources/erc-d/erc-d-t.el
(erc-d-t-kill-related-buffers): Don't forget about `erc-dcc-chat-mode'
buffers.
* 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.