commit 760b54de080c238ea9f7b16055e820862d3e8896 (HEAD, refs/remotes/origin/master) Author: Yuan Fu Date: Sun Jun 2 21:52:48 2024 -0700 Use parser notifier to set parser ranges This is a continuation from an earlier commit where I added treesit-parser-changed-ranges and friends. Dmitry raised an concern about the edge case where the parser re-parses multiple times before treesit--pre-redisplay has a chance to run and process changed ranges. Instead of making treesit-parser-changed-ranges DTRT and become more complicated, it's agreed that using parser notifier is a better solution (and treesit-parser-changed-ranges can probably be removed). So, I took out the code that does the work from treesit--pre-redisplay and put them into treesit--font-lock-mark-ranges-to-fontify. This function will be called on each parser re-parse. And in treesit--pre-redisplay, to ensure that treesit--f-l-m-r-to-f gets called, we force the primary parser to re-parse. I also added a new variable that major modes need to set, treesit-primary-parser. I also added code that makes Emacs guess the primary parser if that variable isn't set. Documentation fot treesit-primary-parser will come later. For futher reference, the message id for the message that prompted this change is * lisp/treesit.el (treesit-primary-parser): New variable. (treesit--font-lock-mark-ranges-to-fontify): New function. (treesit--guess-primary-parser): New function. (treesit--pre-redisplay): Extract out. (treesit--pre-syntax-ppss): Add comments. (treesit-major-mode-setup): Guess and set treesit-primary-parser; add treesit--font-lock-mark-ranges-to-fontify as a notifier to the primary parser. diff --git a/lisp/treesit.el b/lisp/treesit.el index 0475227c726..aa3beb86174 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -793,6 +793,18 @@ omitted, default END to BEG." "Generic tree-sitter font-lock error" 'treesit-error) +;; The primary parser will be access frequently (after each re-parse, +;; before redisplay, etc, see +;; `treesit--font-lock-mark-ranges-to-fontify'), so we don't want to +;; allow it to be a callback function which returns the primary parser +;; (it might be slow). It's not something that needs to be dynamic +;; anyway. +(defvar-local treesit-primary-parser nil + "The primary parser for this buffer. + +The primary parser should be a parser that parses the entire buffer, as +opposed to embedded parsers which parses only part of the buffer.") + (defvar-local treesit-font-lock-settings nil "A list of SETTINGs for treesit-based fontification. @@ -1391,13 +1403,15 @@ Because `pre-redisplay-functions' could be called multiple times during a single command loop, we use this variable to debounce calls to `treesit--pre-redisplay'.") -(defun treesit--pre-redisplay (&rest _) - "Force a reparse on the primary parser and do some work. +(defun treesit--font-lock-mark-ranges-to-fontify (ranges _parser) + "A notifier that marks ranges that needs refontification. + +For RANGES and PARSER see `treesit-parser-add-notifier'. After the parser reparses, we get the changed ranges, and 1) update non-primary parsers' ranges in the changed ranges 2) mark these ranges as to-be-fontified, -3) tell syntax-ppss to start reparsing from the min point of the ranges +3) tell syntax-ppss to start reparsing from the min point of the ranges. We need to mark to-be-fontified ranges before redisplay starts working, because sometimes the range edited by the user is not the only range @@ -1405,33 +1419,48 @@ that needs to be refontified. For example, when the user types the final slash of a C block comment /* xxx */, not only do we need to fontify the slash, but also the whole block comment, which previously wasn't fontified as comment due to incomplete parse tree." + (dolist (range ranges) + ;; 1. Update ranges. + (treesit-update-ranges (car range) (cdr range)) + ;; 2. Mark the changed ranges to be fontified. + (when treesit--font-lock-verbose + (message "Notifier received range: %s-%s" + (car range) (cdr range))) + (with-silent-modifications + (put-text-property (car range) (cdr range) 'fontified nil)) + ;; 3. Set `treesit--syntax-propertize-start'. + (if (null treesit--syntax-propertize-start) + (setq treesit--syntax-propertize-start (car range)) + (setq treesit--syntax-propertize-start + (min treesit--syntax-propertize-start (car range)))))) + +(defun treesit--guess-primary-parser () + "Guess the primary parser of the current buffer and return it. + +Normally in a tree-sitter major mode, there is a primary parser that +parses the entire buffer (as opposed to embedded parsers which only +parses part of the buffer). This function tries to find and return that +parser." + (if treesit-range-settings + (let ((query (car (car treesit-range-settings)))) + (if (treesit-query-p query) + (treesit-parser-create + (treesit-query-language query)) + (car (treesit-parser-list)))) + (car (treesit-parser-list)))) + +(defun treesit--pre-redisplay (&rest _) + "Force a reparse on the primary parser and mark regions to be fontified. + +The actual work is carried out by +`treesit--font-lock-mark-ranges-to-fontify', which see." (unless (eq treesit--pre-redisplay-tick (buffer-chars-modified-tick)) - (let ((primary-parser - ;; TODO: We need something less ugly than this for getting - ;; the primary parser/language. - (if treesit-range-settings - (let ((query (car (car treesit-range-settings)))) - (if (treesit-query-p query) - (treesit-parser-create - (treesit-query-language query)) - (car (treesit-parser-list)))) - (car (treesit-parser-list))))) - ;; Force a reparse on the primary parser. - (treesit-parser-root-node primary-parser) - (dolist (range (treesit-parser-changed-ranges primary-parser)) - ;; 1. Update ranges. - (treesit-update-ranges (car range) (cdr range)) - ;; 2. Mark the changed ranges to be fontified. - (when treesit--font-lock-verbose - (message "Notifier received range: %s-%s" - (car range) (cdr range))) - (with-silent-modifications - (put-text-property (car range) (cdr range) 'fontified nil)) - ;; 3. Set `treesit--syntax-propertize-start'. - (if (null treesit--syntax-propertize-start) - (setq treesit--syntax-propertize-start (car range)) - (setq treesit--syntax-propertize-start - (min treesit--syntax-propertize-start (car range)))))) + (when treesit-primary-parser + ;; Force a reparse on the primary parser, if everything is setup + ;; correctly, the parser should call + ;; `treesit--font-lock-mark-ranges-to-fontify' (which should be a + ;; notifier function of the primary parser). + (treesit-parser-root-node treesit-primary-parser)) (setq treesit--pre-redisplay-tick (buffer-chars-modified-tick)))) @@ -1445,6 +1474,10 @@ whole region affected by the last reparse. START and END mark the current to-be-propertized region." (treesit--pre-redisplay) + ;; `treesit--syntax-propertize-start' is set by + ;; `treesit--font-lock-mark-ranges-to-fontify', which is called after + ;; each re-parser on the primary parser and in + ;; `treesit--pre-redisplay'. (let ((new-start treesit--syntax-propertize-start)) (if (and new-start (< new-start start)) (progn @@ -2991,6 +3024,8 @@ enable tree-sitter navigation commands for them. Make sure necessary parsers are created for the current buffer before calling this function." + (unless treesit-primary-parser + (setq treesit-primary-parser (treesit--guess-primary-parser))) ;; Font-lock. (when treesit-font-lock-settings ;; `font-lock-mode' wouldn't set up properly if @@ -3000,7 +3035,10 @@ before calling this function." (font-lock-fontify-syntactically-function . treesit-font-lock-fontify-region))) (treesit-font-lock-recompute-features) - (add-hook 'pre-redisplay-functions #'treesit--pre-redisplay 0 t)) + (add-hook 'pre-redisplay-functions #'treesit--pre-redisplay 0 t) + (when treesit-primary-parser + (treesit-parser-add-notifier + treesit-primary-parser #'treesit--font-lock-mark-ranges-to-fontify))) ;; Syntax (add-hook 'syntax-propertize-extend-region-functions #'treesit--pre-syntax-ppss 0 t) commit b44d511102dd3a94495d8f8446c88ac8898cd58f Author: Jim Porter Date: Sun Jun 2 12:03:44 2024 -0700 ; Remove superfluous 'quit' handler in 'eshell-send-input' This is now handled by the command form itself, thanks to eef32d13da5. * lisp/eshell/esh-mode.el (eshell-send-input): Remove 'quit' handler. diff --git a/lisp/eshell/esh-mode.el b/lisp/eshell/esh-mode.el index 7c030639955..ea2ccb08be1 100644 --- a/lisp/eshell/esh-mode.el +++ b/lisp/eshell/esh-mode.el @@ -659,15 +659,11 @@ newline." (eval cmd) (eshell-eval-command cmd input)))) (eshell-life-is-too-much))))) - (quit - (eshell-reset t) - (run-hooks 'eshell-post-command-hook) - (signal 'quit nil)) (error (eshell-reset t) (eshell-interactive-print (concat (error-message-string err) "\n")) - (run-hooks 'eshell-post-command-hook) + (run-hooks 'eshell-post-command-hook) (insert-and-inherit input))))))))) (defun eshell-send-eof-to-process () commit bffe73b562f4065bfa99095a46f1bdb731bebc13 Author: Michael Albinus Date: Sun Jun 2 19:30:12 2024 +0200 New user option 'shell-history-file-name' * doc/emacs/misc.texi (Shell Ring): Explain shell-history-file-name. * doc/misc/tramp.texi (Inline methods): Be more specific with containers. (Remote processes): New subsection "Managing remote shell history". Explain shell-history-file-name. (Frequently Asked Questions): Add items to Tramp speedup. Remove entry about history file. * etc/NEWS: New user option 'shell-history-file-name'. * lisp/shell.el (shell-history-file-name): New defcustom. (shell-mode): Use it. (Bug#71049) diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi index 3bee88bca86..68ea030e219 100644 --- a/doc/emacs/misc.texi +++ b/doc/emacs/misc.texi @@ -1331,16 +1331,18 @@ buffer, or even killing large parts of it, does not affect the history that these commands access. @vindex comint-input-ring-file-name +@vindex shell-history-file-name +@cindex @env{HISTFILE} environment variable Some shells store their command histories in files so that you can -refer to commands from previous shell sessions. Emacs reads -the command history file for your chosen shell, to initialize its own -command history. The file name is @file{~/.bash_history} for bash, -@file{~/.sh_history} for ksh, and @file{~/.history} for other shells. - -@vindex tramp-histfile-override - If you run the shell on a remote host, this setting might be -overwritten by the variable @code{tramp-histfile-override}. It is -recommended to set this variable to @code{nil}. +refer to commands from previous shell sessions. Emacs reads the command +history file for your chosen shell, to initialize its own command +history. The history file name is the string specified in +@code{shell-history-file-name}. If that user option is @code{t}, the +command history is not read. If the value is @code{nil}, the command +history is read from the file specified in environment variable +@env{HISTFILE}, or from @file{~/.bash_history} for bash, +@file{~/.sh_history} for ksh, @file{~/.zsh_history"} for zsh, or +@file{~/.history} for other shells. @node Shell History Copying @subsubsection Shell History Copying diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 74081767caa..ec8a8d5c3eb 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi @@ -976,7 +976,8 @@ session. @end table @noindent -The following methods allow to access containers in different ways: +The following methods allow to access running containers in different +ways: @table @asis @item @option{docker} @@ -1017,6 +1018,9 @@ The host name may be either a container's name or ID, as returned by the default Toolbox container for the host will be used. There is no such default for Distrobox. +Contrary to the other container-based methods, these two methods start +a created container, if it isn't running yet. + These are optional methods, @pxref{Optional methods}. They do not support user names. @@ -4080,8 +4084,59 @@ host. Furthermore, set @code{tramp-use-connection-share} to unwanted side effects. +@anchor{Managing remote shell history} +@subsection Managing remote shell history +@cindex shell history +@vindex tramp-histfile-override +@vindex HISTFILE@r{, environment variable} +@vindex HISTFILESIZE@r{, environment variable} +@vindex HISTSIZE@r{, environment variable} + +Due to the remote shell saving tilde expansions triggered by +@value{tramp}, the shell history file is probably growing rapidly. +@value{tramp} can suppress this behavior with the user option +@code{tramp-histfile-override}. When set to @code{t}, environment +variable @env{HISTFILE} is unset, and environment variables +@env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this +with @command{bash} 5.0.0. There is a bug in @command{bash} which +lets @command{bash} die. + +Alternatively, @code{tramp-histfile-override} could be a string. +Environment variable @env{HISTFILE} is set to this file name then. Be +careful when setting to @file{/dev/null}; this might result in +undesired results when using @command{bash} as remote shell. + +Another approach is to disable @value{tramp}'s handling of the +@env{HISTFILE} at all by setting @code{tramp-histfile-override} to +@code{nil}. In this case, saving history could be turned off by +putting this shell code in @file{.bashrc} or @file{.kshrc}: + +@example +@group +if [ -f $HOME/.sh_history ] ; then + /bin/rm $HOME/.sh_history +fi +if [ "$@{HISTFILE-unset@}" != "unset" ] ; then + unset HISTFILE +fi +if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then + unset HISTSIZE +fi +@end group +@end example + +For @option{ssh}-based method, add the following line to your +@file{~/.ssh/environment}: + +@example +HISTFILE=/dev/null +@end example + + @subsection Running @code{shell} on a remote host @cindex @code{shell} +@vindex explicit-shell-file-name +@vindex shell-history-file-name Set @code{explicit-shell-file-name} to the appropriate shell name when using @value{tramp} between two hosts with different operating @@ -4126,6 +4181,14 @@ of @code{explicit-shell-file-name} for different remote hosts. @end group @end lisp +The command @code{shell} reads the remote history file in order to to +initialize the history input ring. You can set the user option +@code{shell-history-file-name} in order to specify which remote +history file is taken, or whether to suppress this at all. It accepts +the same values as @code{tramp-histfile-override}, see @pxref{Managing +remote shell history}. @code{shell-history-file-name} accepts also +connection-local values in @code{shell} buffers. + @subsection Running @code{shell-command} on a remote host @cindex @code{shell-command} @@ -5170,6 +5233,13 @@ connections, apply the following code. @end group @end lisp +@item +Use direct asynchronous processes if possible. + +@item +Suppress reading the remote history file in @code{shell}. Set +@code{shell-history-file-name} to @code{t}. + @item Disable excessive traces. Set @code{tramp-verbose} to 3 or lower, default being 3. Increase trace levels temporarily when hunting for @@ -5476,54 +5546,6 @@ as follows: @end lisp -@item -Why is @file{~/.sh_history} on the remote host growing? - -@vindex tramp-histfile-override -@vindex HISTFILE@r{, environment variable} -@vindex HISTFILESIZE@r{, environment variable} -@vindex HISTSIZE@r{, environment variable} -Due to the remote shell saving tilde expansions triggered by -@value{tramp}, the history file is probably growing rapidly. -@value{tramp} can suppress this behavior with the user option -@code{tramp-histfile-override}. When set to @code{t}, environment -variable @env{HISTFILE} is unset, and environment variables -@env{HISTFILESIZE} and @env{HISTSIZE} are set to 0. Don't use this -with @command{bash} 5.0.0. There is a bug in @command{bash} which -lets @command{bash} die. - -Alternatively, @code{tramp-histfile-override} could be a string. -Environment variable @env{HISTFILE} is set to this file name then. Be -careful when setting to @file{/dev/null}; this might result in -undesired results when using @command{bash} as remote shell. - -Another approach is to disable @value{tramp}'s handling of the -@env{HISTFILE} at all by setting @code{tramp-histfile-override} to -@code{nil}. In this case, saving history could be turned off by -putting this shell code in @file{.bashrc} or @file{.kshrc}: - -@example -@group -if [ -f $HOME/.sh_history ] ; then - /bin/rm $HOME/.sh_history -fi -if [ "$@{HISTFILE-unset@}" != "unset" ] ; then - unset HISTFILE -fi -if [ "$@{HISTSIZE-unset@}" != "unset" ] ; then - unset HISTSIZE -fi -@end group -@end example - -For @option{ssh}-based method, add the following line to your -@file{~/.ssh/environment}: - -@example -HISTFILE=/dev/null -@end example - - @item Where are remote files trashed to? diff --git a/etc/NEWS b/etc/NEWS index e24c6bf0ddc..53abce8a472 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1047,6 +1047,15 @@ When this user option is non-nil, 'shell-get-old-input' ('C-RET') includes multiple shell "\" continuation lines from command output. Default is nil. ++++ +*** New user option 'shell-history-file-name'. +When this user option is set to t, 'shell-mode' does not read the shell +history file. Setting this user option to a string specifies the name +of the shell history file to be read. A nil value triggers reading the +environment variable 'HISTFILE'. + +In a 'shell' buffer, this user option is connection-local. + ** Make mode *** The Makefile browser is now obsolete. @@ -1182,7 +1191,7 @@ manual "(tramp) Improving performance of asynchronous remote processes". --- *** Direct asynchronous processes use 'tramp-remote-path'. When a direct asynchronous process is invoked, it uses 'tramp-remote-path' -for setting the remote PATH environment variable. +for setting the remote 'PATH' environment variable. ** File Notifications @@ -1922,10 +1931,11 @@ grammars. The Info manual "(elisp) Parsing Expression Grammars" has documentation and examples. ** New major mode 'shell-command-mode'. -This mode is used by default for the output of 'async-shell-command'. +This mode is used by default for the output of asynchronous 'shell-command'. To revert to the previous behavior, set the (also new) variable 'async-shell-command-mode' to 'shell-mode'. Any hooks or mode-specific variables used should be adapted appropriately. + * Incompatible Lisp Changes in Emacs 30.1 diff --git a/lisp/shell.el b/lisp/shell.el index 4352811912a..9399906715f 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -419,6 +419,22 @@ Useful for shells like zsh that has this feature." "Shell file name started in `shell'.") (put 'shell--start-prog 'permanent-local t) +(defcustom shell-history-file-name nil + "The history file name used in `shell-mode'. +When it is a string, this file name will be used. +When it is nil, the environment variable HISTFILE is used. +When it is t, no history file name is used in `shell-mode'. + +The settings obey whether `shell-mode' is invoked in a remote buffer. +In that case, HISTFILE is taken from the remote host, and the string is +interpreted as local file name on the remote host. + +If `shell-mode' is invoked in a local buffer, and no history file name +can be determined, a default according to the shell type is used." + :type '(choice (const :tag "Default" nil) (const :tag "Suppress" t) file) + :version "30.1") +(put 'shell-history-file-name 'permanent-local t) + ;;; Basic Procedures (defun shell--unquote&requote-argument (qstr &optional upos) @@ -721,27 +737,33 @@ command." (setq list-buffers-directory (expand-file-name default-directory)) ;; shell-dependent assignments. (when (ring-empty-p comint-input-ring) - (let ((remote (file-remote-p default-directory)) - (shell (or shell--start-prog "")) - (hsize (getenv "HISTSIZE")) - (hfile (getenv "HISTFILE"))) - (when remote - ;; `shell-snarf-envar' does not work trustworthy. - (setq hsize (shell-command-to-string "echo -n $HISTSIZE") - hfile (shell-command-to-string "echo -n $HISTFILE"))) + (let* ((remote (file-remote-p default-directory)) + (shell (or shell--start-prog "")) + (hfile (cond ((stringp shell-history-file-name) + shell-history-file-name) + ((null shell-history-file-name) + (if remote + (shell-command-to-string "echo -n $HISTFILE") + (getenv "HISTFILE"))))) + hsize) (and (string-equal hfile "") (setq hfile nil)) - (and (stringp hsize) - (integerp (setq hsize (string-to-number hsize))) - (> hsize 0) - (setq-local comint-input-ring-size hsize)) - (setq comint-input-ring-file-name - (concat - remote - (or hfile - (cond ((string-equal shell "bash") "~/.bash_history") - ((string-equal shell "ksh") "~/.sh_history") - ((string-equal shell "zsh") "~/.zsh_history") - (t "~/.history"))))) + (when (and (not remote) (not hfile)) + (setq hfile + (cond ((string-equal shell "bash") "~/.bash_history") + ((string-equal shell "ksh") "~/.sh_history") + ((string-equal shell "zsh") "~/.zsh_history") + (t "~/.history")))) + (when (stringp hfile) + (setq hsize + (if remote + (shell-command-to-string "echo -n $HISTSIZE") + (getenv "HISTSIZE"))) + (and (stringp hsize) + (integerp (setq hsize (string-to-number hsize))) + (> hsize 0) + (setq-local comint-input-ring-size hsize)) + (setq comint-input-ring-file-name + (concat remote hfile))) (if (or (equal comint-input-ring-file-name "") (equal (file-truename comint-input-ring-file-name) (file-truename null-device))) commit 2849c0cda3785124465806134b316f95231a67a5 Author: Michael Albinus Date: Sun Jun 2 16:53:56 2024 +0200 Fix last change * lisp/net/tramp.el (tramp-remote-path): Add "/opt/homebrew/bin" and "/opt/homebrew/sbin". diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 91e584cf7d6..21d563d6bfa 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1370,7 +1370,8 @@ let-bind this variable." '(tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" - "/opt/bin" "/opt/sbin" "/opt/local/bin" "/opt/homebrew/bin") + "/opt/bin" "/opt/sbin" "/opt/local/bin" + "/opt/homebrew/bin" "/opt/homebrew/sbin") "List of directories to search for executables on remote host. For every remote host, this variable will be set buffer local, keeping the list of existing directories on that host. commit a37e812d9677a1e97daf112ec2d821aaacd7664f Author: Michael Albinus Date: Sun Jun 2 15:09:44 2024 +0200 Fix bug#71235 * lisp/dired.el (dired-insert-directory): Fix remote case. * lisp/net/tramp.el (tramp-remote-path): Add "/opt/homebrew/bin". diff --git a/lisp/dired.el b/lisp/dired.el index f2a75df6ef1..c51e5e42c29 100644 --- a/lisp/dired.el +++ b/lisp/dired.el @@ -1710,9 +1710,10 @@ see `dired-use-ls-dired' for more details.") (cond ((and dir-wildcard (files--use-insert-directory-program-p)) (setq switches (concat "-d " switches)) (let* ((default-directory (car dir-wildcard)) + (ls (or (and remotep "ls") + insert-directory-program)) (script (format "%s %s %s" - insert-directory-program - switches (cdr dir-wildcard))) + ls switches (cdr dir-wildcard))) (sh (or (and remotep "/bin/sh") (executable-find shell-file-name) (executable-find "sh"))) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 3dffe7544ab..91e584cf7d6 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -1370,7 +1370,7 @@ let-bind this variable." '(tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" - "/opt/bin" "/opt/sbin" "/opt/local/bin") + "/opt/bin" "/opt/sbin" "/opt/local/bin" "/opt/homebrew/bin") "List of directories to search for executables on remote host. For every remote host, this variable will be set buffer local, keeping the list of existing directories on that host. commit 4303e5c9fa37368b50677f21aba977758f100e3c Author: Eli Zaretskii Date: Sun Jun 2 14:14:10 2024 +0300 ; Improve diagnostics in Image Dired * lisp/image/image-dired-external.el (image-dired--check-executable-exists): Improve diagnostics. diff --git a/lisp/image/image-dired-external.el b/lisp/image/image-dired-external.el index da272c146c9..5a9fc504370 100644 --- a/lisp/image/image-dired-external.el +++ b/lisp/image/image-dired-external.el @@ -240,7 +240,8 @@ function, consider that function to be an alternative to running EXECUTABLE." (or (and (executable-find cmd) (image-dired--probe-thumbnail-cmd cmd)) (and func (fboundp func) 'function) - (error "Executable %S not found or not pertinent" executable)))) + (error "Executable named by `%S' (%s) not found or not pertinent" + executable (symbol-value executable))))) ;;; Creating thumbnails commit b71fa27987d89774c84b0c9362ddfb4a0f679856 Author: Spencer Baugh Date: Sun May 26 09:26:09 2024 -0400 In rgrep, check matching files before excluding files There are a lot of excluding globs, and checking them all is expensive. The files glob (i.e. the glob for files we actually want) is usually just one or two entries, so it's quite fast to check. If find checks the files glob first and then the excluding glob, it has to do much less checking (since the files glob will substantially narrow down the set of files on its own), and find performance is much better. In my benchmarking, this takes (rgrep "foo" "*.el" "~/src/emacs/trunk/") from ~410ms to ~130ms. Further optimizations are possible now that the ignores and matched files are in the same argument which can be rearranged more easily without compatibility issues; I'll do those optimizations in later commits. * lisp/progmodes/grep.el (rgrep-find-ignores-in-): Add. * lisp/progmodes/grep.el (rgrep-default-command): Check rgrep-find-ignores-in- and move the excluded files glob to part of the "files" argument. (Bug#71179) diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index 0a9de04fce1..459f00e6805 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -214,6 +214,21 @@ by `grep-compute-defaults'; to change the default value, use :set #'grep-apply-setting :version "22.1") +(defvar rgrep-find-ignores-in- t + "If nil, when `rgrep' expands `grep-find-template', file ignores go in . + +By default, the placeholder contains find options for affecting the +directory list, and the placeholder contains the find options which +affect which files are matched, both `grep-find-ignored-files' and the +FILES argument to `rgrep'. + +This separation allows the two sources of file matching in to be +optimized together into a set of options which are overall faster for +\"find\" to evaluate. + +If nil, contains ignores both for directories and files, and +contains only the FILES argument. This is the old behavior.") + (defvar grep-quoting-style nil "Whether to use POSIX-like shell argument quoting.") @@ -1364,45 +1379,49 @@ to indicate whether the grep should be case sensitive or not." (defun rgrep-default-command (regexp files dir) "Compute the command for \\[rgrep] to use by default." - (require 'find-dired) ; for `find-name-arg' - (grep-expand-template - grep-find-template - regexp - (concat (shell-quote-argument "(" grep-quoting-style) - " " find-name-arg " " - (mapconcat - (lambda (x) (shell-quote-argument x grep-quoting-style)) - (split-string files) - (concat " -o " find-name-arg " ")) - " " - (shell-quote-argument ")" grep-quoting-style)) - dir - (concat - (when-let ((ignored-dirs (rgrep-find-ignored-directories dir))) - (concat "-type d " - (shell-quote-argument "(" grep-quoting-style) - ;; we should use shell-quote-argument here - " -path " - (mapconcat - (lambda (d) - (shell-quote-argument (concat "*/" d) grep-quoting-style)) - ignored-dirs - " -o -path ") - " " - (shell-quote-argument ")" grep-quoting-style) - " -prune -o ")) - (when-let ((ignored-files (grep-find-ignored-files dir))) - (concat (shell-quote-argument "!" grep-quoting-style) " -type d " - (shell-quote-argument "(" grep-quoting-style) - ;; we should use shell-quote-argument here - " -name " - (mapconcat - (lambda (ignore) (shell-quote-argument ignore grep-quoting-style)) - ignored-files - " -o -name ") - " " - (shell-quote-argument ")" grep-quoting-style) - " -prune -o "))))) + (require 'find-dired) ; for `find-name-arg' + (let ((ignored-files-arg + (when-let ((ignored-files (grep-find-ignored-files dir))) + (concat (shell-quote-argument "(" grep-quoting-style) + ;; we should use shell-quote-argument here + " -name " + (mapconcat + (lambda (ignore) (shell-quote-argument ignore grep-quoting-style)) + ignored-files + " -o -name ") + " " (shell-quote-argument ")" grep-quoting-style))))) + (grep-expand-template + grep-find-template + regexp + (concat (shell-quote-argument "(" grep-quoting-style) + " " find-name-arg " " + (mapconcat + (lambda (x) (shell-quote-argument x grep-quoting-style)) + (split-string files) + (concat " -o " find-name-arg " ")) + " " + (shell-quote-argument ")" grep-quoting-style) + (when (and rgrep-find-ignores-in- ignored-files-arg) + (concat " " (shell-quote-argument "!" grep-quoting-style) " " ignored-files-arg))) + dir + (concat + (when-let ((ignored-dirs (rgrep-find-ignored-directories dir))) + (concat "-type d " + (shell-quote-argument "(" grep-quoting-style) + ;; we should use shell-quote-argument here + " -path " + (mapconcat + (lambda (d) + (shell-quote-argument (concat "*/" d) grep-quoting-style)) + ignored-dirs + " -o -path ") + " " + (shell-quote-argument ")" grep-quoting-style) + " -prune -o ")) + (when (and (not rgrep-find-ignores-in-) ignored-files-arg) + (concat (shell-quote-argument "!" grep-quoting-style) " -type d " + ignored-files-arg + " -prune -o ")))))) (defun grep-find-toggle-abbreviation () "Toggle showing the hidden part of rgrep/lgrep/zrgrep command line." commit 7983f882823bafd5dd834c24d4defb26525f687b Author: Po Lu Date: Sun Jun 2 16:39:18 2024 +0800 ; * etc/NEWS: Name the systems that support touch-screen events. diff --git a/etc/NEWS b/etc/NEWS index 80bf0b4fefa..e24c6bf0ddc 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -520,11 +520,11 @@ function call. +++ ** Emacs now has better support for touchscreen devices. -On systems that understand them, many touch screen gestures are now -implemented and translated into mouse or gesture events, and support for -tapping tool bar buttons and opening menus has been written. Countless -packages, such as Dired and Custom have been adjusted to better -understand touch screen input. +On systems that understand them (at present X, Android, and PGTK), many +touch screen gestures are now implemented and translated into mouse or +gesture events, and support for tapping tool bar buttons and opening +menus has been written. Countless packages, such as Dired and Custom +have been adjusted to better understand touch screen input. --- ** On X, Emacs now supports input methods which perform "string conversion". commit 253b1d6ee817222b5394fa7791cfbb0de29e4a65 Author: Po Lu Date: Sun Jun 2 16:37:39 2024 +0800 Trim redundancies from EmacsTileObject * java/org/gnu/emacs/EmacsTileObject.java (EmacsTileObject) : Delete unused field. : Qualify as `static'. diff --git a/java/org/gnu/emacs/EmacsTileObject.java b/java/org/gnu/emacs/EmacsTileObject.java index 2caa28cbcd6..a79ae826d51 100644 --- a/java/org/gnu/emacs/EmacsTileObject.java +++ b/java/org/gnu/emacs/EmacsTileObject.java @@ -33,9 +33,6 @@ public final class EmacsTileObject { - /* Color filter object set by EmacsGC. */ - private ColorFilter colorFilter; - /* Bitmap object set by EmacsGC. */ private Bitmap bitmap; @@ -46,7 +43,7 @@ public final class EmacsTileObject private Rect boundsRect; /* Paint providing graphics properties for drawBitmap. */ - private Paint paint; + private final Paint paint; commit 50c4feb13246f1f82efd761dd13d31d5474cffa0 Author: Po Lu Date: Sun Jun 2 16:17:34 2024 +0800 Document a GDK misdesign interfering with touch screens and menus * etc/PROBLEMS (Runtime problems specific to PGTK): Document a misdesign preventing menus from being displayed in response to touch screen events. diff --git a/etc/PROBLEMS b/etc/PROBLEMS index da861ebe6e7..085ed4d0532 100644 --- a/etc/PROBLEMS +++ b/etc/PROBLEMS @@ -3512,6 +3512,22 @@ Compose key to stop working. On X Windows, users should not use Emacs configured with PGTK, since this and many other problems do not exist on the regular X builds. +** On occasion, menus cannot be activated by touch screen events. + +Menus might not be displayed after a mode-line item, or another command +that produces a menu, is activated by touch screen events. This is the +product of several bugs or misdesigns in the GDK Wayland backend which +cannot be circumvented by Emacs. Specifically, Wayland denies clients +that cannot provide a sufficiently recent event serial number the +ability to display pop-up windows, but GDK only considers the serial +numbers of touch screen events when their touch sequences remain active, +and, as touch screen activity is not registered by Emacs until after the +toolkit's delivery of touch sequences completes, by the time +`x-popup-menu' is called, the only eligible event serials are those of +the last keyboard event and the last mouse event, which will not suffice +if Wayland has received pop-up or drag-and-drop requests from other +clients since their generation. + * Runtime problems specific to Android ** Text displayed in the default monospace font looks horrible. commit 1ea398e8f1d32310ef0b462567e60254c6189766 Author: Vincenzo Pupillo Date: Sun May 26 21:07:50 2024 +0200 Make comment-indent-new-line conform better to CC Mode (bug#71225) * lisp/progmodes/c-ts-common.el: (c-ts-common-comment-indent-new-line): Single line comment and block comment now behave more like the c-indent-new-comment-line. diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el index b1520db22e9..f027fc28c04 100644 --- a/lisp/progmodes/c-ts-common.el +++ b/lisp/progmodes/c-ts-common.el @@ -303,20 +303,31 @@ and /* */ comments. SOFT works the same as in ;; Or //! (used in rust). ((save-excursion (beginning-of-line) - (looking-at (rx "//" (group (* (any "/!")) (* " "))))) - (let ((whitespaces (match-string 1))) + (re-search-forward + (rx "//" (group (* (any "/!")) (* " "))) + (line-end-position) + t nil)) + (let ((offset (- (match-beginning 0) (line-beginning-position))) + (whitespaces (match-string 1))) (if soft (insert-and-inherit ?\n) (newline 1)) (delete-region (line-beginning-position) (point)) - (insert "//" whitespaces))) + (insert (make-string offset ?\s) "//" whitespaces))) ;; Line starts with /* or /**. ((save-excursion (beginning-of-line) - (looking-at (rx "/*" (group (? "*") (* " "))))) - (let ((whitespace-and-star-len (length (match-string 1)))) + (re-search-forward + (rx "/*" (group (? "*") (* " "))) + (line-end-position) + t nil)) + (let ((offset (- (match-beginning 0) (line-beginning-position))) + (whitespace-and-star-len (length (match-string 1)))) (if soft (insert-and-inherit ?\n) (newline 1)) (delete-region (line-beginning-position) (point)) - (insert " *" (make-string whitespace-and-star-len ?\s)))) + (insert + (make-string offset ?\s) + " *" + (make-string whitespace-and-star-len ?\s)))) ;; Line starts with *. ((save-excursion