
Mg: an Emacs-like editor in 160 kb - snoopybbt
http://homepage.boetes.org/software/mg/
======
philsnow
> Since it is written completely in C, there is currently _no language in
> which extensions can be written_; however, keys can be rebound and certain
> parameters can be changed in startup files.

mg seems almost, but not quite, entirely unlike emacs.

the thing that makes emacs emacs is not the keybindings or the so-called
"modeless" editing (which is a misinterpretation by vim folks, emacs is way
more modeful than vim), but the built-in scriptability / extensibility.

~~~
SamReidHughes
Not when I'm on some tiny VM or computer and want something nicer than Nano
that has something remotely close to Emacs keybindings. Then it's the
keybindings, not the scriptability. I just want a reasonable editor.

~~~
Peaker
It's a bit funny, the most unreasonable thing about emacs are its default key
bindings...

Some of the most frequent operations, like switching between buffers or
windows takes _3_ key strokes!

~~~
gnuvince
Vim doesn't appear to be any better in this regard: switching windows is
_Ctrl+W Ctrl+W_ (three strokes) and switching buffers is _:bn <CR>_ (five
strokes).

------
beagle3
Related: Fabrice Bellard[0]'s QEmacs.
[http://bellard.org/qemacs/](http://bellard.org/qemacs/) \- a 160KB executable
provides a mostly complete Emacs experience (sans scripting .. sort of like
Mg), but does include syntax coloring, unicode, and watching video inside the
editor. A 60KB stripped down version has a feature set comparable to Mg as far
as I can tell.

[0] of FFMPEG, QEMU, BPG, TCC, JSLINUX and more fame.

~~~
PuercoPop
> a mostly complete Emacs experience (sans scripting ...),

That is mostly not like not Emacs? Or did Zwei and other emacsen had the same
key bindings as emacs and gnu's readline?

~~~
melling
"sans scripting"

The Lisp scripting is the entire point of Emacs. Who cares about the
keybindings. I don't really see the point. Can't you just compile emacs? I
remember 25 years ago when people thought emacs was too big, and small emacs
clones were popular, but in 2015 no one cares, right?

Rather than solving these easier useless problems, why doesn't someone solve
the harder problem of making a better emacs clone with a high-performance
Emacs Lisp clone. Then Emacs could be used to replace Visual Studio, Xcode,
etc. Emacs is an editor construction kit:

[http://ergoemacs.org/features.html](http://ergoemacs.org/features.html)

[https://github.com/syl20bnr/spacemacs](https://github.com/syl20bnr/spacemacs)

~~~
jlarocco
I was thinking the same thing.

I mean, I can run full GNU Emacs on my Raspberry Pi. What's the point of a
"micro emacs" missing all the good parts?

~~~
__david__
You cannot, however, install full blown Emacs on your Netgear router running
OpenWRT. Mg is heaven sent in cases like that. Tiny linux machines still exist
(Raspberry Pi is _not_ tiny, resource-wise).

~~~
melling
Emacs should be able to run on 16MB machines without X linked.

[http://superuser.com/questions/313105/ram-requirements-of-
em...](http://superuser.com/questions/313105/ram-requirements-of-emacs)

A dozen Emacs "clones" already exist for even lower memory machines:

[https://www.gnu.org/software/zile/](https://www.gnu.org/software/zile/)

[http://www.emacswiki.org/emacs/Jove](http://www.emacswiki.org/emacs/Jove)

Anyway, like I mentioned, wouldn't time be better spent creating a high-
performance clone rather than a partially functional tiny clone?

~~~
__david__
> Emacs should be able to run on 16MB machines without X linked.

My point exactly. These little routers have just a few megs of RAM. Emacs also
has ~70MB of (compressed!) elisp files. On a machine with single digit MBs of
flash, that's just not workable.

And! Even if you _do_ have 70MB of disk and 16MB of RAM available, Emacs isn't
necessarily performant. Emacs was dog slow when I had a $5/month prgmr vm, but
Mg was blazing fast.

> A dozen Emacs "clones" already exist for even lower memory machines

Mg isn't new, in case that is what you are thinking (it's at least 10 years
old).

I tried a bunch of tiny emacs clones a few years ago and Mg was the absolute
best. All the rest had weird gratuitous differences or were missing obvious
important keys (one of them didn't have M-d). Mg isn't complete (obviously)
but it has a surprising number of plain editing keystrokes built in and
functions perfectly for editing conf files or crontabs or other small remote
tasks.

> Anyway, like I mentioned, wouldn't time be better spent creating a high-
> performance clone rather than a partially functional tiny clone?

Whose time? And what do you mean by high-performance clone?

 _Edit:_ I see, I missed your (way) above comment. To re-answer: Those tasks
are orthogonal. Nifty higher level editing junk is certainly a good idea, and
people _are_ working on it. I don't see why it would need to be an Emacs clone
though, why not just make Emacs itself better? That's the whole point of it in
the first place.

~~~
vidarh
> Mg isn't new, in case that is what you are thinking (it's at least 10 years
> old).

Mg is based on MicroEmacs, as far as I know, which makes it roughly 30 years
old.

------
minikomi
Would be even smaller without all the weird quotes in theo.c

    
    
        "Stop slacking you lazy bum!",
        "slacker slacker lazy bum bum bum slacker!",
        "I could search... but I'm a lazy bum ;)",
        "sshutup sshithead, ssharpsshooting susshi sshplats ssharking assholes.",
        "Lazy bums slacking on your asses."
    

etc!

~~~
mykhal
i you're lonely, just M-x theo ^M ^M ^M ...

------
typedweb
Standard text editor in OpenBSD. As an emacs user for 20+ years, mg feels good
and not lacking like the other tiny emacs clones.

------
NelsonMinar
I use mg all the time. It only takes half a second to launch and lets me use
the emacs keyboard muscle memory I built up over 20 years. Happily I'm able to
use a modern editor for most real editing.

------
oskarth
Did it ever occur to people that less can be more in terms of features? There
might be a reason why people like Torvalds (Linux and de Raadt (OpenBSD,
OpenSSH) specifically don't use the stock Emacs.

Here are some other data points: Hickey (Clojure) uses the stock Acqumacs with
zero customization and Graham (creator of HN and the first real web app) uses
plain vi to edit Lisp.

If you want to use a text editor to get work done, sane defaults and an editor
that gets out of the way is king.

~~~
josteink
> Did it ever occur to people that less can be more in terms of features?

It can be, but it doesn't have to be. Sometimes more _is_ more.

As for your examples...

> Here are some other data points: ... Graham (creator of HN and the first
> real web app) uses plain vi to edit Lisp.

And you can tell the great amount of effort that makes him put into this very
fine website, can't you?

This is probably the worst website I frequently visit in terms of features,
design, technical basis and mobile readability. It sucks in all respects
except community.

If this is the pinnacle of websites which vi can get us, please move everyone
everywhere to anything else, notepad included. I've created better websites
than this in Notepad (during my early university years), and that's not a
joke.

------
Animats
This has been done before, most notably as JOVE, Jonathan's Own Version of
EMACS for the PDP-11. JOVE was written by Jonathan Payne while in high school,
around 1980. That had to fit in a 16-bit machine, with 128KB of RAM available
to the program.

~~~
vidarh
Mg's lineage is almost as old, coming out of MicroEMACS, first published in
1985. The first version of MicroGNUEmacs, now Mg, was published in 1986.

------
film42
I use emacs for most of my daily development, but always rely on nano or vi in
the terminal due to emacs startup time. I'm going to give mg a shot this week!

~~~
Dewie
You could also run Emacs as a server.

~~~
film42
I've actually looked into this, but it seemed like far too much overhead to
simply open, edit and save a file; especially remotely.

~~~
barrkel
Remotely, sure (though I usually use joe for that), but for local edits, I
start emacs --daemon as part of my regular login procedure (along with
creating multiple terminal windows) and thereafter use emacsclient (aliased to
'e') for almost all file editing.

Only annoying thing is the way it retains buffers for modified files when you
exit, even if you choose not to save them.

emacs -q (or faster, -Q) could be used in a pinch, but I find default emacs
almost unusable.

------
robobro
My .mg file -

global-set-key "\^h" delete-backward-char

global-set-key "\e[1~" beginning-of-line

global-set-key "\e[4~" end-of-line

set-default-mode fill

set-fill-column 72

Been using it for quite some time and really dig it.

------
theophrastus
For some curious reason all my browser right-click download efforts on that
webpage resulted in a wrong-sized corrupted file. Yet good old curl does the
job just fine:

    
    
        curl -O http://homepage.boetes.org/software/mg/mg-20150316.tar.gz
    

And I can't remember when the last time i've had a program compile with just
'make' and no messing about. It's quite impressive. Thank you!

------
gnuvince
As an Emacs guy, I really like mg(1). The one missing feature is Unicode
support.

~~~
tjradcliffe
I'm an mg guy who uses Emacs when he has to. Unlike Emacs, mg is an editor. I
don't know what tool-class Emacs properly falls into, but as many people here
have pointed out, it's closer to a general-purpose scriptable environment than
an editor. Editing is a side-effect of the other capabilities, very nearly. I
know at least one person who uses Emacs as their shell.

For those of us who just want a clean, fast, light-weight editor, mg is great.
It's what Emacs would have been had it been an editor, instead of something
else.

~~~
reality_czech
"I just want an editor" is the vi philosophy, and has been since olden times.
Emacs users tend to write a lot of emacs modes and lisp macros, whereas vi
users generally use external programs or the shell.

The thing is, vi is much better at being "just an editor" than emacs is. The
key bindings for vi are highly ergonomic and let you keep your fingers on the
home row almost all the time. With emacs, you're playing "twister" with your
fingers, often pressing 3 or 4 keys simultaneously just do to some simple task
like quitting or indenting a paragaph. vi also supports things like deleting
to the end of the line, going to the end of the file, or even appending to the
end of a line with a single keypress.

If you're using something with emacs key bindings but no emacs-like
extensibility, you're really getting the worst of both worlds. You really
should just be using vi. And you will find a lot of people with your philsophy
who use it, and it is installed on nearly every system out there.

------
mixedmath
It is no wonder that Richard Stallman asked them to change their name away
from MicroGnuEmacs, especially when mg is not under GPL.

------
davidw
I would suggest 'jed' as a small alternative to Emacs. Its keybindings are
mostly the same, and it's extensible.

[http://www.jedsoft.org/jed/](http://www.jedsoft.org/jed/)

I happily used it on my first Linux computer, which only had 4 megs of ram.

------
__david__
I really like Mg. I tried a bunch of mini-emacsen at one point and Mg was the
only one that had a decent set of Emacs key-bindings and didn't have weird
gratuitous differences. It's so small that it launches instantaneously, even
on tiny, slow computers.

------
iso8859-1
how does this compare to torvalds emacs?
[https://git.kernel.org/cgit/editors/uemacs/uemacs.git](https://git.kernel.org/cgit/editors/uemacs/uemacs.git)

------
snoopybbt
Hey, OP's point on the topic:

I like GNU Emacs, and I run GNU Emacs most of the time.

I _do_ know how to use vi/vim and I'm quite pragmatic on the matter.

When I am doing server configurations, by the way, vi/vim start up way, way
more quickly than GNU Emacs.

This is good, but as I use emacs most of the time, I end up in mixing keyboard
shortcuts.

Thus, on my system, $EDITOR is /usr/bin/mg and /usr/bin/vi (vi, not vim) is a
symlink to /usr/bin/mg.

So I get emacs keybindings and a fast-starting editor.

If i __do__ need syntax highlighting or anything, i run vim (not a symmlink)
or the full GNU Emacs.

Put simply.

------
mhax
At 160k it's not really in the true spirit of Emacs. _ducks_

------
wirrbel
really interesting how this tiny, old editor provokes so much "just use emacs"
"just use vim" comments. kind of missing the point

------
jhallenworld
How does it compare with Jmacs (part of JOE)?

BTW, anyone have a copy of Gosling's emacs? I know it went closed source, but
I doubt it matters at this point.

------
lispm
FYI: the list of Emacs implementations:

[http://www.finseth.com/emacs.html](http://www.finseth.com/emacs.html)

------
aaronem
Easier just to learn enough of vi to get around. I mean, if I need a more
familiar editor, I'm just going. to visit the file remotely via Tramp, and for
simple stuff like quick config edits on remote machines, quicker just to use
vi or sed or a Perl one-liner.

------
ehmuidifici
Also it's still available for Archlinux (via AUR)

[https://www.archlinux.org/packages/community/i686/mg/](https://www.archlinux.org/packages/community/i686/mg/)

~~~
auxym
Community repo is a different thing from AUR

------
RexRollman
Cleanng up software older than me:
[http://blog.anthrobsd.net/043.html](http://blog.anthrobsd.net/043.html)

------
jpmattia
off topic but related: Has anyone had any luck getting emacs to run on an
ipad+keyboard, with sensible key-bindings (including a mapping for meta)?

------
sebastianavina
Very neat, I really wanted something like this

------
Scarbutt
Is this toó big for busybox?

~~~
jasonm23
It should be ok for a busybox.

------
Swizec
But does it have Tetris?

~~~
jasonm23
I'd be happier if it just had Zap to Char.

