João Távora [Sat, 6 Jan 2024 23:56:33 +0000 (17:56 -0600)]
Eglot: careful when invoking code actions on no symbol at all
Invoking code actions without a marked region or over a symbol
will trip certain servers up since BEG and END in eglot-code-actions
will be nil, causing 'eglot--pos-to-lsp-position' to assume point (which
is OK) but the 'flymake-diagnostics' call to return all diagnostics.
This causes an absolutely undecipherable JavaScript backtrace to be
sent back to Eglot from typescript-language-server.
Stefan Monnier [Sat, 6 Jan 2024 23:50:25 +0000 (18:50 -0500)]
(describe-package-1): Fix bug#68288
Fix support for multiple maintainers in `describe-package` and
in `package-report-bug`.
* lisp/emacs-lisp/package.el (describe-package-1): There's no
`:maintainers:`, instead `:maintainer` can hold a list of maintainers.
(package-maintainers): Adapt to the possibility of having
multiple maintainers.
(package-report-bug): Don't burp if the package is not installed.
Eli Zaretskii [Sat, 6 Jan 2024 11:26:29 +0000 (13:26 +0200)]
Fix icons.el when icon does not exist as a file
* lisp/emacs-lisp/icons.el (icons--create): Handle the case when
ICON is a file that doesn't exists or is unreadable. Suggested by
David Ponce <da_vid@orange.fr>. (Bug#66846)
Fix file-name resolution in *compilation* and *grep* buffers
Resolving symlinks in file names could lead to non-existent files
if some leading directory is a symlink to its parent.
In emacs 28 'expand-file-name' was replaced by 'file-truename' to
solve bug #8035.
* lisp/progmodes/compile.el (safe-expand-file-name): New function.
(compilation-find-file-1): Call 'safe-expand-file-name'. (Bug#67930)
Eli Zaretskii [Sat, 6 Jan 2024 09:15:31 +0000 (11:15 +0200)]
; Improve documentation of 'buffer-match-p'
* doc/lispref/buffers.texi (Buffer List):
* doc/lispref/windows.texi (Choosing Window): Add caveats for
calling 'buffer-match-p' too early, when CONDITION is
'derived-mode' or 'major-mode'. (Bug#68081)
When 'isearch-wrap-pause' is 'no' or 'no-ding', let-bind 'isearch-cmds'
to avoid changing it by 'isearch-push-state' in 'isearch-repeat',
so that a later DEL (isearch-delete-char) doesn't stop at the
intermediate failing state (bug#68158).
Eli Zaretskii [Fri, 5 Jan 2024 07:38:58 +0000 (09:38 +0200)]
Improve documentation of derived modes and their parents
* doc/lispref/modes.texi (Derived Modes): Expand documentation of
functions that manipulate parent modes of a derived mode.
Document 'provided-mode-derived-p'. Improve indexing.
Stefan Monnier [Fri, 5 Jan 2024 03:12:14 +0000 (22:12 -0500)]
* lisp/startup.el (startup--load-user-init-file): Fix last change
Use `condition-case-unless-debug` only in the branch when
`--debug-init` is not in use, otherwise it prevents `handler-bind`
from triggering the debugger.
Graham Marlow [Tue, 2 Jan 2024 21:58:22 +0000 (13:58 -0800)]
Improve yaml-ts-mode fill-paragraph (bug#68226)
When using fill-paragraph on a block_scalar (the element within a
block_node) fill the paragraph such that the contents remain
within the block_node. This fixes the previous behavior that would
clobber a block_node.
Stefan Monnier [Tue, 26 Dec 2023 02:41:08 +0000 (21:41 -0500)]
(backtrace-on-redisplay-error): Use `handler-bind`
Reimplement `backtrace-on-redisplay-error` using `push_handler_bind`.
This moves the code from `signal_or_quit` to `xdisp.c` and
`debug-early.el`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace):
Add `base` arg to strip "internal" frames.
(debug--early): New function, extracted from `debug-early`.
(debug-early, debug-early--handler): Use it.
(debug-early--muted): New function, extracted (translated) from
`signal_or_quit`; trim the buffer to a max of 10 backtraces.
* src/xdisp.c (funcall_with_backtraces): New function.
(dsafe_calln): Use it.
(syms_of_xdisp): Defsym `Qdebug_early__muted`.
* src/eval.c (redisplay_deep_handler): Delete var.
(init_eval, internal_condition_case_n): Don't set it any more.
(backtrace_yet): Delete var.
(signal_or_quit): Remove special case for `backtrace_on_redisplay_error`.
* src/keyboard.c (command_loop_1): Don't set `backtrace_yet` any more.
* src/lisp.h (backtrace_yet): Don't declare.
Stefan Monnier [Wed, 27 Dec 2023 20:06:32 +0000 (15:06 -0500)]
(signal_or_quit): Preserve error object identity
Make sure we build the (ERROR-SYMBOL . ERROR-DATA) object only once
when signaling an error, so that its `eq` identity can be used.
It also gets us a tiny bit closer to having real "error objects"
like in most other current programming languages.
* src/eval.c (maybe_call_debugger): Change arglist to receive the error
object instead of receiving the signal and the data separately.
(signal_or_quit): Build the error object right at the beginning so it
stays `eq` to itself.
Rename the `keyboard_quit` arg to `continuable` so say what it does
rather than what it's used for.
(signal_quit_p): Change arg to be the error object rather than just the
error-symbol.
* src/keyboard.c (cmd_error_internal, menu_item_eval_property_1):
Adjust calls to `signal_quit_p` accordingly.
* test/src/eval-tests.el (eval-tests--error-id): New test.
Stefan Monnier [Wed, 27 Dec 2023 04:56:09 +0000 (23:56 -0500)]
eval.c: Add new var `lisp-eval-depth-reserve`
Rather than blindly increase `max-lisp-eval-depth` when entering the
debugger or running `signal-hook-function`, use this new "reserve"
to keep track of how much we have grown the stack for "debugger"
purposes so that for example recursive calls to `signal-hook-function`
can't eat up the whole C stack.
* src/eval.c (max_ensure_room): Rewrite.
(restore_stack_limits): Move before `max_ensure_room`. Rewrite.
(call_debugger, signal_or_quit): Adjust calls accordingly.
Also grow `max-lisp-eval-depth` for `hander-bind` handlers.
(init_eval_once): Don't initialize `max_lisp_eval_depth` here.
(syms_of_eval): Initialize it here instead.
Add new var `lisp-eval-depth-reserve`.
Stefan Monnier [Tue, 26 Dec 2023 04:55:53 +0000 (23:55 -0500)]
(macroexp--with-extended-form-stack): Use plain `let`
`macroexp--with-extended-form-stack` used manual push/pop so that upon
non-local exits the "deeper" value is kept, so the error handler gets
to know what was the deeper value, so as to be able to compute more
precise error locations.
Replace this with a `handler-bind` which catches that "deeper" value
more explicitly.
* lisp/emacs-lisp/bytecomp.el (bytecomp--displaying-warnings):
Use `handler-bind` to catch the value of `byte-compile-form-stack`
at the time of the error. Also consolidate the duplicated code.
* lisp/emacs-lisp/macroexp.el (macroexp--with-extended-form-stack):
Use a plain dynbound let-rebinding.
Stefan Monnier [Thu, 21 Dec 2023 04:31:39 +0000 (23:31 -0500)]
Move batch backtrace code to `top_level_2`
Move ad-hoc code meant to ease debugging of bootstrap (and batch mode)
to `top_level_2` so it doesn't pollute `signal_or_quit`.
* src/lisp.h (pop_handler, push_handler_bind): Declare.
* src/keyboard.c (top_level_2): Setup an error handler to call
`debug-early` when noninteractive.
* src/eval.c (pop_handler): Not static any more.
(signal_or_quit): Remove special case for noninteractive use.
(push_handler_bind): New function, extracted from `Fhandler_bind_1`.
(Fhandler_bind_1): Use it.
(syms_of_eval): Declare `Qdebug_early__handler`.
* lisp/emacs-lisp/debug-early.el (debug-early-backtrace): Weed out
frames below `debug-early`.
(debug-early--handler): New function.
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--error-frame, bytecomp--byte-op-error-backtrace):
Make test pass again and simplify, using handler-bind instead
of the previous debugger hack.
Stefan Monnier [Thu, 28 Dec 2023 05:46:36 +0000 (00:46 -0500)]
Fix ert-tests.el for the new `handler-bind` code
Now that `ert.el` uses `handler-bind` instead of `debugger`, some
details of the behavior have changed. More specifically,
three tests are now broken, but these basically tested the failure
of ERT's machinery to record errors when ERT was run within
a `condition-case`.
AFAICT, these tests do not check for a behavior that we want,
so rather than "fix" them, I deleted them (bug#67862).
* test/lisp/emacs-lisp/ert-tests.el (ert-test-error-debug)
(ert-test-fail-debug-with-condition-case): Delete.
(ert-test-should-failure-debugging): Don't use `ert-debug-on-error`.
(ert-test-with-demoted-errors): It now passes. Bug#11218 is fixed!
Stefan Monnier [Tue, 19 Dec 2023 04:57:45 +0000 (23:57 -0500)]
ert.el: Use `handler-bind` to record backtraces
* lisp/emacs-lisp/ert.el (ert--should-signal-hook): Delete function.
(ert--expand-should-1): Don't bind `signal-hook-function`.
(ert--test-execution-info): Remove `next-debugger` slot.
(ert--run-test-debugger): Adjust to new calling convention.
Pass the `:backtrace-base` info to the debugger.
(ert--run-test-internal): Use `handler-bind` rather than let-binding
`debugger` and `debug-on-error`.
* lisp/emacs-lisp/ert-x.el (ert-remote-temporary-file-directory): Don't
use `defconst` if it's not meant to stay constant (e.g. we let-bind it
in tramp-tests.el).
Stefan Monnier [Tue, 19 Dec 2023 04:47:56 +0000 (23:47 -0500)]
(eval-expression): Fix bug#67196
* lisp/simple.el (eval-expression--debug): New function.
(eval-expression): Use it together with `handler-bind` instead of
let-binding `debug-on-error`.
Stefan Monnier [Tue, 26 Dec 2023 03:32:17 +0000 (22:32 -0500)]
New special form `handler-bind`
AFAIK, this provides the same semantics as Common Lisp's `handler-bind`,
modulo the differences about how error objects and conditions are
represented.
* lisp/subr.el (handler-bind): New macro.
* src/eval.c (pop_handler): New function.
(Fhandler_Bind_1): New function.
(signal_or_quit): Handle new handlertypes `HANDLER` and `SKIP_CONDITIONS`.
(find_handler_clause): Simplify.
(syms_of_eval): Defsubr `Fhandler_bind_1`.
* test/src/eval-tests.el (eval-tests--handler-bind): New test.
* lisp/emacs-lisp/lisp-mode.el (lisp-font-lock-keywords):
Move 'handler-bind' from CL-only to generic Lisp.
(handler-bind): Remove indentation setting, it now lives in the macro
definition.
* doc/emacs/mini.texi (Completion Options): Update documentation
of 'completions-sort'.
* doc/lispref/minibuf.texi (Completion Variables): Fox wording.
Add a cross-reference to where 'completions-sort' is documented.
Juri Linkov [Thu, 4 Jan 2024 17:20:30 +0000 (19:20 +0200)]
Support display-sort-function in completion-category-overrides (bug#68214)
* doc/lispref/minibuf.texi (Completion Variables):
Add 'display-sort-function' to the table of
'completion-category-overrides'.
* lisp/calendar/calendar.el (calendar-read-date): Add metadata
category 'calendar-month' for completing-read reading a month name.
* lisp/minibuffer.el (completion-category-defaults):
Add 'display-sort-function' with identity for the category 'calendar-month'.
(completion-category-overrides): Add customization for completion sorting
with 'display-sort-function' and a choice like in 'completions-sort'.
(completion-metadata-override-get): New function.
(minibuffer-completion-help): Use 'completion-metadata-override-get'
instead of 'completion-metadata-get' to get sort-fun from
'display-sort-function'.
Morgan Willcock [Sun, 31 Dec 2023 20:47:17 +0000 (20:47 +0000)]
Fix last change in tempo.el
* lisp/tempo.el: Set marker type for tempo-region-start to
move when text is inserted at its position. This prevents
the template from inserting text into the region. (Bug#68185)
Morgan Willcock [Sun, 31 Dec 2023 20:47:17 +0000 (20:47 +0000)]
Ensure indent-region argument order in tempo.el is correct
* lisp/tempo.el (tempo-insert): Call 'indent-region' with the
stored region markers to ensure that the start and end arguments
are used in the correct order. (Bug#68185)
Po Lu [Wed, 3 Jan 2024 05:42:27 +0000 (13:42 +0800)]
Don't magnify extent of shifts by variable glyph interpolation
* src/sfnt.c (sfnt_infer_deltas_2): Correctly index
x_coordinates and y_coordinates computing deltas for plain
shift.
(sfnt_vary_simple_glyph): Copy glyph contents to original_x and
original_y not the first time is create, but before each tuple
is applied.
Stefan Kangas [Wed, 3 Jan 2024 04:11:10 +0000 (05:11 +0100)]
Delete obsolete GC debugging code
This code was introduced in 2014 to catch a GC bug that, according to
Paul Eggert in 2019, "seems to have been fixed" (see 2b552f34892
2019-08-21 "Don’t debug fset by default"). It has been marked
obsolete since that time, and no one has mentioned it on our mailing
lists since. Let's just get rid of it.
Fix non-permenent decryption to show up temperarily.
In a decrypted mime part, replace CRLF with newline,
* lisp/mail/rmail.el (rmail-epa-decrypt-1): If NOT descrypting permanently,
put the decrypts into the view buffer.
(rmail-epa-decrypt, rmail-epa-decrypt-1):
In a decrypted mime part, replace CRLF with newline,
Po Lu [Tue, 2 Jan 2024 04:26:57 +0000 (12:26 +0800)]
Improve rounding of projection vector versors
* src/sfnt.c (sfnt_short_frac_dot): New function.
(sfnt_validate_gs): Guarantee dot product of freedom and
projection vectors are properly rounded. If the final product
is short of 1/16th of a vector, reset it to an entire vector.
Servers like typescript-language-server, when asked for {"only" :
"source.organizeImports"}, return actions with the
"source.organizeImports.ts" kind. Eglot rejected these actions, but
according to the spec:
Kinds are a hierarchical list of identifiers separated by `.` [...]
The set of kinds is open.
So I guess we can use string-prefix-p
* lisp/progmodes/eglot.el (eglot-code-actions): Use string-prefix-p.
Aaron Jensen [Sat, 30 Dec 2023 23:06:45 +0000 (18:06 -0500)]
Avoid race condition in parallel native-compilation
* lisp/emacs-lisp/comp.el (comp-delete-or-replace-file): Avoid
race condition by relying on 'rename-file' being an atomic
operation on Posix filesystems. (Bug#68083)
SES manual clean-up any « ignore »'d text to be translated
Remove from the English version any ignore'd chunk of text that has
been contributed yet only in the French version, and let only the
comment indicating re-alignment is needed.
Kjetil Orbekk [Fri, 29 Dec 2023 13:59:23 +0000 (08:59 -0500)]
Fix vg-hg-annotate-time bug
* lisp/vc/vc-hg.el (vc-hg-annotate-time): Fix extraction of timestamp
from string.
* test/lisp/vc/vc-hg-tests.el (vc-hg-annotate-time): Test that the
correct timestamp is found.
Po Lu [Mon, 1 Jan 2024 03:27:59 +0000 (11:27 +0800)]
Bring GX point interpolation further into standards compliance
* src/sfnt.c (sfnt_infer_deltas_2): New function; factor much of
sfnt_infer_deltas_1 into this function, then modify its
treatment of untouched points positioned at their reference
points to align with standard GX treatment.
(sfnt_infer_deltas_1): Remove all code not concerning anchor
point discovery.
(main): Adjust tests.
F. Jason Park [Fri, 29 Dec 2023 04:20:55 +0000 (20:20 -0800)]
Use advertised PREFIX when formatting nicks in ERC
* lisp/erc/erc-speedbar.el (erc-speedbar-insert-user): Run
`erc-get-channel-membership-prefix' in associated buffer if possible.
* lisp/erc/erc.el (erc-get-channel-membership-prefix): Use known
prefix mappings when determining status chars.
* test/lisp/erc/erc-tests.el (erc--parsed-prefix): Use common helpers
for initializing buffers, and use a more realistic example for PREFIX
value.
(erc--update-channel-modes): Add current buffer to `erc-server-user'
object to maintain essential invariant, even though this doesn't
affect the test's outcome.
(erc-tests--equal-including-properties): Move to `erc-tests-common'
and rename `erc-tests-common-equal-with-props'.
(erc--merge-prop, erc--remove-from-prop-value-list,
erc--remove-from-prop-value-list/many): Use new name for
`erc-tests-common-equal-with-props'.
(erc-get-channel-membership-prefix): New test.
(erc--determine-speaker-message-format-args,
erc--determine-speaker-message-format-args/queries-as-channel,
erc--determine-speaker-message-format-args/queries): Use new name
for `erc-tests-common-equal-with-props'.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-equal-with-props): New macro, originally
`erc-tests--equal-including-properties' from erc-tests.el.
(erc-tests-common-make-server-buf): Initialize tables and make NAME
argument optional. (Bug#67677)
F. Jason Park [Fri, 29 Dec 2023 04:21:13 +0000 (20:21 -0800)]
Fix regression in erc-button-add-button
* lisp/erc/erc-button.el (erc-button--nick): Abide by recommended
internal naming convention and use "cusr" instead of "cuser" for
referring to an `erc-channel-user' object.
(erc-button--fallback-cmem-function,
erc-button--get-user-from-spkr-prop): Use new, preferred name
`erc-channel-members' for `erc-channel-users' table.
(erc-button-add-nickname-buttons): Use "cmem" instead of "cuser" to
refer to values of the `erc-channel-members' table, which are cons
cells, not `erc-channel-user' objects. Use updated slot name `cusr'
when initializing `erc-button--nick' object.
(erc-button-add-button): Honor wishes of
`erc-button--modify-nick-function' advice members when they set the
`nickname-face' slot of the passed-around `erc-button--nick' object to
nil to indicate a desire to forgo adding a face while still
buttonizing the inserted nick with `erc-data', etc. (Bug#67767)
F. Jason Park [Fri, 29 Dec 2023 04:21:30 +0000 (20:21 -0800)]
Make erc-update-channel-current-member stricter
* lisp/erc/erc.el (erc--update-cusr-status-if-changed): Remove unused
macro.
(erc-update-current-channel-member): Redo doc string and abide by its
original language to the letter by not honoring a value of t for the
five channel-membership status parameters, even though this may break
user code that accidentally passes t instead of `on'. Avoid double
lookup for nick in `erc-server-users'. Rename some variables as per
recommended conventions for `erc-channel-user' objects. Stash
downcased nick for further reuse. Don't bother factoring in `addp' to
return value because `cusr-changed-p' is always non-nil when `addp'
is.
F. Jason Park [Thu, 28 Dec 2023 05:13:45 +0000 (21:13 -0800)]
Don't discard trimmed args in erc-cmd-MODE
* lisp/erc/erc.el (erc-cmd-MODE): Use matched non-whitespace portion
of input line instead of the original line. Otherwise, when the user
types "/MODE #chan", the server sees "MODE #chan", with twos spaces.
(erc--parse-nuh): Improve doc.
F. Jason Park [Sun, 31 Dec 2023 00:27:08 +0000 (16:27 -0800)]
Use format-prompt in erc-select-read-args
* lisp/erc/erc-button.el (erc-button-cmd-KICK, erc-button-cmd-MSG):
Use `read-string' instead of `read-from-minibuffer'.
* lisp/erc/erc.el (erc-select-read-args): Use `format-prompt', which
isn't normally available in Emacs 27 without Compat.
F. Jason Park [Sun, 31 Dec 2023 00:39:18 +0000 (16:39 -0800)]
Restore predicate for detecting date stamps in ERC
* etc/ERC-NEWS: Mention function `erc-stamp-inserting-date-stamp-p'.
* lisp/erc/erc-stamp.el (erc-stamp-inserting-date-stamp-p): New
function for third parties to detect whether the message being
inserted is a date stamp. Date stamps as independent messages were
originally introduced as part of bug#60936.
F. Jason Park [Sun, 31 Dec 2023 01:09:17 +0000 (17:09 -0800)]
Fix regression in erc-keep-place-indicator-mode
* lisp/erc/erc-goodies.el (erc-keep-place): Revert portion of 65735efdca0 "Improve multi-window erc-keep-place-indicator-mode" that
skipped modifying `window-prev-buffers' when the indicator's minor
mode was enabled.
* test/lisp/erc/erc-scenarios-keep-place-indicator.el: Modify test to
assert that point's place is preserved after switching away from a
buffer with the indicator enabled.
* test/lisp/erc/resources/keep-place/follow.eld: Update.
This feature was originally introduced by bug#59943.
Alan Mackenzie [Sun, 31 Dec 2023 11:02:50 +0000 (11:02 +0000)]
CC Mode. Preserve space syntax-table props in open strings
This fixes bug#68111, allowing, e.g., backward-kill-word to
work properly.
* lisp/progmodes/cc-mode.el (c-clear-string-fences): On an open
string which isn't followed by another string, remove the
syntax-table properties just from template delimiters rather
than setting the syntax-table properties of all the string to
punctuation.