Sunday, 21 December 2014

Running emacs and org-mode under Android. I’m doing this on my Android tablet -
it’s not perhaps as useful on a phone, though it’s not unmanageable.

There used to be an Emacs app for Android in the Google Play store - in fact
it’s still there, but the server it used to download its files from is no longer
working - and the app was always a bit fiddly to get to work properly.

Here’s a better way of getting it working:

Install ZShaolin, a console terminal emulator (zsh shell) for Android with a
number of useful commandline tools like rsync, awk, imagmagick etc.

Unzip the files from there and place at /sdcard/emacs/ on your device.

Then, open up ZShaolin and start a session, and type “emacs”. Voilà.

Now for getting org-mode to work. Org-mode is part of the basic Emacs setup in
recent versions of Emacs (including the one above). For some reason, though, at
least when I ran it, I had trouble turning on org-mode. Here’s the fix:

Create a .emacs file (if you don’t have one already) in ~ under ZShaolin and
put the following into:

Now, most likely you will have org-files that you want to keep synchronized. You
may already be running MobileOrg, with something like a Dropbox
synchronisation. Note that the way that the MobileOrg app works, you can’t edit
the org files that it uses directly. MobileOrg utilises some sort of database
and the changes that it pushes back are done so through the database, so editing
the org files that MobileOrg is synched with (say, in Dropbox) won’t result in
any changes being propagated back to your other devices.

So, if you’re running MobileOrg with Dropbox, you’ll need to have a separate
Dropbox synchronisation in order to be able to edit org-files in Emacs on
Android in a way that allows for propagation of changes from Android to other
devices/repositories.

Here’s a method which allows for editing of org-mode files on Emacs which allows
for back-propagation via Dropbox:

Create a separate Dropbox synchronisation directory - that is, separate from
the one you use for MobileOrg synchronisation. [The way I did this on my
Linux desktop was to create a symlink from my “Org folder” in my Documents
directory to the “actual” Org directory in my Dropbox folder. In my setup,
this directory also synchs with a git repository, so I ended up excluding the
hidden .git directory from synching with Dropbox, since I have only a free,
very-limited-space Dropbox account.]

Open up the Dropbox app on your Android device. Navigate to your new Org
directory (not the one you use for MobileOrg). “Open” any of the org files you
want to have access to. It doesn’t matter if they successfully open or not -
the act of “opening” them gets the Dropbox app to save a local copy which it
will keep synchronised with your Dropbox repository.

The location for these local files is a path like this:
/sdcard/Android/data/com.dropbox.android/files/u87923223/scratch/YourOrgDirectoryName/
the u-number part of the path I assume varies from user to user; and of course
the final part of the path will depend on what you named your Org folder and
files

Files in the above path can be opened in Emacs on Android. Any changes you
make will be propagated via Dropbox.

Again, this will be perhaps of limited use on a phone — though ZShaolin does
have a built-in software keyboard which works very well for Emacs — on a
tablet device with a keyboard (I use an Asus tablet) it works pretty
well. (Though I haven’t figured out how to remap CAPSLOCK on my tablet to CTRL
yet….)

2 comments
:

Thanks for your kind tip. But after I tried to download your files on mega.co.nz, I couldn’t find emacs executable binary of original version. Do you still have it? Or can I get some link to download it?Thank you!

Hmm.. perhaps one still needs to download the Emacs app from the Play Store: https://play.google.com/store/apps/details?id=com.zielm.emacs -- It won't be able to download the Emacs folder (but that's what I've put on Mega), but it should install the binary. Let me know if this works for you.

About this blog

Posts on a variety of topics, including steam-powered analytical engines, Linux, (La)TeX, and Emacs. Some posts are musings, some are hacks for getting things to work right, some are useful tips I came across or came up with, some are links to topics of interest.