Eli Zaretskii [Sat, 31 Dec 2022 07:24:32 +0000 (09:24 +0200)]
Fix the build broken by latest GnuTLS-related changes
* src/gnutls.c (key_file2_aux): Don't use GNUTLS_PKCS_PBES2_*
constants that are defined only in latest versions of GnuTLS.
(Bug#50507)
(Fgnutls_boot): Mention in the doc string that some flags of
'gnutls_certificate_set_x509_key_file2' are only supported since
GnuTLS 3.6.3.
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings):
* lisp/emacs-lisp/bytecomp.el (bytecomp--warn-dodgy-eq-arg):
Suppress warning using (suspicious FUNCTION), where FUNCTION is
not always `eq`.
* lisp/net/gnutls.el (gnutls-boot-parameters): Add the keys :pass and
:flags, and update the documentation.
* src/gnutls.c (gnutls-boot): Add the keys :pass and :flags, and
update the documentation.
(syms_of_gnutls): Add the symbols :pass, :flags, and the symbols that
correspond to the enumeration constants of the GnuTLS enum
`gnutls_pkcs_encrypt_flags_t'.
(key_file2_aux): Private helper function that translates a list of
symbols to its corresponding `unsigned int' value of the GnuTLS C enum
`gnutls_pkcs_encrypt_flags_t'.
Eli Zaretskii [Fri, 30 Dec 2022 14:43:38 +0000 (16:43 +0200)]
; Fix recently modified docs of 'set-face-attribute' (bug#52493)
* doc/lispref/display.texi (Attribute Functions): Clarify wording
and restore removed information about resetting attributes to
'unspecified' for future frames.
* lisp/faces.el (set-face-attribute): Minor copyedit of doc
string.
Yuan Fu [Fri, 30 Dec 2022 10:56:26 +0000 (02:56 -0800)]
Add treesit-install-language-grammar
Per discussion on emacs-devel, I added function to install and compile
language grammars.
* lisp/treesit.el (treesit-language-source-alist): New variable.
(treesit-install-language-grammar)
(treesit--call-process-signal)
(treesit--install-language-grammar-1): New functions.
Yuan Fu [Fri, 30 Dec 2022 08:47:22 +0000 (00:47 -0800)]
Change "language definition" to "language grammar" in manual.
"Language grammar" is apparently the more widely used term among
people talking about tree-sitter. To avoid confusion, I think it's
good to use that rather than "language definition", which is a term
that I made up :-)
Feel free to revert this if it is too much change.
Jim Porter [Sat, 24 Dec 2022 22:31:50 +0000 (14:31 -0800)]
Fix reference-counting of Eshell I/O handles
This ensures that output targets in Eshell are only closed when Eshell
is actually done with them. In particular, this means that
"{ echo foo; echo bar } | rev" prints "raboof" as expected
(bug#59545).
* lisp/eshell/esh-io.el (eshell-create-handles): Structure the handles
differently so the targets and their ref-count can be shared.
(eshell-duplicate-handles): Reimplement this to share targets between
the original and new handle sets. Add STEAL-P argument.
(eshell-protect-handles, eshell-copy-output-handle)
(eshell-interactive-output-p, eshell-output-object): Account for
changes to the handle structure.
(eshell-close-handle): New function...
(eshell-close-handles, eshell-set-output-handle): ... use it.
(eshell-get-targets): Remove. This only existed to make the previous
implementation of 'eshell-duplicate-handles' work.
* lisp/eshell/esh-cmd.el (eshell-with-copied-handles): New argument
STEAL-P.
(eshell-do-pipelines): Use STEAL-P for the last item in the pipeline.
(eshell-parse-command): Don't copy handles for the last command in the
list; explain why we can't use STEAL-P here.
(eshell-eval-command): When queuing input, set 'eshell-command-body'
and 'eshell-test-body' for the 'if' conditional (see
'eshell-do-eval').
* test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/for-loop-pipe)
(esh-cmd-test/while-loop-pipe, esh-cmd-test/if-statement-pipe)
esh-cmd-test/if-else-statement-pipe): New tests.
(esh-cmd-test/while-loop): Use 'pop' to simplify the test a bit.
* test/lisp/eshell/eshell-test-helpers.el
(eshell-test--max-subprocess-time): Rename to...
(eshell-test--max-wait-time): ... this.
(eshell-wait-for): New function...
(eshell-wait-for-subprocess): ... use it.
* test/lisp/eshell/eshell-tests.el (eshell-test/queue-input): Fix this
test. Previously, it didn't correctly verify that the original
command completed.
* test/lisp/eshell/em-tramp-tests.el
(em-tramp-test/should-replace-command): New macro...
(em-tramp-test/su-default, em-tramp-test/su-user)
(em-tramp-test/su-login, em-tramp-test/sudo-shell)
(em-tramp-test/sudo-user-shell, em-tramp-test/doas-shell)
(em-tramp-test/doas-user-shell): ... use it.
Paul Eggert [Fri, 30 Dec 2022 05:27:45 +0000 (21:27 -0800)]
Default mbox "From " time zone to -0000
* lisp/mail/rmailout.el (rmail-nuke-pinhead-header):
Default the time zone to "-0000" instead of "EST", as "-0000" is
the RFC-2822-and-later standard for unknown time zones.
Paul Eggert [Fri, 30 Dec 2022 03:16:09 +0000 (19:16 -0800)]
In cal-dst, be consistent re default to UTC
* lisp/calendar/cal-dst.el (calendar-standard-time-zone-name)
(calendar-daylight-time-zone-name):
When using alphabetic time zone abbreviations, default to "UTC"
rather than to "EST" or "EDT", to be consistent with the behavior
when using numeric time zone abbreviations.
Also, in the numeric time zone use "-0000" rather than "+0000"
to show that the time zone is unknown; this is the RFC 5322
standard.
LdBeth [Fri, 30 Dec 2022 03:16:09 +0000 (19:16 -0800)]
Fix newsticker timezone decode
'newsticker--decode-rfc822-date' has the regex pattern for
North American timezones but the actual timezone conversion
for them was not implmented. Now cond cases are added to
handle them as specified in RFC822.
Gregory Heytings [Thu, 29 Dec 2022 22:41:58 +0000 (22:41 +0000)]
Clarify the documentation of 'set-face-attribute'
* lisp/faces.el (set-face-attribute): Mention the evaluation order
of attribute-value pairs in the docstring.
* doc/lispref/display.texi (Attribute Functions): Likewise, and
explain with an example that a different argument order might give
different results. Also align the documentation in the manual
with that of the docstring, whose changes were discussed in
bug#57499 but not included in the manual.
Gregory Heytings [Mon, 19 Dec 2022 22:18:22 +0000 (22:18 +0000)]
Handle non-string values in pcomplete
* lisp/pcomplete.el (pcomplete-arg): When
pcomplete-parse-arguments-function returns a non-string value,
return the string the user typed in, and attach the value as a
text property to that string. Fixes bug#59956 and bug#60021.
Gregory Heytings [Thu, 29 Dec 2022 21:50:26 +0000 (21:50 +0000)]
Fix completion when completion-auto-select is set
* lisp/minibuffer.el (completion--do-completion): Do not display
"Complete, but not unique" messages when completion-auto-select is
set. Fixes bug#60359.
Consistent empty-body warning messages for let and let*
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test--with-suppressed-warnings):
Make warning messages for let and let* consistent with other
empty-body warnings.
Warn about code like (when SOME-CONDITION) because these may indicate
bugs. Warnings currently apply to `when`, `unless`, `ignore-error`,
`with-suppressed-warnings` and (as before) `let` and `let*`.
* lisp/emacs-lisp/byte-run.el (with-suppressed-warnings):
Update doc string.
* lisp/emacs-lisp/bytecomp.el: (byte-compile-warning-types)
(byte-compile-warnings): Add empty-body.
(byte-compile-initial-macro-environment):
Add empty-body warning for with-suppressed-warnings.
* lisp/emacs-lisp/macroexp.el (macroexp--expand-all):
Use the empty-body category for let and let*.
* lisp/subr.el (when, unless, ignore-error): Add empty-body warning.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-test--with-suppressed-warnings): Add test cases.
Eli Zaretskii [Thu, 29 Dec 2022 11:52:09 +0000 (13:52 +0200)]
Avoid assertion violations in treesit.c with --enable-checking
* src/treesit.c (Ftreesit_node_first_child_for_pos)
(Ftreesit_node_descendant_for_range): Check validity of buffer
positions before converting them to byte-positions, to avoid
assertion violations in buf_charpos_to_bytepos.
Richard Hansen [Sun, 18 Dec 2022 05:24:16 +0000 (00:24 -0500)]
; whitespace.el: Use the new 'ert-with-buffer-selected' in tests
Commit 286c48137f69fa96b80d197da90c69a42df604a3 added a new
`ert-with-test-buffer-selected' macro. Use that macro in
'whitespace-mode' tests to avoid code duplication. (Bug#60332)
* test/lisp/whitespace-tests.el (whitespace--with-buffer-selected):
Macro deleted.
(whitespace-tests--indirect-clone-breaks-base-markers)
(whitespace-tests--indirect-clone-markers)
(whitespace-tests--regular-clone-markers): Use
'ert-with-buffer-selected'.
Stefan Kangas [Thu, 29 Dec 2022 05:30:09 +0000 (06:30 +0100)]
Merge from origin/emacs-29
909091d7578 ; Minor cleanup for tree-sitter font-lock rules in js-ts-... e78e69b3318 Clean up font-lock rules in js-ts-mode 0a61e4e2b71 ; * doc/lispref/parsing.texi (Using Parser): Minor improv... 398ed75c276 ; * lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragrap... 19b8733aa27 Fix syntax for < and > in c++-ts-mode (bug#60351) f509246ba12 Call tree-sitter parser notifier on the first parse ec6feeaa191 Fix tree-sitter parser notifier recursion
Yuan Fu [Thu, 29 Dec 2022 00:52:47 +0000 (16:52 -0800)]
Clean up font-lock rules in js-ts-mode
Changes for each feature:
- string: Take out string-interpolation bits.
- string-interpolation: New.
- declaration: Rename to definition.
- identifier: Remove.
- property: Use a pred to filter out methods.
- expression: Rename to assignment.
- function: New.
- pattern: Merge into assignment.
* lisp/progmodes/js.el (js--treesit-font-lock-settings): See above.
(js--treesit-property-not-function-p)
(js--treesit-lhs-identifier-query): New variable.
(js--treesit-fontify-assignment-lhs): New functions.
(js-ts-mode): Update feature list.
Yuan Fu [Wed, 28 Dec 2022 23:44:26 +0000 (15:44 -0800)]
Fix syntax for < and > in c++-ts-mode (bug#60351)
< and > are usually punctuation, e.g., in ->. But when used for
templates, they should be considered pairs. Right now we always
consider them as pairs which is incorrect.
Yuan Fu [Wed, 28 Dec 2022 23:19:34 +0000 (15:19 -0800)]
Fix tree-sitter parser notifier recursion
See the comment for detail.
* src/treesit.c (treesit_ensure_parsed): Move the need_reparse short
circuit to the very beginning. Move the call to
treesit_call_after_change_functions to the very end.
Juri Linkov [Wed, 28 Dec 2022 18:48:40 +0000 (20:48 +0200)]
* lisp/help.el: Use 'C-h C-q' to toggle 'help-quick' window (bug#60249).
(help-map): Bind "C-q" to 'help-quick-toggle'. Rebind "q" to 'help-quit'.
(help-quick): Replace help-quit-or-quick with help-quick-toggle.
(help-quick-toggle): New command.
(help-quit-or-quick): Remove command.
(help-for-help): Replace help-quick-or-quit with help-quick-toggle.
Juri Linkov [Wed, 28 Dec 2022 18:27:07 +0000 (20:27 +0200)]
* lisp/isearch.el: Small fixes.
(isearch-wrap-pause): Mention the new feature of `no' and `no-ding'
in the docstring.
(isearch-lax-whitespace, isearch-forward-thing-at-point): Add the
group 'isearch' since another defgroup changed the default group.
(isearch-delete-char): Use 'isearch-invisible' instead of 'search-invisible'
since the users might change the current value with 'M-s i'.
Juri Linkov [Wed, 28 Dec 2022 18:14:43 +0000 (20:14 +0200)]
* lisp/vc/diff-mode.el (diff-minor-mode-prefix): Replace "ESC" with "\e".
"ESC" looks like an attempt to use kbd syntax in customization.
But actually now 'key-description' is used in 'diff-minor-mode-map'
to convert "\e" to "ESC".
We don't really need to rely on forward-sexp to define what to
transpose. In tree-sitter we can consider siblings as "balanced
expressions", and swap them without doing any movement to calculate
where the siblings in question are.
* lisp/simple.el (transpose-sexps-function): New defvar-local.
(transpose-sexps): Use the new defvar-local if available.
(transpose-subr): Check whether the mover function returns a cons of
conses, then run transpose-subr-1 on the position-pairs.
* lisp/treesit.el (treesit-transpose-sexps): New function.
F. Jason Park [Mon, 26 Dec 2022 05:36:53 +0000 (21:36 -0800)]
Warn of absent networks module in ERC
* doc/misc/erc.texi: Add linkable note in Modules chapter about some
modules being required. Also tweak markup in auth-source section.
* etc/ERC-NEWS: Mention the special role of `networks'.
* lisp/erc/erc-backend.el (erc--server-post-connect-hook): Add
internal hook for core modules to perform post-network-process,
pre-protocol config validation even when they haven't been loaded.
(erc--register-connection): Run `erc--server-post-connect-hook'.
* lisp/erc/erc-networks.el (erc-networks--bouncer-targets,
erc-networks-on-MOTD-end): Fix comments and doc strings. Also change
former from constant to internal variable in case adjustment needed
between releases.
(erc-networks--warn-on-connect): New function to warn about the
`networks' module being absent from `erc-modules'. This could
probably run at any time up to and including when the logical IRC
connection is established, but doing so at the process/protocol
boundary seems ideal.
* lisp/erc/erc-sasl.el (erc--register-connection): Defer to base
method instead of calling `erc-login' explicitly.
* lisp/erc/erc.el (erc-generate-new-buffer-name): Don't reconcile
buffer names when networks module not in play.
(erc-format-target-and/or-network): Don't assume networks module
loaded.
* test/lisp/erc/erc-scenarios-base-unstable.el:
(erc-scenarios-networks-no-module): New test.
* test/lisp/erc/resources/networks/no-module/basic.eld: New test data
file. (Bug#60331.)
F. Jason Park [Wed, 28 Dec 2022 14:18:01 +0000 (06:18 -0800)]
Avoid "already compiled" warning in erc-compat
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search):
Don't `byte-compile' sub-29 secrets wrapper. This was especially
noisy in tests. Ditch closed-over vars via HOF instead of suppressing
because compiling emits "unused lexical" warning on Emacs 27.
Eli Zaretskii [Wed, 28 Dec 2022 13:10:39 +0000 (15:10 +0200)]
Make last change of w32 GUI dialogs conditional and reversible
* src/w32term.c (syms_of_w32term) <w32-yes-no-dialog-show-cancel>:
New boolean variable.
(w32_initialize): Fix query for visible system caret: 'bool' is a
single-byte data type, whereas SystemParametersInfo wants a BOOL,
which is a 32-bit int.
* src/w32menu.c (simple_dialog_show): Show "Cancel" button only if
'w32-yes-no-dialog-show-cancel' is non-nil.
Yuan Fu [Wed, 28 Dec 2022 04:37:29 +0000 (20:37 -0800)]
Add tree-sitter helper functions for Imenu
We didn't add an integration for Imenu because we aren't sure what
should it look like. Now we have a pretty good idea. All the major
modes copy-paste the two Imenu functions and tweaks them in a standard
way. With the addition of treesit-defun-type-regexp and
treesit-defun-name-function, now is a good time to standardize Imenu
integration.
In the next commit we update all the major modes to use this
integration.
* doc/lispref/modes.texi (Imenu): Add manual.
* doc/lispref/parsing.texi (Tree-sitter major modes): Update manual.
* lisp/treesit.el (treesit-simple-imenu-settings): New varaible.
(treesit--simple-imenu-1)
(treesit-simple-imenu): New functions.
(treesit-major-mode-setup): Setup Imenu.
Yuan Fu [Wed, 28 Dec 2022 01:02:03 +0000 (17:02 -0800)]
Fix treesit--things-around (bug#60355)
Current implementation of treesit--things-around only searches forward
for REGEXP and go up the tree until it finds a valid thing, if nothing
matches it gives up. This makes it sometimes miss defuns. The new
implementation tries multiple times (of search forward + go up) until
it exhausts all possible defun nodes.
* lisp/treesit.el (treesit--things-around): New implementation.
(treesit--navigate-defun): Refactor to use treesit-node-top-level to
simplify code, and add some guards in the predicate function.
* test/src/treesit-tests.el:
(treesit--ert-defun-navigation-elixir-program): New variable.
(treesit-defun-navigation-nested-4): New test.
Yuan Fu [Tue, 27 Dec 2022 23:07:03 +0000 (15:07 -0800)]
Improve treesit-node-top-level and treesit-parent-until
* lisp/treesit.el (treesit-node-top-level): Now it can accept a
predicate function. Add an optional argument INCLUDE-NODE.
(treesit-parent-until): Add an optional argument INCLUDE-NODE.
Stefan Kangas [Tue, 27 Dec 2022 16:24:18 +0000 (17:24 +0100)]
Make elide-head-headers-to-hide more forgiving
* lisp/elide-head.el (elide-head-headers-to-hide): Make regexp
more forgiving of line breaks and comment characters in address.
* test/lisp/elide-head-tests.el (gpl3-6): New test.