Eli Zaretskii [Thu, 15 Dec 2022 21:39:58 +0000 (23:39 +0200)]
Avoid segfaults due to invalid selected-window's buffer
* lisp/startup.el (initial-scratch-message): Don't use \\[...]
commands for substitute-command-keys.
* lisp/simple.el (get-scratch-buffer-create): Don't call
substitute-command-keys on initial-scratch-message, to avoid
signaling an error in rare cases. (Bug#60096)
Make tab-bar-tab-group-format-function also handle current group
* lisp/tab-bar.el (tab-bar--format-tab-group): Call
'tab-bar-tab-group-format-default' to format current group tab.
(tab-bar-tab-group-format-default): Update function to also handle
current group tab (bug#60073).
Ensure package directories for source packages from checkouts
* lisp/emacs-lisp/package-vc.el (package-vc-install-from-checkout):
Set the :dir entry, since `package-vc--unpack-1' assumes the field is
set, as is the case when invoking `package-vc--unpack'.
Eli Zaretskii [Thu, 15 Dec 2022 08:47:11 +0000 (10:47 +0200)]
Mention 'tree-sitter' in user manual and NEWS
* doc/emacs/programs.texi (Program Modes): Mention tree-sitter and
the modes supported by it.
* etc/NEWS: Mention tree-sitter in the Installation Changes
section.
Dmitry Gutov [Thu, 15 Dec 2022 01:21:14 +0000 (03:21 +0200)]
Fix ruby-add-log-current-method after nested class definition
* lisp/progmodes/ruby-mode.el (ruby--add-log-current-indent):
New function.
(ruby-add-log-current-method): Use it.
Check for "class" and "module" indentation to filter out the
definitions which don't include the given position. Also try to
match "def" only once (for performance), because if the closest
one doesn't include the given position, none will.
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-add-log-current-method-after-inner-class-outside-methods)
(ruby-add-log-current-method-after-inner-class-outside-methods-with-text):
New tests.
Add indent rules to js/typescript/tsx-ts-mode (bug#60074)
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts-mode--indent-rules): Add in binary_expression and
jsx_fragment.
* lisp/progmodes/js.el (js--treesit-indent-rules): Add the same rules.
This commit introduces support for the semi-popular TOML
config-format[1] through a new major-mode: toml-ts-mode.
I've read through the full spec[2], and from what I can see this
major-mode should provide correct syntax-highligting for every sort of
config-declaration which adheres to the specification.
Besides that it also adds support for imenu and basic tree-sitter
based navigation.
Daniel Martín [Tue, 13 Dec 2022 21:28:13 +0000 (22:28 +0100)]
Add < and > to the syntax table in c++-ts-mode (bug#60049)
* lisp/progmodes/c-ts-mode.el (c++-ts-mode--syntax-table): Add a
specific syntax table for C++. Consider "<" and ">" open/close
delimiters (C++ templates).
(c++-ts-mode): Use the new syntax table.
Eli Zaretskii [Wed, 14 Dec 2022 18:13:47 +0000 (20:13 +0200)]
Update the documentation of overlays (bug#59996)
* src/buffer.c (Foverlay_recenter, Foverlay_lists): Update the doc
strings.
* lisp/subr.el (copy-overlay): Update comment.
* doc/lispref/internals.texi (Buffer Internals): Remove buffer
fields relevant to the old implementation; add the new interval
tree field.
* doc/lispref/display.texi (Overlays, Managing Overlays): Update
text to be consistent with the new implementation of overlays.
(Managing Overlays): Remove documentation of 'overlay-recenter'.
* etc/NEWS: Mention incompatible aspects of overlay
reimplementation.
Eli Zaretskii [Wed, 14 Dec 2022 15:46:16 +0000 (17:46 +0200)]
; Improve description of scoping and let-bindings
* doc/lispref/variables.texi (Local Variables, Variable Scoping):
Explain the move to lexical-binding and elaborate on 'let*'.
Suggested by Michael Heerdegen <michael_heerdegen@web.de>.
(Bug#60027)
F. Jason Park [Tue, 13 Dec 2022 07:58:03 +0000 (23:58 -0800)]
Don't send erc-sasl-user as USER command argument
* lisp/erc/erc-sasl.el (erc-sasl--send-cap-ls): Add internal switch
for sending an opening "CAP LS". The rationale for not enabling this
by default is twofold: one, it more strongly implies that ERC supports
IRCv3 client capability negotiation, which is somewhat disingenuous;
and, two, We'd still be "faking it" by firing and forgetting, and more
balls in the air makes things less predictable.
(erc--register-connection): Possibly send a "CAP LS" before anything
depending on the value of `erc-sasl--send-cap-ls'. Also, don't
attempt to send `erc-session-username' when it holds an SASL username
because the latter may contain protocol-defying characters.
* test/lisp/erc/resources/base/local-modules/fourth.eld: change user
parameter of "USER" command to reflect nick when `erc-sasl-user' is
set to `:user'. (Bug#59976.)
F. Jason Park [Tue, 13 Dec 2022 07:58:03 +0000 (23:58 -0800)]
Set erc-network to a "given" ID instead of failing
* lisp/erc/erc-networks.el (erc-networks--determine): Return the
so-called "given" ID from a non-nil `:id' keyword arg passed to `erc'
or `erc-tls'.
(erc-networks--allow-unknown-network): Add internal variable to
allow IRC session to continue despite the network being unknown.
(erc-networks--set-name): Tell the user about falling back to a given
ID when the network can't be determined. When that's so, end the
session by destroying the connection unless
`erc-networks--allow-unknown-network' is enabled. (Bug#59976.)
(erc-networks--ensure-announced): Include the fallback announced
server name in the error message.
* test/lisp/erc/erc-networks-tests.el (erc-networks--set-name): Add
dummy server process and don't expect an error to be signaled.
* test/lisp/erc/erc-scenarios-misc.el
(erc-scenarios-networks-announced-missing): Don't expect an error to
be signaled.
* test/lisp/erc/resources/networks/announced-missing/foonet.eld:
Remove "mode" match pattern.
F. Jason Park [Mon, 12 Dec 2022 03:41:43 +0000 (19:41 -0800)]
Limit casemapping to appropriate ranges in ERC
* lisp/erc/erc-common.el (erc-downcase): Use case table for
`erc-downcase' so that case conversions are limited to the ASCII
interval.
* lisp/erc/erc.el (erc-casemapping--rfc1459-strict,
erc--casemapping-rfc1459): Make these case tables instead of
translation tables. The functions in case-table.el modify the
standard syntax table, but that doesn't seem to make sense here,
right?
* test/lisp/erc/erc-tests.el (erc-downcase): Add cases showing
mappings outside of the ASCII range. (Bug#59976.)
F. Jason Park [Mon, 12 Dec 2022 03:41:43 +0000 (19:41 -0800)]
Actually accept non-symbols as IDs in erc-open
* lisp/erc/erc.el (erc-generate-new-buffer-name): Despite what it says
in the documentation, only symbols were being accepted as valid `:id'
entry-point arguments. This uses the interned `princ' representation
of the argument instead.
* test/lisp/erc/erc-scenarios-base-netid-samenet.el
(erc-scenarios-common--base-network-id-same-network): Randomly specify
a string for the ID param instead of a non-nil symbol when opening a
new connection.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common-assert-initial-buf-name): Adjust helper to allow
for non-symbol IDs. (Bug#59976.)
F. Jason Park [Mon, 12 Dec 2022 03:16:07 +0000 (19:16 -0800)]
; Be nicer when updating browse-url var in erc-compat
* lisp/erc/erc-compat.el: Be more cautious about modifying
`browse-url-default-handlers' when loading erc-compat on Emacs 28. A
user may have already added an entry for irc:// URLs before loading
`erc-compat'.
F. Jason Park [Sat, 3 Dec 2022 07:11:24 +0000 (23:11 -0800)]
Respect a nil erc-session-password when reconnecting
* lisp/erc/erc.el (erc-open): Simplify `old-vars' expression.
(erc--compute-server-password): Only compute a server password when
first connecting. For compatibility, this respects third-party code
that expects session passwords in target buffers when initially
non-nil.
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-auth-source-reconnect): Add new test.
* test/lisp/erc/resources/services/auth-source/recon.eld: Add new test
data file. (Bug#59858.)
F. Jason Park [Thu, 1 Dec 2022 07:10:58 +0000 (23:10 -0800)]
Add dedicated auth-source section in ERC manual
* doc/misc/erc.texi: Move auth-source description from the Password
subheading of the Advanced chapter's Connecting section to the new
Integrations section as a new node, Auth-Source, and give it a bit
more structure. Fix various misuses of xref vs. pxref. Convert URL
subheading to subsection and add anchor. Prefer "backend" as a single
word, based on usage in other manuals. Also replace loud "warning" in
SASL troubleshooting section.
* etc/ERC-NEWS: Re-link auth-source mention.
* lisp/erc/erc-sasl.el (erc-sasl-auth-source-function): Update info
node in doc string.
* lisp/erc/erc-services.el (erc-auth-source-services-function):
Re-link auth-source info node in doc string.
* lisp/erc/erc.el (erc-password, erc-auth-source-server-function,
erc-auth-source-join-function): Re-link auth-source info node in doc
strings.
* lisp/emacs-lisp/shortdoc.el
(symbol, comparison): New.
(string, list, number): Remove or change examples that do not have
well-defined results, such as `eq` on strings or floats.
Edit other examples for better illustrating each respective operation.
* lisp/emacs-lisp/shortdoc.el (shortdoc--display-function):
If the parameter of :eval is a string then read, evaluate and print
the result. This was always the intention and is documented behaviour.
Michael Albinus [Wed, 14 Dec 2022 09:52:04 +0000 (10:52 +0100)]
Fix Tramp tests in eglot-tests, prefix tests uniquely
* test/lisp/progmodes/eglot-tests.el (eglot--call-with-fixture):
Use `make-nearby-temp-file'.
(eglot--call-with-tramp-test): Set `tramp-verbose' and
`default-directory'. The latter is needed for `make-nearby-temp-file'.
(eglot-test-tramp-test, eglot-test-tramp-test-2): Tag them as
:expensive-test.
(all): Prefix all tests with `eglot-test-' uniquely.
Juri Linkov [Tue, 13 Dec 2022 17:47:47 +0000 (19:47 +0200)]
Support a function in the BUFFER-LIST arg of list-buffers-noselect (bug#59935)
* lisp/buff-menu.el (Buffer-menu-buffer-list): New buffer-local variable.
(list-buffers-noselect): Set Buffer-menu-buffer-list to 'buffer-list'
that now keeps the buffer-local value of the provided buffer list
or a function that returns the buffer list.
(list-buffers--refresh): Handle buffer-list and Buffer-menu-buffer-list
as a function and as a list.
* lisp/progmodes/project.el (project-list-buffers): Let-bind
'buffer-list-function' used by both legacy code and the new version
of list-buffers-noselect that supports its arg BUFFER-LIST as a function.
Eli Zaretskii [Tue, 13 Dec 2022 15:35:17 +0000 (17:35 +0200)]
Improve resetting face attributes when looking for suitable fonts
* src/xfaces.c (syms_of_xfaces)<face-font-lax-matched-attributes>:
Change the default value to t. Update doc string.
(realize_gui_face): When 'Vface_font_lax_matched_attributes' is t,
reset the 3 default font attributes efficiently. Call
'font_maybe_unset_attribute' only if the value is neither nil nor
t. (Bug#59347)
Yuan Fu [Tue, 13 Dec 2022 04:25:53 +0000 (20:25 -0800)]
Add improved tree-sitter navigation
This new set of functions (and tests) should eliminate
defun-navigation bugs and limitations we currently have. This commit
doesn't change any existing bahavior: treesit-beginning/end-of-defun
and friends are unchanged. The plan is to later switch gear and
replace the current functions with the new ones introduced in this
change.
This is a relatively big change, but I've setup a comprehensive test,
and it should fix current bugs, so I think it's ok to put it on the
release branch.
The gist of the new navigation is to use treesit--defuns-around to
find the previous sibling defun, next sibling defun, and the parent
defun, then use this information to move to previous/next
beginning/end of defun in treesit--navigate-defun.
I also added comprehensive testing that tests all four possible
operations (prev-beg, next-beg, prev-end, next-end) starting at all
possible positions (between two sibling defuns, inside a sibling
defun, etc).
* lisp/treesit.el (treesit-defun-type-regexp): Expand definition to
allow (REGEXP . FILTER). Old functions don't support this, but it
should be fine since we are soon replacing them.
(treesit-defun-tactic)
(treesit-defun-skipper): New variables.
(treesit-default-defun-skipper)
(treesit--defuns-around)
(treesit--top-level-defun)
(treesit--navigate-defun): New functions.
* test/src/treesit-tests.el (treesit--ert-insert-and-parse-marker)
(treesit--ert-collect-positions)
(treesit--ert-test-defun-navigation): New helper functions.
(treesit--ert-defun-navigation-python-program)
(treesit--ert-defun-navigation-js-program)
(treesit--ert-defun-navigation-bash-program)
(treesit--ert-defun-navigation-nested-master): New variables.
(treesit-defun-navigation-nested-1)
(treesit-defun-navigation-nested-2)
(treesit-defun-navigation-nested-3)
(treesit-defun-navigation-top-level): New tests.
Stefan Kangas [Tue, 13 Dec 2022 00:43:48 +0000 (01:43 +0100)]
Add cross-reference to flush-lines
* lisp/replace.el (flush-lines, kill-matching-lines): Add
cross-references between commands, using the names
'(kill|delete)-matching-lines' for symmetry. (Bug#59934)
Daniel Martín [Sun, 11 Dec 2022 14:57:43 +0000 (15:57 +0100)]
Align C++ access specifiers to their enclosing class/struct/union
(bug#59966)
The default style in c++-mode aligns access specifiers like "private",
"public" or "protected" to their enclosing class, struct, or union.
The "ellemtel" style indents access specifiers, but this C++ style is
not supported by c++-ts-mode yet.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): Align access
specifiers to their enclosing class/struct/union.
Randy Taylor [Sun, 11 Dec 2022 02:40:25 +0000 (21:40 -0500)]
Add cmake-ts-mode
* admin/notes/tree-sitter/build-module/batch.sh:
* admin/notes/tree-sitter/build-module/build.sh: Add cmake support.
* etc/NEWS: Mention it.
* lisp/progmodes/cmake-ts-mode.el: New major mode with
tree-sitter support.
* lisp/progmodes/eglot.el (eglot-server-programs): Add it.
Add expression for generic_name in csharp-ts-mode (bug#59897)
Given the below example, we want 'services' to be font-locked in
'font-lock-variable-name-face' in all cases. Previously this only
worked in the first case, and the other was font-locked as
'font-lock-function-name-face'.
Stefan Kangas [Mon, 12 Dec 2022 10:50:38 +0000 (11:50 +0100)]
; Skip two eglot tests when typescript is missing
* test/lisp/progmodes/eglot-tests.el
(javascript-basic, project-wide-diagnostics-typescript): Skip tests
when the npm package "typescript" is not installed.
Yuan Fu [Sun, 11 Dec 2022 22:43:58 +0000 (14:43 -0800)]
Add customizale faces for tree-sitter explorer
* lisp/treesit.el (treesit-explorer-anonymous-node)
(treesit-explorer-field-name): New face.
(treesit--explorer-draw-node): Use the new faces.
(treesit-explore-mode): Change playground to explorer.
Juri Linkov [Sun, 11 Dec 2022 17:24:34 +0000 (19:24 +0200)]
Don't use diff-mode buffer as a patch when it's visiting a file (bug#59962)
* lisp/vc/vc.el (vc-deduce-fileset-1): Don't call diff-vc-deduce-fileset
for diff-mode when buffer-file-name is non-nil. This is because in this case
a file with a diff might be committed to VCS. So don't use it as a patch
to commit with 'C-x v v'.
Fix use-package-defaults defcustom type (bug#59941)
* lisp/use-package/use-package-core.el (use-package-defaults):
Enlarge type to allow for keywords such as :ensure and :pin to be
added later, remedying a failure in test-custom-opts.