Merge from savannah/emacs-30

a5ef9e2568 Document means of executing Emacs from unrelated Android ...
0de0056fd6 Don't emit a prompt in Eshell when a background command i...
ec1e300a21 Fix reference from buffer-stale-function docstring
This commit is contained in:
Po Lu 2024-07-12 12:15:50 +08:00
commit 38fa3e9350
4 changed files with 75 additions and 15 deletions

View file

@ -364,17 +364,58 @@ consult the values of the variables @code{ctags-program-name},
@code{ebrowse-program-name}, and @code{rcs2log-program-name}.
@xref{Subprocess Creation,,, elisp, the Emacs Lisp Reference Manual}.
The @file{/assets} directory containing Emacs start-up files is
meant to be inaccessible to processes not directly created by
@code{zygote}, the system service responsible for starting
applications. Since required Lisp is found in the @file{/assets}
directory, it would thus follow that it is not possible for Emacs to
start itself as a subprocess. A special binary named
@command{libandroid-emacs.so} is provided with Emacs, which tries its
best to start Emacs for the purpose of running Lisp in batch mode.
However, the approach it takes was devised by reading Android source
code, and is not sanctioned by the Android compatibility definition
documents, so your mileage may vary.
The @file{/assets} directory containing Emacs start-up files is meant
to be inaccessible to processes not directly created by @code{zygote},
the system service responsible for starting applications. Since
required Lisp is found in the @file{/assets} directory, it would thus
follow that it is not possible for Emacs to start itself as a
subprocess. A special binary named @command{libandroid-emacs.so} is
provided with Emacs, which is installed into the library directory, and
which tries its best to start Emacs for the purpose of running Lisp in
batch mode. The approach it takes was devised by reference to Android
source code, and is not sanctioned by the Android compatibility
definition documents, so your mileage may vary.
@cindex EMACS_CLASS_PATH environment variable, Android
Even when the location of the @command{libandroid-emacs.so} command is
known in advance, special configuration is required to run Emacs from
elsewhere than a subprocess of an existing Emacs session, as it must be
made to understand the location of resources and shared libraries in or
extracted from the installed application package. The OS command
@command{pm path org.gnu.emacs} will print the location of the
application package, and the adjacent @file{lib} directory will hold
shared libraries extracted from the same, though the said command must
be invoked in a peculiar manner to satisfy system restrictions on
communication between pseudoterminal devices created by user
applications and system services such as the package manager, which is
to say, with the standard IO streams redirected to a real file or a
pipe. Such values, once established, must be specified in the
environment variables @code{EMACS_CLASS_PATH} and
@code{EMACS_LD_LIBRARY_PATH}, so that this sample shell script may be
installed as @code{emacs} in any location that is accessible:
@example
#!/system/bin/sh
package_name=`pm path org.gnu.emacs 2>/dev/null </dev/null \
| sed 's/^package://'`
emacs=
ld_path=
EMACS_CLASS_PATH=$package_name
for libdir in `dirname $package_name`/lib/*; do
ld_path=$@{ld_path:+$@{ld_path@}:@}$libdir
test -x "$libdir"/libandroid-emacs.so \
&& emacs="$libdir"/libandroid-emacs.so
done
EMACS_LD_LIBRARY_PATH=$ld_path
export EMACS_CLASS_PATH
export EMACS_LD_LIBRARY_PATH
test -x "$emacs" || exit 1
exec $emacs "$@@"
@end example
@cindex call-process, Android
@vindex android-use-exec-loader

View file

@ -1030,6 +1030,9 @@ process(es) in a cons cell like:
PROC is the process that invoked this from its sentinel, and
STATUS is its status."
(when proc
;; Iterate over all the commands associated with this process. Each
;; element is a list of the form (BACKGROUND FORM PROCESSES) (see
;; `eshell-add-command').
(dolist (command (eshell-commands-for-process proc))
(unless (seq-some #'eshell-process-active-p (nth 2 command))
(setf (nth 2 command) nil) ; Clear processes from command.
@ -1040,8 +1043,12 @@ STATUS is its status."
(not (string-match eshell-reset-signals status)))
(eshell-resume-eval command)
(eshell-remove-command command)
(declare-function eshell-reset "esh-mode" (&optional no-hooks))
(eshell-reset))))))
;; Check if the command we just aborted is marked as a
;; background command. If not, we need to reset the prompt so
;; the user can enter another command.
(unless (car command)
(declare-function eshell-reset "esh-mode" (&optional no-hooks))
(eshell-reset)))))))
(defun eshell-resume-eval (command)
"Destructively evaluate a COMMAND which may need to be deferred.

View file

@ -6857,7 +6857,7 @@ For historical reasons, a value of nil means to use the default function.
This should not be relied upon.
For more information on how this variable is used by Auto Revert mode,
see Info node `(emacs)Supporting additional buffers'.")
see Info node `(elisp)Reverting'.")
(defvar-local buffer-auto-revert-by-notification nil
"Whether a buffer can rely on notification in Auto-Revert mode.

View file

@ -113,7 +113,7 @@ bug#59469."
(with-temp-eshell
(eshell-match-command-output
(format "*echo hi > #<%s> &" bufname)
(rx "[echo" (? ".exe") "] " (+ digit) "\n"))
(rx bos "[echo" (? ".exe") "] " (+ digit) "\n"))
(eshell-wait-for-subprocess t))
(should (equal (buffer-string) "hi\n"))))
@ -129,6 +129,18 @@ bug#59469."
(eshell-wait-for-subprocess t))
(should (equal (buffer-string) "olleh\n"))))
(ert-deftest esh-cmd-test/background/kill ()
"Make sure that a background command that gets killed doesn't emit a prompt."
(skip-unless (executable-find "sleep"))
(let ((background-message (rx bos "[sleep" (? ".exe") "] " (+ digit) "\n")))
(with-temp-eshell
(eshell-match-command-output "*sleep 10 &" background-message)
(kill-process (caar eshell-process-list))
(eshell-wait-for-subprocess t)
;; Ensure we didn't emit another prompt after killing the
;; background process.
(should (eshell-match-output background-message)))))
;; Lisp forms