PlanDuSite ModificationsRécentes Nouvelles SectionElisp CommentFaire

EmacsOnAndroid

This is about installing Emacs into an Android device. See GoogleAndroid for tips about using Emacs to develop Android applications.

Introduction: ways to run Emacs on Android devices

Some of them are hypothetical.

Native port (installable Android application)

A first version of a native port was released August 2012. Quickly installable like any other Android app, with no need to root the mobile device. Key bindings, etc., work with physical keyboards -e.g. mini bluetooth keyboard- and External Keyboard Helper Pro app, or with on-screen Hacker’s Keyboard app. Init file: /sdcard/emacs/.emacs (optional). See Google Play: Emacs, and GitHub: zielmicha/emacs-android (Emacs port issues, etc.).

Keep Android, install Linux and Emacs in a chroot jail, run Emacs from an Android shell client

For a Linux and Emacs environment in a chrooted loopback filesystem on a rooted tablet, see Running Emacs on an Android tablet. Android apps such as ConnectBot? shell client and Hacker’s Keyboard (including Ctrl, etc. keys) can be used with Emacs in this way.

Remove Android, install another GNU/Linux, install Emacs there

This is known to work, but you need to get root access to your tablet and remove Android. See below for some experiences with particular tablets.

Don't run Emacs, just use a SSH client to connect to a server which runs Emacs

This is by far the easiest and fastest way. It does not require uninstalling Android, and Emacs will run at normal speed.

You could also use VNC if you need graphics.

Or even… use other programmer editor, and simulate Emacs behaviour there

There are libre editors which can be extended to use Emacs key bindings, for instance:

Installing Debian/Ubuntu and Emacs on G1/G2 phone

There is a lot of online information for hacking HTC mobile phones on the xda-developers website. This includes the G1 and G2 google phones. One of these hacks is to get a full distribution such as Debian or Ubuntu running, on which you can then install Emacs :)

Check out the wiki to get an overview of hacking the G1, and how to flash the ROM etc.

First you need to root your phone.

Then you can update your ROM to a newer version. There are lots of different ROM updates available here. I recommend installing JesusFreke's ROMs initially, and then upgrading to the latest stable cyanogen ROM. If you make an ext2/3 partition on your SD card, then when you install the cyanogen ROM it will apply Apps2SD which allows you to install many more apps than normal. I also recommend using cyanogen's recovery image (which allows you to easily backup your phone). You will also need to install the latest radio image available here.

Read how to install new images and updates here.

Then have a look at these simple instructions on installing Debian (Note: you may need to alter the installer.sh script as mentioned in post #3566 here).

If you like it a little less “simple” and more solid, I’d rather recommend Bayle Shank’s instructions on installing debian into an ext partition by hand here, as parts of that installer are really bogus. In that case you’ll also have to enable compcache by hand, which Bayle Shank’s script doesn’t do, so you just paste his script into the “custom_shells” section of the user.conf obtained from [1]. Also you might want to use a non-root user for your emacs work, in that case [2] will help. – TauPan

Once you have Debian installed you can just “apt-get emacs” to install emacs 22.

To install Ubuntu instead, see here. He provides downloads for prebuilt Jaunty (9.04) images which makes it very easy to set up. Again it’s a simple matter to install emacs via apt-get.

I strongly recommend using ConnectBot in local mode as the terminal emulator, since it preserves the running terminal session even when you switch away to other apps and back, and also has some extremely convenient keybindings and many other great features – AdamSpiers

Here are some useful thoughts on reducing emacs' footprint for low-powered devices.

Using emacs for making calls and sending texts

To access the android api from emacs you need to first install the android scripting environment which you can get here (see here for how to install apk files). Then get it working in your Debian installation: see here

Making phone calls

With this recipe you can make phone calls from your bbdb buffer:

  1. Make sure you have the android scripting environment installed and working in your Debian installation (see previously mentioned links)
  2. Save the following python code to ‘dialnumber.py’ and save it to ‘/root/android/’ in your Debian installation (you will need to create this directory):
    #!/usr/bin/env python
    import android
    import sys
    droid = android.Android()
    droid.callNumber(sys.argv[1])
  1. You can now use the following function from the bbdb buffer to call the phone number of the record at point (but you must have an ASE shell terminal running on Android):
    (defun joebloggs/bbdb-android-dial (phone force-area-code)
      "Dial the number at point.
    If the point is at the beginning of a record, dial the first
    phone number.  Does not dial the extension.  Does not apply the
    transformations from bbdb-dial-local-prefix-alist if a prefix arg
    is given."
      (interactive (list (bbdb-current-field)
                 current-prefix-arg))
      (if (eq (car-safe phone) 'name)
          (setq phone (car (bbdb-record-phones (bbdb-current-record)))))
      (if (eq (car-safe phone) 'phone)
          (setq phone (car (cdr phone))))
      (or (vectorp phone) (error "not on a phone field"))
      (let* ((number (bbdb-phone-string phone)) shortnumber)
        (when (not force-area-code)
          (let ((alist bbdb-dial-local-prefix-alist))
        (while alist
          (if (string-match (concat "^" (eval (caar alist))) number)
              (setq shortnumber (concat (car (cdar alist))
                        (substring number (match-end 0)))
                alist nil))
          (setq alist (cdr alist)))))
        ;; cut off the extension
        (if (string-match "x[0-9]+$" number)
        (setq number (substring number 0 (match-beginning 0))))
        ;; This is terrifically Americanized...
        ;; Leading 0 => local number (?)
        (if (and (not shortnumber) bbdb-dial-local-prefix
             (string-match "^0" number))
        (setq number (concat bbdb-dial-local-prefix number)))
        ;; Leading + => long distance/international number
        (if (and (not shortnumber) bbdb-dial-long-distance-prefix
             (string-match "^\+" number))
        (setq number (concat bbdb-dial-long-distance-prefix " "
                     (substring number 1))))
        ;; use the short number if it's available
        (setq number (or shortnumber number))
        (if (not bbdb-silent-running)
        (message "Dialing %s" number))
        (shell-command (concat "export AP_PORT=$(netstat -napt|sed -n 's/^tcp.*127.0.0.1:\\([0-9]*\\).*LISTEN.*ase$/\\1/gp');/root/android/dialnumber.py " number))))

Sending SMS text messages

With this recipe you can send text messages from emacs:

  1. Make sure you have the android scripting environment installed and working in your Debian installation (see previously mentioned links)
  2. Save the following python code to ‘sendtext.py’ and save it to ‘/root/android/’ in your Debian installation:
    #!/usr/bin/env python
    import android
    import sys
    droid = android.Android()
    droid.sendTextMessage(sys.argv[1], sys.argv[2])
  1. install Lisp:sms.el and read the instructions
  2. if you want to use your BBDB with sms.el install Lisp:bbdb-sms.el and read the instructions

CategoryPorts