All Projects → italia389 → MightEMacs

italia389 / MightEMacs

Licence: other
Fast and full-featured Emacs-style text editor

Programming Languages

c
50402 projects - #5 most used programming language
shell
77523 projects
MAXScript
40 projects
objective c
16641 projects - #2 most used programming language

You are looking at the ReadMe file for MightEMacs, an Emacs-style text editor which runs on macOS, Linux, and Unix platforms. See file Install.txt for build and installation instructions. A C99 C compiler is required if you are not installing on a macOS or Linux platform, or do not want to use the included binaries.

History and Project Goals

MightEMacs is designed to be a fast and full-featured text editor. Goals of the project are to create a lightweight Emacs-style text editor that will do the following:

  1. Provide the ability to edit code quickly and easily with few keystrokes.
  2. Use key bindings that are well designed and intuitive.
  3. Be as easy as possible to learn.
  4. Be robust and powerful enough to perform sophisticated editing and automation tasks, provide a high level of extensibility, and yet not be overly complex.

MightEMacs is focused on editing files well and being easily extensible, but also being an editor that is not daunting -- one that can be learned fairly quickly by the average programmer. The tradeoff is that it lacks some features (and complexity) of other editors. It uses a Text User Interface and is run from a terminal window. It is not an IDE and doesn't try to be. It is however, very fast, robust, and provides most of the things you would expect from an Emacs editor, like the ability to create multiple buffers, windows, and screens, built-in and user-defined modes of different types, a kill ring, search ring, key macro ring, sophisticated navigation, searching, and editing commands, multiple working directories, language-specific auto-formatting, fence matching, extensibility, a built-in help system, and more.

It also supports a C-like scripting language called MScript that is very powerful and easy to learn (assuming you already have programming experience). The distribution package includes several scripts as well that perform various tasks, such as finding a file that contains a particular function or method definition and opening it at that location, rewrapping text in a comment block, wrapping a pair of fence characters or quotes around one or more words in the text, or grep'ing for files and performing a global search and replace on them.

See the memacs(1) man page and on-line help (via ESC ?) for further information.

Examples

