Don't use pointer arithmetic for untagging Lisp values (bug#65491)
* src/lisp.h (XUNTAG):
Instead of casting a Lisp value to char * and subtracting the tag,
cast it to a suitable integral type and work on that.
This should result in identical or at least equivalent code, except
that it avoids potential problems arising from the restrictions on
pointer arithmetic in C. In particular, a null pointer can be neither
an operand in nor the result of pointer arithmetic.
C compilers know this and would, prior to this change, optimise
XUNTAG(obj, Lisp_Int0, mytype) != NULL
to 1. This means, for example, that make_pointer_integer and
XFIXNUMPTR could not be entrusted with null pointers, and
next_vector in alloc.c was unsafe to use.
Jim Porter [Mon, 18 Sep 2023 17:17:12 +0000 (10:17 -0700)]
Fix another race condition when waiting for Eshell processes
When checking if the other processes in our pipeline are "alive", we
also need to check whether their sentinels are finished. Otherwise,
we might proceed with command evaluation while one of the other
processes is still cleaning up.
* lisp/eshell/esh-proc.el (eshell-process-active-p): New function...
(eshell-wait-for-process)
* lisp/eshell/esh-cmd.el (eshell-resume-command): ... use it.
Po Lu [Mon, 18 Sep 2023 06:13:30 +0000 (14:13 +0800)]
Correct crash in child processes under armeabi Android
* exec/trace.c (process_system_call) <READLINKAT_SYSCALL>:
Examine tracee->waiting_for_syscall and avoid rewriting user
arguments if a system call is presently being executed by the
kernel. Reported by Romário Rios <romariorios@protonmail.com>.
Danny Freeman [Fri, 15 Sep 2023 15:29:05 +0000 (11:29 -0400)]
Offset ranges before applying embedded tree-sitter parser
This feature would allow treesitter major modes to easily specify
offsets when using embeded parsers. A potential use case for this is
javascript template strings, when we want to apply a different parser
to the string's contents, but do not want to include the template
string's delimiters.
* lisp/treesit.el
(treesit-query-range): Accept an optional offest arg, apply the offset
to all returned ranges.
(treesit-range-rules): Accept an optional :offset keyword arg to adjust
ranges an embded parser is applied to.
(treesit-update-ranges): Forward optional :offset setting from
`treesit-range-rules' to `treesit-query-rang'.
* test/lisp/treesit-tests.el
(treesit-range-offset): Tests the new offset functionality.
Jim Porter [Mon, 18 Sep 2023 04:06:46 +0000 (21:06 -0700)]
Use 'eshell-with-temp-command' (indirectly) to parse Eshell script files
* lisp/eshell/esh-cmd.el (eshell--region-p): New function.
(eshell-with-temp-command, eshell-parse-command): Support
'(:file . FILENAME)' to use the contents of FILENAME.
* lisp/eshell/em-script.el (eshell-source-file): Call
'eshell-parse-command' and use backticks.
* java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Call
damageRect with integer coordinates in lieu of consing a new
Rect.
* java/org/gnu/emacs/EmacsDrawable.java (damageRect) <IIII>:
Declare a new variant of damageRect, accepting four integers
designating the extents of the damage rectangle.
* java/org/gnu/emacs/EmacsPixmap.java (damageRect) <IIII>: New
stub.
* java/org/gnu/emacs/EmacsView.java (damageRect) <IIII>:
Implement this overloaded variant of damageRect.
* src/android.c (android_init_emacs_drawable)
(android_init_emacs_window): Move search for `damageRect' to
android_init_emacs_window.
(android_damage_window): Call IIII variant of `damageRect' to
avoid consing a new rectangle. Ameliorate dynamic method
dispatch overhead.
F. Jason Park [Thu, 7 Sep 2023 02:40:11 +0000 (19:40 -0700)]
Spoof channel users in erc-button--phantom-users-mode
* lisp/erc/erc-backend.el (erc--cmem-from-nick-function): Update
forward declaration.
(erc-server-PRIVMSG): Use new name for `erc--user-from-nick-function',
now `erc--cmem-from-nick-function'.
* lisp/erc/erc-button.el (erc-button--phantom-users,
erc-button--phantom-cmems): Rename former to latter.
(erc-button--fallback-user-function,
erc-button--fallback-cmem-function): Rename former to latter.
(erc--phantom-channel-user, erc--phantom-server-user): New superficial
`cl-struct' definitions "subclassing" `erc-channel-user' and
`erc-server-user'. Note that these symbols lack an `erc-button'
prefix.
(erc-button--add-phantom-speaker): Look for channel member instead of
server user, creating one if necessary. Return a made-up
`erc-channel-user' along with a fake `erc-server-user'.
(erc-button--get-phantom-user, erc-button--get-phantom-cmem): Rename
former to latter.
(erc-button--phantom-users-mode, erc-button--phantom-users-enable,
erc-button--phantom-users-disable): Use updated "cmem" names for
function-valued interface variables and their implementing functions.
Remove obsolete comment.
(erc-button-add-nickname-buttons): Attempt to query fallback function
for channel member instead of server user.
* lisp/erc/erc.el (erc--user-from-nick-function,
erc--cmem-from-nick-function): Rename former to latter.
(erc--examine-nick, erc--cmem-get-existing): Rename former to
latter. (Bug#60933)
F. Jason Park [Wed, 13 Sep 2023 12:42:24 +0000 (05:42 -0700)]
Run erc--scrolltobottom-on-pre-insert unconditionally
* lisp/erc/erc-goodies.el (erc--scrolltobottom-all): Pass `no-force'
argument to `set-window-start'.
(erc--scrolltobottom-on-pre-insert): Convert from generic to normal
function and drop `erc-input' method completely. A non-nil `insertp'
slot means a message is marked for insertion in the read-only portion
of the buffer, above the prompt. But conditionally restoring window
parameters based on that flag is insufficient because the window still
needs adjusting whenever input is typed, regardless of whether it's
erased or "inserted." (Bug#64855)
F. Jason Park [Mon, 11 Sep 2023 05:55:16 +0000 (22:55 -0700)]
; Fix example in display-buffer section of ERC manual
* doc/misc/erc.texi: Fix `display-buffer-alist' example and mention
that it's only meant for users of Emacs 29 and above.
* test/lisp/erc/erc-tests.el (erc-setup-buffer--custom-action): Add
simplistic test case for example in manual.
Stefan Kangas [Sun, 17 Sep 2023 20:56:00 +0000 (22:56 +0200)]
Rename describe-map-tree to help--describe-map-tree
This function should have been made internal in the first place.
* lisp/help.el (help--describe-map-tree): Rename from
'describe-map-tree'. Keep old name as an obsolete alias, and update
all callers.
Expanded defcustom type byte-compilation warnings (bug#65852)
Warn about more kinds of mistakes in :type arguments of `defcustom`
and `define-widget`. These include:
- misplaced keyword args, as in (const red :tag "A reddish hue")
- missing subordinate types, as in (repeat :tag "List of names")
or (choice list string)
- duplicated values, as in (choice (const yes) (const yes))
- misplaced `other` member, as in
(choice (const red) (other nil) (const blue))
- various type name mistakes, as in (vector bool functionp)
* lisp/emacs-lisp/bytecomp.el (byte-compile--defcustom-type-quoted)
(byte-compile-nogroup-warn): Remove.
(byte-compile-normal-call): Remove call to the above.
(bytecomp--cus-warn, bytecomp--check-cus-type)
(bytecomp--custom-declare): New.
Michael Albinus [Sun, 17 Sep 2023 10:13:14 +0000 (12:13 +0200)]
Make "toolbox" and "flatpak" multi-hop completion capable in Tramp
* lisp/net/tramp-container.el (tramp-skeleton-completion-function):
Bind `tramp-verbose' to 0.
(tramp-toolbox--completion-function)
(tramp-flatpak--completion-function): Use METHOD as argument.
Use `tramp-skeleton-completion-function'.
(tramp-completion-multi-hop-methods): Add "toolbox" and "flatpak".
Add prettify-symbols configuration to 'rust-ts-mode'
* lisp/progmodes/rust-ts-mode.el
(rust-ts-mode-prettify-symbols-alist): New variable.
(rust-ts-mode--prettify-symbols-compose-p): New function.
(rust-ts-mode): Use it.
Eli Zaretskii [Sun, 17 Sep 2023 05:26:46 +0000 (01:26 -0400)]
Merge from origin/emacs-29
bcf287bd114 typescript-ts-mode.el: Minor touches 67c82710764 Improve namespacing situation WRT to recent change in typ... 33ff4fed03d Make move-end-of-line in minibuffer consistent (bug#65980)
Improve namespacing situation WRT to recent change in typescript-ts-mode.el
* lisp/progmodes/typescript-ts-mode.el
(typescript-ts--syntax-propertize):
Rename from ts-ts--syntax-propertize.
(tsx-ts--syntax-propertize-captures):
Rename from ts-ts--syntax-propertize-captures.
(typescript-ts--s-p-query):
Rename from ts-ts--s-p-query.
Update all references (bug#65470).
Michael Albinus [Sat, 16 Sep 2023 18:35:35 +0000 (20:35 +0200)]
Make "kubernetes" multi-hop completion capable in Tramp
* lisp/net/tramp-container.el (tramp-skeleton-completion-function):
New defmacro.
(tramp-container--completion-function): Use it.
(tramp-kubernetes--completion-function): Use METHOD as argument.
Use `tramp-skeleton-completion-function'.
(tramp-skeleton-kubernetes-vector): New defmacro.
(tramp-kubernetes--current-context)
(tramp-kubernetes--current-context-data): Use it.
(tramp-completion-multi-hop-methods): Add "kubernetes".
Don't use pointer arithmetic for untagging Lisp values
* src/lisp.h (XUNTAG):
Instead of casting a Lisp value to char * and subtracting the tag,
cast it to a suitable integral type and work on that.
This should result in identical or at least equivalent code, except
that it avoids potential problems arising from the restrictions on
pointer arithmetic in C. In particular, a null pointer can be neither
an operand in nor the result of pointer arithmetic.
C compilers know this and would, prior to this change, optimise
XUNTAG(obj, Lisp_Int0, mytype) != NULL
to 1. This means, for example, that make_pointer_integer and
XFIXNUMPTR could not be entrusted with null pointers, and
next_vector in alloc.c was unsafe to use.
* src/alloc.c: The size of a vector block is bound by the number of
words, not bytes, represented by the pseudovector header RESTSIZE
field, because that limits how big a PVEC_FREE object can be.
Stefan Kangas [Sat, 16 Sep 2023 12:34:20 +0000 (14:34 +0200)]
Add missing builtin package declarations
* lisp/finder.el (finder--builtins-alist): Add new package
directories 'leim' and 'obsolete' as part of the 'emacs' package.
Add new package directory 'use-package' as part of the
'use-package' package.
* lisp/net/eudc-capf.el:
* lisp/net/eudcb-ecomplete.el:
* lisp/net/eudcb-macos-contacts.el:
* lisp/net/eudcb-mailabbrev.el: Declare library as part of the
'eudc' package.
* lisp/mail/ietf-drums-date.el: Declare library as part of the
'ietf-drums' package.
* lisp/image/image-dired-dired.el:
* lisp/image/image-dired-external.el:
* lisp/image/image-dired-tags.el:
* lisp/image/image-dired-util.el: Declare library as part of the
'image-dired' package.
* lisp/emacs-lisp/oclosure.el:
* lisp/keymap.el:
* lisp/progmodes/c-ts-common.el: Declare library as part of the
'emacs' package. (Bug#62751)
Eli Zaretskii [Sat, 16 Sep 2023 11:36:49 +0000 (07:36 -0400)]
Merge from origin/emacs-29
755ae813a6a ; Declare some treesit.c functions in typescript-ts-mode.el. 89fa204b706 Fix loss of encrypted data in plstore.el d9a1175a611 Close SQL database when corresponding 'sqlite-mode' buffe... cbd8fac283a Fix Unicode normalization of characters 825be05b379 Support one-time passwords in Tramp f880b94e649 Fix the 'C' and 'c' categories of characters 58fd212d8a2 Fix Emoji zooming commands 8970cdd009a ; Fix last change. ba924be4522 ; * etc/DEBUG: Improve the redisplay section. e110312ad95 ; * doc/lispref/minibuf.texi (Text from Minibuffer): Ment... 65f4810003b tsx-ts-mode--font-lock-compatibility-bb1f97b: Improve 6fe11b88ed0 Avoid using --display in emacsclient to reuse frames on PGTK 2fc7463c0e5 ; * INSTALL: Don't advertise -O3. (Bug#65988) 29055412f2d ; Fix doc string of 'lsh' 738d8543337 Support emacsclient on Windows with server on GNU or Unix... f0a89fa1d0e ; * lisp/saveplace.el (save-place-ignore-files-regexp): F... c9cb8ee0fc0 Fix defcustom in saveplace.el (Bug#65977) 5ec8be1d589 ; * lisp/subr.el (string-suffix-p, string-prefix-p): Doc ... 809305e6d8f Fix 'window-text-pixel-size' when there are several image... ea14b0dcc20 : Doc fix. 01e8a0c6cbf Doc fix for prettify-symbols-unprettify-at-point 0065621d0d3 (report_overlay_modification): Fix bug#65929 6cc6455e931 Fix SVG colors (bug#56182) 9396d73942e * doc/emacs/text.texi (Outline Minor Mode): Add a note ab... a65d1a5a167 Improve documentation of 'list-abbrevs' 5dcc4b7eab1 Tweak s-p-f for js-ts-mode 1fb2fb501f3 typescript-ts-mode, tsx-ts-mode: Fix syntax properties fo... 946b395e7e1 * lisp/progmodes/c-ts-mode.el (c++-ts-mode): Provide (bug... 33ee3e588fd Fix regression of treesit_cursor_helper_1 d11d81dfcc6 ; Fix doc typos (Bug#65868) 6554ec22465 Update docs for passing of Thien-Thi Nguyen 5ab2792d5c1 Update defvar usage tips example in manual 35d88c657e1 Document using Flymake together with Eglot 3f04efe9e7d ; * src/font.h (struct font): Comment about use of averag... 459b5f6b6d1 ; * admin/authors.el (authors-aliases): Update. 0c029ae8bcb ; tweak etc/TODO item
Jens Schmidt [Tue, 30 May 2023 21:00:56 +0000 (23:00 +0200)]
Fix loss of encrypted data in plstore.el
* lisp/plstore.el (plstore--insert-buffer): Fix loss of encrypted
data when a plstore gets opened and saved without being decrypted
between these steps. (Bug#63627)
Earl Hyatt [Sat, 19 Aug 2023 22:26:45 +0000 (18:26 -0400)]
Make using Edmacro easier for long sequences of keys
* lisp/edmacro.el (edmacro-set-macro-to-region-lines)
(edmacro-reverse-key-order): New command and user option to
make working with longer lists of keys, such as from
'kmacro-edit-lossage', easier.
(edit-kbd-macro): Move regexps used to identify parts of
buffer to internal variables.
(edmacro--macro-lines-regexp, edmacro-mode-font-lock-keywords):
Allow noting whether the most recent line of keys is displayed
first.
(edmacro-mode-map): Bind the new command to 'C-c C-r'.
(edmacro-mode): Describe the new command in the mode
documentation string.
* doc/emacs/kmacro.texi (Edit Keyboard Macro): Mention
'edmacro-insert-key' and the newly added
'edmacro-set-macro-to-region-lines' and
'edmacro-reverse-key-line-order'.
* etc/NEWS (Edmacro): Add section describing the new features.
Eli Zaretskii [Sat, 16 Sep 2023 09:17:23 +0000 (12:17 +0300)]
Fix Unicode normalization of characters
* lisp/international/ucs-normalize.el
(ucs-normalize-composition-exclusions, check-range): Update from
Unicode 15.0 data. (Bug#65996)
* test/lisp/international/ucs-normalize-tests.el
(ucs-normalize-tests--failing-lines-part1)
(ucs-normalize-tests--failing-lines-part2): Update to reflect
changes in ucs-normalize.el.
* admin/notes/unicode: Mention the updates in ucs-normalize.el.
Po Lu [Sat, 16 Sep 2023 02:38:46 +0000 (10:38 +0800)]
Update Android port
* java/org/gnu/emacs/EmacsContextMenu.java (display): Return
false if the list of menu buttons is empty, lest Android cease
displaying menus on the assumption that Emacs is defective.
* src/fns.c (sort_list): Render sentence motion commands
functional within commentary
* src/sfntfont.c (sfntfont_list_family): Sort and deduplicate
the returned family list and make it a list of symbols.
(syms_of_sfntfont) <Qstring_lessp>: New defsym.
Stefan Monnier [Fri, 15 Sep 2023 18:44:59 +0000 (14:44 -0400)]
(mutually_exclusive_p): Fix the regression from commit 6fad73d7cc53
Commit 6fad73d7cc53 throws away some useful optimization because
it misfired in some cases (as seen in bug#657260). Here we try to
recover those useful optimizations with a slightly more careful
algorithm.
* src/regex-emacs.c (mutually_exclusive_aux): Rename from
`mutually_exclusive_p`. Add two new args. Improve the
case where we need to recurse.
(mutually_exclusive_p): New function defined on top of it.
* test/src/regex-emacs-tests.el (regexp-tests-backtrack-optimization):
Re-enable the test.
* src/regex-emacs.c (mutually_exclusive_exactn)
(mutually_exclusive_charset): New functions, extracted from
`mutually_exclusive_p`.
(mutually_exclusive_p): Use them.
* lisp/progmodes/typescript-ts-mode.el
(tsx-ts-mode--font-lock-compatibility-bb1f97b):
Test the more complex query, because the current one leads to
false positives (mentioned in bug#65470).
Davide Masserut [Thu, 24 Aug 2023 16:33:39 +0000 (18:33 +0200)]
Avoid using --display in emacsclient to reuse frames on PGTK
Using hard-coded display values can cause PGTK graphical frames to
open using the wrong backend or not open at all.
* Makefile.in (install-etc): Use --reuse-frame instead of
--display=$DISPLAY. (Bug#65509)
Stefan Kangas [Fri, 15 Sep 2023 08:52:03 +0000 (10:52 +0200)]
Mark two tests as expensive
* test/lisp/calendar/todo-mode-tests.el
(todo-test-add-and-delete-file):
* test/lisp/simple-tests.el (simple-tests-shell-command-39067):
Mark tests taking more than 10 seconds to run on a MacBook Pro from
2015 as expensive.
Eli Zaretskii [Fri, 15 Sep 2023 07:02:00 +0000 (10:02 +0300)]
Support emacsclient on Windows with server on GNU or Unix systems
* lisp/server.el (server-process-filter): If 'tty-name' is literally
"CONOUT$", assume the client runs on MS-Windows and force the
frame type to GUI. This allows to run emacsclient on MS-Windows
when the server runs on a Posix host. (Bug#65812)
Po Lu [Fri, 15 Sep 2023 02:30:12 +0000 (10:30 +0800)]
Correct bug#65919
* src/process.c (child_signal_notify): Expunge call to
non-reentrant function from signal handler.
* src/xfns.c (setup_xi_event_mask): Cease selecting for
XI_FocusIn and XI_FocusOut under X toolkit builds.
* src/xterm.c (xi_handle_interaction, xi_handle_focus_change)
(xi_handle_focus_change): Make conditional on GTK 3 or no
toolkit builds.
(xi_handle_delete_frame, x_free_frame_resources): Adjust
correspondingly.
(handle_one_xevent) <EnterNotify, LeaveNotify>: Examine
EnterNotify and LeaveNotify events for focus changes
irrespective of whether XI2 is enabled under the X toolkit and
GTK 2.x.
Po Lu [Thu, 14 Sep 2023 08:53:04 +0000 (16:53 +0800)]
Avert a crash in the Android last resort font driver
* java/org/gnu/emacs/EmacsFontDriver.java (FONT_INVALID_CODE):
New constant.
(hasChar, encodeChar): Accept a jint character code rather than
a jchar.
* java/org/gnu/emacs/EmacsSdk23FontDriver.java (hasChar)
(encodeChar): Return 0 or FONT_INVALID_CODE if the character is
not representable in a Java char.
Stefan Kangas [Wed, 13 Sep 2023 20:45:02 +0000 (22:45 +0200)]
Doc fix for prettify-symbols-unprettify-at-point
* lisp/progmodes/prog-mode.el
(prettify-symbols-unprettify-at-point): Document that it has to be
set before enabling 'prettify-symbols-mode'. (Bug#65884)
Yuan Fu [Thu, 14 Sep 2023 02:16:04 +0000 (19:16 -0700)]
Fix treesit-font-lock-fontify-region wrt local parsers
* lisp/treesit.el (treesit--update-ranges-local): Minor change.
(treesit-font-lock-fontify-region): Don't try to fontify if node is
nil. Don't use alist-get to get the root node for a language: there
might be multiple root nodes (from multiple local parsers) for the
same language.
(treesit-major-mode-setup): Remove existing local parsers when major
mode is activated.
Po Lu [Thu, 14 Sep 2023 01:57:09 +0000 (09:57 +0800)]
Improve the Android last resort font driver
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (Sdk7Typeface):
Rename fileName to familyName and cease attempting to infer a
style from it.
(EmacsSdk7FontDriver): Employ preset typefaces rather than
enumerating each typeface within the system fonts directory.
(draw): Circumvent kerning difficulties by advancing past each
character individually.
Yuan Fu [Thu, 14 Sep 2023 01:14:03 +0000 (18:14 -0700)]
Improve docstring for treesit-language-at
* lisp/treesit.el (treesit-language-at-point-function)
(treesit-language-at): Several people has confused over this, make it
extra clear than treesit-language-at requires
treesit-language-at-point-function to work.