Liu Hui [Thu, 18 Jan 2024 04:00:00 +0000 (12:00 +0800)]
Respect the delimiter of completer in Python shell completion
* lisp/progmodes/python.el: (python-shell-completion-setup-code): Fix
the completion code of IPython. Change the return value to JSON string
and ...
(python-shell-completion-get-completions): ... simplify parsing.
(inferior-python-mode): Update docstring.
(python-shell-readline-completer-delims): New variable indicating the
word delimiters of readline completer.
(python-shell-completion-native-setup): Set the completer delimiter.
(python-shell-completion-native-get-completions): Convert output string
to completions properly.
(python-shell--get-multiline-input)
(python-shell--extra-completion-context)
(python-shell-completion-extra-context): New functions.
(python-shell-completion-at-point): Send text beginning from the line
start if the completion backend does not need word splitting. Remove
the detection of import statement because it is not needed anymore.
Create proper completion table based on completions returned from
different backends.
* test/lisp/progmodes/python-tests.el (python-tests--completion-module)
(python-tests--completion-parameters)
(python-tests--completion-extra-context): New helper functions.
(python-shell-completion-at-point-jedi-completer)
(python-shell-completion-at-point-ipython): New tests. (bug#68559)
Eshel Yaron [Fri, 9 Feb 2024 10:15:24 +0000 (11:15 +0100)]
Remove minibuffer up-to-one-word completion
Deprecate 'minibuffer-complete-word', and cease binding 'SPC' during
minibuffer completion altogether.
* lisp/minibuffer.el (minibuffer-complete-word): Turn it into an
obsolete alias of 'minibuffer-complete'.
(minibuffer-confirm-exit-commands): Remove 'minibuffer-complete-word'.
(completion--try-word-completion): Drop it.
(minibuffer-local-completion-map): Cease binding 'SPC'.
(minibuffer-local-filename-completion-map)
(completion-pcm-complete-word-inserts-delimiters): Deprecate.
(completion-pcm--string->pattern, completing-read-default): Simplify.
Paul Eggert [Wed, 7 Feb 2024 21:17:57 +0000 (13:17 -0800)]
Port better to Autoconf 2.72
* configure.ac: Set ac_cv_type_gid_t=yes to pacify Autoconf 2.72
AC_TYPE_GETGROUPS. Problem reported by Nick Bowler in:
https://lists.gnu.org/r/autoconf-patches/2024-02/msg00001.html
Stefan Monnier [Wed, 7 Feb 2024 16:20:46 +0000 (11:20 -0500)]
(file-notify--test-wait-event): Rename from `file-notify--test-read-event`
* test/lisp/filenotify-tests.el (file-notify--test-wait-event):
Rename to better reflect its purpose rather than
its implementation. Also make it return nil so callers won't be
tempted to use the return value.
* etc/NEWS: Remove superfluous mention of key binding.
* lisp/buff-menu.el (Buffer-menu--selection-message): Go back to
previous wording. It's not about what is hidden but what is shown;
the message is displayed in response to different actions.
Eli Zaretskii [Wed, 7 Feb 2024 13:33:51 +0000 (15:33 +0200)]
Don't compile lib/copy-file-range.c on MS-Windows
* nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_copy-file-range): Set to
true to avoid compiling copy-file-range.c on MS-Windows. The
function 'copy_file_range' is not used on MS-Windows, while
compiling the file triggers warnings because lib/unistd.h, where
its prototype is declared, is omitted in the MS-Windows build.
Po Lu [Wed, 7 Feb 2024 13:09:18 +0000 (21:09 +0800)]
Fix DEBUG_THREADS in the Android port
* java/org/gnu/emacs/EmacsService.java (EmacsService): New field
`mainThread'.
(onCreate): Set `mainThread' to the thread where the service's
looper executes.
(checkEmacsThread): Compare against SERVICE.mainThread.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--font-lock-settings):
Also highlight method definitions where the arguments are literal
values, not identifiers (bug#67246).
Dmitry Gutov [Wed, 7 Feb 2024 01:54:29 +0000 (03:54 +0200)]
elixir-ts-mode: Bring the faces' use closer to other ts modes
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--font-lock-settings):
Rename feature 'elixir-function-name' to 'elixir-definition' and
update all deferences. Add parameters' highlighting with
font-lock-variable-name-face. Change variable references'
highlighting to use font-lock-variable-use-face.
Move the feature 'elixir-variable' from feature level 3 to level 4, to
match other ts modes (bug#67246).
Stefan Monnier [Tue, 6 Feb 2024 18:21:22 +0000 (13:21 -0500)]
(loaddefs-generate--parse-file): Be a bit more defensive
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--parse-file):
Don't fail in case of an error while generating the prefixes.
(loaddefs-generate--compute-prefixes): Don't burp when
`read-from-string` returns something else than a symbol.
Change hash range reduction from remainder to multiplication
This makes both lookups and rehashing cheaper. The index vector size
is now always a power of 2. The first table size is reduced to
6 (from 8), because index vectors would become excessively big
otherwise.
* src/lisp.h (struct Lisp_Hash_Table): Replace index_size with
index_bits. All references adapted.
(hash_table_index_size): New accessor; use it where applicable.
* src/fns.c (hash_index_size): Replace with...
(compute_hash_index_bits): ...this new function, returning the log2 of the
index size. All callers adapted.
(hash_index_index): Knuth multiplicative hashing instead of remainder.
(maybe_resize_hash_table): Reduce first table size from 8 to 6.
Optionally show internal buffers in Buffer Menu mode
Internal buffers were never shown before but they can be of interest
to Elisp developers, especially since there is no general mechanism to
remove unused buffers.
Po Lu [Tue, 6 Feb 2024 09:52:33 +0000 (17:52 +0800)]
Implement Lisp threading on Android
Much like the NS port, only the main thread receives input from
the user interface, which is fortunately not a major problem for
packages such as lsp-mode that create Lisp threads.
* configure.ac: Enable with_threads under Android.
* src/android.c (android_init_events): Set `main_thread_id' to
the ID of the main thread.
(setEmacsParams): Set new global variable `android_jvm' to the
JVM object, for the purpose of attaching Lisp threads to the
JVM.
(android_select): [THREADS_ENABLED]: If the caller isn't the
main thread, resort to pselect. Don't check query before select
returns.
(android_check_query): Export.
* src/android.h (_ANDROID_H_): Define new macro and update
prototypes.
* src/process.c (android_select_wrapper): New function.
(wait_reading_process_output): If THREADS_ENABLED, call
thread_select through the Android select wrapper.
* src/thread.c (post_acquire_global_lock): Call
android_check_query; replace android_java_env with the incoming
Lisp thread's.
(run_thread): Attach and detach the thread created to the JVM.
(init_threads): Set the main thread's JNI environment object.
* src/thread.h (struct thread_state) <java_env>: New field.
Stefan Monnier [Mon, 5 Feb 2024 22:58:47 +0000 (17:58 -0500)]
Prefer `ITREE_FOREACH` over `overlays_in`
Use `ITREE_FOREACH` instead of `overlays_in` if that can save us from
allocating an array.
* src/buffer.c (overlays_in): Mark as static.
(mouse_face_overlay_overlaps): Use `ITREE_FOREACH` instead of `overlays_in`.
(disable_line_numbers_overlay_at_eob): Same, and also change return
value to a boolean.
* src/buffer.h (overlays_in): Don't declare.
* src/editfns.c (overlays_around): Delete function.
(Fget_pos_property): Use `ITREE_FOREACH` and keep the "best so far"
instead of using `overlays_in` and sorting the elements.
* src/lisp.h (disable_line_numbers_overlay_at_eob): Change return
type to a boolean.
* src/xdisp.c (should_produce_line_number): Adjust accordingly.
Grudgingly accept function values in the function position
* lisp/emacs-lisp/cconv.el (cconv-convert):
Warn about (F ...) where F is a non-symbol function value (bytecode
object etc), but let it pass for compatibility's sake (bug#68931).
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp--fun-value-as-head):
New test.
Po Lu [Mon, 5 Feb 2024 10:34:22 +0000 (18:34 +0800)]
Fix frame focus tracking under Android
* java/org/gnu/emacs/EmacsActivity.java (invalidateFocus): New
argument WHENCE, a unique number identifying the circumstances
leading up to the call. All callers changed.
(attachWindow): Call `invalidateFocus' from the UI thread.
(onWindowFocusChanged): Don't remove activity from
`focusedActivities' if it already exists should `hasWindowFocus'
return true.
Yuan Fu [Sun, 4 Feb 2024 05:24:29 +0000 (21:24 -0800)]
Improve treesit-forward-sexp behavior for leaf nodes (bug#68899)
treesit-forward-sexp uses treesit--navigate-thing with 'restricted'
tactic. In this tactic we don't move over the parent thing. However,
this makes forward-sexp useless for symbols when point is in the
symbol rather than at the beginning of it: in that case, the symbol is
considered parent and treesit-forward-sexp won't move to the end of
it.
To solve that, we allow to move across the parent even in 'restricted'
mode if the parent is a leaf thing.
Here, "leaf thing" is defined as "doesn't have any child 'thing'
inside it".
* lisp/treesit.el (treesit--navigate-thing): Move over parent in
'restricted' tactic if the parent is a leaf thing.
The assertion failure was raised at lread.c:411 during the
`lread-invalid-bytecodes` test in `test/src/lread-tests.el`.
I suspect we could remove the assertion instead.
Stefan Monnier [Sun, 4 Feb 2024 17:50:55 +0000 (12:50 -0500)]
(w->base_line_number): Rework the way we flush the cache
* src/xdisp.c (BASE_LINE_NUMBER_VALID_P): New macro.
(try_scrolling): Use it.
(redisplay_window, Fformat_mode_line): Use it to flush the
base_line_number (if it's stale) once at the beginning.
(decode_mode_spec): Don't use (or set) `w->start` and
`w->base_line_number` when operating on another buffer!
Eshel Yaron [Tue, 6 Feb 2024 19:33:53 +0000 (20:33 +0100)]
Support bookmarking Xref results buffers
* lisp/progmodes/xref.el (bookmark-make-record-default)
(bookmark-make-record, bookmark-prop-get)
(bookmark-handle-bookmark, bookmark-get-rear-context-string)
(bookmark-get-front-context-string): Declare functions.
(xref-backend-context, xref-backend-restore): New generic functions.
(xref--backend, xref--identifier, xref--kind)
(xref--original-buffer, xref--original-point): New local variables.
(xref--show-common-initialize): Set them in Xref results buffer.
(xref-default-bookmark-name-format): New user option.
(xref-bookmark-make-record, xref-bookmark-jump): New functions.
(xref--xref-buffer-mode): Set 'bookmark-make-record-function'.
(xref-fetcher-alist): New variable.
(xref--show-xref-buffer, xref-show-definitions-buffer)
(xref-show-definitions-buffer-at-bottom): Use it.
(xref--read-identifier): Improve error message.
(xref-make-fetcher): Extract from...
(xref--create-fetcher): ...here.
* doc/emacs/maintaining.texi (Xref Commands): Document new feature.
* etc/NEWS: Announce new feature and Xref generic functions.
Eshel Yaron [Sun, 4 Feb 2024 12:57:06 +0000 (13:57 +0100)]
; Fix remote shell file name selection
* lisp/shell.el (shell): Cease providing 'file-remote-p' as completion
predicate when reading remote shell file name. The completion predicate
in 'read-file-name' gets the non-directory part of the file name, which
in particular does not include the remote part, if any, so this
predicate always fail in these settings. Moreover, this predicate
didn't make a lot of sense to begin with.
Stefan Kangas [Sun, 4 Feb 2024 09:28:40 +0000 (10:28 +0100)]
Delete compat code in `url` library
* lisp/url/url-cid.el (url-cid): Delete compat code for ancient Gnus.
* lisp/url/url-ldap.el (url-ldap-certificate-formatter): Delete compat
code; ssl.el has never been in Emacs.
* lisp/url/url-mailto.el (url-mail): Make into alias for 'message-mail',
since it is always fboundp.
Eli Zaretskii [Sun, 4 Feb 2024 09:45:15 +0000 (11:45 +0200)]
Fix display of invisible text with opposite directionality
* src/xdisp.c (handle_invisible_prop): Skip invisible text
correctly when it starts at position whose resolved bidi level is
above the base paragraph level. (Bug#68446)
Stefan Monnier [Sun, 4 Feb 2024 04:05:03 +0000 (23:05 -0500)]
tramp: Tweak the ls-lisp declarations
* lisp/net/tramp-sh.el (ls-lisp-use-insert-directory-program): Don't
declare its existence...
(tramp-sh-handle-insert-directory): ...test it instead.
* lisp/net/tramp.el (ls-lisp-dirs-first, ls-lisp-emulation)
(ls-lisp-ignore-case, ls-lisp-use-insert-directory-program)
(ls-lisp-verbosity): Move declaration...
(tramp-handle-insert-directory): ...to the point where we have a good
reason to think these variables exist.
João Távora [Thu, 30 Nov 2023 13:32:50 +0000 (07:32 -0600)]
Fix prefix discovery for files with read-symbol-shorthands (bug#67325)
In a previous commit, the local-variable read-symbol-shorthands is
already read into the temporary buffer used for the autoload parsing
aerobatics, so all we needed to do in 'l-g--compute-prefixes' is
use 'read' to give 'read-symbol-shorthands' a chance to kick in.
Add font locking to the shorthand prefix of a given printed symbol
name by checking if any of the shorthand prefixes in
read-symbol-shorthands are a prefix for that print name. Although
this does more string comparisons, it didn't prove to be any slower
than the existing approach, and is more correct.
This version is more accurate when highlighting files with many
overlapping shorthands. Given:
Eli Zaretskii [Sat, 3 Feb 2024 11:00:15 +0000 (13:00 +0200)]
Fix downcasing of mode-name in compile.el
* lisp/progmodes/compile.el (compilation--downcase-mode-name): New
function.
(compilation-start, kill-compilation): Use it instead of calling
'downcase' on 'mode-name'. (Bug#68795)
Fix incompatibility with tree-sitter-javascript >= 0.20.2
Starting from version 0.20.2 the grammar's primary expression
"function" has been renamed to "function_expression". A new
function checks if the new primary expression is available,
and if so, it returns the correct rules.
* lisp/progmodes/js.el
(js--treesit-font-lock-compatibility-definition-feature): New
function.
(js--treesit-font-lock-settings): Use it. (Bug#68879)
Eli Zaretskii [Sat, 3 Feb 2024 09:09:36 +0000 (11:09 +0200)]
Avoid signaling errors from 'pixel-fill-region'
* lisp/textmodes/pixel-fill.el (pixel-fill-region): Make sure the
selected window displays the current buffer. This is important
when this function is called inside 'with-current-buffer' or
similar forms which temporarily change the buffer displayed in the
selected window. (Bug#67791)
F. Jason Park [Wed, 31 Jan 2024 14:01:54 +0000 (06:01 -0800)]
Reassociate erc-networks--id for orphaned queries
* lisp/erc/erc-networks.el (erc-networks--examine-targets): Adopt the
server's network ID in query buffers created before MOTD's end. Do
this to avoid a type error in the process filter when renaming
buffers.
* lisp/erc/erc-networks.el (erc-networks--examine-targets): New test.
* test/lisp/erc/erc-scenarios-base-upstream-recon-znc.el
(erc-scenarios-upstream-recon--znc/severed): New test.
* test/lisp/erc/erc-scenarios-misc.el
(erc-scenarios-base-mask-target-routing): Adjust timeout.
* test/lisp/erc/resources/base/upstream-reconnect/znc-severed.eld:
New file.
* test/lisp/erc/resources/erc-tests-common.el
(erc-tests-common-make-server-buf): Use NAME parameter for creating
ID.
F. Jason Park [Wed, 31 Jan 2024 02:17:41 +0000 (18:17 -0800)]
Fix local variable persistence in erc-stamp
* etc/ERC-NEWS: Mention renaming of `erc-munge-invisible-property'.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-disable): Remove
correct function from `erc-mode-hook'.
(erc-stamp--recover-on-reconnect): Revise doc string.
(erc-munge-invisibility-spec, erc-stamp--manage-local-options-state):
Mark former name as obsolete and rename to latter. Don't use helper
macro meant only for local modules. This bug originated from c68dc778
"Manage some text props for ERC insertion-hook members", which stemmed
from bug#60936.
(erc-stamp--setup, erc-hide-timestamps, erc-show-timestamps)
(erc-toggle-timestamps): Use new name for
`erc-munge-invisibility-spec'.
* lisp/erc/erc.el (erc--restore-initialize-priors): Raise error at
runtime if mode var doesn't belong to a local module.
* test/lisp/erc/erc-stamp-tests.el (erc-stamp-tests--insert-right)
(erc-timestamp-intangible--left): Use new name for
`erc-munge-invisibility-spec'.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Shadow
`erc-last-input-time'.
(erc--restore-initialize-priors): Add error form to expected
expansion, and skip test on Emacs 27.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--make-bindings): Shadow `erc-last-input-time'.
F. Jason Park [Tue, 30 Jan 2024 03:04:58 +0000 (19:04 -0800)]
Teach customize-option about erc-modules
* lisp/erc/erc-goodies.el (erc-scrolltobottom-mode)
(erc-scrolltobottom-enable): Use `setq' instead of `setopt' because
the latter isn't defined in Emacs 27 and 28. This fix is unrelated to
the main thrust of this commit.
* lisp/erc/erc.el (erc-modules): Make good on decades old language in
info node "(erc) Modules" by ensuring `customize-option' can find this
option before its containing library is loaded. Like
`gnus-select-method', this option serves as an entry point for
configuring the application and is presented that way in tutorials and
library front matter. Moreover, it can't be reasonably autoloaded in
the traditional way because of its many dependencies and large textual
footprint.
(erc-display-message): Revise doc string.
Stefan Monnier [Fri, 2 Feb 2024 23:59:21 +0000 (18:59 -0500)]
cperl-mode.el: Don't use obsolete `special-display-popup-frame`
* lisp/progmodes/cperl-mode.el (cperl-info-on-command): Simplify,
to let `pop-to-buffer` decide whether to create a new frame or not,
so it can be controlled by `display-buffer-alist`.
Stefan Monnier [Wed, 31 Jan 2024 23:56:43 +0000 (18:56 -0500)]
bytecomp.el: Rewrite the way we print dynamic docstrings
We used to print dynamic docstrings "manually" for two reasons:
- References should look like `(#$ . POS)` but `prin1` was unable
to print just `#$` for an sexp.
- `make-docfile` needed to find those docstrings and the object
to which they belonged.
The second point is moot now that we don't use `make-docfile` on
`.elc` files. So this patch lifts the first restriction,
using `print-number-table`.
The rest of the patch then simplifies and regularises the
bytecompiler's generation of dynamic docstrings, which can
now also easily be done for "inner" defvars and other places.
* lisp/emacs-lisp/bytecomp.el:
(byte-compile--list-with-n): New function.
(byte-compile--docstring-style-warn): Rename from
`byte-compile-docstring-style-warn` and change calling convention.
(byte-compile--\#$, byte-compile--docstrings): New vars.
(byte-compile-close-variables): Bind them.
(byte-compile--docstring): New function.
(byte-compile-from-buffer): Set `byte-compile--\#$`.
(byte-compile-output-file-form): Use `byte-compile--\#$` instead
of special casing specific forms.
(byte-compile--output-docform-recurse, byte-compile-output-docform):
Delete functions.
(byte-compile-file-form-autoload, byte-compile-file-form-defalias)
(byte-compile-file-form-defvar-function, byte-compile-lambda):
Use `byte-compile--docstring` and `byte-compile--list-with-n`.
(byte-compile--declare-var): Add optional `not-toplevel` arg.
(byte-compile-defvar): Add `toplevel` arg. Use `byte-compile--docstring`.
(byte-compile-file-form-defvar): Delegate to `byte-compile-defvar`.
(byte-compile--custom-declare-face): New function. Use it for
`custom-declare-face`.
(byte-compile-file-form-defmumble): Use `byte-compile-output-file-form`
* src/doc.c (Fdocumentation_stringp): New function.
(syms_of_doc): Defsubr it.
(store_function_docstring): Remove left-over code from when we
used DOC for the docstring of some Lisp files.