mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 04:10:54 -08:00
Implement `restart-emacs' on Android
* java/org/gnu/emacs/EmacsService.java (restartEmacs): New function. * src/android.c (struct android_emacs_service) (android_init_emacs_service): Add new method. (android_restart_emacs): New function. * src/android.h: Update prototypes. * src/emacs.c (Fkill_emacs): Call android_restart_emacs whenever appropriate.
This commit is contained in:
parent
22749d69e5
commit
f9e32ce157
4 changed files with 47 additions and 1 deletions
|
|
@ -611,4 +611,16 @@ public class EmacsService extends Service
|
|||
|
||||
return manager.thing;
|
||||
}
|
||||
|
||||
public void
|
||||
restartEmacs ()
|
||||
{
|
||||
Intent intent;
|
||||
|
||||
intent = new Intent (this, EmacsActivity.class);
|
||||
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
startActivity (intent);
|
||||
System.exit (0);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ struct android_emacs_service
|
|||
jmethodID name_keysym;
|
||||
jmethodID sync;
|
||||
jmethodID browse_url;
|
||||
jmethodID restart_emacs;
|
||||
};
|
||||
|
||||
struct android_emacs_pixmap
|
||||
|
|
@ -1659,6 +1660,7 @@ android_init_emacs_service (void)
|
|||
FIND_METHOD (sync, "sync", "()V");
|
||||
FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;)"
|
||||
"Ljava/lang/String;");
|
||||
FIND_METHOD (restart_emacs, "restartEmacs", "()V");
|
||||
#undef FIND_METHOD
|
||||
}
|
||||
|
||||
|
|
@ -4987,6 +4989,23 @@ android_browse_url (Lisp_Object url)
|
|||
return tem;
|
||||
}
|
||||
|
||||
/* Tell the system to restart Emacs in a short amount of time, and
|
||||
then kill Emacs. Never return. This is used to implement
|
||||
`restart-emacs'. */
|
||||
|
||||
_Noreturn void
|
||||
android_restart_emacs (void)
|
||||
{
|
||||
/* Try to call the Java side function. Normally, this should call
|
||||
System.exit to terminate this process. */
|
||||
(*android_java_env)->CallVoidMethod (android_java_env,
|
||||
emacs_service,
|
||||
service_class.restart_emacs);
|
||||
|
||||
/* Exit anyway, in case EmacsService did not do so. */
|
||||
exit (0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else /* ANDROID_STUBIFY */
|
||||
|
|
|
|||
|
|
@ -89,6 +89,7 @@ extern void android_get_keysym_name (int, char *, size_t);
|
|||
extern void android_wait_event (void);
|
||||
extern void android_toggle_on_screen_keyboard (android_window, bool);
|
||||
extern void android_window_updated (android_window, unsigned long);
|
||||
extern _Noreturn void android_restart_emacs (void);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
16
src/emacs.c
16
src/emacs.c
|
|
@ -2948,7 +2948,14 @@ killed. */
|
|||
#ifndef WINDOWSNT
|
||||
/* Do some checking before shutting down Emacs, because errors
|
||||
can't be meaningfully reported afterwards. */
|
||||
if (!NILP (restart))
|
||||
if (!NILP (restart)
|
||||
/* Don't perform the following checks when Emacs is running as
|
||||
an Android GUI application, because there the system is
|
||||
relied on to restart Emacs. */
|
||||
#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
|
||||
&& !android_init_gui
|
||||
#endif
|
||||
)
|
||||
{
|
||||
/* This is very unlikely, but it's possible to execute a binary
|
||||
(on some systems) with no argv. */
|
||||
|
|
@ -3010,6 +3017,13 @@ killed. */
|
|||
if (!NILP (restart))
|
||||
{
|
||||
turn_on_atimers (false);
|
||||
#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
|
||||
/* Re-executing the Emacs process created by the system doesn't
|
||||
work. Instead, schedule a restart for a few hundered
|
||||
milliseconds and exit Emacs. */
|
||||
if (android_init_gui)
|
||||
android_restart_emacs ();
|
||||
#endif
|
||||
#ifdef WINDOWSNT
|
||||
if (w32_reexec_emacs (initial_cmdline, initial_wd) < 0)
|
||||
#else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue