Move side-effect-free and pure declarations to function definitions
Some Lisp functions still had their `side-effect-free` and `pure`
properties declared in byte-opt.el; do it at their definition instead.
The lists in byte-opt.el now only contain functions implemented in C
and function aliases.
Define 'display-time-time-and-date-indicator' face
* etc/NEWS: Announce the new face for the 'display-time-format'.
* lisp/time.el (display-time-time-and-date-indicator): Define new face.
(display-time-string-forms): Use the new face. (Bug#61567)
Alan Mackenzie [Fri, 17 Feb 2023 09:14:10 +0000 (09:14 +0000)]
Add handling of the C11 _Generic construct to C Mode
This fixes bug #61481.
* lisp/progmodes/cc-engine.el (c-guess-basic-syntax): Add a new CASE 6 for
_Generic.
* lisp/progmodes/cc-fonts.el (c-fontify-types-and-refs): Use `let*' rather
than `let'.
(c-get-fontification-context): Add the new result `generic', and add handling
to determine it.
(c-font-lock-declarations): Call c-font-lock-c11-generic-clause when needed.
(c-font-lock-c11-generic-clause): New function.
* lisp/progmodes/cc-langs.el (c-generic-kwds, c-generic-key): New lang
constants/variable.
Stefan Kangas [Fri, 17 Feb 2023 05:30:17 +0000 (06:30 +0100)]
Merge from origin/emacs-29
f1f571e72ae Add electric indent for preproc directives 83af806ab7c Rename 'emacs-news-toggle-tag' to 'emacs-news-cycle-tag' 5bc88b3b175 Add menu to news-mode 40f4bc4e0aa ; Avoid installing VC package dependencies multiple times 1c9d81a2b42 Attempt to recognise if a VC package has no Elisp files
It looks like there are few if no other cases where we get this
particular error in the AST than with insertion of '#'.
Consider:
```
int
main()
{
|
}
```
If we only add '#' the AST yields (ERROR (ERROR)), which we can
exploit to hook onto electric indent. The end result should be the
hashtag anchored to column 0.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New rule.
(c-ts-base-mode): Add # to electric-indent-chars.
Robert Pluim [Thu, 16 Feb 2023 12:04:53 +0000 (13:04 +0100)]
Rename 'emacs-news-toggle-tag' to 'emacs-news-cycle-tag'
* lisp/textmodes/emacs-news-mode.el (emacs-news-cycle-tag): Renamed
from 'emacs-news-toggle-tag'.
(emacs-news-mode-map, emacs-news-mode-menu): Use new name.
* test/lisp/textmodes/emacs-news-mode-resources/cycle-tag.erts:
Renamed from "toggle-tag.erts".
* test/lisp/textmodes/emacs-news-mode-tests.el (emacs-news-cycle-tag):
Rename test from 'emacs-news-toggle-tag', and call
'emacs-news-cycle-tag' with new resource file name.
Robert Pluim [Thu, 16 Feb 2023 09:40:40 +0000 (10:40 +0100)]
Add menu to news-mode
* lisp/textmodes/emacs-news-mode.el (emacs-news-mode-map): Add binding
for 'emacs-news-delete-temporary-markers'.
(emacs-news-mode-menu): Add menu for common actions.
; Avoid installing VC package dependencies multiple times
* lisp/emacs-lisp/package-vc.el (package-vc-install-dependencies):
Check if two package names are eq, instead checking the structural
equality of package-desc objects.
Attempt to recognise if a VC package has no Elisp files
* lisp/emacs-lisp/package-vc.el (package-vc-non-code-file-names): Add
new variable used to avoid false-positives.
(package-vc--unpack): Recursively search for .el files excluding the
ones listed in 'package-vc-non-code-file-names', offering to abort the
installation if none are found.
Fix test errors when run with fancy charset (bug#61534)
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--unescaped-char-literals, test-suppression):
Bind `text-quoting-style` to `grave` around tests to force
generation of ASCII quotes.
* test/src/lread-tests.el (lread-tests--unescaped-char-literals):
Subject the reference string to the same text styling as that
under scrutiny.
* lisp/eshell/esh-mode.el (eshell-mode-unload-hook):
* lisp/eshell/esh-module.el (eshell-module-unload-hook): Make
obsolete.
* lisp/eshell/em-ls (eshell-ls-enable-in-dired,
eshell-ls-disable-in-dired): New functions...
(eshell-ls-use-in-dired): ... use them.
* lisp/eshell/esh-module.el (eshell-module--feature-name,
eshell-unload-modules): New functions.
(eshell-unload-extension-modules): Use 'eshell-unload-modules'.
* lisp/eshell/em-hist.el: Stop requiring 'eshell' and 'em-pred'
(extension modules shouldn't require each other so they can be
independent).
(eshell-hist-parse-modifier): Ensure this can only be called when
'em-pred' is in use, and declare the relevant function.
* lisp/eshell/eshell.el (eshell-non-interactive-p): Move from here...
* lisp/eshell/esh-mode.el (eshell-non-interactive-p): ... to here.
F. Jason Park [Tue, 14 Feb 2023 15:29:25 +0000 (07:29 -0800)]
; Prevent ERC-induced false positive in JUnit report
* test/lisp/erc/erc-scenarios-internal.el: Mimic other test files,
like perl-mode-tests.el, in setting `ert-load-file-name' globally.
This file formerly caused a false positive in the error detection
logic of `ert-write-junit-test-summary-report'. It affected all
scheduled pipelines, including those for the release branch, Emacs 29.
Robert Pluim [Wed, 15 Feb 2023 13:31:43 +0000 (14:31 +0100)]
New option 'diff-ignore-whitespace-switches'
Allows specifying the switches to use when ignoring whitespace for
those of us who don't like "-b".
* lisp/vc/diff-mode.el (diff-ignore-whitespace-switches): New defcustom.
(diff-refresh-hunk): Use it when ignoring whitespace.
* doc/emacs/files.texi (Diff Mode): Describe the new option.
* etc/NEWS: Announce the new option.
Robert Pluim [Tue, 10 Jan 2023 18:55:50 +0000 (19:55 +0100)]
Teach 'diff-ignore-whitespace-hunk' how to regenerate all hunks
This implements the request from Bug#58516.
* lisp/vc/diff-mode.el (diff--ignore-whitespace-all-hunks): New
function. Iterate over all hunks, regenerate ignoring whitespace
changes.
(diff-ignore-whitespace-hunk): Call `diff--ignore-whitespace-all-hunks'
when called with a prefix arg.
* doc/emacs/files.texi (Diff Mode): Describe new functionality.
* etc/NEWS: Announce the change.
Randy Taylor [Thu, 9 Feb 2023 02:43:04 +0000 (21:43 -0500)]
Fix rust-ts-mode type and module highlighting (Bug#61302)
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode--font-lock-settings):
Specify import queries to avoid clashing with scoped identifiers in
the code. Highlight attributes with font-lock-preprocessor-face.
Dmitry Gutov [Tue, 14 Feb 2023 17:29:30 +0000 (19:29 +0200)]
rust-ts-mode: Highlight variable reassignments
* lisp/progmodes/rust-ts-mode.el (rust-ts-mode):
New treesit font-lock feature: 'assignment' (bug#61302).
(rust-ts-mode--fontify-pattern): Remove the node lookup step.
(rust-ts-mode--font-lock-settings): Update variable declaration
queries to match the 'pattern' child node right away. Add
highlights for 'assignment.
Gregory Heytings [Tue, 14 Feb 2023 20:22:50 +0000 (20:22 +0000)]
Improve backward compatibility of save-restriction
* src/editfns.c (save_restriction_save_1): Renamed from
'save_restrictions_save'. Make it static.
(save_restriction_restore_1): Renamed from
'save_restriction_restore'. Make it static.
(save_restriction_restore): New function, combining
'save_restriction_save_1' and 'narrowing_locks_save'.
(save_restriction_save): New function, combining
'save_restriction_restore_1' and 'narrowing_locks_restore'.
(Fsave_restriction): Restore the previous code.
(narrowing_locks_save, narrowing_locks_restore): Make them static.
* src/lisp.h: Remove two functions that are not externally visible
anymore.
* src/comp.c (helper_save_restriction): Restore the previous code.
* src/bytecode.c (exec_byte_code): Restore the previous code.
Jonas Bernoulli [Wed, 1 Feb 2023 19:25:16 +0000 (20:25 +0100)]
Rewrite emoji's usage of transient
* lisp/international/emoji.el:
(emoji--done-derived): Remove variable.
(emoji-insert, emoji-recent, emoji-search, emoji-list-select):
Define using 'transient-define-prefix'. Use a base suffix group
whose value is calculated dynamically.
(emoji--setup-prefix, emoji--setup-suffixes, emoji-group-description):
New functions used to dynamically calculate suffixes.
(emoji--narrow): New suffix class, used to pass state to recursive,
narrowed invocations of the prefix command the user initially invoked.
(emoji-insert-glyph): New suffix command that is used for all glyphs
that have no derivations. Previously a separate command was define
for each glyph.
(emoji--fontify-glyph): Replace 'inhibit-derived' argument with
'done-derived' argument.
(emoji--define-transient): Remove function.
(emoji--layout): New function, replacing 'emoji--define-transient'.
Return the suffixes in 'define-transient-prefix' format. Unlike
the replaced function, do not define any new commands, instead use
either the current prefix command or 'emoji-insert-glyph'.
(emoji--recent-transient): Remove function.
(emoji--char-sequence): New function.
(emoji--add-recent): Remove all text properties from glyph.
(emoji--choose-emoji): Remove function.
F. Jason Park [Wed, 30 Nov 2022 06:53:44 +0000 (22:53 -0800)]
; Prepare to update ERC version to 5.5
* doc/misc/erc.texi: Mention in various places that ERC is also
available from GNU ELPA.
* etc/ERC-NEWS: Mention Compat dependency and shorten title for
auth-source section.
* lisp/erc/erc-backend.el: (erc-server-reconnect-function,
erc-tags-format): Update package version to 5.5.
(erc--parse-message-tags): Downcase warning "type" to remain
consistent with all other ERC warnings.
* lisp/erc/erc-button.el: (erc-button-alist): Change package-version
to 5.5.
* lisp/erc/erc-match.el (erc-match-quote-when-adding): Update package
version to 5.5.
* lisp/erc/erc-sasl.el: Mention actual info node in Commentary.
(erc-sasl): Update package version to 5.5.
(erc-sasl-password): Reword doc string.
(erc-sasl-auth-source-function): Capitalize "info" in doc string.
* lisp/erc/erc-services.el (erc-auth-source-services-function): Update
package version to 5.5. Capitalize "info" in doc string. Change
choice type from const to function-item.
* lisp/erc/erc.el (erc-password): Capitalize "info" in doc string.
(erc-inhibit-multiline-input, erc-ask-about-multiline-input,
erc-prompt-hidden, erc-hide-prompt, erc-unhide-query-prompt,
erc-join-buffer, erc-reconnect-display, erc-kill-server-hook,
erc-kill-channel-hook, erc-kill-buffer-hook,
erc-url-connect-function): Update package version to 5.5.
(erc-auth-source-server-function, erc-auth-source-join-function):
Update package version to 5.5. Change choice type from const to
function-item. Capitalize "info" in doc string.
(erc-tls): Capitalize "info" in doc string.
Paul Eggert [Mon, 13 Feb 2023 20:32:11 +0000 (12:32 -0800)]
Fix insert-file-contents on /proc files
This should fix Bug#9800 (2011-10-19).
* src/fileio.c (Finsert_file_contents):
Do not trust st_size even on regular files, as the file might
be a Linux /proc file, or it might be growing.
Instead, always read to EOF when END is nil.
Paul Eggert [Mon, 13 Feb 2023 16:51:45 +0000 (08:51 -0800)]
Don’t scan text twice to guess coding system
* src/fileio.c (Finsert_file_contents): If the file shrank
below 4 KiB, don’t read duplicate text into READ_BUF.
This also removes a use of SEEK_END, which Linux /proc
file systems do not support (not that we should get here
with /proc).
Paul Eggert [Mon, 13 Feb 2023 01:52:46 +0000 (17:52 -0800)]
Improve insert-file-contents on non-regular files
* src/fileio.c (Finsert_file_contents):
If the file is not a regular file, check REPLACE and VISIT
before doing further syscalls that won’t matter in this case.
Hoisting stack reduction ops allows them to coalesce and/or cancel out
pushing ops, and for useful operations to sink and combine, such as
not + goto-if-[not-]nil.
* lisp/emacs-lisp/byte-opt.el (byte-optimize-lapcode):
Add the rule
Ulrich Müller [Sun, 12 Feb 2023 19:57:49 +0000 (20:57 +0100)]
Fix spurious display of eclipses in Calendar
* lisp/calendar/lunar.el (eclipse-check): Don't show an eclipse
unless the phase is new moon or full moon. (bug#61460)
* test/lisp/calendar/lunar-tests.el (lunar-test-eclipse-check)
(lunar-test-phase-list): Update tests.
Stefan Kangas [Mon, 13 Feb 2023 05:30:12 +0000 (06:30 +0100)]
Merge from origin/emacs-29
eb2b0931cf1 Add lambda_expression to c-ts-common-indent-type-regexp-a... 2da05876edb ; Use the right name when specifying VC packages d4fc7012978 Tolerate missing elpa-packages.eld files 8bc1b7d0b27 Avoid warning about 'load-path' in non-interactive sessions 3d17aee13d9 ; Fix installation of dependencies for VC packages 86ca7df6a34 ; Mention Hunspell private-dictionary misfeature in doc s... 7287b7b53a1 Support webkit2gtk-4.1 048a2dabfc4 ; Fix typo
* lisp/emacs-lisp/package-vc.el
(package-vc--download-and-read-archives): Replace
'condition-case-unless-debug' with a regular 'condition-case'.
It appears a few people using third-party archives that don't serve
package specifications have been having issues with package-vc, when
toggle-on-error is enabled. In their case, package-vc would raise an
error in its first invocation, but it would go on working normally
afterwards. As this behaviour is confusing and the user can't do much
about a missing elpa-packages.eld to begin with, we satisfy ourselves
with printing out a message and continuing on.
Po Lu [Sun, 12 Feb 2023 11:55:28 +0000 (19:55 +0800)]
Support input method ``text conversion'' on X Windows
* configure.ac (HAVE_TEXT_CONVERSION): Define on X.
* etc/NEWS: Announce new change.
* src/emacs.c (main): Always call init_xterm.
* src/frame.c (do_switch_frame): Use `fset_selected_window'.
* src/insdel.c (struct safe_del_range_context): New structure.
(safe_del_range_1, safe_del_range_2, safe_del_range): New
functions.
* src/lisp.h: Export new functions.
* src/window.c (run_window_change_functions): Report selected
window and buffer changes so that the input method can be reset.
* src/xfns.c (XICCallback, Xxic_preedit_caret_callback)
(Xxic_preedit_done_callback, Xxic_preedit_start_callback)
(Xxic_preedit_draw_callback): Fix coding style.
(Xxic_string_conversion_callback): New callback.
(create_frame_xic): Register string conversion callback.
(struct x_xim_text_conversion_data): New field `size'.
(x_encode_xim_text_1, x_encode_xim_text): New functions.
(xic_string_conversion_callback): New function.
* src/xterm.c (x_reset_conversion): New function.
(text_conversion_interface): New variable.
(init_xterm): Initialize text conversion interface.
Jim Porter [Sat, 11 Feb 2023 20:37:32 +0000 (12:37 -0800)]
Make sure core Eshell modules are loaded
Previously, if you removed all (or most) extension modules from
Eshell, it failed to load esh-var.el, meaning that you couldn't use
variable expansions. To avoid this issue, we now explicitly load the
core modules in esh-mode.el.
Michael Albinus [Sat, 11 Feb 2023 17:11:56 +0000 (18:11 +0100)]
Support Tramp user name completion
* lisp/net/tramp.el (tramp-build-completion-file-name-regexp)
(tramp-completion-handle-expand-file-name)
(tramp-completion-handle-file-name-directory): Support user name
completion.
This rule hoists stack reduction to where it is more likely to be
exploited further, may reduce the op size through smaller
immediates, and sometimes removes either or both operations
outright.
The rule is inhibited by an immediately following `return` op
because other rules will produce better code in that case.
- Add the rule
(discardN-preserve-tos|dup) OP return --> OP return
where OP is a unary operation such as `not` or `car`.
- Generalise a previous rule to
NOEFFECT PRODUCER return --> PRODUCER return
where PRODUCER is now any op that pushes a value without looking at
the stack: const, varref, point etc.
Alan Mackenzie [Sat, 11 Feb 2023 10:45:31 +0000 (10:45 +0000)]
Make edebug see unused variables when lexical-binding is non-nil
This fixes bug #59213.
* lisp/emacs-lisp/cconv.el (cconv-dont-trim-unused-variables): New variable.
(cconv-fv, cconv-make-interpreted-closure): Add/amend doc strings.
(cconv-make-interpreted-closure): Test cconv-dont-trim-unused-variables, and
if non-nil, don't "optimize" the lexical environment.
* lisp/emacs-lisp/edebug.el (edebug-make-enter-wrapper): Compile a binding of
cconv-dont-trim-unused-variables to t around the call of edebug-enter.
* lisp/emacs-lisp/testconver.el (testcover-analyze-coverage): Add a new arm to
the pcase form to handle the new form of edebug-enter.
Eli Zaretskii [Sat, 11 Feb 2023 09:48:48 +0000 (11:48 +0200)]
; Remove extraneous local variables from image-dired-*.el files
These cause annoying prompts when visiting these files, and evidently
belong to a third-party package.
* lisp/image/image-dired-external.el:
* lisp/image/image-dired-tags.el:
* lisp/image/image-dired-dired.el:
* lisp/image/image-dired-util.el: Remove unsafe local-variables.
Gregory Heytings [Fri, 10 Feb 2023 20:55:47 +0000 (20:55 +0000)]
Save and restore the absence of narrowing locks
* src/editfns.c (narrowing_locks_save): Return the buffer with a
empty locks list when the current buffer has no narrowing locks.
(narrowing_locks_restore): Remove the narrowing locks if the
buffer had no narrowing locks.