@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.
-
- 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.
+@xref{Initial Options}.
+
+ 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.
</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"
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
--- /dev/null
+/* 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
+{
+
+}
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 ()
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);
}
}
@Override
- public void
+ public final void
onCreate (Bundle savedInstanceState)
{
Preference tem;
items. */
tem = findPreference ("start_quick");
-
listener = new Preference.OnPreferenceClickListener () {
@Override
public boolean
};
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
{
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;
(float) pixelDensityY,
classPath, EmacsService.this);
}
- }, needDashQ,
+ }, extraStartupArgument,
/* If any file needs to be opened, open it now. */
EmacsOpenActivity.fileToOpen);
thread.start ();
{
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;
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;
}
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, };
}
--- /dev/null
+<!-- 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>
<resources>
<bool name="isAtLeastKitKat">false</bool>
+ <bool name="isBeforeNougat">true</bool>
</resources>
--- /dev/null
+<!-- 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>
<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>