From 6962823c83c29a585812f92d72f91cd0c83ed464 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Mon, 14 Aug 2023 16:04:03 +0800 Subject: [PATCH 01/23] ; * etc/PROBLEMS: Fix typo and clarify wording. I-Bus is merely one of the many X input methods plagued with crashes. --- etc/PROBLEMS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/PROBLEMS b/etc/PROBLEMS index f3d7eb303e3..6585d5b479d 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -1219,8 +1219,8 @@ And restart Emacs. This is due to an old bug in the implementation of the X protocol's XIM transport: when an input method crashes for some reason, Xlib cannot recover. Emacs cannot do anything about this except wait for -the I-Bux developers to fix their crashes. You can work around these -problems by disabling XIM in your X resources: +input method developers to fix their crashes. You can work around +these problems by disabling XIM in your X resources: Emacs.useXIM: false From 922b64902866d7c2d1f891d7608a2ed02a577164 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 14 Aug 2023 15:30:23 +0200 Subject: [PATCH 02/23] * Add missing alias to `native-comp-enable-subr-trampolines'. * lisp/subr.el (comp-enable-subr-trampolines): Alias to native-comp-enable-subr-trampolines. --- lisp/subr.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/subr.el b/lisp/subr.el index 872c701dbe7..857513b03dc 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1901,6 +1901,8 @@ instead; it will indirectly limit the specpdl stack size as well.") 'native-comp-enable-subr-trampolines "29.1") +(defvaralias 'comp-enable-subr-trampolines 'native-comp-enable-subr-trampolines) + (make-obsolete-variable 'native-comp-deferred-compilation 'native-comp-jit-compilation "29.1") From cf3145a486bc36f8f5f8d73d54aa0c5e4ff516e2 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Mon, 14 Aug 2023 15:48:53 +0200 Subject: [PATCH 03/23] * Add missing alias to `native-comp-enable-subr-trampolines'. * lisp/subr.el (native-comp-deferred-compilation): Alias to native-comp-jit-compilation. --- lisp/subr.el | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lisp/subr.el b/lisp/subr.el index 857513b03dc..28473f1d38c 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1907,6 +1907,8 @@ instead; it will indirectly limit the specpdl stack size as well.") 'native-comp-jit-compilation "29.1") +(defvaralias 'native-comp-deferred-compilation 'native-comp-jit-compilation) + ;;;; Alternate names for functions - these are not being phased out. From 32280205e2727425e40094bf39b881634d8572f6 Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Mon, 14 Aug 2023 17:12:23 -0700 Subject: [PATCH 04/23] Add user options mentioned in the Eshell manual to the variable index * doc/misc/eshell.texi: Make variable index entries use "code" style, and add indexing for any options already in the manual. --- doc/misc/eshell.texi | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index b5311e63a56..6515b1ac732 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -4,7 +4,7 @@ @settitle Eshell: The Emacs Shell @include docstyle.texi @defindex cm -@synindex vr fn +@syncodeindex vr fn @c %**end of header @copying @@ -442,6 +442,7 @@ overwriting files. If both settings are non-@code{nil}, the commands always prompt. If both settings are @code{nil} (the default), the commands signal an error. +@vindex eshell-default-target-is-dot Several commands observe the value of @code{eshell-default-target-is-dot}. If non-@code{nil}, then the default target for the commands @command{cp}, @command{mv}, and @@ -505,6 +506,8 @@ directory. With @kbd{cd -42}, you can access the directory stack slots by number. @item +@vindex eshell-cd-shows-directory +@vindex eshell-list-files-after-cd If @code{eshell-cd-shows-directory} is non-@code{nil}, @command{cd} will report the directory it changes to. If @code{eshell-list-files-after-cd} is non-@code{nil}, then @command{ls} @@ -528,6 +531,8 @@ buffer. Copy a file to a new location or copy multiple files to the same directory. +@vindex eshell-cp-overwrite-files +@vindex eshell-cp-interactive-query If @code{eshell-cp-overwrite-files} is non-@code{nil}, then @command{cp} will overwrite files without warning. If @code{eshell-cp-interactive-query} is non-@code{nil}, then @@ -545,6 +550,7 @@ Compare files using Emacs's internal @code{diff} (not to be confused with @code{ediff}). @xref{Comparing Files, , , emacs, The GNU Emacs Manual}. +@vindex eshell-plain-diff-behavior If @code{eshell-plain-diff-behavior} is non-@code{nil}, then this command does not use Emacs's internal @code{diff}. This is the same as using @samp{alias diff '*diff $*'}. @@ -572,6 +578,7 @@ Echoes its input. By default, this prints in a Lisp-friendly fashion prints a list of all the arguments; otherwise, it prints the empty string. +@vindex eshell-plain-echo-behavior If @code{eshell-plain-echo-behavior} is non-@code{nil}, @command{echo} will try to behave more like a plain shell's @command{echo}, printing each argument as a string, separated by a space. @@ -592,6 +599,7 @@ cmd*}. @item exit @cmindex exit +@vindex eshell-kill-on-exit Exit Eshell and save the history. By default, this command kills the Eshell buffer, but if @code{eshell-kill-on-exit} is @code{nil}, then the buffer is merely buried instead. @@ -615,6 +623,7 @@ The @command{grep} commands are compatible with GNU @command{grep}, but use Emacs's internal @code{grep} instead. @xref{Grep Searching, , , emacs, The GNU Emacs Manual}. +@vindex eshell-plain-grep-behavior If @code{eshell-plain-grep-behavior} is non-@code{nil}, then these commands do not use Emacs's internal @code{grep}. This is the same as using @samp{alias grep '*grep $*'}, though this setting applies to all @@ -653,6 +662,8 @@ and @code{("foo" "bar")} both evaluate to @code{("foo" "bar")}. @cmindex ln Create links to files. +@vindex eshell-ln-overwrite-files +@vindex eshell-ln-interactive-query If @code{eshell-ln-overwrite-files} is non-@code{nil}, @command{ln} will overwrite files without warning. If @code{eshell-ln-interactive-query} is non-@code{nil}, then @@ -664,6 +675,7 @@ Alias to Emacs's @code{locate} function, which simply runs the external @command{locate} command and parses the results. @xref{Dired and Find, , , emacs, The GNU Emacs Manual}. +@vindex eshell-plain-locate-behavior If @code{eshell-plain-locate-behavior} is non-@code{nil}, then Emacs's internal @code{locate} is not used. This is the same as using @samp{alias locate '*locate $*'}. @@ -672,21 +684,25 @@ internal @code{locate} is not used. This is the same as using @cmindex ls Lists the contents of directories. +@vindex eshell-ls-use-colors If @code{eshell-ls-use-colors} is non-@code{nil}, the contents of a directory is color-coded according to file type and status. These colors and the regexps used to identify their corresponding files can be customized via @w{@kbd{M-x customize-group @key{RET} eshell-ls @key{RET}}}. +@vindex eshell-ls-date-format The user option @code{eshell-ls-date-format} determines how the date is displayed when using the @option{-l} option. The date is produced using the function @code{format-time-string} (@pxref{Time Parsing,,, elisp, GNU Emacs Lisp Reference Manual}). +@vindex eshell-ls-initial-args The user option @code{eshell-ls-initial-args} contains a list of arguments to include with any call to @command{ls}. For example, you can include the option @option{-h} to always use a more human-readable format. +@vindex eshell-ls-default-blocksize The user option @code{eshell-ls-default-blocksize} determines the default blocksize used when displaying file sizes with the option @option{-s}. @@ -710,6 +726,8 @@ Make new directories. @cmindex mv Move or rename files. +@vindex eshell-mv-overwrite-files +@vindex eshell-mv-interactive-query If @code{eshell-mv-overwrite-files} is non-@code{nil}, @command{mv} will overwrite files without warning. If @code{eshell-mv-interactive-query} is non-@code{nil}, @command{mv} @@ -734,6 +752,8 @@ Print the arguments separated by newlines. Push the current directory onto the directory stack, then change to another directory. +@vindex eshell-pushd-dunique +@vindex eshell-pushd-dextract If @code{eshell-pushd-dunique} is non-@code{nil}, then only unique directories will be added to the stack. If @code{eshell-pushd-dextract} is non-@code{nil}, then @samp{pushd @@ -748,6 +768,8 @@ Prints the current working directory. Removes files, buffers, processes, or Emacs Lisp symbols, depending on the argument. +@vindex eshell-rm-interactive-query +@vindex eshell-rm-removes-directories If @code{eshell-rm-interactive-query} is non-@code{nil}, @command{rm} will prompt before removing anything. If @code{eshell-rm-removes-directories} is non-@code{nil}, then @@ -1036,6 +1058,7 @@ Tramp, may add extra information to this value. @section Aliases @vindex $* +@vindex eshell-aliases-file Aliases are commands that expand to a longer input line. For example, @command{ll} is a common alias for @code{ls -l}, and would be defined with the command invocation @kbd{alias ll 'ls -l $*'}; with this defined, @@ -1081,6 +1104,7 @@ slash module (@pxref{Electric forward slash}). @node History @section History @cmindex history +@vindex eshell-history-size The @samp{history} command shows all commands kept in the history ring as numbered list. If the history ring contains @code{eshell-history-size} commands, those numbers change after every @@ -1100,6 +1124,7 @@ command beginning with @code{foo}, and @samp{!?foo} to the last command containing @code{foo}. The n-th argument of the last command beginning with @code{foo} is accessible by @code{!foo:n}. +@vindex eshell-history-file-name The history ring is loaded from a file at the start of every session, and written back to the file at the end of every session. The file path is specified in @code{eshell-history-file-name}. Unlike other shells, @@ -1285,6 +1310,7 @@ to @code{$(@var{lisp})}, this is identical to @code{@{@var{command}@}} when on its own, but the @code{$} allows it to be used inside double quotes or as part of a string. +@vindex eshell-convert-numeric-arguments Normally, the output is split line-by-line, returning a list (or the first element if there's only one line of output); if @code{eshell-convert-numeric-arguments} is non-@code{nil} and every @@ -1350,12 +1376,12 @@ the result of @var{expr} is not a string or a sequence. @node Globbing @section Globbing -@vindex eshell-glob-case-insensitive Eshell's globbing syntax is very similar to that of Zsh (@pxref{Filename Generation, , , zsh, The Z Shell Manual}). Users coming from Bash can still use Bash-style globbing, as there are no incompatibilities. +@vindex eshell-glob-case-insensitive By default, globs are case sensitive, except on MS-DOS/MS-Windows systems. You can control this behavior via the @code{eshell-glob-case-insensitive} option. You can further customize @@ -1709,6 +1735,9 @@ garbage output, since the Eshell buffer is not a terminal emulator. Eshell solves this problem by running such programs in Emacs's terminal emulator. +@vindex eshell-visual-commands +@vindex eshell-visual-subcommands +@vindex eshell-visual-options Programs that need a terminal to display output properly are referred to in this manual as ``visual commands'', because they are not simply line-oriented. You must tell Eshell which commands are visual, by @@ -1926,6 +1955,7 @@ modules.@footnote{ERC provides a similar module facility.} @node Optional modules @section Optional modules +@vindex eshell-modules-list In addition to the various modules enabled by default (documented above), Eshell provides several other modules which are @emph{not} enabled by default. If you want to enable these, you can add them to @@ -1953,6 +1983,7 @@ text, @kbd{C-u} to kill the current input text, and @kbd{C-w} to @code{backward-kill-word}. If the history module is enabled, it also binds @kbd{C-p} and @kbd{C-n} to move through the input history. +@vindex eshell-confine-point-to-input If @code{eshell-confine-point-to-input} is non-@code{nil}, this module prevents certain commands from causing the point to leave the input area, such as @code{backward-word}, @code{previous-line}, etc. From 221ed70b90a4af0b514634ab5765511ccae9328b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Tue, 15 Aug 2023 17:08:12 +0300 Subject: [PATCH 05/23] ; Improve documentation of 'define-alternatives' * doc/lispref/commands.texi (Generic Commands): * lisp/simple.el (define-alternatives): Improve documentation of 'define-alternatives'. --- doc/lispref/commands.texi | 82 +++++++++++++++++++++++++++++++-------- lisp/simple.el | 49 +++++++++++++++-------- 2 files changed, 97 insertions(+), 34 deletions(-) diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index f84afcf52bd..0298a5d77ee 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -710,29 +710,77 @@ context. @node Generic Commands @subsection Select among Command Alternatives @cindex generic commands -@cindex alternatives, defining +@cindex alternative commands, defining -The macro @code{define-alternatives} can be used to define -@dfn{generic commands}. These are interactive functions whose -implementation can be selected from several alternatives, as a matter -of user preference. +Sometimes it is useful to define a command that serves as a ``generic +dispatcher'' capable of invoking one of a set of commands according to +the user's needs. For example, imagine that you want to define a +command named @samp{open} that can ``open'' and display several +different types of objects. Or you could have a command named +@samp{mua} (which stands for Mail User Agent) that can read and send +email using one of several email backends, such as Rmail, Gnus, or +MH-E. The macro @code{define-alternatives} can be used to define such +@dfn{generic commands}. A generic command is an interactive function +whose implementation can be selected from several alternatives, as a +matter of user preference. @defmac define-alternatives command &rest customizations -Define the new command @var{command}, a symbol. +This macro defines the new generic @var{command}, which can have +several alternative implementations. The argument @var{command} +should be an unquoted symbol. -When a user runs @kbd{M-x @var{command} @key{RET}} for the first time, -Emacs prompts for which real form of the command to use, and records -the selection by way of a custom variable. Using a prefix argument -repeats this process of choosing an alternative. +When invoked, the macro creates an interactive Lisp closure +(@pxref{Closures}). When the user runs @w{@kbd{M-x @var{command} +@key{RET}}} for the first time, Emacs asks to select one of the +alternative implementations of @var{command}, offering completion for +the names of these alternatives. These names come from the user +option whose name is @code{@var{command}-alternatives}, which the +macro creates (if it didn't exist before). To be useful, this +variable's value should be an alist whose elements have the form +@w{@code{(@var{alt-name} . @var{alt-func})}}, where @var{alt-name} is +the name of the alternative and @var{alt-func} is the interactive +function to be called if this alternative is selected. When the user +selects an alternative, Emacs remembers the selection, and will +thereafter automatically call that selected alternative without +prompting when the user invokes @kbd{M-x @var{command}} again. To +choose a different alternative, type @w{@kbd{C-u M-x @var{command} +@key{RET}}}--then Emacs will again prompt for one of the alternatives, +and the selection will override the previous one. -The variable @code{@var{command}-alternatives} should contain an alist -with alternative implementations of @var{command}. -Until this variable is set, @code{define-alternatives} has no effect. +The variable @code{@var{command}-alternatives} can be created before +calling @code{define-alternatives}, with the appropriate values; +otherwise the macro creates the variable with a @code{nil} value, and +it should then be populated with the associations describing the +alternatives. Packages that wish to provide their own implementation +of an existing generic command can use @code{autoload} cookies +(@pxref{Autoload}) to add to the alist, for example: + +@lisp +;;;###autoload (push '("My name" . my-foo-symbol) foo-alternatives +@end lisp + +If the optional argument @var{customizations} is non-@code{nil}, it +should consist of alternating @code{defcustom} keywords (typically +@code{:group} and @code{:version}) and values to add to the definition +of the @code{defcustom} @code{@var{command}-alternatives}. + +Here is an example of a simple generic dispatcher command named +@code{open} with 3 alternative implementations: + +@example +@group +(define-alternatives open + :group 'files + :version "42.1") +@end group +@group +(setq open-alternatives + '(("file" . find-file) + ("directory" . dired) + ("hexl" . hexl-find-file))) +@end group +@end example -If @var{customizations} is non-@code{nil}, it should consist of -alternating @code{defcustom} keywords (typically @code{:group} and -@code{:version}) and values to add to the declaration of -@code{@var{command}-alternatives}. @end defmac @node Interactive Call diff --git a/lisp/simple.el b/lisp/simple.el index 86f65d9d98e..abd587245fe 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -10664,10 +10664,13 @@ warning using STRING as the message.") ;;; Generic dispatcher commands -;; Macro `define-alternatives' is used to create generic commands. -;; Generic commands are these (like web, mail, news, encrypt, irc, etc.) -;; that can have different alternative implementations where choosing -;; among them is exclusively a matter of user preference. +;; Macro `define-alternatives' can be used to create generic commands. +;; Generic commands are commands that can have different alternative +;; implementations, and choosing among them is the matter of user +;; preference in each case. For example, you could have a generic +;; command `open' capable of "opening" a text file, a URL, a +;; directory, or a binary file, and each of these alternatives would +;; invoke a different Emacs function. ;; (define-alternatives COMMAND) creates a new interactive command ;; M-x COMMAND and a customizable variable COMMAND-alternatives. @@ -10677,26 +10680,38 @@ warning using STRING as the message.") ;; ;;;###autoload (push '("My impl name" . my-impl-symbol) COMMAND-alternatives (defmacro define-alternatives (command &rest customizations) - "Define the new command `COMMAND'. + "Define a new generic COMMAND which can have several implementations. -The argument `COMMAND' should be a symbol. +The argument `COMMAND' should be an unquoted symbol. Running `\\[execute-extended-command] COMMAND RET' for \ -the first time prompts for which -alternative to use and records the selected command as a custom -variable. +the first time prompts for the +alternative implementation to use and records the selected alternative. +Thereafter, `\\[execute-extended-command] COMMAND RET' will \ +automatically invoke the recorded selection. Running `\\[universal-argument] \\[execute-extended-command] COMMAND RET' \ -prompts again for an alternative -and overwrites the previous choice. +again prompts for an alternative +and overwrites the previous selection. -The variable `COMMAND-alternatives' contains an alist with -alternative implementations of COMMAND. `define-alternatives' -does not have any effect until this variable is set. +The macro creates a `defcustom' named `COMMAND-alternatives'. +CUSTOMIZATIONS, if non-nil, should be pairs of `defcustom' +keywords and values to add to the definition of that `defcustom'; +typically, these keywords will be :group and :version with the +appropriate values. -CUSTOMIZATIONS, if non-nil, should be composed of alternating -`defcustom' keywords and values to add to the declaration of -`COMMAND-alternatives' (typically :group and :version)." +To be useful, the value of `COMMAND-alternatives' should be an +alist describing the alternative implementations of COMMAND. +The elements of this alist should be of the form + (ALTERNATIVE-NAME . FUNCTION) +where ALTERNATIVE-NAME is the name of the alternative to be shown +to the user as a selectable alternative, and FUNCTION is the +interactive function to call which implements that alternative. +The variable could be populated with associations describing the +alternatives either before or after invoking `define-alternatives'; +if the variable is not defined when `define-alternatives' is invoked, +the macro will create it with a nil value, and your Lisp program +should then populate it." (declare (indent defun)) (let* ((command-name (symbol-name command)) (varalt-name (concat command-name "-alternatives")) From 26949819df07cb36ed773cc9df6ca91f5f49e3d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Mon, 14 Aug 2023 21:46:11 +0200 Subject: [PATCH 06/23] ; lisp/progmodes/csharp-mode.el (treesit-query-capture): Declare (bug#65297). --- lisp/progmodes/csharp-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el index 74968f3a06a..fb5a3d450a7 100644 --- a/lisp/progmodes/csharp-mode.el +++ b/lisp/progmodes/csharp-mode.el @@ -45,6 +45,7 @@ (declare-function treesit-node-start "treesit.c") (declare-function treesit-node-type "treesit.c") (declare-function treesit-node-child-by-field-name "treesit.c") +(declare-function treesit-query-capture "treesit.c") (defgroup csharp nil "Major mode for editing C# code." From 21b2ecee66142cdc1a803415fd8a135be11abb4f Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Tue, 15 Aug 2023 22:09:14 -0700 Subject: [PATCH 07/23] Fix command example in Eshell manual * doc/misc/eshell.texi (Introduction): Fix example (bug#65303). Reported by Eric Gillespie . --- doc/misc/eshell.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/misc/eshell.texi b/doc/misc/eshell.texi index 6515b1ac732..c9d84cf2851 100644 --- a/doc/misc/eshell.texi +++ b/doc/misc/eshell.texi @@ -141,7 +141,7 @@ computer frequently enough, it is more than worthwhile in the long run. Any tool you use often deserves the time spent learning to master it. @footnote{For the understandably curious, here is what that command looks like: But don't let it fool you; once you know what's going on, -it's easier than it looks: @code{ls -lt **/*.doc(Lk+50aM+5)}.} +it's easier than it looks: @code{ls -lt **/*.doc(Lk+100aM+6)}.} @menu * Contributors to Eshell:: People who have helped out! From 3712e8bc385e05520b4f410abd4f627ac668c65d Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Wed, 16 Aug 2023 01:58:03 +0200 Subject: [PATCH 08/23] ; Fix typos in lisp/keymap.el doc strings (bug#65329). Copyright-paper-exempt: yes --- lisp/keymap.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/keymap.el b/lisp/keymap.el index cd06b830e0a..017b2d6ead0 100644 --- a/lisp/keymap.el +++ b/lisp/keymap.el @@ -78,7 +78,7 @@ called from Lisp, COMMAND can be anything that `keymap-set' accepts as its DEFINITION argument. If COMMAND is a string (which can only happen when this function is -callled from Lisp), it must satisfy `key-valid-p'. +called from Lisp), it must satisfy `key-valid-p'. Note that if KEY has a local binding in the current buffer, that local binding will continue to shadow any global binding @@ -102,7 +102,7 @@ called from Lisp, COMMAND can be anything that `keymap-set' accepts as its DEFINITION argument. If COMMAND is a string (which can only happen when this function is -callled from Lisp), it must satisfy `key-valid-p'. +called from Lisp), it must satisfy `key-valid-p'. The binding goes in the current buffer's local keymap, which in most cases is shared with all other buffers in the same major mode." From 205d87cdca09c648da4fc8ec622c135e1655a08b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 16 Aug 2023 15:34:09 +0300 Subject: [PATCH 09/23] Fix unpacking ZIP archives on MS-Windows * lisp/arc-mode.el (archive-zip-summarize): Decode file names as UTF-8 when bit 11 of flags is set, even on MS-Windows. (Bug#65305) --- lisp/arc-mode.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el index 5e696c091b2..05a71fb4c5a 100644 --- a/lisp/arc-mode.el +++ b/lisp/arc-mode.el @@ -1990,6 +1990,7 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." (setq p (+ p (point-min))) (while (string= "PK\001\002" (buffer-substring p (+ p 4))) (let* ((creator (get-byte (+ p 5))) + (gpflags (archive-l-e (+ p 8) 2)) ;; (method (archive-l-e (+ p 10) 2)) (modtime (archive-l-e (+ p 12) 2)) (moddate (archive-l-e (+ p 14) 2)) @@ -2001,7 +2002,12 @@ This doesn't recover lost files, it just undoes changes in the buffer itself." (efnname (let ((str (buffer-substring (+ p 46) (+ p 46 fnlen)))) (decode-coding-string str - (or (if (and w32-fname-encoding + ;; Bit 11 of general purpose bit flags (bytes + ;; 8-9) of Central Directory: 1 means UTF-8 + ;; encoded file names. + (or (if (/= 0 (logand gpflags #x0800)) + 'utf-8-unix) + (if (and w32-fname-encoding (memq creator ;; This should be just 10 and ;; 14, but InfoZip uses 0 and From a8c8a4e3680d76254427844b707bb397d77c3984 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 16 Aug 2023 15:42:24 +0300 Subject: [PATCH 10/23] ; * src/fns.c (Fcopy_sequence): Doc fix. (Bug#64960) --- src/fns.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/fns.c b/src/fns.c index af5f9479a36..6d248b29824 100644 --- a/src/fns.c +++ b/src/fns.c @@ -734,7 +734,8 @@ usage: (vconcat &rest SEQUENCES) */) DEFUN ("copy-sequence", Fcopy_sequence, Scopy_sequence, 1, 1, 0, doc: /* Return a copy of a list, vector, string, char-table or record. The elements of a list, vector or record are not copied; they are -shared with the original. +shared with the original. See Info node `(elisp) Sequence Functions' +for more details about this sharing and its effects. If the original sequence is empty, this function may return the same empty object instead of its copy. */) (Lisp_Object arg) From 8cf5659ec2fb70681505b9803a2182ab00b509b4 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 16 Aug 2023 20:19:34 +0300 Subject: [PATCH 11/23] ; Fix defcustom in completion.el * lisp/completion.el (completion-search-distance): Fix doc string and customization type. (Bug#65327) --- lisp/completion.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/completion.el b/lisp/completion.el index f119fc6028b..eed6e77da4c 100644 --- a/lisp/completion.el +++ b/lisp/completion.el @@ -322,9 +322,11 @@ This can be time consuming." :type 'boolean) (defcustom completion-search-distance 15000 - "How far to search in the buffer when looking for completions. -In number of characters. If nil, search the whole buffer." - :type 'integer) + "How far in the buffer to search when looking for completions. +Limit is measured in characters. If nil, search the whole buffer." + :type '(choice + (const :tag "No limit" nil) + (integer :tag "Limit in characters"))) (defcustom completions-merging-modes '(lisp c) "List of modes {`c' or `lisp'} for automatic completions merging. From 7856d51436b759aa03ac2b32126d177cebbbca8c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 16 Aug 2023 20:42:16 +0300 Subject: [PATCH 12/23] Fix horizontal scrolling of images with C-f * lisp/image-mode.el (image-forward-hscroll): Calculate the window-width more accurately, as the number of full columns that fits in the window's text-area. (Bug#65187) --- lisp/image-mode.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lisp/image-mode.el b/lisp/image-mode.el index 1820defa195..336d89dd52d 100644 --- a/lisp/image-mode.el +++ b/lisp/image-mode.el @@ -248,8 +248,9 @@ Stop if the right edge of the image is reached." (image-set-window-hscroll (max 0 (+ (window-hscroll) n)))) (t (let* ((image (image-get-display-property)) - (edges (window-inside-edges)) - (win-width (- (nth 2 edges) (nth 0 edges))) + (edges (window-edges nil t nil t)) + (win-width (- (/ (nth 2 edges) (frame-char-width)) + (/ (nth 0 edges) (frame-char-width)))) (img-width (ceiling (car (image-display-size image))))) (image-set-window-hscroll (min (max 0 (- img-width win-width)) (+ n (window-hscroll)))))))) From 636fb267c46f62c89bc34b7de1c78a25c0b20f37 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 17 Aug 2023 10:07:48 +0300 Subject: [PATCH 13/23] Improve documentation of case transfer in replacement commands * doc/emacs/search.texi (Replacement and Lax Matches): * src/search.c (Freplace_match): * lisp/replace.el (query-replace, query-replace-regexp): Clarify in the doc string and the manual how letter-case is transferred from the replaced text to the replacement text. (Bug#65347) --- doc/emacs/search.texi | 25 +++++++++++++++++++++++-- lisp/replace.el | 10 ++++++---- src/search.c | 4 +++- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi index 45378d95f65..e5542a0fcf3 100644 --- a/doc/emacs/search.texi +++ b/doc/emacs/search.texi @@ -1658,6 +1658,7 @@ command's first argument. If @code{case-fold-search} is set to @code{nil}, case is always significant in all searches. @vindex case-replace +@cindex case preservation in replace commands In addition, when the second argument of a replace command is all or partly lower case, replacement commands try to preserve the case pattern of each occurrence. Thus, the command @@ -1671,7 +1672,27 @@ replaces a lower case @samp{foo} with a lower case @samp{bar}, an all-caps @samp{FOO} with @samp{BAR}, and a capitalized @samp{Foo} with @samp{Bar}. (These three alternatives---lower case, all caps, and capitalized, are the only ones that @code{replace-string} can -distinguish.) +distinguish.) Note that Emacs decides whether to up-case or capitalize +the replacement text by analyzing each word in the text being +replaced, and will preserve the letter-case of the replaced text only +if @emph{all} of its words use the same letter-case. Thus, the +command + +@example +M-x replace-string @key{RET} foo bar @key{RET} baz quux @key{RET} +@end example + +@noindent +replaces @samp{Foo Bar} with @samp{Baz Quux} because both words in +@samp{Foo Bar} are capitalized. By contrast, the same command +replaces @samp{Foo bar} with @samp{baz quux}, i.e.@: it leaves the +letter-case of the replacement text unchanged, since the two words in +@samp{Foo bar} use different capitalization. What exactly is +considered a ``word'' depends on the syntax tables that are in effect +in the current buffer (@pxref{Syntax Tables,,, elisp, The Emacs Lisp +Reference Manual}); thus, @samp{Foo_Bar} is two words in Text mode, +but could be a single word in some major mode that supports a +programming language. If upper-case letters are used in the replacement string, they remain upper case every time that text is inserted. If upper-case letters are @@ -1708,7 +1729,7 @@ This command finds occurrences of @samp{foo} one by one, displays each occurrence and asks you whether to replace it. Aside from querying, @code{query-replace} works just like @code{replace-string} (@pxref{Unconditional Replace}). In particular, it preserves case -provided @code{case-replace} is non-@code{nil}, as it normally is +provided that @code{case-replace} is non-@code{nil}, as it normally is (@pxref{Replacement and Lax Matches}). A numeric argument means to consider only occurrences that are bounded by word-delimiter characters. A negative prefix argument replaces backward. diff --git a/lisp/replace.el b/lisp/replace.el index 1555731f6e3..eeac734f3bd 100644 --- a/lisp/replace.el +++ b/lisp/replace.el @@ -417,8 +417,9 @@ Replacement transfers the case pattern of the old text to the new text, if both `case-fold-search' and `case-replace' are non-nil and FROM-STRING has no uppercase letters. \(Transferring the case pattern means that if the old text -matched is all caps, or capitalized, then its replacement is -respectively upcased or capitalized.) +matched is all caps, or all of its words are capitalized, then its +replacement is respectively upcased or capitalized. For more +details about this, see `replace-match'.) Ignore read-only matches if `query-replace-skip-read-only' is non-nil, ignore hidden matches if `search-invisible' is nil, and ignore more @@ -492,8 +493,9 @@ there are uppercase letters in REGEXP. Replacement transfers the case pattern of the old text to the new text, if both `case-fold-search' and `case-replace' are non-nil and REGEXP has no uppercase letters. (Transferring the case pattern -means that if the old text matched is all caps, or capitalized, -then its replacement is respectively upcased or capitalized.) +means that if the old text matched is all caps, or all of its words +are capitalized, then its replacement is respectively upcased or +capitalized. For more details about this, see `replace-match'.) Ignore read-only matches if `query-replace-skip-read-only' is non-nil, ignore hidden matches if `search-invisible' is nil, and ignore more diff --git a/src/search.c b/src/search.c index 0bb52c03eef..25c68f0788c 100644 --- a/src/search.c +++ b/src/search.c @@ -2359,7 +2359,9 @@ the replacement text. Otherwise, maybe capitalize the whole text, or maybe just word initials, based on the replaced text. If the replaced text has only capital letters and has at least one multiletter word, convert NEWTEXT to all caps. Otherwise if all words are capitalized -in the replaced text, capitalize each word in NEWTEXT. +in the replaced text, capitalize each word in NEWTEXT. Note that +what exactly is a word is determined by the syntax tables in effect +in the current buffer. If optional third arg LITERAL is non-nil, insert NEWTEXT literally. Otherwise treat `\\' as special: From d9af79ae39d3216273faa923d91f586b0a16cc04 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 17 Aug 2023 10:51:36 +0300 Subject: [PATCH 14/23] Fix cloning 'face-remapping-alist' for indirect buffers * lisp/face-remap.el (face-remap--copy-face): Remove. (face-attrs--make-indirect-safe): Use 'copy-tree'. Suggested by Stefan Monnier . --- lisp/face-remap.el | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lisp/face-remap.el b/lisp/face-remap.el index 3ec271b67a4..c5f7af37406 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el @@ -70,21 +70,10 @@ :foreground :background :stipple :overline :strike-through :box :font :inherit :fontset :distant-foreground :extend :vector]) -(defun face-remap--copy-face (val) - "Return a copy of the `face' property value VAL." - ;; A `face' property can be either a face name (a symbol), or a face - ;; property list like (:foreground "red" :inherit default), - ;; or a list of such things. - ;; FIXME: This should probably be shared to some extent with - ;; `add-face-text-property'. - (if (or (not (listp val)) (keywordp (car val))) - val - (copy-sequence val))) - (defun face-attrs--make-indirect-safe () "Deep-copy the buffer's `face-remapping-alist' upon cloning the buffer." (setq-local face-remapping-alist - (mapcar #'face-remap--copy-face face-remapping-alist))) + (mapcar #'copy-tree face-remapping-alist))) (add-hook 'clone-indirect-buffer-hook #'face-attrs--make-indirect-safe) From 8f683b51d8bc9e8c66608fb6056e0f8765f274f8 Mon Sep 17 00:00:00 2001 From: dannyfreeman Date: Fri, 11 Aug 2023 16:43:58 -0400 Subject: [PATCH 15/23] Fix jsx font-lock in older tree-sitter-js grammars * lisp/progmodes/js.el (js--treesit-font-lock-settings): Use queries that are backwards compatible with tree-sitter-javascript bb1f97b. * list/progmodes/js.el (-jsx--treesit-font-lock-compatibility-bb1f97b): Delete unused function. (Bug#65234) --- lisp/progmodes/js.el | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index c583b6f6191..9d2990e7bc9 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3501,35 +3501,6 @@ Check if a node type is available, then return the right indent rules." "&&" "||" "!") "JavaScript operators for tree-sitter font-locking.") -(defun js-jsx--treesit-font-lock-compatibility-bb1f97b () - "Font lock rules helper, to handle different releases of tree-sitter-javascript. -Check if a node type is available, then return the right font lock rules." - ;; handle commit bb1f97b - (condition-case nil - (progn (treesit-query-capture 'javascript '((member_expression) @capture)) - '((jsx_opening_element - [(member_expression (identifier)) (identifier)] - @font-lock-function-call-face) - - (jsx_closing_element - [(member_expression (identifier)) (identifier)] - @font-lock-function-call-face) - - (jsx_self_closing_element - [(member_expression (identifier)) (identifier)] - @font-lock-function-call-face))) - (error '((jsx_opening_element - [(nested_identifier (identifier)) (identifier)] - @font-lock-function-call-face) - - (jsx_closing_element - [(nested_identifier (identifier)) (identifier)] - @font-lock-function-call-face) - - (jsx_self_closing_element - [(nested_identifier (identifier)) (identifier)] - @font-lock-function-call-face))))) - (defvar js--treesit-font-lock-settings (treesit-font-lock-rules @@ -3639,8 +3610,10 @@ Check if a node type is available, then return the right font lock rules." :language 'javascript :feature 'jsx - (append (js-jsx--treesit-font-lock-compatibility-bb1f97b) - '((jsx_attribute (property_identifier) @font-lock-constant-face))) + '((jsx_opening_element name: (_) @font-lock-function-call-face) + (jsx_closing_element name: (_) @font-lock-function-call-face) + (jsx_self_closing_element name: (_) @font-lock-function-call-face) + (jsx_attribute (property_identifier) @font-lock-constant-face)) :language 'javascript :feature 'number From fac0e2d533427ba7afc2c11427f46acc57fa6be8 Mon Sep 17 00:00:00 2001 From: Jens Schmidt Date: Tue, 15 Aug 2023 21:37:08 +0200 Subject: [PATCH 16/23] Avoid false "wrong passphrase" messages in EPA * lisp/epa-file.el (epa--wrong-password-p): Use a stricter regexp to match "wrong passphrase" errors generated by GnuPG. (Bug#65316) --- lisp/epa-file.el | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lisp/epa-file.el b/lisp/epa-file.el index 4d8ca11e809..a27f241c0c3 100644 --- a/lisp/epa-file.el +++ b/lisp/epa-file.el @@ -123,9 +123,16 @@ encryption is used." (cons "Opening input file" (cdr error)))))) (defun epa--wrong-password-p (context) + "Return whether a wrong password caused the error in CONTEXT." (let ((error-string (epg-context-error-output context))) + ;; Use a strict regexp here that really only matches "wrong + ;; passphrase" errors to avoid hiding diagnostic information + ;; (bug#65316). Below regexp also can fail to match non-English + ;; messages, since at least the "decryption failed" part of it + ;; seems to be localized. But since this means false negatives + ;; this is probably OK. (and (string-match - "decryption failed: \\(Bad session key\\|No secret key\\)" + "decryption failed: \\(Bad session key\\|Bad passphrase\\)" error-string) (match-string 1 error-string)))) From f6ebd1ef0d028fb5d4551e6766ee882538db132a Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 18 Aug 2023 09:19:59 +0300 Subject: [PATCH 17/23] ; * src/treesit.c (Ftreesit_node_parent): Improve commentary. --- src/treesit.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/treesit.c b/src/treesit.c index 705ef6af39f..e359f903f28 100644 --- a/src/treesit.c +++ b/src/treesit.c @@ -1886,6 +1886,10 @@ Return nil if NODE has no parent. If NODE is nil, return nil. */) TSNode treesit_node = XTS_NODE (node)->node; Lisp_Object parser = XTS_NODE (node)->parser; TSTreeCursor cursor; + /* See the comments to treesit_cursor_helper about the algorithm for + finding the parent node. The complexity is roughly proportional + to the square root of the current node's depth in the parse tree, + and we punt if the tree is too deep. */ if (!treesit_cursor_helper (&cursor, treesit_node, parser)) return return_value; From 456ecabe9e860aaf5d4f09d1871bd7cc26b8e359 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 Aug 2023 11:50:09 +0300 Subject: [PATCH 18/23] Fix the documentation of 'cl-flet' * doc/misc/cl.texi (Function Bindings): Update the description. (Bug#65362) --- doc/misc/cl.texi | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi index 0284554ed9e..5de33350f4f 100644 --- a/doc/misc/cl.texi +++ b/doc/misc/cl.texi @@ -1238,10 +1238,15 @@ of variables. @defmac cl-flet (bindings@dots{}) forms@dots{} This form establishes @code{let}-style bindings for functions rather -than values. Each @var{binding} must be a list of the form -@samp{(@var{name} @var{arglist} @var{body}@dots{})}. Within -@var{forms}, any reference to the function @var{name} uses the local -definition instead of the global one. +than values. Each @var{binding} must be a list of one of two forms: +either @w{@code{(@var{name} @var{expr})}} or @w{@code{(@var{name} +@var{arglist} @var{body}@dots{})}}. The @var{name} is the name of the +function, @var{expr} is an expression which returns the function value +to which the corresponding @var{name} should be bound, and +@var{arglist} and @var{body} are the argument list and the body of the +function to bind to @var{name}. Within @var{forms}, any reference to +the function @var{name} uses the local definition provided by +@var{bindings} instead of the global one. A ``reference'' to a function name is either a call to that function, or a use of its name quoted by @code{function} to be passed on to, From 500ced133ad85437fefb98cd89a162a6ff6b7e09 Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 12 Aug 2023 01:40:07 -0700 Subject: [PATCH 19/23] Fix building of VC package manuals with relative org links/includes * lisp/emacs-lisp/package-vc.el (package-vc--build-documentation): Ensure that default-default is the docs-directory around org-export-to-file to ensure that links to relative files work correctly. (Bug#65243) --- lisp/emacs-lisp/package-vc.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index b4c911015b5..ffc7afeb2ee 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -356,7 +356,8 @@ otherwise it's assumed to be an Info file." (with-temp-buffer (insert-file-contents file) (setq file (make-temp-file "ox-texinfo-")) - (org-export-to-file 'texinfo file) + (let ((default-directory docs-directory)) + (org-export-to-file 'texinfo file)) (setq clean-up t))) (with-current-buffer (get-buffer-create " *package-vc doc*") (erase-buffer) From c125bd060e28367239779e25c1586a52fbfa54db Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Sat, 19 Aug 2023 11:27:02 +0200 Subject: [PATCH 20/23] Fix order in which package-vc dependencies are resolved * lisp/emacs-lisp/package-vc.el (package-vc-install-dependencies): Avoid a type-mismatch when comparing two packages. (Bug#65283) --- lisp/emacs-lisp/package-vc.el | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ffc7afeb2ee..c7a30736e32 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -413,13 +413,11 @@ version of that package." (desc (cadr (assoc package pac)))) (and desc (seq-some (apply-partially #'depends-on-p target) - (package-desc-reqs desc)))))) + (mapcar #'car (package-desc-reqs desc))))))) (dependent-order (a b) (let ((desc-a (package-desc-name a)) (desc-b (package-desc-name b))) - (or (not desc-a) (not desc-b) - (not (depends-on-p desc-b desc-a)) - (depends-on-p desc-a desc-b))))) + (depends-on-p desc-a desc-b)))) (mapc #'search requirements) (cl-callf sort to-install #'version-order) (cl-callf seq-uniq to-install #'duplicate-p) From 781ddd7e7d87de150d74d6d8615c25e68b42275b Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 19 Aug 2023 17:01:18 +0300 Subject: [PATCH 21/23] Fix touchpad scrolling on MS-Windows * src/w32term.c (w32_construct_mouse_wheel): The number of lines to scroll should always be positive in wheel-scroll events. Whether to scroll up or down is encoded in the modifiers, which produce either wheel-up or wheel-down event. (Bug#65070) * doc/lispref/commands.texi (Misc Events): Clarify the documentation of 'wheel-up' and 'wheel-down' events. --- doc/lispref/commands.texi | 11 ++++++----- src/w32term.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 0298a5d77ee..028209b2bc1 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -2249,11 +2249,12 @@ occurred. @var{clicks}, if present, is the number of times that the wheel was moved in quick succession. @xref{Repeat Events}. @var{lines}, if -present and not @code{nil}, is the number of screen lines that should -be scrolled. @var{pixel-delta}, if present, is a cons cell of the -form @w{@code{(@var{x} . @var{y})}}, where @var{x} and @var{y} are the -numbers of pixels by which to scroll in each axis, a.k.a.@: -@dfn{pixelwise deltas}. +present and not @code{nil}, is the positive number of screen lines +that should be scrolled (either up, when the event is @code{wheel-up}, +or down when the event is @code{wheel-down}). @var{pixel-delta}, if +present, is a cons cell of the form @w{@code{(@var{x} . @var{y})}}, +where @var{x} and @var{y} are the numbers of pixels by which to scroll +in each axis, a.k.a.@: @dfn{pixelwise deltas}. @cindex pixel-resolution wheel events You can use these @var{x} and @var{y} pixelwise deltas to determine diff --git a/src/w32term.c b/src/w32term.c index 2899e82b295..40b04b15993 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -3412,7 +3412,7 @@ w32_construct_mouse_wheel (struct input_event *result, W32Msg *msg, ((double)FRAME_LINE_HEIGHT (f) * scroll_unit) / ((double)WHEEL_DELTA / delta); nlines = value_to_report / FRAME_LINE_HEIGHT (f) + 0.5; - result->arg = list3 (make_fixnum (nlines), + result->arg = list3 (make_fixnum (eabs (nlines)), make_float (0.0), make_float (value_to_report)); } From baeb2d71ae7720c5335cd11aefa752f24374fa92 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Thu, 10 Aug 2023 14:27:29 -0700 Subject: [PATCH 22/23] Support defun navigation for DEFUN in c-ts-mode (bug#64442) Before this change, beginning/end-of-defun just ignores DEFUN in c-ts-mode. After this change, beginning/end-of-defun can recognize DEFUN, but a DEFUN definition is considered two defuns. Eg, beginning/end-of-defun will stop at (1) (2) and (3) in the following snippet: (1)DEFUN ("treesit-node-parser", Ftreesit_node_parser, Streesit_node_parser, 1, 1, 0, doc: /* Return the parser to which NODE belongs. */) (Lisp_Object node) (2){ CHECK_TS_NODE (node); return XTS_NODE (node)->parser; } (3) Ideally we want point to only stop at (1) and (3), but that'll be a lot harder to do. * lisp/progmodes/c-ts-mode.el: (c-ts-mode--defun-valid-p): Refactor to take in account of DEFUN body. (c-ts-mode--emacs-defun-body-p): New function. (c-ts-base-mode): Add DEFUN and DEFUN body to recognized types. (c-ts-mode--emacs-defun-at-point): Now that we recognize both parts of a DEFUN as defun, c-ts-mode--emacs-defun-at-point needs to be updated to adapt to it. --- lisp/progmodes/c-ts-mode.el | 115 +++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 55 deletions(-) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 98797bf3ce7..34a89b4dcad 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -880,29 +880,36 @@ Return nil if NODE is not a defun node or doesn't have a name." (defun c-ts-mode--defun-valid-p (node) "Return non-nil if NODE is a valid defun node. Ie, NODE is not nested." - (or (c-ts-mode--emacs-defun-p node) - (not (or (and (member (treesit-node-type node) - '("struct_specifier" - "enum_specifier" - "union_specifier" - "declaration")) - ;; If NODE's type is one of the above, make sure it is - ;; top-level. - (treesit-node-top-level - node (rx (or "function_definition" - "type_definition" - "struct_specifier" - "enum_specifier" - "union_specifier" - "declaration")))) - - (and (equal (treesit-node-type node) "declaration") - ;; If NODE is a declaration, make sure it is not a - ;; function declaration. - (equal (treesit-node-type - (treesit-node-child-by-field-name - node "declarator")) - "function_declarator")))))) + (let ((top-level-p (lambda (node) + (not (treesit-node-top-level + node (rx (or "function_definition" + "type_definition" + "struct_specifier" + "enum_specifier" + "union_specifier" + "declaration"))))))) + (pcase (treesit-node-type node) + ;; The declaration part of a DEFUN. + ("expression_statement" (c-ts-mode--emacs-defun-p node)) + ;; The body of a DEFUN. + ("compound_statement" (c-ts-mode--emacs-defun-body-p node)) + ;; If NODE's type is one of these three, make sure it is + ;; top-level. + ((or "struct_specifier" + "enum_specifier" + "union_specifier") + (funcall top-level-p node)) + ;; If NODE is a declaration, make sure it's not a function + ;; declaration (we only want function_definition) and is a + ;; top-level declaration. + ("declaration" + (and (not (equal (treesit-node-type + (treesit-node-child-by-field-name + node "declarator")) + "function_declarator")) + (funcall top-level-p node))) + ;; Other types don't need further verification. + (_ t)))) (defun c-ts-mode--defun-for-class-in-imenu-p (node) "Check if NODE is a valid entry for the Class subindex. @@ -955,6 +962,11 @@ files using the DEFUN macro." t) "DEFUN"))) +(defun c-ts-mode--emacs-defun-body-p (node) + "Return non-nil if NODE is the function body of a DEFUN." + (and (equal (treesit-node-type node) "compound_statement") + (c-ts-mode--emacs-defun-p (treesit-node-prev-sibling node)))) + (defun c-ts-mode--emacs-defun-at-point (&optional range) "Return the defun node at point. @@ -969,31 +981,18 @@ function returns the declaration node. If RANGE is non-nil, return (BEG . END) where BEG end END encloses the whole defun. This is for when the entire defun is required, not just the declaration part for DEFUN." - (or (when-let ((node (treesit-defun-at-point))) - (if range - (cons (treesit-node-start node) - (treesit-node-end node)) - node)) - (and c-ts-mode-emacs-sources-support - (let ((candidate-1 ; For when point is in the DEFUN statement. - (treesit-node-prev-sibling - (treesit-node-top-level - (treesit-node-at (point)) - "compound_statement"))) - (candidate-2 ; For when point is in the body. - (treesit-node-top-level - (treesit-node-at (point)) - "expression_statement"))) - (when-let - ((node (or (and (c-ts-mode--emacs-defun-p candidate-1) - candidate-1) - (and (c-ts-mode--emacs-defun-p candidate-2) - candidate-2)))) - (if range - (cons (treesit-node-start node) - (treesit-node-end - (treesit-node-next-sibling node))) - node)))))) + (when-let* ((node (treesit-defun-at-point)) + (defun-range (cons (treesit-node-start node) + (treesit-node-end node)))) + ;; Make some adjustment for DEFUN. + (when c-ts-mode-emacs-sources-support + (cond ((c-ts-mode--emacs-defun-body-p node) + (setq node (treesit-node-prev-sibling node)) + (setcar defun-range (treesit-node-start node))) + ((c-ts-mode--emacs-defun-p node) + (setcdr defun-range (treesit-node-end + (treesit-node-next-sibling node)))))) + (if range defun-range node))) (defun c-ts-mode-indent-defun () "Indent the current top-level declaration syntactically. @@ -1111,13 +1110,19 @@ BEG and END are described in `treesit-range-rules'." ;; Navigation. (setq-local treesit-defun-type-regexp - (cons (regexp-opt '("function_definition" - "type_definition" - "struct_specifier" - "enum_specifier" - "union_specifier" - "class_specifier" - "namespace_definition")) + (cons (regexp-opt (append + '("function_definition" + "type_definition" + "struct_specifier" + "enum_specifier" + "union_specifier" + "class_specifier" + "namespace_definition") + (and c-ts-mode-emacs-sources-support + '(;; DEFUN. + "expression_statement" + ;; DEFUN body. + "compound_statement")))) #'c-ts-mode--defun-valid-p)) (setq-local treesit-defun-skipper #'c-ts-mode--defun-skipper) (setq-local treesit-defun-name-function #'c-ts-mode--defun-name) From 3296031ad74f8cdc9638ae948b5372a81a43a2d1 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 20 Aug 2023 11:09:40 +0300 Subject: [PATCH 23/23] ; Another improvement for documentation of pixelwise scrolling * doc/lispref/commands.texi (Misc Events): More details about pixelwise mouse-wheel scrolling events. (Bug#65070) --- doc/lispref/commands.texi | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/doc/lispref/commands.texi b/doc/lispref/commands.texi index 028209b2bc1..110b2479d11 100644 --- a/doc/lispref/commands.texi +++ b/doc/lispref/commands.texi @@ -2242,11 +2242,12 @@ mouse cursor when the finger moved off the mouse wheel. @cindex @code{wheel-down} event @item (wheel-up @var{position} @var{clicks} @var{lines} @var{pixel-delta}) @itemx (wheel-down @var{position} @var{clicks} @var{lines} @var{pixel-delta}) -These kinds of event are generated by moving a mouse wheel. The +These events are generated by moving a mouse wheel. The @var{position} element is a mouse position list (@pxref{Click Events}), specifying the position of the mouse cursor when the event occurred. +@vindex mwheel-coalesce-scroll-events @var{clicks}, if present, is the number of times that the wheel was moved in quick succession. @xref{Repeat Events}. @var{lines}, if present and not @code{nil}, is the positive number of screen lines @@ -2254,24 +2255,35 @@ that should be scrolled (either up, when the event is @code{wheel-up}, or down when the event is @code{wheel-down}). @var{pixel-delta}, if present, is a cons cell of the form @w{@code{(@var{x} . @var{y})}}, where @var{x} and @var{y} are the numbers of pixels by which to scroll -in each axis, a.k.a.@: @dfn{pixelwise deltas}. +in each axis, a.k.a.@: @dfn{pixelwise deltas}. Usually, only one of +the two will be non-zero, the other will be either zero or very close +to zero; the larger number indicates the axis to scroll the window. +When the variable @code{mwheel-coalesce-scroll-events} is @code{nil}, +the scroll commands ignore the @var{lines} element, even if it's +non-@code{nil}, and use the @var{pixel-delta} data instead; in that +case, the direction of scrolling is determined by the sign of the +pixelwise deltas, and the direction (up or down) implied by the event +kind is ignored. @cindex pixel-resolution wheel events You can use these @var{x} and @var{y} pixelwise deltas to determine how much the mouse wheel has actually moved at pixel resolution. For example, the pixelwise deltas could be used to scroll the display at pixel resolution, exactly according to the user's turning the mouse -wheel. +wheel. This pixelwise scrolling is possible only when +@code{mwheel-coalesce-scroll-events} is @code{nil}, and in general the +@var{pixel-delta} data is not generated when that variable is +non-@code{nil}. @vindex mouse-wheel-up-event @vindex mouse-wheel-down-event -This kind of event is generated only on some kinds of systems. On -some systems, @code{mouse-4} and @code{mouse-5} are used instead. For -portable code, use the variables @code{mouse-wheel-up-event}, -@code{mouse-wheel-up-alternate-event}, @code{mouse-wheel-down-event} -and @code{mouse-wheel-down-alternate-event} defined in -@file{mwheel.el} to determine what event types to expect for the mouse -wheel. +The @code{wheel-up} and @code{wheel-down} events are generated only on +some kinds of systems. On other systems, @code{mouse-4} and +@code{mouse-5} are used instead. For portable code, use the variables +@code{mouse-wheel-up-event}, @code{mouse-wheel-up-alternate-event}, +@code{mouse-wheel-down-event} and +@code{mouse-wheel-down-alternate-event} defined in @file{mwheel.el} to +determine what event types to expect from the mouse wheel. @vindex mouse-wheel-left-event @vindex mouse-wheel-right-event