Avoid resizing mutation in subst-char-in-string, take two
This time we take care to preserve properties, and add a test.
* lisp/subr.el (subst-char-in-string):
Use string-replace to avoid resizing mutation and O(n^2) time.
* test/lisp/subr-tests.el (subr--subst-char-in-string): New test.
Juri Linkov [Mon, 13 May 2024 06:59:07 +0000 (09:59 +0300)]
* lisp/imenu.el: Support more values for imenu-flatten (bug#70846)
(imenu-flatten): Change type boolean to choice
of more values for prefix/suffix section names.
(imenu--completion-buffer): Add :annotation-function if
'imenu-flatten' is 'annotation'.
(imenu--flatten-index-alist): Put property 'imenu-section' if
'imenu-flatten' is 'annotation'.
Po Lu [Mon, 13 May 2024 06:40:15 +0000 (14:40 +0800)]
Communicate frame titles to the window manager on Android
* java/org/gnu/emacs/EmacsActivity.java (detachWindow)
(attachWindow): Call updateWmName.
(updateWmName): New function; transfer wm name from the window
attached to the task's description.
* java/org/gnu/emacs/EmacsWindow.java (EmacsWindow)
<wmName>: New field.
(setWmName): New function.
* src/android.c (android_init_emacs_window): Link to new
function.
(android_set_wm_name): New function.
* src/androidfns.c (android_set_name_internal, android_set_name)
(android_implicitly_set_name, android_explicitly_set_name)
(android_set_title): Port from X.
Dmitry Gutov [Sun, 12 May 2024 17:42:08 +0000 (20:42 +0300)]
Fix 'C-u C-x p g' globally and 'A' in dired-mode
* lisp/progmodes/project.el (project-find-regexp): Ensure the
DEFAULT-DIRECTORY is set correctly for the 'C-u' case (bug#70888).
* lisp/progmodes/project.el (project--files-in-directory):
Ensure that the DIR argument ends with a slash --
'dired-do-find-regexp' passes it differently, for example.
* lisp/progmodes/xref.el (xref--group-name-for-display): Ensure
the project-relative and absolute display modes work well for
groups with "relative" file names.
(xref--analyze, xref--add-log-current-defun): Change accordingly.
* test/lisp/progmodes/project-tests.el
(project-find-regexp-with-prefix): New test.
* lisp/net/tramp-compat.el (tramp-nspawn): Warn, if that package is used.
* lisp/net/tramp-container.el (tramp-nspawn-program): New defcustom.
(tramp-nspawn-method): New defconst.
(tramp-nspawn--completion-function, tramp-enable-nspawn-method):
New defuns.
Dmitry Gutov [Sun, 12 May 2024 02:57:10 +0000 (05:57 +0300)]
completion--replace: Fix completion cycling
* lisp/minibuffer.el (completion--replace):
Don't "insert before markers" after all because in some cases
(https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg00701.html)
- like cycling - BEG can be denoted by a marker as well.
(minibuffer-completion-help): Make FIELD-END simply a fixnum. And
adjust its value manually inside the local
completion-list-insert-choice-function (bug#48356).
* lisp/emacs-lisp/cl-seq.el (cl-sort):
Don't use string mutation when sorting the characters in a string.
This avoids O(n^2) run time and makes it future-safe.
Po Lu [Sun, 12 May 2024 12:24:19 +0000 (20:24 +0800)]
Properly deinitialize directory cursors on closedir
* src/androidvfs.c (android_saf_tree_closedir): Call
cursor.close, for deleting the local reference to enable its
garbage collection is not sufficient to release all related
resources.
Po Lu [Sun, 12 May 2024 07:46:38 +0000 (15:46 +0800)]
Additional changes to processing of Num Lock on Android
* java/org/gnu/emacs/EmacsView.java (onKeyDown, onKeyMultiple)
(onKeyDown): Disregard Num and Scroll Lock keys, and return
value of window functions to the system.
* java/org/gnu/emacs/EmacsWindow.java (eventModifiers): Return
normalized meta state, not only those bits the system considers
modifiers.
(onKeyDown, onKeyUp): Ignore numpad keys to which no base
characters are assigned, so that the system may generate the
proper action keys instead.
Po Lu [Sun, 12 May 2024 06:13:27 +0000 (14:13 +0800)]
Correct earlier changes to processing of Num Lock on Android
* java/org/gnu/emacs/EmacsWindow.java (onKeyDown, onKeyUp):
Cease stripping META_NUM_LOCK_ON and META_SCROLL_LOCK_ON from
meta masks reported to getUnicodeChar.
Po Lu [Sun, 12 May 2024 05:27:43 +0000 (13:27 +0800)]
Pacify warnings in gmalloc.c
* src/gmalloc.c (__malloc_initialize_hook): Also declare in
advance on Glibc 2.24 and later.
(__after_morecore_hook, __morecore): Likewise on Glibc 2.34 and
later.
Paul Eggert [Sat, 4 May 2024 17:08:48 +0000 (10:08 -0700)]
Pacify gcc -Wmissing-variable-declarations
This is a new warning diagnostic in GCC 14.
* lib-src/etags.c (mercury_heuristics_ratio):
* src/pgtkselect.c, src/xselect.c (selection_request_stack):
* src/xselect.c (outstanding_transfers):
* src/xterm.c (pending_selection_requests)
(x_dnd_waiting_for_motif_finish_display):
Now static.
* lib-src/make-docfile.c (close_emacs_globals):
Arrange for lispsym to be declared with extern first,
when compiling lread.c.
* src/alloc.c (gdb_make_enums_visible) [__GNUC__]:
* src/emacs.c (RCS_Id):
* src/keyboard.c (stop_character):
* src/print.c (print_output_debug_flag):
Now declared with extern first.
* src/lisp.h (DEFINE_GDB_SYMBOL_BEGIN) [MAIN_PROGRAM]:
Arrange for ID to be declared extern first.
* src/lisp.h (garbage_collection_inhibited):
* src/xterm.h (x_frame_parm_handlers):
Declare here, so that its interface is properly checked. Other decls
removed.
Paul Eggert [Sat, 4 May 2024 16:55:27 +0000 (09:55 -0700)]
Adjust to recent Gnulib changes
* admin/merge-gnulib: Also remove the new Gnulib file
m4/off64_t.m4, as Emacs doesn’t need off64_t.
* configure.ac (gl_TYPE_OFF64_T): Define a nearly no-op.
kobarity [Thu, 9 May 2024 15:39:10 +0000 (00:39 +0900)]
Support Python 3 in 'package-test-update-archives-async'
* test/lisp/emacs-lisp/package-resources/package-test-server.py:
Support Python 3.
* test/lisp/emacs-lisp/package-tests.el
(package-test-update-archives-async): Search for an executable
named "python", "python3", or "python2". (Bug#70722)
Eli Zaretskii [Sat, 11 May 2024 09:16:48 +0000 (12:16 +0300)]
Fix Rmail summary by thread
* lisp/mail/rmailsum.el (rmail-summary-by-thread): Use value of
'rmail-total-messages' local to 'rmail-buffer'. Patch by Andrea
Monaco <andrea.monaco@autistici.org>.
Po Lu [Sat, 11 May 2024 06:38:54 +0000 (14:38 +0800)]
Improve documentation of p-s-p-scroll-down-page
* lisp/pixel-scroll.el
(pixel-scroll-precision-scroll-down-page): Document unit in
which the height of the window is measured, and what manner of
height applies. Reported by Eli Zaretskii <eliz@gnu.org>.
Eric Abrahamsen [Fri, 10 May 2024 19:38:57 +0000 (12:38 -0700)]
Update gnus-draft-check-draft-articles to use find-buffer-visiting
* lisp/gnus/gnus-draft.el (gnus-draft-check-draft-articles): Don't loop
through all the buffers; this removes the need for the `file-remote-p'
check. Also give the user some nicer feedback about what's going on.
Eric Abrahamsen [Fri, 10 May 2024 15:49:57 +0000 (08:49 -0700)]
Remove extra message-set-auto-save-file-name call in Gnus drafts
Bug#70579
* lisp/gnus/gnus-draft.el (gnus-draft-setup): This function is already
being called as part of the message-mail -> message-mode call
above. Running it twice results in a jump in assigned article numbers,
and the corresponding active value of the drafts group.
Juri Linkov [Fri, 10 May 2024 16:45:21 +0000 (19:45 +0300)]
Support customization of sorting order for Imenu completion candidates
* lisp/imenu.el (imenu--completion-buffer):
Set completion-extra-properties to '(:category imenu).
(imenu--flatten-index-alist): Use imenu--subalist-p to handle
newer format (INDEX-NAME INDEX-POSITION FUNCTION ARGUMENTS...)
as well (bug#70846).
Eli Zaretskii [Fri, 10 May 2024 12:56:30 +0000 (15:56 +0300)]
Fix 'dictionary-tooltip-mode'
* lisp/tooltip.el (tooltip-event-buffer): Make sure 'posn-window'
returns a window before calling 'window-buffer'.
* lisp/net/dictionary.el (dictionary-default-dictionary)
(dictionary-tooltip-dictionary): Doc fixes.
(dictionary-tooltip-dictionary): Change default value to t, which
means the same dictionary as 'dictionary-default-dictionary'.
(dictionary-do-search): If NOMATCHING is non-nil, do not insert
anything into the current buffer, as that is unexpected when
showing definitions in tooltips.
(dictionary-word-at-mouse-event): Be defensive about the values
returned by 'tooltip-event-buffer' and 'posn-point': they can be
unexpected when the mouse pointer is on the tool bar or mode line
etc.
(dictionary-display-tooltip): Ignore errors in this function.
(dictionary-tooltip-mode): Ignore mouse-movement events on tool
bar and tab-bar.
(dictionary-dictionaries): Decode the server response to present
dictionaries in human-readable form. Document in the doc string
the format of the return value.
Juri Linkov [Fri, 10 May 2024 06:52:09 +0000 (09:52 +0300)]
* lisp/imenu.el (imenu-flatten): New defcustom (bug#70846).
(imenu-level-separator): Adjust the docstring.
(imenu--flatten-index-alist): New function revived
from the initial implementation of this package.
(imenu-choose-buffer-index): Use imenu--flatten-index-alist
when imenu-flatten is non-nil.
(imenu-buffer-menubar): Remove obsolete variable.
Po Lu [Fri, 10 May 2024 03:01:29 +0000 (11:01 +0800)]
Fix bug#70856
* lisp/pixel-scroll.el (pixel-scroll-precision-scroll-down)
(pixel-scroll-precision-scroll-up): Apply finer threshold for
the minimum unit of scrolling.
(pixel-scroll-precision-scroll-down-page): Document true
restrictions on DELTA. (bug#70856)
Andrew G Cohen [Sun, 7 Apr 2024 23:36:17 +0000 (07:36 +0800)]
Don't limit gnus thread searches to a single message
* lisp/gnus/gnus-search.el (gnus-search-single-p): Searches for a
single message id finish after finding this one message; thread searches
continue until all messages are found.
Paul Eggert [Thu, 9 May 2024 19:24:18 +0000 (12:24 -0700)]
Improve static checking when using upcoming GCC 13.3
* src/lisp.h: In GCC 13.3 and later, do not ignore
-Wanalyzer-allocation-size.
* src/marker.c: In GCC 13.3 and later, do not ignore
-Wanalyzer-deref-before-check.
The issue was that the function always returned nil because
the closing parentheses were in the wrong position. This
meant that the function couldn't give back the data it was
supposed to, making the whole srecode system not work
properly.
By moving the parentheses to the correct place, the function
now returns a hash table with all the templates it finds.
* lisp/cedet/srecode/find.el (srecode-all-template-hash):
Adjusted the position of closing parentheses so that the mhash
variable is returned correctly. (Bug#70765)
* src/xwidget.c (store_xwidget_download_callback_event)
(store_xwidget_js_callback_event, syms_of_xwidget): Define
symbols for symbols interned with `intern' from a constant
string, delete duplicate DEFSYM directives, and substitute them
for such calls to intern. This excludes only those symbols
which are interned and referenced only once during Emacs's
initialization, the timing of whose interning is
inconsequential, and symbols in w32.c, which would need to be
transferred to a new syms_of_w32 function that I cannot test.
At the beginning of the buffer call 'treesit-outline-search'
recursively with the `looking-at' argument set to t, since
`treesit-navigate-thing' can't find a thing at bobp (bug#70789).
john muhl [Fri, 3 May 2024 20:51:01 +0000 (15:51 -0500)]
Improve indentation in 'lua-ts-mode' (bug#70785)
* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
- Ignore comments when aligning arguments, parameters and fields.
- Apply simpler rules to simpler usage of anonymous functions.
- Better handling of table as a function argument.
(lua-ts--comment-first-sibling-matcher):
(lua-ts--first-real-sibling-anchor):
(lua-ts--last-arg-function-call-matcher):
(lua-ts--top-level-function-call-matcher): New function.
(lua-ts--g-parent):
(lua-ts--g-g-parent): New function.
(lua-ts--g-g-g-parent): Use it.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
Add tests.
john muhl [Sat, 27 Apr 2024 23:52:41 +0000 (18:52 -0500)]
; Quietly skip 'lua-ts-mode' tests (bug#70786)
* test/lisp/align-tests.el (align-lua):
* test/lisp/progmodes/lua-ts-mode-tests.el
(lua-ts-test-indentation):
(lua-ts-test-movement):
(lua-ts-test-font-lock):
(lua-ts-test-which-function): Suppress warnings when the grammar is not
installed.
Dmitry Gutov [Thu, 9 May 2024 02:30:32 +0000 (05:30 +0300)]
choose-completion: Retain the suffix after completion boundary
* lisp/minibuffer.el (completion-base-suffix):
Remove as not optimal after all (bug#48356).
(completion--replace): Use insert-before-markers-and-inherit.
(minibuffer-completion-help): Don't set completion-base-affixes,
implement the same logic more optimally by local search and
querying for field boundaries. Also fix the problem with
completion table, predicate and extra-props being looked up in the
wrong buffer.
(minibuffer-next-completion, minibuffer-choose-completion):
Don't bind completion-use-base-affixes anymore.
* lisp/simple.el (completion-base-affixes)
(completion-use-base-affixes): Remove.
(completion-list-insert-choice-function):
Don't pass them through anymore.
F. Jason Park [Tue, 7 May 2024 04:59:48 +0000 (21:59 -0700)]
Prefer erc--skip property to erc-track--skipped-msgs
* lisp/erc/erc-stamp.el (erc-add-timestamp): Honor an overriding
`erc--ts' "msg prop".
(erc-stamp--defer-date-insertion-on-post-modify): Add `erc--skip'
for the `track' module.
* lisp/erc/erc-track.el (erc-track--skipped-msgs): Remove unused
variable. Originally added as part of bug#60936.
(erc-track-modified-channels): Rely on the `erc--skip' "msg prop"
instead of the now defunct `erc-track--skipped-msgs' variable for
detecting requests to omit `track' mode-line updates during
`erc-display-message'.
F. Jason Park [Wed, 8 May 2024 22:26:29 +0000 (15:26 -0700)]
Avoid shared-ref read syntax in ERC message catalogs
* lisp/erc/erc.el (erc--message-speaker-ctcp-action-input)
(erc--message-speaker-ctcp-action-statusmsg-input): Don't use
shared/circular references, like #1=foo ... #1#, in literal strings
because it triggers CI validation failures. These message-format
definitions were originally introduced as part of bug#67677.