Minimum Profit - Programmer Text Editor Copyright (C) 1991-2002 Angel Ortega <angel@triptico.com> Home Page: http://www.triptico.com/software/mp.html
This software is GPL. NO WARRANTY. See file 'COPYING' for details.
If you are reading this (you are), you probably know what a text editor is and thus I won't explain what 'open file', 'search and replace', 'tab size' and things like those, means. Only the special or not-so- intuitive features will be explained. In any other aspect, mp is just like the text editor you were using until today, before you've found this unknown jewel that will change your life.
The key bindings aren't changeable, so forget about that (unless you modify the source and recompile). You'll see that some of them reminds you to ancient Borland editors; this is true because the Mp Project began in 1991 and that was the de-facto standard then. There is also no configuration file nor fancy things as scripting, project building or regular expression matching; just the text editor as one file, once compiled. In later days it had all of this, and then I realized that I didn't need all those bells and whistles but a small, fast and portable thing.
For Linux/Unix, you just need the usual ncurses/curses library, GNU gcc and GNU make. For MS Windows, you need the lccwin32 compiler and the GNU make that comes with DJGPP.
To compile, just run
$ make
and it should build correctly, no errors nor warnings (this must be GNU make; in your system may be installed as gmake).
If you don't have ncurses but the plain curses (as in many Unix flavours), run
$ make CURSES=curses
In previous versions, language dependent messages needed to be set at compile time, but now this is not necessary. On startup, Minimum Profit tests the LANG or the LC_ALL variables for a recognized language, and sets it as the current one. By now, english, spanish and german languages are available.
Tab size defaults to 8 spaces; if you want 4 (or any other funny size), do
$ make CFLAGS=-DDEFAULT_TAB_SIZE=4
To install it, as root, type
# make install
and it will be instaled in /usr/local/bin. If you want it at /usr/bin, do
# make install PREFIX=/usr
If you need to build mp static (to use it in, for example, small floppy rescue distros), just compile it as
$ make LDFLAGS=-static
If you use win32 and a GNU make version that is not the one that comes with DJGPP (for example, the cygwin32 one) the system won't be correctly autodetected; you must use
$ make SYSTEM=WIN32
to force it to be win32 and use the lccwin32 compiler. This will change soon.
If you have an odd Unix system lacking the glob()
function, do
$ make CFLAGS=-DWITHOUT_GLOB
note that you won't be able to use the file list in this case.
Many people complained about new color scheme, so I reverted to the old one. If this make you unhappy, you can do
$ make CFLAGS=-DALT_COLOR=1
so you can use by default the yellow-over-red menus (remember that you always can swap between color schemes in runtime with --alt-color).
If you have ncurses and the compilation process complains about an unresolved
symbol 'use_default_colors()
', you have an old ncurses; upgrade it or use
$ make CFLAGS=-DNO_TRANSPARENCY
Of course, you can also use this if transparency in X terminals annoys you.
mp supports tags as in vi. This means that you can do
mp -t ShootPlasmaGun
and it will open the source code file that includes a symbol (function or variable) called ShootPlasmaGun and that resides in the current directory. As vi, mp uses the 'tags' file created by the program 'ctags'. There is an awesome version of this program, called 'Exuberant Ctags', that is able to recognize other languages that C, notably Perl, Python and millions of other crap.
Note that mp just needs ctags for building the 'tags' file, not for using it. This means that, though you don't have ctags in your win32 machine and you cannot create the tags file, you can use one created in a real operating system.
Tags are searched as substrings; if more than one tag containing (in any position) the string you pass is found, a list will be shown to allow you to select the one you want. If you pass an empty string, all the tags in the current directory will be shown, making mp look like a very sexy code browser.
Mp tries to detect the type of a file by looking inside its contents and, if failed, by its extension. It correctly detects C, C++, Perl, Man pages, RFC822 mail messages, HTML, SGML and XML. If you favourite language isn't listed here, you can read the 'Syntax highlighters authoring Mini-HOWTO' below and add your own one. File type detection is also used in inline help.
If you press F1, mp takes the word below the cursor and executes man sending it as an argument (unless the file is recognized as Perl code, where 'perldoc -f' is used). A new help page is opened in a new (read-only) window. You can close it as a normal text or swap back to the original source (with F6). Help doesn't work in win32 (well, it does, but it's a dirty hack and is far from usable, as it has c:\bin\lcc\bin\win32.hlp hardcoded, see below to change it).
Macro (or learning) mode is activated when you hit F10 (you'll notice that you are recording a macro by an 'R' letter in the status line). Since then, any key you type will be recorded in an internal buffer. To stop recording, just hit F10 again. To recall the recorded keys, go to wherever you want, press F7 and they will be inserted in the current cursor position (macros are silently limited to 1024 bytes). Any letter or cursor movement key can be recorded.
What the hell is a hardware cursor? Is that stupid blinking underscore in your text console. As you probably know yet, mp intensively uses colors for syntax hilight and to show the next character insert position. If you want this blinking thingie to follow the insert position (and not sitting forever in the status line), use the -hw or --hardware-cursor switch. If you use a black and white monitor or a crappy terminal emulation as vt100, you may need to set this option, though mp usually behave well in this colorless situations. There is no such thing as a hardware cursor in win32.
These are the options I use in my .muttrc:
set editor="mp --word-wrap 75 --col80 --mode mail"
This line forces mp execution with word wrapping on column 75 and marking the 80th column for correct message formatting. The --mode mail switch orders mp to bypass any syntax hilight detection and force it to treat the file as a mail message, beautifying message headers and '>' quotes. Now you can write / reply to all your spam in fancy colors.
The 'System command...' menu option lets you run system commands. If you run a program as is (for example, 'date'), mp just reads its standard output and inserts it into cursor position. If you precede it by a | (pipe) symbol (as in '|lpr') it runs the command sending the current file being edited as the program's standard input. This is useful for printing or sending a text by email. Of course, this doesn't work in win32 (even if it did, it couldn't be useful. How many win32 programs makes standard I/O, or any other standard thing?).
When a file is read, tabs are converted into spaces, using the current tab size setting. When written again, tabs are recalculated. This is not a problem when editing makefiles or such, but is a potential cause of trouble if a tab is using as a delimiter (for example, in sql export files), as they can appear in unexpected places. Solution: don't use tabs as delimiters (they can be a pain in the ass) or don't use mp (at least for editing this kind of files). Remember, you use mp at your own risk.
Aren't you fed up of filesystem travelling in search of a block of text you usually insert into every file (like the license covering your software)? I am. No more find && grep && cut && paste. Say no to it just now.
Mp templates are stored in $HOME
/.mp_templates and have a name (a line of
text preceded by two % characters) and a body of text. When you hit
Ctrl-U, all template names you defined are showed on screen in a list for
you to just move over and push ENTER and by magical arts be inserted into
current opened file's cursor position. And for the sake of sloth, you can
open the template file directly from the Edit menu.
The tools/ directory holds mp_doccer, a small Perl script that extracts specially marked comments from C source code files and builds beautiful HTML documentation. See the README file there.
Some Win32 default values are changeable via the registry. These keys are defined under "HKEY_CURRENT_USER\Software\Minimum Profit" and are the following:
Key | Description | Default | |||
TemplateFile | The drive:path of the template file | nothing | |||
FontFace | The font face of the text | "Lucida Console" | |||
FontSize | The font size | 12 | |||
Win32HelpPath | The path to the Win32 API help file | "C:\bin\lcc\bin\win32.hlp" |
The file mp.reg is a template for setting these values. Remember that the registry is a very dangerous thing to play with; do your usual backups before touching anything (is this really possible anyway?).
To be done.