Following are some examples of MightEMacs' features and how it can be used to edit code. The cursor (point) is shown as (^) and keys that are typed are shown in bold. Control keys are shown as C-X, where X is usually a letter. Note that the C-_ (control + underscore) key, which is used often, can usually be entered without holding down the shift key (control + dash), which makes it easier to type. Hence, it is shown as C-- in the examples.

  1. Duplicate a block of lines in JavaScript:

     switch(grade) {
         case 'A':
             "Good job"
             break(^)
     
     C-- 2 (n == -2)
     ESC d (duplicate current line + prior two)
     

    Yields:

     switch(grade) {
         case 'A':
             "Good job"
             break
         (^)case 'A':
             "Good job"
             break
     
  2. Copy and paste in shell script:

     if [ $x -lt 0 ]; then
         echo 'Error: x cannot be negative' 1>&2
     (^)
     
     C-SPC (set mark)
     C-p C-p (move up two lines)
     C-c C-l (copy current line to kill ring)
     C-x C-x . (swap point and mark)
     C-u C-u (n == 0)
     C-y (yank line that was copied without moving point)
     el (enter more text)
     

    Yields:

     if [ $x -lt 0 ]; then
         echo 'Error: x cannot be negative' 1>&2
     el(^)if [ $x -lt 0 ]; then
     
  3. Cut and paste in C++:

     do {
         process(i);
         } while(++i < 5);(^)
     
     ESC C-a (move to beginning of text: "}")
     C-f (forward character)
     C-d (delete character at point: " ")
     C-h C-k (kill to end of current line)
     C-- C-- (n == -2)
     ESC C-a (move to beginning of text two lines above)
     C-d C-d C-y (delete "do" and yank "while" clause)
     DEL (delete previous character: ";")
     

    Yields:

     while(++i < 5)(^) {
         process(i);
         }
     
  4. Search forward and backward in Python:

     # Print function.(^)
     def printme(str):
         "This prints a string passed into this function"
         print str
         return
      
     # Call function.
     printme("Jack and Jill...")
     printme("went up the hill.")
     
     C-u (n == 2)
     C-s print ESC (search forward for "print" two times)
     C-u 3 (n == 3)
     C-] (find next occurrence three more times)
     C-r Call ESC (search backward for "Call" once)
     

    Yields:

     # Print function.
     def printme(str):
         "This prints a string passed into this function"
         print str
         return
      
     # (^)Call function.
     printme("Jack and Jill...")
     printme("went up the hill.")
     
  5. Replace a string pattern in Ruby:

     (^)files.each do |fileInfo|
         fileName = fileInfo[1]
         if fileInfo[0].nil?
             fileInfo[0] = fileName
         end
     end
     
     C-u (n == 2)
     ESC r fileName ESC (replace "fileName"...)
     pathname ESC (with "pathname" two times)
     

    Yields:

     files.each do |fileInfo|
         pathname = fileInfo[1]
         if fileInfo[0].nil?
             fileInfo[0] = pathname(^)
         end
     end
     
  6. Query replace a regular expression pattern in C:

     if(flags & OpEval)(^)
         mset(mkp, NULL);
     else if(n >= 0)
         mset(mkp, wkbuf);
     else
         // mset(a, b) where a is a char buffer.
         mset(NULL, wkbuf);
     
     ESC q (query replace...)
     (mset\()([^,]+), ?([^)]+):r ESC ("from" regular expression...)
     \1\3, \2 ESC ("to" replacement pattern)
     SPC SPC n SPC q (replace first two occurrences, skip third, do last)
     

    Yields (reversed mset() arguments):

     if(flags & OpEval)
         mset(NULL, mkp);
     else if(n >= 0)
         mset(wkbuf, mkp);
     else
         // mset(a, b) where a is a char buffer.
         mset(wkbuf, NULL(^));
     
  7. Rewrap comment block in Java:

     // MightEMacs can rewrap
         // comment blocks composed of contiguous single-line
     // comments.  Indentation of first comment line is
     // used for whole block.  Also, the
     // prefixes (for example, "//" or "#") can be
             // conf(^)igured.
     public class HelloWorld {
     
     ESC . (rewrap block of comment lines)
     

    Yields:

     // MightEMacs can rewrap comment blocks composed of contiguous
     // single-line comments.  Indentation of first comment line is
     // used for whole block.  Also, the prefixes (for example, "//"
     // or "#") can be configured.(^)
     public class HelloWorld {
     
  8. Add numbers to a block of lines in Swift:

     /* Create array. */
     var attr:[String] = [
         "Name",
         "Street",
         "City",
         "State",
         "Home phone",
         "Cell phone"](^)
     
     C-- 5 (n == -5)
     ESC # (enumerate lines)
     0 RTN /* %u %/ ESC 1 RTN (enter parameters)
     

    Yields:

     /* Create array. */
     var attr:[String] = [
     /* 0 */    "Name",
     /* 1 */    "Street",
     /* 2 */    "City",
     /* 3 */    "State",
     /* 4 */    "Home phone",
     /* 5 */    "Cell phone"]
     (^)
     
  9. Mark and swap positions in HTML:

     <head>
         <title>Example(^)</title>
         Header.
     </head>
     <body>
         <h3>Mark and Swap</h3>
         Marks, which are visible characters like X or /, can be set
         at various places in a buffer and returned to later.  The
         default mark "." is also used to define a region.
     </body>
     
     C-SPC (set mark "." -- default)
     C-u ESC C-e (move forward to end of second word: "Header")
     C-u C-SPC x (set mark "x")
     C-u 7 C-e (move down to end of seventh line)
     

    Yields:

     <head>
         <title>Example</title>
         Header.
     </head>
     <body>
         <h3>Mark and Swap</h3>
         Marks, which are visible characters like X or /, can be set
         at various places in a buffer and returned to later.  The
         default mark "." is also used to define a region.(^)
     </body>
     
     C-x C-x . (swap point with mark "." -- now at "Example")
     C-x C-x . (swap again -- back at "region.")
     C-x C-x x (swap with mark "x" -- now at "Header")
     C-x C-x x (swap again -- back at "region.")
     ESC SPC x (go to mark "x")
     

    Yields:

     <head>
         <title>Example</title>
         Header(^).
     </head>
     <body>
         <h3>Mark and Swap</h3>
         Marks, which are visible characters like X or /, can be set
         at various places in a buffer and returned to later.  The
         default mark "." is also used to define a region.
     </body>
     
  10. Multi-file query replace in C:

    C-x f (find files...)
    *.c (enter filename template...)
    mset( ESC (enter search pattern)
    

    Yields (on message line):

    [10 files found: buffer.c, edit.c, ..., region.c, search.c]
    
    C-- ESC C-q (query replace on files found...)
    ESC (accept "mset(" search pattern entered previously...)
    markSet( ESC (enter replacement pattern)
    SPC SPC ! (do replacement twice, then do rest unprompted)
    (repeat on 9 remaining files)
    

    Yields (in all files):

    if(flags & OpEval)
        markSet(NULL, mkp);
    else if(n >= 0)
        markSet(wkbuf, mkp);
    else
        // markSet(a, b) where a is a char buffer.
        markSet((^)wkbuf, NULL);
    
  11. Move text and change case of letters in PHP:

    $found = FALSE;
    if($r == 0)
        echo "No addresses found";
    else {
        echo "Complete address list";
        $found = TRUE;
        }(^)
    
    C-- C-- C-a (move up two lines to beginning of line)
    C-u ESC f (move forward two words)
    C-u 3 ESC C-t (change next three words to title case)
    C-p C-b (move up one line and backward one character: "{")
    C-h ' (kill fenced region: "{" through "}")
    DEL (delete previous character: " ")
    C-p C-h C-l (move to previous line and kill it)
    

    Yields:

    $found = FALSE;
    if($r == 0)
    (^)else
    
    C-b (move backward one character to end of previous line)
    SPC C-- C-y (insert a space and yank -1th entry from kill ring)
    C-u 3 C-a (move to beginning of third line down)
    C-y (yank 0th entry from kill ring)
    C-p C-x C-u (move to previous line and convert it to upper case)
    C-p (move to beginning of previous line...)
    ESC C-l (and convert first word to lower case)
    

    Yields:

    $found = FALSE;
    if($r == 0) {
        echo "Complete Address List";
        $found = TRUE;
        }
    else
        echo(^) "NO ADDRESSES FOUND";
    
  12. Other things you can do:

    ESC C-\ (trim white space from end of all lines in buffer)
    C-- 4 TAB (set tabbing style to four spaces)
    C-u ESC ) (indent all lines in region two tab stops)
    C-u 5 C-x C-e 4 (change 4-space tabs to hard tabs in next five lines)
    C-x ( ... C-x ) work RTN (record keystrokes, save as "work" macro...)
    C-u 10 C-x e (then play back 10 times)
    C-x | sort RTN (pipe buffer through "sort" command and replace with result)
    C-x ` date RTN (execute "date" command and insert its output at point)
    ESC t y (truncate buffer forward -- delete all text from point to end of buffer)
    ESC u (undelete -- restore most recently-deleted text)
    

Distribution

The current distribution of MightEMacs may be obtained at https://github.com/italia389/MightEMacs.git.

Contact and Feedback

User feedback is welcomed and encouraged. If you have the time and interest, please contact Rick Marinelli [email protected] with your questions, comments, bug reports, likes, dislikes, or whatever you feel is worth mentioning. Questions and feature requests are welcomed as well. You may also post questions or comments on the MightEMacs discussion forum on Reddit at http://reddit.com/r/memacs.

Notes

This distribution of MightEMacs is version 9.5.1. Installer packages containing 64-bit binaries are included for Linux platforms and macOS ver. 10.12 and later. The sources can be compiled as well if desired; however, the build process has not been tested on other Unix platforms and there may be some (hopefully minor) issues which will need to be resolved. If you are compiling the sources and encounter any problems, please contact the author with the details.

Note that the editor uses both the CXL and XRE libraries, so those libraries must be built first and linked with MightEMacs if you are building the editor from the source code. Instructions for doing this are in file CustomInstall.txt.

Credits

MightEMacs (c) Copyright 2020 Richard W. Marinelli was written by Rick Marinelli [email protected].

See License.txt for the MightEMacs license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].