Stefan Monnier [Thu, 14 Mar 2024 16:49:08 +0000 (12:49 -0400)]
Followup changes to `cl-type-of`
These changes came up while working on `cl-type-of` but are not
directly related to the new `cl-type-of`.
The BASE_PURESIZE bump was needed at some point on one of my
machine, not sure why.
* src/puresize.h (BASE_PURESIZE): Bump up.
* src/sqlite.c (bind_value): Don't use `Ftype_of`.
* lisp/emacs-lisp/seq.el (seq-remove-at-position): Simplify.
* lisp/emacs-lisp/cl-preloaded.el (finalizer):
New (previously missing) type.
* doc/lispref/objects.texi (Type Predicates): Minor tweaks.
Stefan Monnier [Sun, 17 Mar 2024 21:29:02 +0000 (17:29 -0400)]
(primitive-function): New type
The type hierarchy and `cl-type-of` code assumed that `subr-primitive`
only applies to functions, but since it also accepts special-forms it makes
it an unsuitable choice since it can't be a subtype of `compiled-function`.
So, use a new type `primitive-function` instead.
* lisp/subr.el (subr-primitive-p): Fix docstring (bug#69832).
(primitive-function-p): New function.
* lisp/emacs-lisp/cl-preloaded.el (primitive-function): Rename
from `subr-primitive` since `subr-primitive-p` means something else.
* src/data.c (Fcl_type_of): Return `primitive-function` instead
of `subr-primitive` for C functions.
(syms_of_data): Adjust accordingly.
Stefan Monnier [Tue, 12 Mar 2024 13:26:24 +0000 (09:26 -0400)]
(cl-type-of): New function to return more precise types (bug#69739)
* src/data.c (Fcl_type_of): New function, extracted from `Ftype_of`.
Make it return more precise types for symbols, integers, and subrs.
(Ftype_of): Use it.
(syms_of_data): Define the corresponding new symbols and defsubr
the new function.
* doc/lispref/objects.texi (Type Predicates): Document it.
* src/comp.c (emit_limple_insn): Use `Fcl_type_of`.
* lisp/emacs-lisp/cl-preloaded.el (subr): Demote it to `atom`.
(subr-native-elisp, subr-primitive): Add `compiled-function` as
parent instead.
(special-form): New type.
Kévin Le Gouguec [Mon, 12 Feb 2024 07:29:19 +0000 (08:29 +0100)]
; Re-apply accidentally reverted commit
This re-applies:
2024-03-17 "Fix vc-dir when "remote" Git branch is local"
(21828f288ef)
reverted as part of the unrelated:
2024-03-17 "Update modus-themes to their 4.4.0 version"
(67b0c1c09ea)
The original commit message follows:
Fix vc-dir when "remote" Git branch is local
While in there, add that "tracking" branch to the vc-dir
buffer. For bug#68183.
* lisp/vc/vc-git.el (vc-git-dir-extra-headers): Reduce
boilerplate with new function 'vc-git--out-ok'; stop calling
vc-git-repository-url when REMOTE is "." to avoid throwing an
error; display tracking branch; prefer "none (<details...>)" to
"not (<details...>)" since that reads more grammatically
correct.
(vc-git--out-ok): Add documentation.
(vc-git--out-str): New function to easily get the output from a
Git command.
* test/lisp/vc/vc-git-tests.el (vc-git-test--with-repo)
(vc-git-test--run): New helpers, defined to steer clear of
vc-git-- internal functions.
(vc-git-test-dir-track-local-branch): Check that vc-dir does
not crash.
Juri Linkov [Sun, 17 Mar 2024 17:57:05 +0000 (19:57 +0200)]
* lisp/tab-bar.el (tab-bar-select-restore-windows): New defcustom.
(tab-bar-select-restore-windows): New function.
(tab-bar-select-tab): Let-bind window-restore-killed-buffer-windows
to tab-bar-select-restore-windows (bug#68235).
* doc/misc/modus-themes.org: Update the manual to better document
existing functionality and cover the new features.
* etc/themes/modus-operandi-deuteranopia-theme.el:
* etc/themes/modus-operandi-theme.el:
* etc/themes/modus-operandi-tinted-theme.el:
* etc/themes/modus-operandi-tritanopia-theme.el:
* etc/themes/modus-vivendi-deuteranopia-theme.el:
* etc/themes/modus-vivendi-theme.el:
* etc/themes/modus-vivendi-tinted-theme.el:
* etc/themes/modus-vivendi-tritanopia-theme.el: Update the
palette of each theme.
* etc/themes/modus-themes.el (require): Remove call to cl-lib
and do not use relevant functions.
(modus-themes-operandi-colors, modus-themes-vivendi-colors)
(modus-themes-version, modus-themes-report-bug): Remove old
calls to 'make-obsolete' and related.
(modus-themes--annotate-theme): Tweak the completion annotation function.
(modus-themes--org-block): Deprecate the user option 'modus-themes-org-blocks'.
(modus-themes-faces): Update faces.
(modus-themes-custom-variables): Update the list of custom
variables.
Detailed release notes are available here:
<https://protesilaos.com/codelog/2024-03-17-modus-themes-4-4-0/>.
Kévin Le Gouguec [Mon, 12 Feb 2024 07:29:19 +0000 (08:29 +0100)]
Fix vc-dir when "remote" Git branch is local
While in there, add that "tracking" branch to the vc-dir
buffer. For bug#68183.
* lisp/vc/vc-git.el (vc-git-dir-extra-headers): Reduce
boilerplate with new function 'vc-git--out-ok'; stop calling
vc-git-repository-url when REMOTE is "." to avoid throwing an
error; display tracking branch; prefer "none (<details...>)" to
"not (<details...>)" since that reads more grammatically
correct.
(vc-git--out-ok): Add documentation.
(vc-git--out-str): New function to easily get the output from a
Git command.
* test/lisp/vc/vc-git-tests.el (vc-git-test--with-repo)
(vc-git-test--run): New helpers, defined to steer clear of
vc-git-- internal functions.
(vc-git-test-dir-track-local-branch): Check that vc-dir does
not crash.
* cross/ndk-build/ndk-build.mk.in (NDK_BUILD_CXX_STL)
(NDK_BUILD_CXX_LDFLAGS): New variables.
* cross/ndk-build/ndk-resolve.mk (NDK_SYSTEM_LIBRARIES):
Introduce several other C++ libraries sometimes present on
Android.
(NDK_SO_EXTRA_FLAGS_$(LOCAL_MODULE)): Insert NDK_BUILD_CXX_STL
when any of these new C++ libraries are requested.
* m4/ndk-build.m4: Completely rewrite C++ compiler and library
detection.
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Attempt to
load more libraries from static initializer.
Stefan Monnier [Sun, 17 Mar 2024 03:10:48 +0000 (23:10 -0400)]
debug.el: Prevent re-entering the debugger for the same error
We can have several active `handler-bind`s that all want to invoke the
debugger, in which case we can have the following sequence:
- The more deeply nested handler calls the debugger.
- After a while the user invokes `debugger-continue`.
- `signal_or_quit` propagates the error up the stack to the
second handler, which calls the debugger again.
- The user thus ends up right back at the same place, as if
`debugger-continue` had not be processed.
Fix this by remembering the last processed error and skipping
the debugger if we bump into it again.
* lisp/emacs-lisp/debug.el (debugger--last-error): New var.
(debugger--duplicate-p): New function.
(debug): Use them.
Martin Rudalics [Fri, 15 Mar 2024 09:35:27 +0000 (10:35 +0100)]
Further adjustments for restoring killed buffer windows (Bug#68235)
* etc/NEWS: Announce 'window-restore-killed-buffer-windows'.
* src/buffer.h (struct buffer) : New field last_name_.
* src/buffer.c (Fbuffer_last_name): New function to return last
name of buffer before it was killed or renamed.
(bset_last_name, Fget_buffer_create, Fmake_indirect_buffer)
(Frename_buffer, Fkill_buffer, init_buffer_once): Set buffer's
last_name_ field accordingly.
* src/window.c (window_restore_killed_buffer_windows): New
variable replacing Vwindow_kept_windows_functions.
(Fset_window_configuration): Use
window_restore_killed_buffer_windows instead of
Vwindow_kept_windows_functions.
* lisp/window.el (window--state-put-2, window-state-put): Use
'window-restore-killed-buffer-windows' instead of
'window-kept-windows-functions'.
* doc/lispref/windows.texi (Window Configurations): Describe
'window-restore-killed-buffer-windows' which replaces
'window-kept-windows-functions'.
Keep indenting text when 'shr-fill-text' is nil (bug#69555)
The 'shr-fill-...' functions handle both hard-filling (adding
newlines to break long lines) and indentation. Setting
'shr-fill-text' to nil currently causes these functions to be
short-circuited completely, so e.g. blockquotes are no longer
indented, whereas the intent of this user option is only to
prevent hard-filling to let visual-line-mode reflow text.
* lisp/net/shr.el (shr-fill-lines): Document that the function
handles more than just filling; move the 'shr-fill-text' check...
(shr-fill-line): ... here, after indentation has been taken care
of.
* test/lisp/net/shr-resources/blockquote.html:
* test/lisp/net/shr-resources/blockquote.txt: New test resources.
* test/lisp/net/shr-tests.el (shr-test--rendering-check): Rename
from 'shr-test', to make the relationship with the 'rendering'
testcase clearer; prefer 'file-name-concat' to 'format'; raise
ERT failure if need be, calling (ert-fail ...) directly instead
of (should (not (list ...))).
(shr-test--rendering-extra-configs): New variable to easily check
that user customizations do not degrade rendering.
(rendering): Consult that new variable; delegate failure-raising
to reduce duplication.
Dmitry Gutov [Fri, 15 Mar 2024 02:28:45 +0000 (04:28 +0200)]
(project--value-in-dir): Ensure that the global value is still honored
* lisp/progmodes/project.el (project--value-in-dir):
Ensure that the global value of the variable is still honored,
when the variable is not in dir-locals.
Stefan Monnier [Fri, 15 Mar 2024 02:15:41 +0000 (22:15 -0400)]
(set-auto-mode): Streamline to fix bug#67795
The old code tested if the mode function is `fboundp` but in an
inconsistent way and without paying attention to
`major-mode-remap`.
* lisp/files.el (set-auto-mode-0): Return `:keep` rather than nil if
the mode was already set. And emit a warning when the mode function
doesn't exist.
(set-auto-mode): Remove checks that the mode function exists now that
`set-auto-mode-0` does it for us. Adjust to the new return values of
that function, and simplify the code using a big `or` instead of
a sequence of steps each setting&testing `done`.
(hack-local-variables--find-variables): Use `major-mode-remap`
when skipping the "mode:" entries that specify modes we don't have.
Also, when (eq handle-mode t), don't bother building a list of results
only to return a single element in the end.
Juri Linkov [Thu, 14 Mar 2024 18:11:33 +0000 (20:11 +0200)]
* lisp/textmodes/flyspell.el (flyspell-check-changes): New user option.
(flyspell--mode-on): Add flyspell-check-changes to post-command-hook
when flyspell-check-changes is non-nil.
(flyspell--mode-off): Remove flyspell-check-changes from post-command-hook.
(flyspell-check-changes): New function (bug#61874).
Juri Linkov [Thu, 14 Mar 2024 17:37:44 +0000 (19:37 +0200)]
* lisp/progmodes/project.el: Don't run modes from .dir-locals.el.
(project--value-in-dir): Use 'alist-get' on 'file-local-variables-alist'
to avoid calling 'hack-local-variables-apply' via
'hack-dir-local-variables-non-file-buffer' because it might enable
undesirable modes such as flyspell-mode in a temporary buffer (bug#69740).
Liu Hui [Mon, 26 Feb 2024 10:46:36 +0000 (18:46 +0800)]
Detect the readline support for Python shell completion
* lisp/progmodes/python.el
(python-shell-comint-watch-for-first-prompt-output-filter):
Detect the readline support.
(python-shell-readline-completer-delims): Update docstring.
(python-shell-completion-native-setup): Move the readline
detection code to ...
(python-shell-readline-detect): ... new function.
(python-shell-completion-native-turn-on-maybe): Skip if Python
has no readline support.
(python-shell-completion-at-point): Respect the delimiter of
readline completer in non-native completion.
* test/lisp/progmodes/python-tests.el
(python-shell-completion-at-point-1)
(python-shell-completion-at-point-native-1)
(python-completion-at-point-1, python-completion-at-point-2)
(python-completion-at-point-pdb-1)
(python-completion-at-point-while-running-1)
(python-completion-at-point-native-1)
(python-completion-at-point-native-2)
(python-completion-at-point-native-with-ffap-1)
(python-completion-at-point-native-with-eldoc-1): Skip tests if
Python has no readline support.
(python-shell-completion-at-point-jedi-completer): Add test for
non-native Python shell completion. (bug#68559)
Visuwesh [Sat, 9 Mar 2024 09:47:26 +0000 (15:17 +0530)]
Add bounds-of-thing-at-point property for 'number'
* lisp/thingatpt.el (thing-at-point-decimal-regexp)
(thing-at-point-hexadecimal-regexp): Extract regexps from...
(number-at-point): ...here. Use them in 'number-at-point'.
(number): Add 'bounds-of-thing-at-point' property as
`forward-word' does not always return the right boundary,
e.g., in latex-mode buffers. (Bug#69239)
Raffael Stocker [Mon, 4 Mar 2024 18:06:07 +0000 (19:06 +0100)]
Fix resetting keyboard hook state on MS-Windows
Register session notifications so Emacs is notified when the
computer is being locked, as required to reset the low level
keyboard hook state. (Bug#69083).
* src/w32term.h:
* src/w32fns.c (setup_w32_kbdhook, remove_w32_kbdhook)
(w32_wnd_proc, globals_of_w32fns, maybe_pass_notification):
Register and manage session notifications in GUI Emacs.
* src/w32console.c (initialize_w32_display, find_ime_window):
* src/w32xfns.c (drain_message_queue): Register notifications
and reset keyboard hook state in console Emacs.
* src/w32.c (term_ntproc): Un-register session notifications
when terminating.
Po Lu [Thu, 14 Mar 2024 05:45:48 +0000 (13:45 +0800)]
Improve /proc/self/exe substitution on Android
* exec/configure.ac (USER_SWORD): New macro.
* exec/exec.c (format_pid): Export this function.
* exec/exec.h:
* exec/trace.c (canon_path): New function.
(handle_readlinkat, handle_openat): Test complete file name
against /proc/self/exe, and further check for /proc/pid/exe.
Po Lu [Wed, 13 Mar 2024 02:59:39 +0000 (10:59 +0800)]
Port more notification senders to non-XDG systems
* doc/lispref/os.texi (Desktop Notifications): Document that
`:timeout' is now implemented.
* java/org/gnu/emacs/EmacsDesktopNotification.java
(EmacsDesktopNotification): New field delay.
(display1): Set delay on Android 8.0 and up.
* lisp/erc/erc-desktop-notifications.el
(erc-notifications-notify): Call Android or Haiku notification
functions on those systems.
* lisp/gnus/gnus-notifications.el (gnus-notifications-action)
(gnus-notification-close): Remove dismissed notifications from
the notification to message map.
(gnus-notifications-notify): Call android-notifications-notify
if possible.
* src/androidselect.c (android_init_emacs_desktop_notification):
Update accordingly.
(android_notifications_notify_1): New argument TIMEOUT.
(Fandroid_notifications_notify): New argument QCtimeout.
(syms_of_androidselect) <QCtimeout>: New symbol.
Stefan Monnier [Tue, 12 Mar 2024 20:09:23 +0000 (16:09 -0400)]
Try and avoid hardcoding lists of function types
* lisp/bind-key.el (bind-key--get-binding-description):
Show docstrings for compiled functions also. Don't hardcode knowledge
about various particular kinds of functions.
* lisp/emacs-lisp/bytecomp.el (display-call-tree): Remove special
support for functions with a `byte-code` body since we never generate
that nowadays. Don't hardcode knowledge
about various particular kinds of functions.
Stefan Monnier [Tue, 12 Mar 2024 19:43:43 +0000 (15:43 -0400)]
Cleanup some type predicates
Use the new `cl--define-built-in-type` to reduce the manually
maintained list of built-in type predicates.
Also tweak docstrings to use "supertype" rather than "super type",
since it seems to be what we use elsewhere.
* lisp/subr.el (special-form-p): Remove redundant `fboundp` test.
(compiled-function-p): Don'Return nil for subrs that aren't functions.
* lisp/emacs-lisp/cl-macs.el (type predicates): Trim down the list.
* lisp/emacs-lisp/cl-preloaded.el (cl--define-built-in-type):
Register the corresponding predicate if applicable.
(atom, null): Specify the predicate name explicitly.
Stefan Monnier [Tue, 12 Mar 2024 16:00:17 +0000 (12:00 -0400)]
cl-generic: Signal an error when a type specializer won't work
* lisp/emacs-lisp/cl-generic.el (cl--generic--unreachable-types): New var.
(cl-generic-generalizers :extra "typeof"): Use it to signal an
error for those types we can't handle.
Jsonrpc: improve performance of process filter function
`run-at-time' keeps `timer-list' list sorted by inserting each
timer based on the timer value. This means that
`timer--time-less-p' needs is executed ~N*N/2 times for each N
pending messages. This means that jsonrpc becomes unusable
for connections that generate a lot messages at the same time.
* lisp/jsonrpc.el (Version): Bump to 1.0.25.
(jsonrpc--process-filter): Improve performance by activating
timers in a different order. (Bug#69241)
* src/android.h (struct android_emacs_service): New function.
* src/androidselect.c (android_notifications_notify_1)
(Fandroid_notifications_notify): New parameter QCresident; save
it within notification lists.
(android_notification_deleted, android_notification_action):
Adjust for changes to the format of notification lists and
cancel non-resident notifications when an action is selected.
(syms_of_androidselect): <QCresident>: New symbol.
Po Lu [Mon, 11 Mar 2024 13:40:47 +0000 (21:40 +0800)]
Implement notification callbacks on Android
* doc/lispref/os.texi (Desktop Notifications): Document that
:on-cancel, :on-action and :actions are now supported on
Android.
* java/org/gnu/emacs/EmacsActivity.java (onNewIntent): New
function.
* java/org/gnu/emacs/EmacsDesktopNotification.java
(NOTIFICATION_ACTION, NOTIFICATION_TAG, NOTIFICATION_DISMISSED):
New constants. <actions, titles>: New fields.
(insertActions): New function.
(display1, display): Insert actions on Jelly Bean and up, and
arrange to be notified when the notification is dismissed.
(CancellationReceiver): New class.
* java/org/gnu/emacs/EmacsNative.java (sendNotificationDeleted)
(sendNotificationAction): New functions.
* src/androidgui.h (struct android_notification_event): New
structure.
(union android_event): New member for notification events.
* src/androidselect.c (android_init_emacs_desktop_notification):
Update JNI signatures.
(android_notifications_notify_1, Fandroid_notifications_notify):
New arguments ACTIONS, ACTION_CB and CANCEL_CB. Convert and
record them as appropriate.
(android_notification_deleted, android_notification_action): New
functions.
(syms_of_androidselect): Prepare a hash table of outstanding
notifications.
<QCactions, QCon_action, QCon_cancel> New defsyms.
* src/androidterm.c (handle_one_android_event)
<ANDROID_NOTIFICATION_DELETED>
<ANDROID_NOTIFICATION_ACTION>: Dispatch event contents to
androidselect.c for processing.
* src/androidterm.h:
* src/androidvfs.c (java_string_class): Export.
* src/keyboard.c (kbd_buffer_get_event) <NOTIFICATION_EVENT>:
Call callback specified by the event.
* src/termhooks.h (enum event_kind) [HAVE_ANDROID]: New
enum NOTIFICATION_EVENT.
Remove trailing period as per "(elisp) Error Symbols".
Relates to the following discussion:
https://lists.gnu.org/r/emacs-devel/2023-10/msg00473.html
https://lists.gnu.org/r/emacs-devel/2024-03/msg00340.html
Paul Eggert [Mon, 11 Mar 2024 07:03:39 +0000 (00:03 -0700)]
Change bare-symbol back to match intent
Also, attempt to document the intent better.
Problem reported by Alan Mackenzie (Bug#69684).
* src/data.c (Fbare_symbol): Do not signal if the SYM is a symbol
with position and symbols-with-pos-enabled is nil. Instead,
ignore symbols-with-pos-enabled, as that was the intent.
* test/src/data-tests.el (data-tests-bare-symbol):
New test, to help prevent this bug from reoccurring.
Improve pp-emacs-lisp-code backquote form printing
* lisp/emacs-lisp/pp.el (pp--quoted-or-unquoted-form-p): New helper
function.
(pp--insert-lisp): Take care of quoted, backquoted and
unquoted expressions; print using an recursive call.
(pp--format-list): Exclude more cases from printing as a function call
by default. Print lists whose second-last element is an (un)quoting
symbol using dotted list syntax; e.g. (a b . ,c) instead of (a b \, c).