Arrange for dialog boxes during emacsclient requests on Android

* lisp/server.el (server-execute): Bind use-dialog-box-override
if (featurep 'android).

* lisp/subr.el (use-dialog-box-override): New option.
(use-dialog-box-p): Always display dialog boxes if variable is
set.
This commit is contained in:
Po Lu 2024-02-25 11:41:02 +08:00
parent 9a801f0b46
commit 05116eac0c
2 changed files with 19 additions and 9 deletions

View file

@ -1439,7 +1439,11 @@ invocations of \"emacs\".")
;; including code that needs to wait.
(with-local-quit
(condition-case err
(let ((buffers (server-visit-files files proc nowait)))
(let ((buffers (server-visit-files files proc nowait))
;; On Android, the Emacs server generally can't provide
;; feedback to the user except by means of dialog boxes,
;; which are displayed in the GUI emacsclient wrapper.
(use-dialog-box-override (featurep 'android)))
(mapc 'funcall (nreverse commands))
(let ((server-eval-args-left (nreverse evalexprs)))
(while server-eval-args-left

View file

@ -3832,16 +3832,22 @@ confusing to some users.")
(declare-function android-detect-keyboard "androidfns.c")
(defvar use-dialog-box-override nil
"Whether `use-dialog-box-p' should always return t.")
(defun use-dialog-box-p ()
"Return non-nil if the current command should prompt the user via a dialog box."
(and last-input-event ; not during startup
(or (consp last-nonmenu-event) ; invoked by a mouse event
(and (null last-nonmenu-event)
(consp last-input-event))
(and (featurep 'android) ; Prefer dialog boxes on Android.
(not (android-detect-keyboard))) ; If no keyboard is connected.
from--tty-menu-p) ; invoked via TTY menu
use-dialog-box))
(or use-dialog-box-override
(and last-input-event ; not during startup
(or (consp last-nonmenu-event) ; invoked by a mouse event
(and (null last-nonmenu-event)
(consp last-input-event))
(and (featurep 'android) ; Prefer dialog boxes on
; Android.
(not (android-detect-keyboard))) ; If no keyboard is
; connected.
from--tty-menu-p) ; invoked via TTY menu
use-dialog-box)))
;; Actually in textconv.c.
(defvar overriding-text-conversion-style)