- Notifications
You must be signed in to change notification settings - Fork43
Micro (GNU) Emacs-like text editor ❤️ public-domain
License
troglobit/mg
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Mg is aMicro Emacs clone created in 1987, based on the originalMicroEMACS v30 released by Dave Conroy in 1985. The name, "MicroGNU Emacs", was disputed early on by the FSF, so today it simply goes bymg
. This software is fully free and in the public domain.
The intention is to be a small, fast, and portable Emacs-like editor forusers who cannot, or do not want to, run the real Emacs for one reasonor another. Compatibility with GNU Emacs is key for Mg, separating itfrom otherErsatzEmacs clones, because there should never be anyreason to learn more than one Emacs flavor.
Try thelatest release,use the tarball with a version in the name, avoid GitHub generated links!Releases come with a
configure
script, so you don't need autotools.Only a C compiler,make
and you're set to go.
When Emacs was born keyboards had aMeta
key. Accessing functionswithMeta
combinations today is usually the same as holding down theAlt
key, or tappingEsc
once.
Other editors use short forms likeCtrl-V
or^V
, in Emacs this iswrittenC-v
. Some usage examples:
Key | Short | Example | Description |
---|---|---|---|
Meta | M- | M-x | Hold downAlt and tapx |
Ctrl | C- | C-g | Hold downCtrl and tapg |
Ctrl | C- | C-x C-c | Hold downCtrl then tapx andc |
To access the built-in Quick Help, pressC-h q
, meaning: hold downCtrl
and taph
, then releaseCtrl
and tapq
. The-
has ameaning, as you can see.
This project is completely self hosting. However, by default you need atermcap library, likeNcurses, to provide APIs like:setupterm()
,tgoto()
, andtputs()
.
See below for how tobuild without Ncurses.
On recent Debian/Ubuntu based systemslibtinfo-dev
can be used, onolder ones the include fileterm.h
is missing, solibncurses-dev
must be used instead:
sudo apt install libtinfo-dev
or
sudo apt install libncurses-dev
On other systems you have to install the full Ncurses library instead,on RHEL, CentOS, and Fedora:
sudo yum install ncurses-devel
or
sudo dnf install ncurses-devel
On macOS you need the Xcode command line tools and headers:
xcode-select --install
Then build Mg from the unpacked release tarball:
./configuremakesudo make install
make clean./configure --without-cursesmakesudo make install
Users who checked out the source from GitHub must run./autogen.sh
first to create the configure script. This requires GNU autotools to beinstalled on the build system.
There are several options to the configure script to disable features,e.g., to reduce the size, or remove features if you want to be on parwith the official Mg. By default, all below features are enabled:
./configure --help[..]--disable-autoexec Disable auto-execute support--disable-cmode Disable C-mode support--disable-compile Disable C compile & grep mode, used by C-mode--disable-cscope Disable Cscope support--disable-ctags Disable ctags(1) support, required by Cscope--disable-dired Disable directory editor--disable-notab Disable notab mode support (not in OpenBSD)--disable-regexp Disable full regexp search--disable-togglenl Disable toggle-newline-prompt extension (not in OpenBSD)--disable-all Disable all optional features[..]--with-startup=FILE Init file to run at startup if ~/.mg is missing--with-mglog Enable debugging to log file, default: ./log/*.log--without-curses Build without curses/termcap, default: auto
To build the smallest possible mg, with many features removed:
./configure --disable-all --enable-size-optimizationsmakesudo make install-strip
To build a completely static mg with all features:
./configure LDFLAGS="-static"makesudo make install-strip
Alpine Linux based Docker container images are available from GitHub:
docker pull ghcr.io/troglobit/mg:latest
To edit files from your host's$HOME
, map it to the container's/root
and run:
docker run -ti -v $HOME:/root ghcr.io/troglobit/mg:latest
This supports reading your~/.mg
and it even takes arguments on thecommand line. Both quick help and the tutorial are bundled.
The history is long and intertwined with other MicroEMACS spin-offs butgoes something like this:
- Nov 15, 1985: MicroEMACS v30 released to mod.sources by Dave G. Conroy
- Mar 3, 1987: First Release (mg1a) via comp.sources.unix
- May 26, 1988: Second release: (mg2a) via comp.sources.misc
- Jan 26, 1992: Linux port released by Charles Hedrick. This versionlater makes its way onto tsx-11, Infomagic, and various other Linuxrepositories.
- Feb 25, 2000: First import into the OpenBSD tree, where it iscurrently maintained with contributions from many others.
- May 8, 2016: Import from OpenBSD 5.9 toGitHub
- May 15, 2016: Mg v3.0, first port back to Linux, by Joachim Wiberg
- Jul 22, 2018: Mg v3.1, removed libite dependency, by Joachim Wiberg
- Aug 26, 2018: Mg v3.2, now fully portable1, by Joachim Wiberg
- Dec 11, 2019: Mg v3.3, misc fixes and new features from OpenBSD
- Aug 23, 2020: Mg v3.4, new modeline, quick-help, support for gzippedfiles, and building without termcap/Ncurses, by Joachim Wiberg
- Oct 17, 2021: Mg v3.5, support for Solaris/Illumos based UNIX systemstested on OmniOS and OpenIndiana, sync with Mg from OpenBSD 7.0
- Apr 10, 2023: Mg v3.6, sync with OpenBSD, improved ctags support
- Aug 13, 2023: Mg v3.7, sync with OpenBSD, improved usability
See the source distribution for the list ofAUTHORS.
This project is derived from OpenBSD Mg, which is the best (maintained)source of the original Micro Emacs based on mg2a. The intention of thisproject is to developnew usability features, track as many other Mgclones as possible, and, unlike the upstream OpenBSD version, enablehidden features using a standard GNU configure script, while remainingfriendly to porting to resource constrained systems. New features:
- Emacs-like modeline with
(row,col)
and newdisplay-time-mode
- Support for building without curses, using termios + escape seq.
- Support for exhuberant/universal ctags
tags
file format - Built-in
*quick*
help usingC-h q
- Tutorial accessible using
C-h t
- Support for Ctrl-cursor + Ctrl-PgUp/PgDn like Emacs
- Support for
M-x no-tab-mode
andM-x version
- Support for opening gzipped text files in read-only mode
Merged, and continously tracked, clones:
- http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/usr.bin/mg/ (upstream)
- https://github.com/hboetes/mg (official portable version)
- https://github.com/ibara/mg (active)
- https://github.com/scott-parker/mg-openbsd (inactive since 2015)
- https://github.com/paaguti/mg3a (continuation of Bengt Larsson's mg3a)
- https://github.com/kisom/kmg (another inactive fork with Go support)
- https://github.com/jasperla/tinyschemg (OpenBSD mg with tinyscheme)
Note: the officialportable Mg project, used by Debian andother GNU/Linux distributions, is maintained by Han Boetes. Unlikethis project, which is stand-alone, Boetes relies onlibbsd tomaintain portability.
Please report any bugs and problems with the packaging and porting tothe GitHub issue trackerhttps://github.com/troglobit/mg/issues
Footnotes
This project has been extensively tested on Debian GNU/Linux,Ubuntu, CentOS, Fedora, Alpine Linux, Solaris/Illumos based systemslike OmniOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, Apple macOS >=10.10, Cygwin, MSYS2, as well as a few embedded Linux systems usingmusl libc and uClibc-ng.↩
About
Micro (GNU) Emacs-like text editor ❤️ public-domain