💾 Archived View for schinkel.bevuta.com › ma › README captured on 2024-06-16 at 12:45:33.
⬅️ Previous capture (2023-11-04)
-=-=-=-=-=-=-
88,dPYba,,adPYba, ,adPPYYba, 88P' "88" "8a "" `Y8 88 88 88 ,adPPPPP88 88 88 88 88, ,88 88 88 88 `"8bbdP"Y8 "ma" is a minimalistic clone of the acme[1] editor used in Plan 9, and is written in Tcl/Tk. It has been tested with Tcl/Tk 8.5, mostly under Linux and OpenBSD. "ma" has successfully been run on Mac OS X with XQuartz, but needs a tiling window manager to be used in a satisfactory way. I used emacs[2] for years, but got bored with the ever growing number of extensions and key-combinations that one has to remember when intensively using that editor. I also got fed up with the fact that purely keyboard driven interfaces involve frantic typing, something that appears to stress me. Acme, which is heavily mouse-controlled, seems to produce a more relaxed, single-handed use, especially for navigation and browsing. I'm slower now (or at least this is my impression), but less hectic while working (it seems). Another advantage of acme is the dynamic nature of extending the user-interface while one is using it - nearly everything is text, and every text can be mouse-sensitive. Note that this editor is single-window based - it doesn't provide multiple windows, nor does it manage them in any way (this is delegated to the window manager.) Installation: Invoke ./build and put the files "ma", "awd", "win", "pty", "plumb" and "B" in your PATH and ".plumb" into your $HOME. Usage: "ma" attempts to work as much as possible like acme, but does no own window-management. Configuration is done in the file "~/.ma", holding Tcl code to modify fonts, colors, etc. A number of command-line options can be provided to set various of these options and to run "ma" in special modes, or to communicate with the "registry", a "ma" instance that allows locating files that are already open. To start the registry, run ma -registry & The registry is implemented using the Tk "send" command, so X-forwarding must be disabled (enter "xhost" to see wether this is the case). "ma" should still run, but features related to the registry will not be available in this case (locating already open windows, and "Putall".) The "B" program takes one ore more filenames (optionally followed by an address) and opens the given files or activates already open windows holding these files. "pty" is a generic program running a subprocess in a pseudo terminal and is used by "win" to have interactive windows inside a "ma" instance. Note that this is currently very crude and does not support escape codes of any kind. "ma-eval" can be used to evaluate Tcl code in a running "ma" instance, "awd" sets the label of the window in which the command is executed. You can create an alias for "cd" to set the label automatically when used inside an interactive shell window: alias cd="_cd" function _cd () { \cd "$@" if test -n "$MA"; then awd bash fi } When the registry is running, the window that has the current focus is drawn with a white border around it. Executing commands in the body of another window will then perform the execution in the context of the focus window. Execution in the tag of a window always has that window as context, regardless of focus. When you create a new, unnamed window and want to save it, then just edit the filename (initially "<unnamed>"). Also saving the file under a different name can be done the same way. The "plumb" program performs a very simple Plan-9 like "plumbing" based on regular expressions, see ".plumb" for some examples on how to define rules, which consists of Tcl code associated to regular expressions. "plumb" takes a string as argument and runs the plumbing rules in "~/.plumb" until a rule matches and succeeds. Text sweeped or clicked with B3 will invoke "plumb" with the string as argument. Environment variables: MA_HISTORY If set, all code that is executed in "win" mode or via B2 is logged in the file given in this variable (this includes all input, including passwords!) C_INCLUDE_PATH Lists additional include-directories, separated by ":" (default: "/usr/include") SHELL Shell to use for executing commands (default: "bash") MA Set to the name of the wish(1) instance when executing external programs. Access from the command line: Using "ma-eval", some elements from a "ma" window can be accessed by sending Tcl code to the process in which a shell command was initiated: For example, ma-eval $MA GetBody would print the contents of the window body to stdout. Here is a selection of some useful Tcl commands that you can use (for more intricate access, study the "ma" source code): GetBody GetTag GetLabel SetBody TEXT SetTag TEXT SetLabel TEXT ReplaceFile FILENAME GetDot SetDot ADDRESSS Insert TEXT InsertFile FILENAME Append TEXT AppendFile FILENAME Note that text may have to be suitable quoted to be passed trough to the Tcl interpreter that is running in the window, like this: ma-eval $MA Insert "{this is a test}" Customization: At the start of the "ma" script, you will find a number of global variables that hold default values for fonts, colors and other settings that are used throughtout the editor. Modify these at your convenience. Extending: The easiest way to add commands is simply to put scripts or programs in your PATH. If you want more thorough integration, you can also define commands at the Tcl level, by using "DefineCommand REGEX EXPR" to define Tcl code to be executed when the command given in REGEX is executed, i.e. DefineCommand {^MyCommand\s+(.+)$} { ... } Arguments (subpatterns in the regex) can be extracted with "GetArg". "ma" is not finished, and probably never will. For more information, consult the source code or contact me[3]. To do: - (bug) crash of program in win-mode doesn't print any message - (bug) KeyRelease-event in .tag (getting through after invoking dmenu(1) in this case) results in incorrect resize of tag, even though only first line contains text - (bug) Automatic resizing of the tag doesn't always work - (bug) sort order in columnar listing is wrong (should be rowwise, not columnwise) - (bug) Tk seems to clear the clipboard when exiting, so the contents copied from a terminated instance are not recovered - (bug) the (pseudo-)selection is sometimes retained even after input - (bug) "Back" should not put position on search-stack if search wraps around - (bug) The exit status of subprocesses in non-win mode is silently discarded. This seems to be a Tcl limitation, see also: https://core.tcl.tk/tips/doc/trunk/tip/462.md Shortcomings: - the file-registry needs to be explicitly started - the "Kill" command (Del key) is not very reliable with respect to what processes are killed (should probably use a process group) - the width used for computing columnar directory layout seems not to be correct (always 80?) - autosnarf when selecting: no idea how to do this, keeping current selection and copying when selection gets empty doesn't work, since selection by mouse apparently clears it in between movements; perhaps detect when selection changes from non-empty to empty - there is no "Zerox" command - works very bad on Mac/Aqua and Windows: - Mac: default Tcl/Tk crashes, freshly installed (Aqua) aborts unexpectedly, B2/B3 are swapped, slow startup (note that Tcl/Tk for XQuartz works surprisingly well, though) - Windows: cursor in text widget barely visible (black, even on dark background), startup very slow, binding Ctrl-keys doesn't seem to work, UpdateTag doesn't seem to treat filename as valid and inserts Win-style path before it (this is with Active State Tcl/Tk, 8.6.4) - there is no backup-file - Address syntax only supports a subset of acme/sam and is rather crude (see also comment in ParseAddr), "/.../"/"?...?" addresses only select a position, not ranges - In "win" mode, "ma" tries to ignore the prompt from input lines, but moving the insertion point may confuse this, if possible use a prompt for interactively used programs that will be ignored by the client program (e.g. ":;" for sh(1) or ";" for rc(1)) - Password-entry in "win" mode works only when the insertion cursor is not moved by mouse or cursor-movement keys - "Putall" is implemented, but will save all files in all open windows, even on virtual screens not currently visible - there is no "Edit" command Differences to the Plan 9 acme: - There is no "move" box - Tab does not insert "\t" but whitespace - (obviously) single-window mode - no dynamic update of undo/redo commands tag (Tcl/Tk 8.6 seems to support access to the undo-stack, though) - auto-chmod when saving file beginning with "#!/" - missing commands: "Zerox", "Edit", "Incl" - supports Key-Up/Down movement by line - inserting with active selection doesn't snarf - indentation-setting is window-local - executing with redirection ("|...", ">...", "<...") in "win" mode invokes shell, and does not send the command to the process running in the window - executing in tag always has current window as context, executing in body has currently focussed window as context (if registry is running) - double-clicking opening bracket selects forward, but quote- scanning works backwards (in acme both bracket and quotes only select backwards) - indent-mode works differently - word under cursor is defined as ws-delimited (excluding parentheses) - win-mode: pressing RETURN before current insert point sends the whole line - "noscroll" mode is much weaker (does not block running process) - basic keyboard commands for mouse-less operation: C-1 (toggle focus), C-2 (execute selection), C-3 (acquire selection) - B3-search is case-insensitive, search with "Look" is not - "//.../" address means search with regex syntax disabled - Supports various emacsish keyboard sequences, as provided by the Tk text widget - Additional commands: Anchor: add address of insertion point into tag Withdraw: hide window Tcl CODE: execute Tcl code Crnl: toggle between UNIX/DOS line-terminator encoding Back: jump back to previous address after search Interrupt: send ^C to interactive subprocess (win mode) - MA highlights matching parens/brackets/braces - Shift-B3 is equivalent to B2 - Acquiring (B3) an existing window doesn't warp mouse to current selection - The "Local" command toggles a state whether directories are opened in the current window or in a new one - "Abort" terminates, like "Del", but with an exit status of 1 - "Wrap" toggles between word-wrapping and char-wrapping. Idioms: