Project Icon

mg

小巧高效的Emacs编辑器替代品

mg是一个小巧高效且可移植的Emacs编辑器替代品,专注于与GNU Emacs的兼容性。它支持Linux、BSD、macOS和Windows等多种平台,提供模式行、快速帮助和ctags支持等类似Emacs的功能。作为完全自由的公有领域软件,mg适合无法或不想运行完整Emacs,但又需要简单强大文本编辑器的用户。

Micro (GNU) Emacs

[![License Badge][]][License] [![GitHub Status][]][GitHub] [![Coverity Status][]][Coverity Scan]

Contents

Introduction

Mg is a [Micro Emacs][] clone created in 1987, based on the original [MicroEMACS][] v30 released by Dave Conroy in 1985. The name, "Micro GNU Emacs", was disputed early on by the FSF, so today it simply goes by mg. This software is fully free and in the public domain.

The intention is to be a small, fast, and portable Emacs-like editor for users who cannot, or do not want to, run the real Emacs for one reason or another. Compatibility with GNU Emacs is key for Mg, separating it from other [ErsatzEmacs][] clones, because there should never be any reason to learn more than one Emacs flavor.

Try the latest 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.

Usage

When Emacs was born keyboards had a Meta key. Accessing functions with Meta combinations today is usually the same as holding down the Alt key, or tapping Esc once.

Other editors use short forms like Ctrl-V or ^V, in Emacs this is written C-v. Some usage examples:

KeyShortExampleDescription
MetaM-M-xHold down Alt and tap x
CtrlC-C-gHold down Ctrl and tap g
CtrlC-C-x C-cHold down Ctrl then tap x and c

To access the built-in Quick Help, press C-h q, meaning: hold down Ctrl and tap h, then release Ctrl and tap q. The - has a meaning, as you can see.

Building

This project is completely self hosting. However, by default you need a termcap library, like [Ncurses][], to provide APIs like: setupterm(), tgoto(), and tputs().

See below for how to build without Ncurses.

With termcap/terminfo/curses

On recent Debian/Ubuntu based systems libtinfo-dev can be used, on older ones the include file term.h is missing, so libncurses-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:

./configure
make
sudo make install

Without curses, completely stand-alone

make clean
./configure --without-curses
make
sudo make install

Building from GIT

Users who checked out the source from GitHub must run ./autogen.sh first to create the configure script. This requires GNU autotools to be installed 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 par with 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-optimizations
make
sudo make install-strip

To build a completely static mg with all features:

./configure LDFLAGS="-static"
make
sudo make install-strip

Docker

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 the command line. Both quick help and the tutorial are bundled.

History

The history is long and intertwined with other MicroEMACS spin-offs but goes 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 version later makes its way onto tsx-11, Infomagic, and various other Linux repositories.
  • Feb 25, 2000: First import into the OpenBSD tree, where it is currently maintained with contributions from many others.
  • May 8, 2016: Import from OpenBSD 5.9 to [GitHub][repo]
  • 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 gzipped files, and building without termcap/[Ncurses][], by Joachim Wiberg
  • Oct 17, 2021: Mg v3.5, support for Solaris/Illumos based UNIX systems tested 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 of [AUTHORS][].

Origin & References

This project is derived from OpenBSD Mg, which is the best (maintained) source of the original Micro Emacs based on mg2a. The intention of this project is to develop new usability features, track as many other Mg clones as possible, and, unlike the upstream OpenBSD version, enable hidden features using a standard GNU configure script, while remaining friendly to porting to resource constrained systems. New features:

  • Emacs-like modeline with (row,col) and new display-time-mode
  • Support for building without curses, using termios + escape seq.
  • Support for exhuberant/universal ctags tags file format
  • Built-in *quick* help

Footnotes

  1. This project has been extensively tested on Debian GNU/Linux, Ubuntu, CentOS, Fedora, Alpine Linux, Solaris/Illumos based systems like OmniOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD, Apple macOS >= 10.10, Cygwin, MSYS2, as well as a few embedded Linux systems using musl libc and uClibc-ng.

项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

白日梦AI

白日梦AI提供专注于AI视频生成的多样化功能,包括文生视频、动态画面和形象生成等,帮助用户快速上手,创造专业级内容。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

讯飞绘镜

讯飞绘镜是一个支持从创意到完整视频创作的智能平台,用户可以快速生成视频素材并创作独特的音乐视频和故事。平台提供多样化的主题和精选作品,帮助用户探索创意灵感。

Project Cover

讯飞文书

讯飞文书依托讯飞星火大模型,为文书写作者提供从素材筹备到稿件撰写及审稿的全程支持。通过录音智记和以稿写稿等功能,满足事务性工作的高频需求,帮助撰稿人节省精力,提高效率,优化工作与生活。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号