Sean Whitton [Fri, 4 Apr 2025 02:49:57 +0000 (10:49 +0800)]
New buffer-local vc-buffer-overriding-fileset and vc-buffer-revision
* lisp/vc/vc.el (vc-buffer-overriding-fileset)
(vc-buffer-revision): New variables (bug#77529).
(vc-find-revision-save, vc-find-revision-no-save): Set them.
(vc-deduce-fileset): Respect vc-buffer-overriding-fileset.
(vc-print-log): Use vc-buffer-revision as a default working
revision.
* lisp/vc/vc-annotate.el (vc-annotate-parent-file)
(vc-annotate-parent-rev): Delete.
(vc-annotate): Respect vc-buffer-overriding-fileset and
vc-buffer-revision. This makes 'C-x v g' work from buffers
generated by 'C-x v ~' (bug#5424).
Set the two variables in the newly prepared buffer.
(vc-annotate-working-revision)
(vc-annotate-extract-revision-at-line)
(vc-annotate-revision-at-line, vc-annotate-warp-revision)
(vc-annotate-goto-line):
* lisp/vc/vc-svn.el (vc-svn-annotate-current-time): Use
vc-buffer-overriding-fileset instead of vc-annotate-parent-file,
vc-buffer-revision instead of vc-annotate-parent-rev.
(vc-annotate-parent-rev): Delete declaration.
* java/org/gnu/emacs/EmacsSdk7FontDriver.java (Sdk7FontEntity)
(Sdk7FontObject): Do not access `metrics' field deleted from
`EmacsService'.
* java/org/gnu/emacs/EmacsService.java (EmacsService)
<metrics, resources>: Delete fields.
<dpiX, dpiY, dpiScaled>: New fields.
(onCreate): Adjust accordingly. Record current display metrics
for subsequent comparison.
(onConfigurationChanged): New function.
* lisp/dynamic-setting.el (font-setting-change-default-font):
Enable on systems where font-get-system-font is not defined if
invoked with SET-FONT nil.
* src/android.c (sendConfigurationChanged): New function.
* src/androidgui.h (ANDROID_CONFIGURATION_CHANGED): New enumerator.
(struct android_configuration_changed): New structure.
(union android_event): Add `config' member.
* src/androidterm.c (handle_one_android_event): Handle
ANDROID_CONFIGURATION_CHANGED events.
(syms_of_androidterm): Define Qfont_render, and
Qdynamic_setting. Provide the latter.
Juri Linkov [Wed, 9 Apr 2025 18:21:53 +0000 (21:21 +0300)]
New command 'treesit-toggle-sexp-mode' (bug#76676).
* lisp/treesit.el (treesit-forward-sexp): Don't use
'treesit-sexp-type-regexp' reserved for list commands
to override their default 'list' thing.
(treesit-down-list, treesit-up-list): Use
'treesit-sexp-type-regexp' instead of 'list'
when it's non-nil.
(treesit-toggle-sexp-mode): New command.
* lisp/progmodes/c-ts-mode.el (c-ts-mode--thing-settings):
Improve 'sexp' thing settings to exclude the top-level
"translation_unit" that just moves to EOF and also "comment".
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--sexp-regexp): Remove.
(elixir-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(elixir-ts--with-parens-0-p, elixir-ts--with-parens-1-p):
New internal functions.
(elixir-ts-mode): Add 'treesit-thing-settings'
instead of 'forward-sexp-function' (bug#76788).
* lisp/progmodes/heex-ts-mode.el (heex-ts--sexp-regexp): Remove.
(heex-ts--forward-sexp): Remove to use the default 'sexp' navigation.
(heex-ts--thing-settings): New variable.
(heex-ts-mode): Use 'heex-ts--thing-settings'
instead of 'forward-sexp-function'.
* lisp/progmodes/java-ts-mode.el (java-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.
* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Improve 'sexp' thing settings to exclude the top-level
"program" that just moves to EOF and also "comment".
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode):
Improve 'sexp' thing to use settings like in c-ts-mode.
* lisp/textmodes/html-ts-mode.el (html-ts-mode--treesit-things-settings):
Improve 'sexp' thing to use settings like in c-ts-mode.
Add "doctype" to the 'list' thing.
Juri Linkov [Wed, 9 Apr 2025 17:40:09 +0000 (20:40 +0300)]
Improve 'treesit-outline-search'.
* lisp/treesit.el (treesit-outline-search): Remove
temporary arg 'recursive'. Use iteration to visit
more ranges until the next outline heading is found.
* lisp/progmodes/php-ts-mode.el (php-ts-mode):
Set 'treesit-outline-predicate' explicitly.
Sean Whitton [Wed, 9 Apr 2025 04:37:32 +0000 (12:37 +0800)]
VC-Dir: Offer to register files before checking in
* lisp/vc/vc.el (vc-only-files-state-and-model): Rewrite
checking that all files are in compatible VC states. In
particular, consistently return 'edited' when all files are
either added, removed or edited, instead of allowing the return
value to depend on the order of the files in VC-Dir, and offer
to registered unregistered files if doing so would allow the
operation to proceed.
(vc-compatible-state): Delete.
(vc-next-action): Replace call to vc-compatible-state.
Document, in this command's docstring, the new feature
implemented in vc-only-files-state-and-model.
* etc/NEWS: Announce the new feature.
Spencer Baugh [Mon, 18 Nov 2024 17:26:55 +0000 (12:26 -0500)]
Preserve an explicit * in pcm-try-completion
An explicitly typed * has different semantics from automatically
inserted PCM wildcards, so it should be preserved on try-completion. We
already do this in some cases, but now we do it more.
This is especially significant for filename completion: removing an
explicit * can take us from
~/src/emacs/trunk/*/minibuf
to
~/src/emacs/trunk//minibuf
The explicit double slash is interpreted by the file name completion
table to mean "start completing from the root directory", so deleting
the * here substantially changes semantics.
* lisp/minibuffer.el (completion-pcm--merge-completions): Don't drop
important wildcards. (bug#74420)
* test/lisp/minibuffer-tests.el (completion-pcm-test-7): Add tests.
Juri Linkov [Tue, 8 Apr 2025 17:43:41 +0000 (20:43 +0300)]
* lisp/treesit.el (treesit--after-change): New function.
(treesit-major-mode-setup): Set 'outline-minor-mode-hook'
to add 'treesit--after-change' with 'treesit-update-ranges'
to 'after-change-functions' (bug#77256).
Juri Linkov [Tue, 8 Apr 2025 17:40:10 +0000 (20:40 +0300)]
New function treesit-parsers-at for treesit-language-at (bug#77256).
* doc/lispref/parsing.texi (Multiple Languages): The variable
'treesit-language-at-point-function' is now optional for
multi-language major modes. Add description of 'treesit-parsers-at'.
* lisp/treesit.el (treesit-language-at-point-function):
Change the the docstring to remove the dissuasion against
deriving the language from parser ranges.
(treesit-language-at): Use the first parser from
'treesit-parsers-at' as the default return value when
'treesit-language-at-point-function' is nil. Adapt the docstring.
(treesit-node-at): Use 'treesit-parsers-at'.
(treesit-parsers-at): New function.
(treesit-local-parsers-at): Use 'treesit-parsers-at'
with the most part of the body moved to it.
(treesit-local-parsers-on): Replace the overlay property
'treesit-parser' with 'treesit-parser-local-p' in the docstring.
(treesit-up-list, treesit-simple-imenu, treesit-outline-level):
Use 'treesit-parsers-at'.
* lisp/progmodes/c-ts-mode.el (c-ts-mode): Don't set
'treesit-language-at-point-function'.
* lisp/progmodes/elixir-ts-mode.el (elixir-ts--treesit-language-at-point):
Remove.
(elixir-ts-mode): Don't set 'treesit-language-at-point-function'.
* lisp/progmodes/js.el (js--treesit-language-at-point): Remove.
(js-ts-mode): Don't set 'treesit-language-at-point-function'.
* lisp/progmodes/php-ts-mode.el (php-ts-mode--html-language-at-point)
(php-ts-mode--language-at-point): Remove.
(php-ts-mode): Don't set 'treesit-language-at-point-function'.
* lisp/textmodes/mhtml-ts-mode.el (mhtml-ts-mode--language-at-point):
Remove.
(mhtml-ts-mode): Don't set 'treesit-language-at-point-function'.
Use 'treesit-language-at' for mode-line lighter.
Sean Whitton [Tue, 8 Apr 2025 12:36:42 +0000 (20:36 +0800)]
Fix window selection after log-edit-show-diff, again
In October I installed a change to vc-diff-patch-string and
labelled it as "Fix window selection after log-edit-show-diff"
but that change only fixed the problem within
log-view-modify-change-comment. This change should fix window
selection after C-c C-d in ordinary checkins.
* lisp/vc/log-edit.el (log-edit-diff-fileset): Use
save-selected-window in order to respect the documented
requirement that values of log-edit-diff-function leave the Log
Edit buffer's window selected when they return.
Sean Whitton [Tue, 8 Apr 2025 06:09:07 +0000 (14:09 +0800)]
Factor out vc-only-files-state-and-model
* lisp/dired-aux.el (vc-compatible-state): Delete declaration.
(vc-only-files-state-and-model): Declare.
(dired-vc-deduce-fileset): Factor out vc-only-files-state-and-model.
* lisp/vc/vc-dir.el (require): Require cl-lib at load time, too.
(vc-only-files-state-and-model): Declare.
(vc-dir-deduce-fileset): Factor out vc-only-files-state-and-model.
* lisp/vc/vc.el (vc-only-files-state-and-model): New function,
factored out of dired-vc-deduce-fileset and vc-dir-deduce-fileset.
Po Lu [Tue, 8 Apr 2025 02:26:18 +0000 (10:26 +0800)]
Replace some calls to `intern' with DEFSYMs
* src/filelock.c (lock_file, unlock_file_handle_error): Call
constant symbols rather than interning them all the time.
(syms_of_filelock): New symbols Qask_user_about_lock,
Quserlock__handle_unlock_error, and
Quserlock__ask_user_about_supersession_threat.
Stefan Monnier [Tue, 8 Apr 2025 01:41:35 +0000 (21:41 -0400)]
(Fload, Feval_buffer): Emit a warning when lexbind is unset (bug#74145)
This emits a warning at run-time rather than at compile time.
* src/lread.c (get_lexical_binding): New function.
(Fload, Feval_buffer): Use it.
(syms_of_lread): New var `internal--get-default-lexical-binding-function`.
* lisp/files.el: Set it.
(internal--get-default-lexical-binding): New function.
Stefan Monnier [Mon, 7 Apr 2025 16:41:49 +0000 (12:41 -0400)]
eieio: Improve some obsolecence warnings and fix #<CLASS CLASS-XX> names
* lisp/emacs-lisp/eieio.el (eieio--constructor-macro): Improve message.
(eieio-object-name-string): Avoid repeated class name in the output of
`eieio-object-name`.
(make-instance, clone): Improve message.
* lisp/emacs-lisp/eieio-core.el (eieio-defclass-autoload): Use the same
obsolescence warning as elsewhere.
Stefan Monnier [Mon, 7 Apr 2025 15:54:06 +0000 (11:54 -0400)]
(Freplace_region_contents): Fix point preservation (bug#77607)
* src/editfns.c (Freplace_region_contents): Save excursion around
temporary restriction (bug#77607) and remove
`record_unwind_protect_excursion` made redundant by commit 40d8650d5177.
Stefan Monnier [Mon, 7 Apr 2025 03:49:37 +0000 (23:49 -0400)]
test/eieio: Silence warnings about slots and obsolete name arg
* test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
(eieio-test-method-order-list-3, eieio-test-method-order-list-6)
(eieio-test-method-order-list-7, eieio-test-method-order-list-8):
Delete obsolete name argument to constructors.
(eieio-test-method-order-list-4): Make sure backward compatibility is
active when testing the obsolete name arg.
* test/lisp/jsonrpc-tests.el (jsonrpc--call-with-emacsrpc-fixture):
Delete obsolete name argument to constructor.
Stefan Monnier [Mon, 7 Apr 2025 03:39:40 +0000 (23:39 -0400)]
eieio: Emit compilation warnings a bit more thoroughly
We used to warn about unknown slots only in `oref`: add the same check
for `oset` and `slot-boundp`.
Similarly, we warned about obsolete name args only when calling the
constructors: add the same check to `make-instance`.
* lisp/emacs-lisp/eieio-core.el (eieio--check-slot-name): New function
extracted from the compiler-macro of `eieio-oref`.
(eieio-oref, eieio-oset): Use it.
* lisp/emacs-lisp/eieio.el (slot-boundp): Use it.
(eieio--constructor-macro): Add category to warning.
(make-instance): Add compiler-macro to warn about obsolete name.
Sean Whitton [Mon, 7 Apr 2025 03:28:13 +0000 (11:28 +0800)]
Add bindings for vc-git-stash-delete-at-point, vc-git-stash-delete
* lisp/vc/vc-git.el (vc-git-stash-map): Bind "D" to
vc-git-stash-delete-at-point.
(vc-dir-git-mode-map): Bind "z d" to vc-git-stash-delete.
* etc/NEWS: Announce the new bindings.
Sean Whitton [Mon, 7 Apr 2025 02:03:46 +0000 (10:03 +0800)]
vc-git-checkin: Don't relativize names of temporary files
* lisp/vc/vc-git.el (vc-git-checkin)
(vc-git--stash-staged-changes): Don't relativize names of
temporary files passed to 'git apply --cached'. More generally,
these are not files managed by the underlying VCS, so they
shouldn't go in the FILE-OR-LIST argument to vc-git-command.
Sean Whitton [Sun, 6 Apr 2025 03:18:57 +0000 (11:18 +0800)]
Teach VC-Dir to automatically add and remove marks on other lines
* lisp/vc/vc-dir.el (vc-dir-allow-mass-mark-changes): New option.
(vc-dir-parent-marked-p): Replace with ...
(vc-dir--parent): ... this.
(vc-dir-children-marked-p): Replace with ...
(vc-dir--children): ... this.
(vc-dir-mark-file): Unmark subitems before marking a directory.
Offer to unmark a directory before marking a subitem.
(vc-dir-unmark-file): For an implicitly marked item, offer to
unmark it by marking everything else that's implicitly marked.
For an unmarked directory with marked subitems, offer to unmark
them all.
* etc/NEWS: Document the changes.
Sean Whitton [Sun, 6 Apr 2025 03:09:22 +0000 (11:09 +0800)]
Fix dired-vc-next-action generating inconsistent marks
* lisp/vc/vc-dir.el (vc-dir-mark-files): Document that
directories passed to this function must have trailing slashes.
Don't mark both a directory and also items under it (bug#76769).
* lisp/dired-aux.el (dired-vc-next-action): Update docstring.
Sean Whitton [Sun, 6 Apr 2025 01:09:32 +0000 (09:09 +0800)]
vc-dir-mark-file: Consistently don't allow marking a subdirectory
* lisp/vc/vc-dir.el (vc-dir-mark-file): Don't allow marking a
subdirectory if its parent is already marked. This fixes an
inconsistency whereby if a subdirectory was already marked then
its parent could not be marked, but not vice-versa (bug #76769).
Eli Zaretskii [Sat, 5 Apr 2025 10:24:22 +0000 (13:24 +0300)]
Teach 'current-column' to account for images
* src/indent.c (check_display_width): Handle 'image' and 'slice'
display specs, instead of using the width of the underlying text.
Accept 2 additional arguments: WINDOW and SCAN_BYTE. (Bug#76107)
Fix mouse highlighting for compact mode lines (bug#77336)
When 'mode-line-compact' is non-nil, the mode line string is
displayed as a whole. That confuses the computation of ranges
of mouse highlighting on the mode line because all the glyphs
have the same Lisp object source. As such, in this commit we
instead split the mode line string by sources, and display those
elements one by one, so the boundaries of each element could be
correctly detected for the purpose of mouse highlighting.
* src/xdisp.c (display_mode_line): Display mode line elements
one by one when 'mode-line-compact' is non-nil.
(display_mode_element): Record source element number of the
stored string via a text property.
(Fformat_mode_line): Initialize 'mode_line_elt_no' to 0.
(syms_of_xdisp): New symbol for the text property.
Paul Nelson [Mon, 31 Mar 2025 13:37:14 +0000 (15:37 +0200)]
Restrict symbol prettification to displayable glyphs
* lisp/international/mule.el (char-displayable-on-frame-p): New
function used to determine whether a character can be
meaningfully displayed on a given frame.
* doc/lispref/display.texi (Fontsets): Document it.
* lisp/progmodes/prog-mode.el
(prettify-symbols--composition-displayable-p): New function used
to restrict to displayable prettification symbols. This
prevents issues with missing characters appearing as boxes.
(prettify-symbols--make-keywords): Use it. (Bug#77381)
Allow display (optionally) function docstring in eldoc. (Bug#77124)
* etc/NEWS: Document changes.
* lisp/progmodes/elisp-mode.el
(elisp-eldoc-funcall-with-docstring-length): New user option.
(elisp-eldoc-funcall-with-docstring): New function.
Visuwesh [Sun, 23 Mar 2025 05:58:16 +0000 (11:28 +0530)]
Improve formatting of 'setopt' suggestion in *Help* buffer
* lisp/help-fns.el (help--recommend-setopt): Remove function,
and...
(help-fns--customize-variable): ... move the relevant code here
to keep related code in the same place. Change the formatting
to also include the :set function if it is set to a named
function. (Bug#77173)
Stefan Monnier [Sat, 5 Apr 2025 03:53:10 +0000 (23:53 -0400)]
perl-mode.el: Avoid obsolete font-lock face vars
* lisp/progmodes/perl-mode.el (perl-mode-abbrev-table): Merge defvar
into the definition.
(perl-font-lock-keywords-1, perl-font-lock-keywords-2): Avoid obsolete
font-lock face vars.
Paul D. Nelson [Mon, 31 Mar 2025 07:07:07 +0000 (09:07 +0200)]
ediff-current-file: New optional startup-hooks arg
* lisp/vc/ediff.el (ediff-current-file): Add optional
startup-hooks argument, so that the user can write wrapper
commands with more finely customized behavior (bug#77323).
Stefan Monnier [Fri, 4 Apr 2025 20:17:36 +0000 (16:17 -0400)]
Handle `TeX-master` holding a buffer
Cleanup initialization of the syntax tables, while we're at it.
* lisp/textmodes/reftex.el (reftex-syntax-table)
(reftex-syntax-table-for-bib): Move initialization into the declaration.
(reftex--prepare-syntax-tables): Delete function.
(reftex-mode): Delete call to it.
(reftex-TeX-master-file): Handle the case where `TeX-master` holds
a buffer (e.g. because of `reftex-find-duplicate-labels`).
Consolidate the two cases where we prompt the user.
Paul Nelson [Wed, 2 Apr 2025 19:38:48 +0000 (21:38 +0200)]
Add RefTeX support for non-file buffers
* lisp/textmodes/reftex.el (reftex--get-buffer-identifier)
(reftex--get-directory, reftex--abbreviate-name)
(reftex--get-basename, reftex--get-truename): New helper
functions that handle both files and buffer objects.
(reftex--remove-buffer-from-master-index): New helper function.
(reftex-tie-multifile-symbols): Support non-file buffers, using
the above.
(reftex-TeX-master-file): Return current buffer when no file.
(reftex-access-scan-info): Remove check requiring file buffers.
(reftex-access-parse-file, reftex-check-parse-consistency): Skip
for non-file buffers.
(reftex-select-external-document): Use new helper function.
(reftex-locate-file): Return buffer objects directly.
(reftex-get-file-buffer-force): Handle buffer objects and
special 'buffer:' strings.
* lisp/textmodes/reftex-global.el (reftex-create-tags-file): Add
error handling for non-file buffers. Leave TAGS unsupported in
non-file buffers.
(reftex-find-duplicate-labels)
(reftex-isearch-switch-to-next-file): Use new helper functions
that handle both files and buffer objects.
(reftex-isearch-switch-to-next-file): Use equal rather than
string= to compare strings/buffers.
* lisp/textmodes/reftex-index.el (reftex-display-index)
(reftex-index-change-entry): Use new helper functions.
(reftex-index-visit-phrases-buffer): Add error handling for
non-file buffers. Leave phrases unsupported in non-file
buffers.
* lisp/textmodes/reftex-parse.el (reftex-do-parse)
(reftex-parse-from-file): Add support for non-file buffers.
(reftex-all-document-files, reftex-where-am-I)
(reftex-notice-new): Use new helper functions.
* lisp/textmodes/reftex-ref.el (reftex-label-info-update):
Support non-file buffers.
(reftex-label-info, reftex-replace-prefix-escapes, reftex-label)
(reftex-replace-prefix-escapes, reftex-offer-label-menu): Use
new helper functions.
* lisp/textmodes/reftex-sel.el (reftex-insert-docstruct): Use
new helper function.
* lisp/textmodes/reftex-toc.el (reftex-toc)
(reftex-recenter-toc-when-idle): Support non-file buffers.
* lisp/textmodes/reftex-cite.el (reftex-bib-or-thebib)
(reftex-get-bibfile-list): Use new helper functions.
* lisp/textmodes/reftex-global.el
(reftex-save-all-document-buffers, reftex-ensure-write-access):
Ignore non-file buffers.
* lisp/textmodes/reftex-parse.el (reftex-all-document-files):
For non-file objects, do not apply relative path transformation.
* test/lisp/textmodes/reftex-tests.el
(reftex-all-used-citation-keys-buffer)
(reftex-renumber-simple-labels-buffer): New tests for operations
on non-file buffers.
RefTeX historically assumed that the buffers it operates on
visit files. To handle non-file buffers:
Modify reftex-TeX-master-file so that it returns the buffer
object itself (as suggested by Stefan Monnier). Modify each
caller to handle buffer objects, aided by some helper functions
added to reftex.el. Replace 'string=' by 'equal' in places.
Use buffer-base-buffer, where appropriate, to handle indirect
buffers (file and non-file).
TAGS files and phrases buffers remain unsupported for non-file
buffers.
* lisp/textmodes/html-ts-mode.el
(html-ts-mode): Avoid the warning if the html language library is not
installed.
Avoids warning if html language library is not installed
when trying to associate mode with filename patterns.
* lisp/textmodes/html-ts-mode.el: Revert the last changes.
Avoids warning if any of the html, javascript, css language libraries
are not installed when attempting to associate mode with filename
templates.
Michael Albinus [Fri, 4 Apr 2025 12:29:00 +0000 (14:29 +0200)]
Fix Tramp problem with loooongish file names
* lisp/net/tramp-sh.el (tramp-readlink-file-truename): New defconst.
(tramp-bundle-read-file-names): Use new %m and %q format specifiers.
(tramp-sh-handle-file-truename): Use `tramp-readlink-file-truename'.
(tramp-bundle-read-file-names, tramp-get-remote-readlink): Simplify.
(tramp-expand-script): Add format specifiers %m and %q for test
commands. Addapt readlink call.
Reported by Stacey Marshall <stacey.marshall@gmail.com>.