Jim Porter [Mon, 16 Jan 2023 02:35:31 +0000 (18:35 -0800)]
Add more detail about how to invoke Eshell commands
* doc/misc/eshell.texi (Variables): Move footnote explaining "REPL"
from here...
(Top): ... to its first use here.
(Commands): Move explanation about kernel functions to here.
(Invocation): Describe command form and Lisp form. Fix documentation
about priority of commands in command form.
(Arguments): Add a cross reference to the Invocation node.
Alan Mackenzie [Tue, 17 Jan 2023 18:15:45 +0000 (18:15 +0000)]
CC Mode: On removal of "typedef", remove pertinent types from c-found-types
For this purpose, record the type names declared by typedef in a text
property, c-typedef, on the typedef. On any change to that "typedef" or a
type, remove the old identifier(s) from c-found-types.
This should fix bug #59671.
* lisp/progmodes/cc-defs.el (c-search-forward-non-nil-char-property): New
macro.
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1): Move the scope of
identifier-start from the "inner" let form to the outer one. Amend the
return value such that the middle element of the second element is now the
position of the "typedef", not merely non-nil.
* lisp/progmodes/cc-fonts.el (c-font-lock-declarators): Disregard the LIMIT
parameter when fontifying the declarators of a typedef construct. Also in
this case, set the c-typedef text property on the "typedef" to the list of
declared types. Amend this list when these declared types change.
(c-font-lock-single-decl): Massage the `types' argument given to
c-font-lock-declarators.
(c-font-lock-cut-off-declarators): Amend to work when the starting point of
the fontification is inside a brace block.
* lisp/progmodes/cc-mode.el (c-before-change-de-typedef)
(c-after-change-de-typedef): New functions.
(c-update-new-id): Replace the erroneous c-end-of-current-token with a clause
containing c-forward-token-2.
(c-before-change): Call c-before-change-de-typedef.
(c-after-change): Call c-after-change-de-typedef.
F. Jason Park [Fri, 13 Jan 2023 14:03:15 +0000 (06:03 -0800)]
Don't preserve non-module minor modes in erc-open
* 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.)
F. Jason Park [Tue, 17 Jan 2023 07:05:16 +0000 (23:05 -0800)]
Use correct buffer for local-module vars in erc-open
* 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.
F. Jason Park [Tue, 10 Jan 2023 19:59:57 +0000 (11:59 -0800)]
; Avoid plist-get as generalized var in erc-compat
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search): The
gv expander for `plist-get' was added in Emacs 28. But ERC still
supports 27, as of this function's introduction, in Emacs 29.
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.
Yuan Fu [Tue, 17 Jan 2023 08:57:54 +0000 (00:57 -0800)]
Fix treesit-node-first-child-for-pos (bug#60127)
The problem is due to a bug in ts_node_first_child_for_pos, but
tree-sitter is moving pretty slowly right now so I reimplemented a
correct version of it in treesit.c.
* src/treesit.c (treesit_cursor_first_child_for_byte): New function.
(Ftreesit_node_first_child_for_pos): Use the new function.
* lisp/htmlfontify.el (hfy-exclude-file-rules):
Fix broken defcustom type; no longer fails test-custom-opts.
Fix regexps not to use newline-sensitive patterns like `.` and `$`
which do not make sense when matching file names.
Better doc string.
* lisp/htmlfontify.el (hfy-list-files): Simplify regexp argument.
Alan Mackenzie [Mon, 16 Jan 2023 17:44:44 +0000 (17:44 +0000)]
CC Mode: Prevent ids in temporary "declarators" getting into c-found-types
This should fix bug #60765. In the scenario type an identifier in front of
foo (bar, baz), as when started a new statement. This temporarily makes the
function call a declarator, and bar and baz types. Don't enter bar and baz
into c-found-types.
* lisp/progmodes/cc-engine.el (c-forward-decl-or-cast-1) (CASE 6): When a
'maybe type triggers this case, set `unsafe-maybe' to non-nil.
João Távora [Mon, 16 Jan 2023 11:48:09 +0000 (11:48 +0000)]
Fix M-x eglot prompt when connection already exists (bug#60557)
Before this change, if a current connection existed at the time of M-x
eglot, user would be first asked to enter into M-x eglot's interactive
spec details about new command line arguments, and only afterwards be
prompted about what to do with the current connection (which could be
to reconnect to it using the same arguments, or tear it down and make
a new one).
This is very confusing, as users may not be fully aware of the
distinction between "reconnect" vs "disconnect-and-connect". They
might not know if any new command line arguments provided are taking
effect or not.
This change simplifies this and removes the option to "reconnect
instead" from M-x eglot (users can do that at any time via M-x
eglot-reconnect). It also ensures that users are informed about a
current connection before asking to enter new command line arguments
and not the other way round.
Yuan Fu [Mon, 16 Jan 2023 08:23:47 +0000 (00:23 -0800)]
Fix tree-sitter indent preset function (bug#60270)
* 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/js.el (js--treesit-indent-rules): Use more parent
anchors and fix typo with wrong indent offset variable.
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Use more parent anchors.
Yuan Fu [Sat, 14 Jan 2023 07:42:44 +0000 (23:42 -0800)]
; Add more c-ts-mode indent and filling tests
* 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.
Yuan Fu [Sun, 15 Jan 2023 08:16:58 +0000 (00:16 -0800)]
Fix statement indent for c-ts-mode (bug#59686) (bug#60280)
Instead of trying to figure out the correct anchor, now we just count
the layers of {} blocks between the node and the root node.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--indent-styles): Use new offset functions
c-ts-mode--close-bracket-offset and c-ts-mode--statement-offset.
(c-ts-mode--bracket-children-anchor): Remove function.
(c-ts-mode--top-level-label-matcher): New variable.
(c-ts-mode--statement-offset)
(c-ts-mode--close-bracket-offset): New offset functions.
Yuan Fu [Sun, 15 Jan 2023 08:15:25 +0000 (00:15 -0800)]
Allow offset in tree-sitter indent rules to be functions
This is needed for fixing C indentation. See next comment.
* doc/lispref/modes.texi (Parser-based Indentation): Update manual.
* lisp/treesit.el (treesit-simple-indent): Try evaluating OFFSET as a
function if it's not integer nor variable.
Yuan Fu [Sat, 14 Jan 2023 07:31:18 +0000 (23:31 -0800)]
Support filling line comments in c-ts-mode
Now we handle line comments separately because for line comments, each
line is an individual node, unlike block comments, where the whole
block comment is a single node. fill-comment-paragraph turns out to
do the job perfectly fine.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--fill-paragraph): Extract out most parts into
c-ts-mode--fill-block-comment.
(c-ts-mode--fill-block-comment): New extracted function.
Yuan Fu [Sat, 14 Jan 2023 07:05:45 +0000 (23:05 -0800)]
; Fix c-ts-mode filling
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--comment-regexp): New variable.
(c-ts-mode--fill-paragraph): Use the new variable, and make sure
start-marker is always initialized.
Further improvement for non-string values in pcomplete
* lisp/pcomplete.el (pcomplete-arg): Use the string representation
of the argument value instead of the text representation of the
argument. Return the value, even when it is not a string, when
index is 'last'. Fixes bug#60464.
* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Indent
inside body.
(java-ts-mode--font-lock-settings): Add rule for name in
annotation_type_element_declaration.
Stefan Monnier [Sat, 14 Jan 2023 14:06:10 +0000 (09:06 -0500)]
apropos.el: Fix bug#60628
* lisp/apropos.el (apropos--map-preloaded-atoms): New function.
(apropos-documentation): Use it.
(apropos-documentation-check-elc-file): Don't presume #@ is preceded by
a newline (since that's not the case any more since commit 900b09c0235d54d5), but be more careful not to burp on false positives.
Fix indentation of object_expressions in csharp-ts-mode
* lisp/progmodes/csharp-mode.el (csharp-ts-mode--indent-rules): Make
sure the opening brace is indented at parent-bol, and everything else
is indented.
Xi Lu [Sat, 7 Jan 2023 14:46:40 +0000 (22:46 +0800)]
Replace 'hfy-find-cmd' with 'directory-files-recursively'.
This removes a potential vulnerability to maliciously
named files. (Bug#60562)
* lisp/htmlfontify.el (hfy-exclude-file-rules): New defcustom.
(hfy-list-files): Reimplement using 'directory-files-recursively'.
Eli Zaretskii [Sat, 14 Jan 2023 08:26:40 +0000 (10:26 +0200)]
Disable and document 'doc-view-mupdf-use-svg' (bug#58041)
* lisp/doc-view.el (doc-view-mupdf-use-svg): Disable by default.
* etc/NEWS: Document. Patch by Visuwesh <visuweshm@gmail.com>.
Do not merge to master.
Eshel Yaron [Sat, 14 Jan 2023 08:12:11 +0000 (10:12 +0200)]
Eglot: don't use "nil" as minibuffer initial input
Doing M-x eglot in a buffer for which buffer-file-name is nil, prompts
the user for a major mode to manage by invoking completing-read. The
way completing-read was called would end up with the string "nil" as
the initial minibuffer input, which is not very useful nor is it a
valid input.
* lisp/progmodes/eglot.el (eglot--guess-contact): Tweak prompt for
major mode. (Bug#60379)
Paul Eggert [Sat, 14 Jan 2023 02:22:47 +0000 (18:22 -0800)]
Fix dependency bug when building lwlib
* lwlib/Makefile.in (DEPFLAGS): Use OBJS to calculate dependency
file names, not ALLOBJS. This fixes a typo introduced
in 2015-05-15 "Replace AC_SUBST_FILE in configure with include in
Makefiles" that caused lwlib/*.o to not be rebuilt sometimes
when that was needed.
Yuan Fu [Sat, 14 Jan 2023 01:26:08 +0000 (17:26 -0800)]
Fix use of build_pure_c_string in treesit.c
This is brought up in bug#60691. build_pure_c_string should only be
used in places such as syms_of_treesit, which are called just once,
during dumping.
(treesit_load_language):
(Ftreesit_pattern_expand):
(Ftreesit_query_expand):
(treesit_eval_predicates): Use new varaibles.
(treesit_check_buffer_size):
(treesit_compose_query_signal_data):
(treesit_check_range_argument):
(Ftreesit_parser_set_included_ranges):
(treesit_predicate_capture_name_to_node):
(treesit_predicate_equal):
(treesit_predicate_match):
(treesit_predicate_pred): Use build_string for signal message.
Daniel Martín [Sun, 8 Jan 2023 13:04:24 +0000 (14:04 +0100)]
Add c-ts-mode tests
* 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.
Yuan Fu [Fri, 13 Jan 2023 01:29:14 +0000 (17:29 -0800)]
Fix c-ts-mode--fill-paragraph
Example:
doc: /* Return non-nil if NODE1 and NODE2 are the same node.
If any one of NODE1 and NODE2 is nil, return nil.
This function uses the same equivalence metric as `equal'. */
* lisp/progmodes/c-ts-mode.el (c-ts-mode--fill-paragraph): Fix the
case where there are words before the /*, like the example above.
Eli Zaretskii [Fri, 13 Jan 2023 08:39:58 +0000 (10:39 +0200)]
Fix minor issues with 'pp' and related commands
* etc/NEWS:
* lisp/emacs-lisp/pp.el (pp-use-max-width, pp-emacs-lisp-code):
Mention in doc string that formatting via 'pp-emacs-lisp-code'
could be slow.
(pp-eval-expression, pp-macroexpand-expression): Honor
'pp-use-max-width'. (Bug#58687)
Gregory Heytings [Thu, 12 Jan 2023 17:47:28 +0000 (19:47 +0200)]
* lisp/simple.el (next-completion): Handle first completion specially.
When completions-header-format is nil and completion-show-help is nil,
the first completion is at the beginning the buffer, so 'M-<down>'
missed it and moved to the second completion. Handle this case by
setting/checking the special text-property 'first-completion' that
is nil at the first call (bug#60411).
* 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/emacs-lisp/package-vc.el (package-vc--unpack): Raise an error
if the package name is empty.
(package-vc-install): Avoid generating an empty file name, if a URL
ends with a slash, and raise an error if the package name is empty.
Alan Mackenzie [Tue, 10 Jan 2023 20:29:37 +0000 (20:29 +0000)]
CC Mode: partially revert commit from 2022-10-04
This reversion is of an ill-advised optimization, which resulted in non-type
identifiers getting fontified as types.
* lisp/progmodes/cc-fonts.el (c-fontify-new-found-type): Rather than writing
the expected face directly to the text, instead remove the `fontified'
property. This allows the full font-lock mechanism to fontify the buffer
correctly.
F. Jason Park [Wed, 4 Jan 2023 07:10:53 +0000 (23:10 -0800)]
Remove obsolete server buffers on MOTD in erc-track
* 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.)
F. Jason Park [Wed, 4 Jan 2023 07:10:53 +0000 (23:10 -0800)]
; Kill some stray buffers left behind by ERC tests
* 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.
Yuan Fu [Mon, 9 Jan 2023 09:44:44 +0000 (01:44 -0800)]
Fix c-ts-mode indentation for 2nd line in block comment (bug#60270)
If the first line is "/*" or "/* ", indent like this:
/*
aaa
If the first line is "/* some text", indent like this:
/* some text
aaa
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles):
(c-ts-mode--looking-at-star): Minor refactor.
(c-ts-mode--comment-2nd-line-matcher)
(c-ts-mode--comment-2nd-line-anchor): New functions.
* lisp/treesit.el (treesit-simple-indent-presets):
prev-adaptive-prefix doesn't handle the comment-start-skip case (i.e,
2nd line) anymore. (Handled by the new matcher.)
Yuan Fu [Mon, 9 Jan 2023 04:30:07 +0000 (20:30 -0800)]
Minor improvement for tree-sitter explorer
If you open an empty python buffer and type
1 + 2
a
b
Currently the explorer only displays the top-level node at point, ie,
only 1 + 2, only a, or only b. That's kind of awkward, so if the
buffer is small, show the entire parse tree.
* lisp/treesit.el (treesit--explorer-refresh): See above.
Yuan Fu [Mon, 9 Jan 2023 03:05:19 +0000 (19:05 -0800)]
Make sure NODE is not the root node in tree-sitter indent (bug#60602)
There are two possible ways to solve the problem raised in the bug
report: either make sure NODE is never the root (so that parent is
never nil), or allow parent to be nil.
If we go with the latter, a lot of matcher and anchor functions need
change (they need to guard against a null parent). I tried it, and
needing to check for null parent is pretty annoying. In comparison,
if NODE is never the root, it is very convenient for the user, and it
doesn't complicate the rule that much (and it's rather intuitive,
people usually don't think of the case where NODE is the root node).
So that's what I choose.
* doc/lispref/modes.texi (Parser-based Indentation): Update manual.
* lisp/treesit.el (treesit-indent-function): Update docstring.
(treesit--indent-1): Make sure NODE is not the root.
Yuan Fu [Mon, 9 Jan 2023 00:57:29 +0000 (16:57 -0800)]
Fix label indent of GNU and Linux style in c-ts-mode (bug#60543)
The previous fix isn't correct.
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--indent-styles): New indent rule. Fix the rule for Linux
style.
(c-ts-mode--top-level-label-matcher): New function.