From ec1e300a215504bb9905a31145924d7f3d2cb9ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= Date: Thu, 11 Jul 2024 01:22:04 +0200 Subject: [PATCH 1/3] Fix reference from buffer-stale-function docstring * lisp/files.el (buffer-stale-function): Fix reference to a non-existent Info node in doc string. (Bug#72049) --- lisp/files.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index 66f47b4aa39..ca2d5b30cb4 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -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. From 0de0056fd6b3b70dde54884db5d9ffc013c49efc Mon Sep 17 00:00:00 2001 From: Jim Porter Date: Tue, 9 Jul 2024 10:45:35 -0700 Subject: [PATCH 2/3] Don't emit a prompt in Eshell when a background command is killed * lisp/eshell/esh-cmd.el (eshell-resume-command): Check for background-ness before resetting the prompt. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/background/simple-command): Make the regexp a bit stricter. (esh-cmd-test/background/kill): New test. --- lisp/eshell/esh-cmd.el | 11 +++++++++-- test/lisp/eshell/esh-cmd-tests.el | 14 +++++++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 0b3137127d2..e97e4f6d067 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -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. diff --git a/test/lisp/eshell/esh-cmd-tests.el b/test/lisp/eshell/esh-cmd-tests.el index 70e1901c169..d8124a19af6 100644 --- a/test/lisp/eshell/esh-cmd-tests.el +++ b/test/lisp/eshell/esh-cmd-tests.el @@ -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 From a5ef9e25680d490e2a453e5ed518aba8f4560b2d Mon Sep 17 00:00:00 2001 From: Po Lu Date: Fri, 12 Jul 2024 11:59:09 +0800 Subject: [PATCH 3/3] Document means of executing Emacs from unrelated Android applications * doc/emacs/android.texi (Android Environment): Document significance, effect and purpose of EMACS_CLASS_PATH and EMACS_LD_LIBRARY_PATH, and the utility of `pm path org.gnu.emacs'. --- doc/emacs/android.texi | 63 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/doc/emacs/android.texi b/doc/emacs/android.texi index 606c5e719cb..2d95f5c8fef 100644 --- a/doc/emacs/android.texi +++ b/doc/emacs/android.texi @@ -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