Stefan Kangas [Wed, 8 Feb 2023 05:30:15 +0000 (06:30 +0100)]
Merge from origin/emacs-29
c9ba05af8df Fix crashes inside 'xfree' called from treesit.c 746748f5c28 Make java-ts-mode use the c-ts-common-indent-type-regexp-... 87d39a30b12 Fix c-ts-mode indentation 7cb92b53987 Fix c-ts-mode indentation d68ff6016d0 Fix c-ts-mode indentation (bug#61291) 2ac8c4bbd6f (eglot-completion-at-point): Return correct values in :co... 321cbd9a601 Tighten and simplify typescript compilation-mode regexps ... 97533e73ad6 ; * lisp/progmodes/c-ts-common.el (treesit-node-prev-sibl... 9dfccb89fc5 Clarify bug-reference-auto-setup-functions docstring. 17ab426670a * lisp/treesit.el (treesit): Fix shortdoc example form (b... 5a6dfab1e4d Use c-ts-common-statement-offset in java-ts-mode (bug#61142) c3262216abb Add array_initializer to java-ts-mode 79ab62e0bb5 go-ts-mode: Highlight variable declarations 1fab91d852e go-ts-mode: Fix highlighting of function name in call_exp... 07ffe902c63 c-ts-mode: Highlight "property functions" as functions a529b0d6463 rust-ts-mode: Fix highlighting of function name in call_e... 088425538f2 rust-ts-mode--font-lock-settings: Improve consistency 793c24a6ac7 Make sure 'M-x show-paren-local-mode' turns on right away 60089dcfe06 Add to bug-reference-auto-setup-functions after its decla... 26e947ccb14 * lisp/vc/vc.el (vc-find-revision-no-save): Fix parens (b... 948e343496b ; Fix byte-compilation warning 6568a1aaf9a Fix inability to turn show-paren-local-mode on manually (... 24085ba6105 ; go-ts-mode--indent-rules: Indent to 0 at top level 0862a79fef5 Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/... bb999df5d6f ; Fix whitespace of last change 929daafa1d6 ; Fix trivial mistake in emoji--choose-emoji d7b4a8487f6 ; * lisp/isearch.el (emoji--read-emoji): Avoid compilatio... e38ff004631 rust-ts-mode: Highlight variable declarations d12727057d4 rust-ts-mode--indent-rules: Indent to 0 at top level 85705a7059f ; Move misplaces parenthesis in emoji--choose-emoji 18c43bb9d6c Ensure upper bound of font-lock region is less than point... 94f291d1505 ; * lisp/paren.el (show-paren-predicate): Doc fix. (Bug#... 3ffd0eddce6 Highlight more complex function parameters 58dc03ba7e4 No longer use transient in isearch-emoji-by-name 0c125fcc67a Make highlighting more regular across TS modes (bug#61205) 1dd751c3ac4 ; Improve documentation of 'proper-list-p' 96181ed3f09 Document 'plistp' 03d9d18513b Fix display of raised/lowered composed text f13479d9556 Fix installation of tree-sitter grammar on MS-Windows 0358267204d Update the Emacs FAQ for Emacs 29 2c33e2889b4 Fix byte-compilation of *-ts-mode.el files b40a929a3f2 ; ruby-ts--syntax-propertize: Amend commentary b80f36b88c7 Make c-ts-mode-set-style's effect local (bug#61245) 671e5d9fad5 ; * lisp/treesit.el (treesit--font-lock-level-setter): Mi... 69380a88e92 c-ts-mode: Highlight name in parameter declarations 89b550eac29 Fix switch statement indentation for go-ts-mode (bug#61238) 1a123feb181 Fix bidi reordering of sequence of whitespace characters ... 8870b54db99 Add tests for compilation support for TypeScript (bug#61104) 873a0a15085 Add support for TypeScript compilation to compile.el (bug... 3a64f81ebc1 Don't clobber match data in 'y-or-n-p' 4c765d93ab3 Refine the previous change d99b5151f8c Add syntax-propertize-function to ruby-ts-mode f25c15ceb7d ; Fix typos 35e238cae8b Improve documentation of 'header-line-indent-mode' c3f58a66514 Don't casemap erc-sasl-user when set to :nick e444115d026 Improve keymap-global-set and keymap-local-set interactiv...
Stefan Monnier [Tue, 7 Feb 2023 23:03:22 +0000 (18:03 -0500)]
(cconv-convert): Fix regression
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv-analyze-form):
Since we can't always remove the wrapper, make sure the wrapper
accepts the expected calling convention (i.e. called with no args).
Yuan Fu [Mon, 6 Feb 2023 03:32:24 +0000 (19:32 -0800)]
Fix c-ts-mode indentation
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.
Dmitry Gutov [Mon, 6 Feb 2023 22:28:25 +0000 (00:28 +0200)]
(eglot-completion-at-point): Return correct values in :company-kind
* lisp/progmodes/eglot.el (eglot-completion-at-point): Return the
correct values in :company-kind for "EnumMember" and "TypeParameter".
The convention is to use kebab case rather than plain downcasing.
Reported in https://github.com/company-mode/company-mode/issues/1370.
* lisp/net/tramp.el (tramp-methods) <->: Add.
(tramp-completion-file-name-handler-alist):
Add `expand-file-name', `file-exists-p', `file-name-directory' and
`file-name-nondirectory'.
(tramp-dissect-file-name): Do not extra check for
`tramp-default-method-marker'.
(tramp-completion-handle-expand-file-name)
(tramp-completion-handle-file-exists-p)
(tramp-completion-handle-file-name-directory)
(tramp-completion-handle-file-name-nondirectory): New defuns.
(tramp-completion-handle-file-name-all-completions): Remove duplicates.
* test/lisp/net/tramp-tests.el
(tramp-test26-interactive-file-name-completion): New test.
Eli Zaretskii [Mon, 6 Feb 2023 16:28:21 +0000 (18:28 +0200)]
Fix 'hack-local-variables' when EOL conversion is inhibited
* lisp/files.el (hack-local-variables--find-variables): Replace
CRs with newlines only if the original buffer is under explicit
selective-display. (Bug#61321)
* lisp/progmodes/bug-reference.el (bug-reference-auto-setup-functions):
Add clarification to docstring that this variable is for packages, not
for users.
Use c-ts-common-statement-offset in java-ts-mode (bug#61142)
* 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.
Dmitry Gutov [Mon, 6 Feb 2023 02:12:25 +0000 (04:12 +0200)]
go-ts-mode: Fix highlighting of function name in call_expression
* lisp/progmodes/go-ts-mode.el (go-ts-mode--font-lock-settings):
Remove :override from the 'property' rules and move them above
'variable' (bug#61302). Just like in rust-ts-mode.
Dmitry Gutov [Sun, 5 Feb 2023 21:42:18 +0000 (23:42 +0200)]
rust-ts-mode: Fix highlighting of function name in call_expression
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings):
Remove :override from the 'property' rules and move them above
'variable' (bug#61302).
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings):
Remove the rule that highlighted scope identifier in a function call
as type. The existing rules will handle it when it does look like a
type (capitalized).
Tassilo Horn [Sun, 5 Feb 2023 18:54:17 +0000 (19:54 +0100)]
Add to bug-reference-auto-setup-functions after its declaring defvar
If it's the init-value of the defvar, add-hook from a third-party
package will suppress the default functions if it takes place before
bug-reference is loaded.
* lisp/progmodes/bug-reference.el (bug-reference-auto-setup-functions):
Add to bug-reference-auto-setup-functions after its declaring defvar.
Dmitry Gutov [Sun, 5 Feb 2023 17:06:47 +0000 (19:06 +0200)]
Fix inability to turn show-paren-local-mode on manually (bug#61098)
* lisp/paren.el (show-paren-local-mode): Don't kill the local
value when both local and global are t. Because the
show-paren-predicate check in show-paren-function also checks
whether a local (non-nil) value of this variable exists.
Dmitry Gutov [Sun, 5 Feb 2023 16:49:24 +0000 (18:49 +0200)]
rust-ts-mode: Highlight variable declarations
(rust-ts-mode--font-lock-settings): Change scoped_type_identifier
highlight to match similar cases. Highlight variable declarations
inside all kinds of destructuring patterns, not just function
definitions.
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--fontify-pattern):
Rename from 'rust-ts-mode--fontify-parameter'. Check the id node's
parent to avoid touching type identifiers.
Allow unbind to commute with discardN and discardN-preserve-tos
* lisp/emacs-lisp/byte-opt.el (byte-after-unbind-ops):
Add discardN and discardN-preserve-tos, both of which
commute with unbind. This enables subsequent optimisations.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Remove code forcing forward motion after applying certain
transformations; these were only there to keep output identical across
refactorings.
LAP optimiser: bind local variables instead of mutating them
This is a refactoring step: there is no change in how the optimiser
works.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Instead of re-using local variables through mutation, bind them at
point of use. This ensures that there is no value leakage by mistake
and actually reduces the static size of the bytecode of this function
somewhat.
The lousy variable names (tmp, tmp2 etc) are retained but
can at least now be changed into something more descriptive.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Instead of using the O(n) `delq' to remove single instructions, use
the O(1) `setcdr'. To do this, anchor the instruction list in a cons
cell and use the predecessor cell in iteration.
Jonas Bernoulli [Wed, 1 Feb 2023 19:25:15 +0000 (20:25 +0100)]
No longer use transient in isearch-emoji-by-name
* lisp/isearch.el (isearch-emoji-by-name): Use 'emoji--read-emoji'
and if that returns derivations, 'completing-read' to select one
of them. This fixes bug#60740.
* lisp/international/emoji.el (emoji--init): Autoload.
(emoji--read-emoji): New function, which doesn't use transient
and returns a list of the glyph and all derivations, if any.
(emoji--choose-emoji): Use 'emoji--read-emoji'.
Dmitry Gutov [Sun, 5 Feb 2023 13:46:28 +0000 (15:46 +0200)]
Make highlighting more regular across TS modes (bug#61205)
* doc/emacs/display.texi (Parser-based Font Lock):
Update description of treesit-font-lock-level, moving 'property' to
level 4.
* lisp/treesit.el (treesit-font-lock-level): Likewise, in docstring.
* lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Do that here.
* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode): Add a comment.
* lisp/progmodes/go-ts-mode.el (go-ts-mode): Add 'definition' to
level 1. Move 'function', 'property' and 'variable' to level 4.
(go-ts-mode--font-lock-settings): Move a bunch of existing rules
to 'definition'. Add highlighting of function parameters.
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode)
(rust-ts-mode--font-lock-settings): Same. And also change "scoped
identifiers" highlights to only match capitalized names.
Yuan Fu [Sat, 4 Feb 2023 02:35:33 +0000 (18:35 -0800)]
Make c-ts-mode-set-style's effect local (bug#61245)
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.
Dmitry Gutov [Sat, 4 Feb 2023 20:46:41 +0000 (22:46 +0200)]
c-ts-mode: Highlight name in parameter declarations
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings):
Uncomment parameter declaration highlighting (bug#61275).
(c-ts-mode--fontify-declarator): Check that identifier was found.
Some declarations can miss identifier name.
Davide Masserut [Thu, 2 Feb 2023 20:00:02 +0000 (21:00 +0100)]
Fix switch statement indentation for go-ts-mode (bug#61238)
* 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.
Stefan Monnier [Sat, 4 Feb 2023 16:23:31 +0000 (11:23 -0500)]
nadvice: Fix bug#61179
Advising interactive forms relies on the ability to distinguish
interactive forms that do nothing else than return a function.
So, be careful to preserve this info.
Furthermore, interactive forms are expected to be evaluated in
the lexical context captured by the closure to which they belong,
so be careful to preserve that context when manipulating those forms.
* lisp/emacs-lisp/cconv.el (cconv-convert, cconv-analyze-form) <lambda>:
Preserve the info that an interactive form does nothing else than
return a function.
* lisp/emacs-lisp/nadvice.el (advice--interactive-form-1): New function.
(advice--interactive-form): Use it.
(advice--make-interactive-form): Refine to also accept function values
quoted with `quote`. Remove obsolete TODO.
* test/lisp/emacs-lisp/nadvice-tests.el: Don't disallow byte-compilation.
(advice-test-bug61179): New test.
* lisp/emacs-lisp/oclosure.el (cconv--interactive-helper): Allow
the `if` arg to be a form.
* lisp/simple.el (oclosure-interactive-form): Adjust accordingly.
Dmitry Gutov [Sat, 4 Feb 2023 02:16:55 +0000 (04:16 +0200)]
Refine the previous change
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--s-p-query): Fix a typo.
(ruby-ts--syntax-propertize): Use pcase-exhaustive to avoid typos.
Put the last s-t property after heredoc's end (apparently
parse-partial-sexp likes that more). Move first s-t property on
percent literals to the very beginning (to be refined later).
Differentiate the %r{} literals from /.../ ones -- tree-sitter
parses them exactly the same.
Dmitry Gutov [Sat, 4 Feb 2023 01:34:22 +0000 (03:34 +0200)]
Add syntax-propertize-function to ruby-ts-mode
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--s-p-query):
New variable.
(ruby-ts--syntax-propertize): New function.
(ruby-ts--parser-after-change): New function.
(ruby-ts-mode): Use both of them.
Alan Mackenzie [Fri, 3 Feb 2023 20:55:59 +0000 (20:55 +0000)]
CC Mode: Fontify a certain foo * bar class by the asymmetric space heuristic
This fixes bug #61144. If the space around the * is "symmetric" we leave foo
* bar unfontified, a multiplication operation. If it is "asymmetric" we
fontify it as a pointer declaration.
* lisp/progmodes/cc-engine.el (c-fdoc-assymetric-space-about-asterisk): New
macro, extracted from c-forward-decl-or-cast-1.
(c-forward-decl-or-cast-1): Invoke the new macro twice, in CASE 16 (new) and
CASE 17.5 (the source of the macro). In CASE 16, additionally set
unsafe-maybe when appropriate.
Eli Zaretskii [Fri, 3 Feb 2023 14:45:56 +0000 (16:45 +0200)]
Improve documentation of 'header-line-indent-mode'
* doc/lispref/modes.texi (Header Lines): Rewrite the documentation
of 'header-line-indent-mode' and its two variables. Fix the
example.
* doc/lispref/display.texi (Pixel Specification): More accurate
description of what happens with :align-to in header-lines.
Improve indexing. (Bug#61239)
F. Jason Park [Fri, 3 Feb 2023 14:01:04 +0000 (06:01 -0800)]
Don't casemap erc-sasl-user when set to :nick
* lisp/erc/erc-sasl.el (erc-sasl-user): Fix doc string.
(erc-sasl--get-user): Don't apply casemapping when the option
`erc-sasl-user' is set to `:nick'. While many servers and
auth-services providers perform case-folding when comparing SASL
usernames, only some recognize RFC1459 mappings, which ERC previously
applied blindly. Instead, ERC now behaves like other clients in
leaving such preparation in the hands of the server. This bug was
introduced with changes new to ERC 5.5 and Emacs 29 (bug#29108).
Robert Pluim [Thu, 2 Feb 2023 10:37:45 +0000 (11:37 +0100)]
Improve keymap-global-set and keymap-local-set interactive use fix
* lisp/keymap.el (keymap-global-set, keymap-local-set): Add optional
`interactive' arg and use it to decide when to convert the key
specification to a string. Add `advertised-calling-convention'
declarations. (Bug#61149)
Stefan Kangas [Fri, 3 Feb 2023 05:30:24 +0000 (06:30 +0100)]
Merge from origin/emacs-29
96ea27278b4 ; Fix c-ts-mode indent test d963a8f1355 Make c-ts-mode indent tests side-effect-free 8a6bdf88b4b Call treesit_record_change in insert_from_gap_1 a2b77c79dcc Use c-ts-common-statement-offset for closing brackets too 74e715cb729 ; Go back to original point when filling comments in c-ts... b8009bbf2d8 ; Fix error where we pass t to treesit-node-type in c-ts-... 88ccf78b206 ; * src/treesit.c (treesit_predicate_match): Simplify las... 20454128b8b Minor improvements in sqlite.c 3b3c47d977b (treesit_predicate_match): Match node text against regexp... e8334781c9f Improve documentation of gdb-mi's dedicated windows c4988840598 Avoid spurious pause in kill-ring-save (Bug#60841) 382ab516cef Change the default of 'treesit-defun-tactic' for 'c-ts-mode' 4d3428e95a9 Fix docstring fontification of CL's 'defstruct' 1c125baa3f0 Teach 'hs-minor-mode' about tree-sitter based modes 2de0ab5cbd3 ; Doc fixes in keymap.el c6660a6d6de Improve documentation of 'repeat-mode' and related variables be304bb3286 ; * etc/NEWS: Mention the 'utf-8-auto' bugfix (bug#60750).
Yuan Fu [Fri, 3 Feb 2023 02:23:21 +0000 (18:23 -0800)]
Make c-ts-mode indent tests side-effect-free
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.
Yuan Fu [Fri, 3 Feb 2023 01:22:22 +0000 (17:22 -0800)]
Call treesit_record_change in insert_from_gap_1
Before this change, insert_from_gap calls treesit_record_change but
insert_from_gap_1 doesn't. However, insert_from_gap_1 is a public
function and is called in many other places outside of insdel.c. This
could lead to tree-sitter's parse tree becoming out-of-sync with the
buffer content.
This change might fix bug#60650.
* src/insdel.c (insert_from_gap_1): Call treesit_record_change.
(insert_from_gap): Remove call to treesit_record_change.
* admin/notes/tree-sitter/treesit_record_change: New file.
Eli Zaretskii [Thu, 2 Feb 2023 19:45:44 +0000 (21:45 +0200)]
Minor improvements in sqlite.c
* src/sqlite.c (Fsqlite_next): Doc fix. Return nil if SQLITE_DONE
was once seen for this statement. (Bug#61151)
(row_to_value): Cons the value in reverse, to avoid the Fnreverse
call. Patch by Helmut Eller <eller.helmut@gmail.com>.
(Bug#61165)
Kévin Le Gouguec [Sun, 29 Jan 2023 10:23:01 +0000 (11:23 +0100)]
Avoid spurious pause in kill-ring-save (Bug#60841)
'indicate-copied-region' checks whether the region is "highlighted"
and if not, briefly moves point to mark to give a visual cue of the
extent of text that was saved to the kill ring.
The region is considered "highlighted" if (a) it is active and (b) its
face specifies a :background. That latter condition does not account
for the multiple ways in which the face can make the region "visually
distinct" from the default face, so switch to the more extensive
predicate face-differs-from-default-p.
The patch also fixes a couple of issues with the predicate's
implementation, and introduces a new user option in case anyone
happened to enjoy unconditional blinking.
* lisp/faces.el (face-differs-from-default-p): Filter out :extend; add
rationale for the attributes we ignore.
* lisp/simple.el (copy-region-blink-predicate): Add option to let
users explicitly opt into or out of blinking point and mark.
(region-indistinguishable-p): New function to detect
"if there is currently no active region highlighting", leveraging
face-differs-from-default-p.
(indicate-copied-region): Use it.
* src/xfaces.c (merge_face_ref): Allow :stipple to be nil, since it is
a documented valid value for that attribute.
* etc/NEWS: Announce user option.
Make `byte-compile-log-lap` more robust and produce nicer output.
This is of interest for Elisp compiler maintainers only.
* lisp/emacs-lisp/byte-opt.el (bytecomp--log-lap-arg): New.
(byte-compile-log-lap-1): Extract argument conversion and rewrite
in a more modern way, fixing bugs. In particular, tags are now
displayed as "X:" where X is the tag number, and that tag number
is shown as argument to goto-like ops.
(byte-optimize-lapcode): Clean up and simplify logging, producing
useful information when `byte-optimize-log` is `byte` as intended.