Skip to content

Mg v4.0

Latest

Choose a tag to compare

@github-actions github-actions released this 10 Jul 19:05
v4.0
7e3f389

Note

The UTF-8 release: multibyte text can now be typed, displayed, and edited in UTF-8 locales. Also new: syntax highlighting, a visible region, and side by side windows.

Changes

  • Initial UTF-8 support, active in UTF-8 locales:
    • Multibyte characters display as single characters, cursor motion and delete operate on whole characters, and files always round trip byte for byte
    • Limitations, see mg(1): every character is drawn one column wide, mini-buffer editing is still byte-wise, case folding is ASCII only
  • 8-bit character input works out of the box: meta-key-mode is now disabled by default, use (meta-key-mode 1) in ~/.mg to get the old behavior back. Terminals that send Meta as an ESC prefix, which is all of them these days, are unaffected
  • Character class table updated from DEC multinational to Latin-1: word motion, case conversion, and case-insensitive search now treat Ð, Þ, ð, þ as letters, and no longer the × and ÷ signs
  • Visual mark mode: the region between mark and dot is drawn in reverse video, like transient-mark-mode in GNU Emacs. New command visual-mark-mode toggles it, enabled by default
  • Shift and the arrow keys mark text, like in GNU Emacs, by word and paragraph with control held too. The first unshifted command drops the selection; a mark set with C-SPC is left alone
  • Syntax highlighting of comments, strings, keywords, types, numbers, and preprocessor directives in buffers with a language mode, such as c-mode. New command font-lock-mode toggles it, enabled by default. Terminals without color show plain text. C and C++ files enable c-mode automatically
  • New command shell-script-mode with shell highlighting rules: POSIX reserved words, builtins, and $variables. Also sets tab width 8 with hard tabs, for here documents, and RET keeps the indent. Enabled automatically for *.sh files and files with a #! line naming a Bourne compatible shell
  • New command python-mode with python highlighting rules: comments, strings including the triple-quoted kind, keywords, built-ins, and decorators. Also sets four column indent steps with spaces only, RET keeps the indent, and TAB indents like the previous line, one level deeper after a colon; TAB again steps back one level at a time and wraps around. Enabled automatically for *.py files and #! lines naming python
  • New command markdown-mode with highlighting rules for the common markdown core: headings, fenced and indented code blocks, block quotes, horizontal rules, list markers, inline code, emphasis, and links. Headings are drawn in bold. Enabled automatically for *.md and *.markdown files
  • New command split-window-horizontally, bound to C-x 3 like GNU Emacs: side by side windows, freely mixed with C-x 2
  • Resizing the terminal grows or shrinks the focused window; the other windows keep their size and move. Pop-ups like the quick
    help no longer swallow the new rows, and side by side layouts survive width and height changes
  • New command balance-windows, bound to C-x + like GNU Emacs: evens out the window sizes in any layout, heights and widths alike; the quick help pop-up keeps its height
  • Move between windows with Meta and the arrow keys: new commands windmove-up, -down, -left and -right select the window in that direction, like windmove in GNU Emacs. M-left and M-right no longer do word motion; C-left and C-right still do
  • Resize windows with Meta, Shift and the arrow keys: the window divider travels with the arrow. Also new: GNU Emacs' commands enlarge-window-horizontally and shrink-window-horizontally, on C-x } and C-x {
  • Pop-up buffers, like the quick help, open below the current window instead of replacing the other one in side by side layouts. The quick help is dismissed with q and no longer disturbs the window layout when closed
  • New command require-final-newline <nil | T | ask>
  • New command use-short-answers: a single y or n answers important questions. Enabled by default, unlike GNU Emacs; get the strict behavior back with use-short-answers 0 in ~/.mg. From PR #37 by Glubbfreund
  • The startup help text in the echo line is dismissed on the first key press, or after ten seconds. Keep the old always-on behavior with display-help-mode 1 in ~/.mg
  • Smart TAB in c-mode and shell-script-mode: TAB indents the current line, or every line in the region when the mark is active, like in GNU Emacs. Shell scripts indent like the previous non-blank line
  • M-q reflows one list item at a time instead of the whole list, with continuation lines aligned under the item text, and refills block quotes keeping the > prefix. Paragraph motion, mark and kill treat list items as paragraphs too
  • M-g g and M-g M-g run goto-line, like GNU Emacs 22 and later. The old C-x g binding remains
  • Dired: new command dired-up-directory, bound to ^, also used by dired-jump, from OpenBSD
  • C-u M-! and C-u M-| insert the shell command output in the current buffer instead of a separate one, from OpenBSD
  • C-mode: respect user defined tab width in indentation, by Daniel Hennigar
  • Mg tutorial updated and converted to Markdown format
  • Support +LINE:COLUMN FILE startup postion, by Delyan Angelov
  • The mini-buffer now displays the initial help text for 10 seconds, or until the user starts typing. Also, the cursor is now shown in the main edit window instead of the mini-buffer

Fixes

  • Sync with OpenBSD, as of March 2026:
    • Fix replace-regexp looping forever on (replace-regexp "^.*$" "") and replacing anchored patterns more than once per line
    • Saving the *scratch* buffer no longer prompts for a file path when there are no changes to save
    • Plug memory leaks in the interpreter and word handling routines, from Han Boetes
    • Handle strdup() failure in several places, from Han Boetes
    • Fix wrongly sized externs, found by Gentoo building with -flto
    • Fix auto-indent-mode with custom tab widths
  • Fix build with dired disabled
  • Fix missing mini-buffer help texts