mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 17:24:23 +00:00
Allow starting Emacs --debug-init on Android
* doc/emacs/android.texi (Android Troubleshooting): Document `debug-init' option. * java/AndroidManifest.xml.in (EmacsLauncherPreferencesActivity): New activity. Export on systems older than Android 7.0. * java/org/gnu/emacs/EmacsActivity.java (onCreate): Adjust for string startup argument. * java/org/gnu/emacs/EmacsLauncherPreferencesActivity.java: New file. * java/org/gnu/emacs/EmacsPreferencesActivity.java (EmacsPreferencesActivity): Don't make final. (startEmacsQ): Give start-up argument as an argument, not as a boolean. (startEmacsDebugInit): New function. (onCreate): Register new listener; make final. * java/org/gnu/emacs/EmacsService.java (onCreate): Pass extraStartupArgument. * java/org/gnu/emacs/EmacsThread.java (EmacsThread): Rename startDashQ to extraStartupArgument. (run): Adjust accordingly. * java/res/values-v24/bool.xml: * java/res/values/bool.xml: * java/res/values/strings.xml: New files. * java/res/xml/preferences.xml: Add new option. Move string resources around.
This commit is contained in:
parent
ddaca337e3
commit
0eb1f4e571
12 changed files with 179 additions and 30 deletions
|
|
@ -608,16 +608,20 @@ to provide that style.
|
|||
@cindex troubleshooting, android
|
||||
|
||||
@cindex emacs -Q, android
|
||||
@cindex emacs --debug-init, android
|
||||
Since Android has no command line, there is normally no way to
|
||||
specify command-line arguments when starting Emacs. This is very
|
||||
nasty when you make a mistake in your Emacs initialization files that
|
||||
prevents Emacs from starting up at all, as the system normally
|
||||
prevents other programs from accessing Emacs's home directory.
|
||||
@xref{Initial Options}.
|
||||
|
||||
However, Emacs can be started with the equivalent of the
|
||||
@code{--quick} option (@pxref{Initial Options}) through a special
|
||||
preferences screen, which can be accessed through the Emacs ``app
|
||||
info'' page in the system settings application.
|
||||
However, Emacs can be started with the equivalent of either the
|
||||
option @code{--quick}, or @code{--debug-init}, through a special
|
||||
preferences screen. Under Android 7.0 and later, this can be accessed
|
||||
through the Emacs ``app info'' page in the system settings program; on
|
||||
older systems, this is displayed as a separate icon on the desktop
|
||||
labeled ``Emacs options''.
|
||||
|
||||
Consult the manufacturer of your device for more details, as how to
|
||||
do this varies by device.
|
||||
|
|
|
|||
|
|
@ -180,6 +180,23 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. -->
|
|||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<!-- Android 6 and earlier don't display ``application
|
||||
preferences'' activities in Settings, so display the
|
||||
preferences activity as a launcher icon instead. -->
|
||||
|
||||
<activity android:autoRemoveFromRecents="true"
|
||||
android:label="Emacs options"
|
||||
android:enabled="@bool/isBeforeNougat"
|
||||
android:exported="@bool/isBeforeNougat"
|
||||
android:icon="@drawable/emacs_wrench"
|
||||
android:name=".EmacsLauncherPreferencesActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<provider android:name="org.gnu.emacs.EmacsDocumentsProvider"
|
||||
android:authorities="org.gnu.emacs"
|
||||
android:exported="true"
|
||||
|
|
|
|||
|
|
@ -193,11 +193,11 @@ public class EmacsActivity extends Activity
|
|||
ViewTreeObserver observer;
|
||||
int matchParent;
|
||||
|
||||
/* See if Emacs should be started with -Q. */
|
||||
/* See if Emacs should be started with any extra arguments, such
|
||||
as `--quick'. */
|
||||
intent = getIntent ();
|
||||
EmacsService.needDashQ
|
||||
= intent.getBooleanExtra ("org.gnu.emacs.START_DASH_Q",
|
||||
false);
|
||||
EmacsService.extraStartupArgument
|
||||
= intent.getStringExtra ("org.gnu.emacs.STARTUP_ARGUMENT");
|
||||
|
||||
matchParent = FrameLayout.LayoutParams.MATCH_PARENT;
|
||||
params
|
||||
|
|
|
|||
31
java/org/gnu/emacs/EmacsLauncherPreferencesActivity.java
Normal file
31
java/org/gnu/emacs/EmacsLauncherPreferencesActivity.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* Communication module for Android terminals. -*- c-file-style: "GNU" -*-
|
||||
|
||||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
GNU Emacs is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or (at
|
||||
your option) any later version.
|
||||
|
||||
GNU Emacs is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
package org.gnu.emacs;
|
||||
|
||||
/* This class only exists because EmacsPreferencesActivity is already
|
||||
defined as an activity, the system wants a new class in order to
|
||||
define a new activity, and only activities can be enabled or
|
||||
disabled per the API level of the host. */
|
||||
|
||||
public final class EmacsLauncherPreferencesActivity
|
||||
extends EmacsPreferencesActivity
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -42,10 +42,11 @@
|
|||
Unfortunately, there is no alternative that looks the same way. */
|
||||
|
||||
@SuppressWarnings ("deprecation")
|
||||
public final class EmacsPreferencesActivity extends PreferenceActivity
|
||||
public class EmacsPreferencesActivity extends PreferenceActivity
|
||||
{
|
||||
/* Restart Emacs with -Q. Call EmacsThread.exit to kill Emacs now, and
|
||||
tell the system to EmacsActivity with some parameters later. */
|
||||
/* Restart Emacs with -Q. Call EmacsThread.exit to kill Emacs now,
|
||||
and tell the system to start EmacsActivity with some parameters
|
||||
later. */
|
||||
|
||||
private void
|
||||
startEmacsQ ()
|
||||
|
|
@ -55,7 +56,24 @@ public final class EmacsPreferencesActivity extends PreferenceActivity
|
|||
intent = new Intent (this, EmacsActivity.class);
|
||||
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.putExtra ("org.gnu.emacs.START_DASH_Q", true);
|
||||
intent.putExtra ("org.gnu.emacs.STARTUP_ARGUMENT", "--quick");
|
||||
startActivity (intent);
|
||||
System.exit (0);
|
||||
}
|
||||
|
||||
/* Restart Emacs with `--debug-init'. Call EmacsThread.exit to kill
|
||||
Emacs now, and tell the system to EmacsActivity with some
|
||||
parameters later. */
|
||||
|
||||
private void
|
||||
startEmacsDebugInit ()
|
||||
{
|
||||
Intent intent;
|
||||
|
||||
intent = new Intent (this, EmacsActivity.class);
|
||||
intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
intent.putExtra ("org.gnu.emacs.STARTUP_ARGUMENT", "--debug-init");
|
||||
startActivity (intent);
|
||||
System.exit (0);
|
||||
}
|
||||
|
|
@ -89,7 +107,7 @@ public final class EmacsPreferencesActivity extends PreferenceActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void
|
||||
public final void
|
||||
onCreate (Bundle savedInstanceState)
|
||||
{
|
||||
Preference tem;
|
||||
|
|
@ -111,7 +129,6 @@ else if (Build.VERSION.SDK_INT
|
|||
items. */
|
||||
|
||||
tem = findPreference ("start_quick");
|
||||
|
||||
listener = new Preference.OnPreferenceClickListener () {
|
||||
@Override
|
||||
public boolean
|
||||
|
|
@ -123,9 +140,19 @@ else if (Build.VERSION.SDK_INT
|
|||
};
|
||||
|
||||
tem.setOnPreferenceClickListener (listener);
|
||||
tem = findPreference ("start_debug_init");
|
||||
listener = new Preference.OnPreferenceClickListener () {
|
||||
@Override
|
||||
public boolean
|
||||
onPreferenceClick (Preference preference)
|
||||
{
|
||||
startEmacsDebugInit ();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
tem.setOnPreferenceClickListener (listener);
|
||||
tem = findPreference ("erase_dump");
|
||||
|
||||
listener = new Preference.OnPreferenceClickListener () {
|
||||
@Override
|
||||
public boolean
|
||||
|
|
|
|||
|
|
@ -79,7 +79,10 @@ public final class EmacsService extends Service
|
|||
{
|
||||
public static final String TAG = "EmacsService";
|
||||
public static volatile EmacsService SERVICE;
|
||||
public static boolean needDashQ;
|
||||
|
||||
/* If non-NULL, an extra argument to pass to
|
||||
`android_emacs_init'. */
|
||||
public static String extraStartupArgument;
|
||||
|
||||
private EmacsThread thread;
|
||||
private Handler handler;
|
||||
|
|
@ -231,7 +234,7 @@ invocation of app_process (through android-emacs) can
|
|||
(float) pixelDensityY,
|
||||
classPath, EmacsService.this);
|
||||
}
|
||||
}, needDashQ,
|
||||
}, extraStartupArgument,
|
||||
/* If any file needs to be opened, open it now. */
|
||||
EmacsOpenActivity.fileToOpen);
|
||||
thread.start ();
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ public class EmacsThread extends Thread
|
|||
{
|
||||
private static final String TAG = "EmacsThread";
|
||||
|
||||
/* Whether or not Emacs should be started -Q. */
|
||||
private boolean startDashQ;
|
||||
/* Whether or not Emacs should be started with an additional
|
||||
argument, and that additional argument if non-NULL. */
|
||||
private String extraStartupArgument;
|
||||
|
||||
/* Runnable run to initialize Emacs. */
|
||||
private Runnable paramsClosure;
|
||||
|
|
@ -40,10 +41,10 @@ public class EmacsThread extends Thread
|
|||
|
||||
public
|
||||
EmacsThread (EmacsService service, Runnable paramsClosure,
|
||||
boolean startDashQ, String fileToOpen)
|
||||
String extraStartupArgument, String fileToOpen)
|
||||
{
|
||||
super ("Emacs main thread");
|
||||
this.startDashQ = startDashQ;
|
||||
this.extraStartupArgument = extraStartupArgument;
|
||||
this.paramsClosure = paramsClosure;
|
||||
this.fileToOpen = fileToOpen;
|
||||
}
|
||||
|
|
@ -56,18 +57,20 @@ public class EmacsThread extends Thread
|
|||
|
||||
if (fileToOpen == null)
|
||||
{
|
||||
if (!startDashQ)
|
||||
if (extraStartupArgument == null)
|
||||
args = new String[] { "libandroid-emacs.so", };
|
||||
else
|
||||
args = new String[] { "libandroid-emacs.so", "-Q", };
|
||||
args = new String[] { "libandroid-emacs.so",
|
||||
extraStartupArgument, };
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!startDashQ)
|
||||
if (extraStartupArgument != null)
|
||||
args = new String[] { "libandroid-emacs.so",
|
||||
fileToOpen, };
|
||||
else
|
||||
args = new String[] { "libandroid-emacs.so", "-Q",
|
||||
args = new String[] { "libandroid-emacs.so",
|
||||
extraStartupArgument,
|
||||
fileToOpen, };
|
||||
}
|
||||
|
||||
|
|
|
|||
BIN
java/res/drawable/emacs_wrench.png
Normal file
BIN
java/res/drawable/emacs_wrench.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
22
java/res/values-v24/bool.xml
Normal file
22
java/res/values-v24/bool.xml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Boolean resources for GNU Emacs on Android.
|
||||
|
||||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
GNU Emacs is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GNU Emacs is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. -->
|
||||
|
||||
<resources>
|
||||
<bool name="isBeforeNougat">false</bool>
|
||||
</resources>
|
||||
|
|
@ -19,4 +19,5 @@
|
|||
|
||||
<resources>
|
||||
<bool name="isAtLeastKitKat">false</bool>
|
||||
<bool name="isBeforeNougat">true</bool>
|
||||
</resources>
|
||||
|
|
|
|||
39
java/res/values/strings.xml
Normal file
39
java/res/values/strings.xml
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<!-- String resources used by GNU Emacs on Android.
|
||||
|
||||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Emacs.
|
||||
|
||||
GNU Emacs is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
GNU Emacs is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. -->
|
||||
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
<string name="start_quick_title">
|
||||
Restart Emacs with -Q
|
||||
</string>
|
||||
<string name="start_quick_caption">
|
||||
Restart Emacs, but do not load site lisp or init files.
|
||||
</string>
|
||||
<string name="start_debug_init_title">
|
||||
Restart Emacs with --debug-init
|
||||
</string>
|
||||
<string name="start_debug_init_caption">
|
||||
Restart Emacs, and display the debugger should an error occur while loading initialization files.
|
||||
</string>
|
||||
<string name="erase_dump_title">
|
||||
Delete dump file
|
||||
</string>
|
||||
<string name="erase_dump_caption">
|
||||
Remove the dumped state created when Emacs was installed.
|
||||
</string>
|
||||
</resources>
|
||||
|
|
@ -19,10 +19,12 @@
|
|||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<Preference android:key="start_quick"
|
||||
android:title="Restart Emacs with -Q"
|
||||
android:summary="Restart Emacs, but do not load site lisp or init files."/>
|
||||
|
||||
android:title="@string/start_quick_title"
|
||||
android:summary="@string/start_quick_caption"/>
|
||||
<Preference android:key="start_debug_init"
|
||||
android:title="@string/start_debug_init_title"
|
||||
android:summary="@string/start_debug_init_caption"/>
|
||||
<Preference android:key="erase_dump"
|
||||
android:title="Delete dump file"
|
||||
android:summary="Remove the dumped state created when Emacs was installed"/>
|
||||
android:title="@string/erase_dump_title"
|
||||
android:summary="@string/erase_dump_caption"/>
|
||||
</PreferenceScreen>
|
||||
|
|
|
|||
Loading…
Reference in a new issue