home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 5 Edit
/
05-Edit.zip
/
me34src.zip
/
me3
/
doc
/
me3mutt.doc
< prev
next >
Wrap
Text File
|
1995-01-14
|
88KB
|
1,802 lines
!!!Concepts chapter:
talk about garbage collection: what when
talk general about bags, marks, buffers
talk about current buffer, current window ain't the same
========================================================================
== The ME Mutt Connection Craig Durland 9/89 10/91 11/91 6/93 ==
========================================================================
This document describes the link between the Mutt2 programming
language (see mutt2.doc) and the Mutt Editor (see me3.doc).
Copyright 1991 Craig Durland
Distributed under the terms of the GNU General Public License.
Distributed "as is", without warranties of any kind, but comments,
suggestions and bug reports are welcome.
========================================================================
== The ME3 Mutt functions ==
========================================================================
(any-modified-buffers) basic.mut [zip : BOOLEAN]
Returns TRUE if one or more buffers exist with the Modified bit set
and the NoCare bit reset.
(append-to-bag bag-id TEXT <text>)
(append-to-bag bag-id CHARACTERS <number>)
(append-to-bag bag-id REGION [mark1 mark2])
(append-to-bag bag-id RECTANGLE [mark1 mark2])
where TEXT = 0, CHARACTERS = 1, REGION = 2 and RECTANGLE = 3.
TEXT : [NUMBER 0 STRING : VOID]
CHARACTERS : [NUMBER 1 NUMBER : VOID]
REGION : [NUMBER 2 [NUMBER [NUMBER]] : VOID]
RECTANGLE : [NUMBER 3 [NUMBER [NUMBER]] : VOID]
These functions append text to a bag.
TEXT : Appends a string to the bag.
REGION : Appends the text contained in a region.
CHARACTERS : Appends n characters, starting from the dot.
RECTANGLE : Copies the region-rectangle. This clears the bag first.
Note that appending anything to a bag with a rectangle in it
(unless it is another rectangle) is a no-op until you clear the
bag.
For example:
If the region contains "This is a test" then
(clear-bag 0)
(append-to-bag 0 REGION) (append-to-bag 0 TEXT " foo bar")
will set the cut buffer to "This is a test foo bar".
See also: create-bag, clear-bag, insert-register, bag-stats,
bag-to-string, prepend-to-bag, constants in me.mh.
(arg-flag [flag [prefix]])) [[BOOLEAN [NUMBER]] : BOOLEAN]
(arg-flag)
Check to see if somebody set the arg-prefix before calling this
routine (via (universal-argument) or (arg-prefix n)).
(arg-flag flag)
Set arg-flag to flag. Does not affect arg-prefix.
(arg-flag flag number)
Set arg-flag to flag and arg-prefix to number.
Returns:
Current setting of arg-flag.
Notes:
Arg-flag holds it value until is it is changed by arg-prefix,
arg-flag, exe-key or the main loop. Thus, it can be important to
reset them in your program if you will be calling another program
that uses them for input (in general, user level programs (eg the
ones bound to keys). It is a good idea to make a copy of the
value upon entry to a program if it is possible that a called
program might change it.
Reset by exe-key and the main loop (when all programs are finished
running) to (FALSE 1).
See also: arg-prefix, exe-key.
(arg-prefix [arg]) [[NUMBER] : NUMBER]
(arg-prefix)
Return the current value of arg-prefix.
(arg-prefix number)
Set the universal-argument and return it.
Notes:
The arg-flag is set to TRUE.
See also: (arg-flag)
(argc) [zip : NUMBER]
The number of parameters on the command line when ME was invoked +1.
eg "ME foo bar" has argc == 3.
Use argv to look at the parameters.
(argv) [NUMBER : STRING]
The ME command line parameters. There are argc of them, numbering
0...argc-1. (argv 0) is the name of the program (ME) (unless you are
running on MS-DOS 2.x where it is ""), (argv 1) is the first word on
the command line, (argv 2) is the next word, etc.
Notes:
Normally, the command line is processed by process-command-line (in
cmdline.mut). If you want to add command line args, do it though
command-line-hook.
(attached-buffer window-id | buffer-name) [NUMBER|STRING : NUMBER]
If given a number, attached-buffer returns the buffer id that is
attached to window n. n == -1 means use the current window.
If given a name, attached-buffer returns the id of the buffer that is
named name. Returns -2 if the buffer does not exist.
For example:
if the cursor is in third window (window #2) which is displaying
buffer "foobar" and foobar has an id of 123 then:
(attached-buffer -1) and (attached-buffer 2) both return 123.
(attached-buffer "foobar") returns 123.
(attached-buffer "FOOBAR") returns -2.
See also: buffers, windows.
(attached-file full-file-name) basic.mut [STRING : NUMBER]
Returns the buffer id of the buffer that is attached to file. If the
file is not attached to any buffer, -2 is returned.
(autoload function-name file-name) autoload.mut [STRING STRING : something]
When function is called for the first time, file is loaded and
function is called again.
See autoload.mut for much better documentation.
(bag-stats bag-id pointer-to-data) [NUMBER BLOB : VOID]
Get stats on a bag. pointer-to-data is a pointer the the data area
that the stats are put into:
(byte type) (small-int width height) (int size) ;; struct BagInfo
type: 0 means text and 1 is rectangle.
width, height: If the register is a rectangle.
size: Number of bytes in the register.
For example:
(defun get-bag-stats
{
(byte type)(small-int width height)(int size) ;; struct BagInfo
(int n)
(n (convert-to 3 (ask "bag id: ")))
(bag-stats n (loc type))
(msg "bag[" n "]: " (if (== type 0) "Text." "Rectangle.")
" Width:" width " Height:" height " Size:" size
)
})
Note:
If the bag is not a rectangle, the width and height are garbage.
See also: append-to-bag, clear-bag, insert-bag.
(bag-to-file bag-id file-name) [NUMBER STRING : BOOLEAN]
Copy the contents of a bag to a file. If the file already exists, it
is overwritten.
If bag-id is bad, the program aborts.
If some kind of error occurs (can't open file-name or can't write all
of bag), FALSE is returned so you can clean up if necessary.
See also: file-to-bag, bag-to-string
(bag-to-string bag-id) [NUMBER : STRING]
Convert bag contents to a string.
If the bag contains a rectangle, the string will be each line of the
rectangle, one after the other.
Note:
The string sticks around until the bag is changed (clear-bag,
append-to-bag, etc). At that point, the string is garbage and can
cause unknown behavior if used. Use the string or save it - don't
expect it to hang around.
See also: append-to-bag
(bind-key keymap-id program-name key-name ...)
[NUMBER STRING STRING [STRING STRING ...] : BOOLEAN]
Put zero or more (program-name key-name) pairs in a keymap.
Keymap-ids can be 0 (global keymap), 1 (local keymap) or a keymap id
returned by create-keymap. If 1 and a local keymap hasn't been
created yet, bind-key creates it.
program-name is the name of a non-HIDDEN program that must exist.
key-name is the string form of a keycode ("a", "C-a", etc).
Notes:
(bind-key id "" "C-a") removes key C-a from the keymap.
See also: create-keymap, install-keymap, clear-keymap.
(bit-and x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary and 2 or more numbers.
See also bit-or, bit-xor.
(bit-clear x bit) basic.mut [NUMBER NUMBER : NUMBER]
Clear a bit in x. For example (bit-clear 0xf 2) returns 0xd.
(bit-not x) basic.mut [NUMBER NUMBER : NUMBER]
Return the ones complement of x.
(bit-or x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary or 2 or more numbers.
See also bit-and, bit-xor.
(bit-xor x y [z ...]) [NUMBER NUMBER [NUMBER ...] : NUMBER]
Binary xor 2 or more numbers.
See also bit-and, bit-or.
(BoB) basic.mut [zip : BOOLEAN]
TRUE if the cursor is at the beginning of the buffer.
See also: EoB.
(buffer-displayed buffer-id) basic.mut [NUMBER : BOOLEAN]
Returns the id of the window that is displaying the buffer. Returns
-2 if the buffer is not being displayed.
(buffer-exists buffer-id) basic.mut [NUMBER : BOOLEAN]
Look though all the buffers to see if buffer-id is one of them.
Returns TRUE if it is.
Notes:
This routine can give false readings in the case a buffer has been
freed and another one created, since buffer id's are recycled. If
this might be a problem, put a hook in FREE-BUFFER-HOOK.
(buffer-flags buffer-id [flags]) [NUMBER [NUMBER] : NUMBER]
Get or set the buffer flags. There are 32 flags.
Bit Flag Notes
--- ---- -----
0x0001 Modified 1 if the buffer has been modified since last save.
0x0002 NoCare 1 if don't care about buffer contents.
0x0004 Hidden 1 if buffer is hidden from user.
0x0008 Undo 1 if undo is turned on for the buffer.
0x0010 Mode Tickle bit: force (modeline-hook) to be called.
0x0020 Immortal Not a temporary buffer.
0x0040 Interactive A buffer for humans.
The lower eight bits are reserved for ME's use, you can use the
other 24. Note - you might want to leave a few bits at the bottom
unused in case I need some more in the future.
Notes:
The Modified flag is set whenever the buffer changes. When it
changes, (modeline-hook) is called.
The NoCare flag is used whenever ME wants exit or change a buffer -
it is set, ME will not ask before changes are made.
A buffer with the Hidden flag set is invisible to the user -
(next-buffer) skips it, the help and command completion routines
ignore it.
If you want a buffer to have undo, set this bit. 0 (off) is the
default.
Mode is a write only flag. Set it if you want (modeline-hook) to be
called.
All buffers are created Mortal by default. This means that they can
be garbage collected when your program is done running. If you
want the buffer to live forever (at least until you free it), set
this bit. Actually, set this bit in (create-buffer).
ME sets the Interactive bit for program convenience. I typically
use it to avoid setting modes, etc for buffers where the modes
won't be used. It is set by: (switch-to-buffer), (visit-file)
and when the last buffer is freed and I have to create *scratch*.
If a tickle bit is set, only tickle bits are processed and other
bits are ignored. So, for example, if you wanted (modeline-hook)
called and set the Undo flag, it takes two calls to
(buffer-flags).
See also: buffer-modified, create-buffer, modeline-hook.
(buffer-modified buffer-id [bool]) [NUMBER [BOOLEAN] : BOOLEAN]
Check to see if buffer n is modified.
If n == -1 the current buffer is used.
(buffer-modified -1) : TRUE if the current buffer is modified.
(buffer-modified 123) : TRUE if the buffer with id 123 has been modified.
(buffer-modified -1 FALSE) : mark the current buffer as not modified.
See also: buffer-flags, current-buffer, (not-modified).
(buffer-name buffer-id or file-name) [NUMBER | STRING : STRING]
(buffer-name buffer-id)
Return the name of a buffer.
(buffer-name -1) returns the name of the current buffer.
(buffer-name file-name)
Convert a string (assumed to be a file name, maybe with path) into a
string that can be used as a buffer name. This is OS dependent
but usually just removed the path from the file name.
Notes:
Wildcards are not expanded, you need to do that yourself. Use
(file-name) (for an existing buffer) or the following program:
;; Overwrite fname with a canonized file name.
;; Returns "" if invalid file name.
(defun cannonize-file-name (string fname)
{
(int bid)
(bid (create-buffer ""))
(file-name bid fname)
(fname (file-name bid))
(free-buffer bid)
(!= "" fname)
})
See also: create-buffer, current-buffer, file-name.
(buffer-read-only [read-only]) basic.mut [[BOOLEAN] : BOOLEAN]
Return TRUE if the current buffer is read only (ie if
(bit-and BFRead_only (buffer-flags -1)) is non-zero).
If read-only is passed in, the flag is set.
See also: toggle-read-only.
(buffer-stats n array int 6) [NUMBER BLOB : VOID]
Get some stats on the nth buffer. n == -1 means current buffer.
These stats are: buffer-size (in characters), dot (number of
characters from the start of the buffer), lines (number of text
lines in the buffer), buffer-row (the line in the buffer the dot is
on), wasted (the number of characters allocated but not used) and
character-at-dot (ASCII value - eg if the dot is on a "A" then
character-at-dot == 65).
Note that buffer-size may NOT be the same as the file size. For
example, on MS-DOS the buffer is smaller than the file because the
<carriage-return><newline> is folded into a newline when the file is
read into the buffer.
An example of a typical Emacs buffer stats routine (ie whats bound to
"^X=") is:
(include tobase.mut)
(defun show-buffer-stats ; bind this to "C-X="
{
;; struct BufferInfo
(int buffer-size dot lines buffer-row wasted char-at-dot ratio)
(buffer-stats -1 (loc buffer-size))
(ratio 0)(if (!= 0 buffer-size)(ratio (/ (* 100 dot) buffer-size)))
(msg "Row: " buffer-row "/" lines " Column: " (current-column)
" CH: 0x" (tobase char-at-dot 16)
" (" ratio "% of " buffer-size ")")
})
See also: nth-buffer
(buffer-to-file file-name &lines &error-code)
[STRING [NUMBER [NUMBER]] : BOOLEAN]
Write the contents of the current buffer to a file.
Returns:
TRUE is all OK, lines is set to the number of lines written and
error-code is set to 0.
FALSE if couldn't successfully write, error_code is set to one of:
3 Error of some kind.
4 Bad file name.
Notes:
Wildcards (*, ~, etc) in file-name are expanded.
Buffer changed flag is cleared.
See also: file-to-buffer.
(buffer-var var-name [value]) [STRING [val] : val]
Each buffer can have local variables. These vars are not used by ME -
they are there for program use.
The current buffer is searched for a buffer variable named var-name.
If it exists and you are trying to set its value, the value is
checked to make sure its type matches that of the buffer var and
then value is copied into the var.
The var is returned (with the new value if set), ready to be used like
any other Mutt var.
For example:
(int n)
(create-buffer-var NUMBER "x") ;; create buffer var x of type number
(create-buffer-var STRING "s" "t") ;; create 2 string buffer vars
(buffer-var "x" 123) ;; set buffer var x to 123
(n (buffer-var "x")) ;; also set n to 123
(buffer-var "s" "foo bar") ;; set buffer var s to "foo bar"
Notes:
Lists and strings are not as well supported in Mutt2 as they could
be. Right now, I don't have list or string pointer variables so
if you want to use a list or string buffer variable without
referring to it by name, you have to do extra data copies. For
example, if you have a list buffer variable and want to modify it,
you can either use (buffer-var "foo") every time you need the list
(and spend time doing lookups) or you can (list foo)(foo
(buffer-var "foo")) and then use foo as you would any other list.
The drawback here is a copy of the buffer var is put into foo
(possibly wasting space if the buffer var is very big and it takes
time to do the copy). You also have to remember to copy foo back
into the buffer bar after you modify it or all your changes will
be garbage collected into never-never land. If I ever get around
to implementing pointer types, you will be able to (pointer list
foo)(foo (loc (buffer-var "foo"))) and then when you modify foo,
you will be really modifying the buffer var, avoiding extraneous
data copies and making less garbage to be collected. You can fake
pointers by passing the buffer var to a function: (bar
(buffer-var "foo")) where (defun bar (list foo) ...). bar will
get a pointer to foo and can change it as described above.
See also: create-buffer-var, markring.mut
(buffers) [zip : NUMBER]
Return the number of buffers.
See also: nth-buffer.
(cannonize-file-name file-name) basic.mut [STRING : STRING]
Returns the canonical file name of file-name. This is a unique file
name that can be used to compare with other file names. It is what
(file-name) returns. Shell style wildcards (*, ~, etc) are expanded.
For example, (cannonize-file-name "~craig/*.mut") might return
"/users/craig/basic.mut".
(case-bag op bag-id) [NUMBER NUMBER : VOID]
Do some case folding on the contents of a bag.
op action
-- ------
0 Lower case text. All text in the bag is converted to lower case
in place.
1 Upper case text.
2 Capitalize text. All text in the bag is capitalized. The
starts of words are converted to upper case and all other text
is converted to lower case. A character is the start of a word
if: It is the first character in the bag and the syntax tables
say it is a word character or the character is a word character
and the character before it is a nonword character (white space).
See also: modify-syntax-entry, case.mut (for examples).
(clear-buffer) [zip : VOID]
Clear the current buffer.
Remove all contents of the buffer and clear the marks. There is no
checking - you need to do that if you care. If undo is turned on,
the undo stack is cleared (yeah, I know it stinks, but I had my
reasons).
clear-buffer-hook is called unless the buffer is being cleared because
it is being freed. That is, when (free-buffer) calls
(clear-buffer), clear-buffer-hook is not called. But
free-buffer-hook is.
See also: clear-buffer-hook, free-buffer
(clear-bag bag-id) [NUMBER : NUMBER]
Clears the bag by setting it to "". The bag type is set to TEXT.
Bag id 0 is the cut buffer.
Returns bag-id.
See also: append-to-bag, create-bag, insert-bag, bag-stats.
(clear-keymap keymap-id) [NUMBER : VOID]
Clear a keymap by removing all the bindings from it. You should not
be using this (ie I don't think its really needed), use
install-keymap instead (maybe installing the null keymap).
See also: create-keymap, install-keymap.
(command-flag op flag) [NUMBER NUMBER : NUMBER | BOOLEAN | VOID]
The command flag is how key driven routines can "talk" to each other.
For example, repeated C-n's stay in the same column. The C-n code
(next-line), knows that the last command was also a next-file if the
command flag is set to 4 (CF-LINE). It also set the command flag to
4 so that if the next key is a next line, it will know to stay in
the same column.
After every keystroke (in the main loop), the current command flag is
copied to the "last" flag and the current flag is cleared.
Note: Command flags only really work for keypress driven routines (ie
interactive programs bound to keys). If program calls these
routines, the command flag is not updated properly because control
flow is not though the main loop. Thus, if these routines are
called several times, they might not function as expected. Usually
this is OK.
If you would like to use a command flag that is not in the predefined
list, you can have ME create one for you. By letting ME generate
it, you can avoid conflicting with future programs.
(command-flag 0 flag)
Sets the command flag for this routine to flag. The next command
will test against this flag. Returns VOID.
(command-flag 1 flag)
Returns TRUE if the last command set flag.
(command-flag 2 flag)
Returns TRUE the last command was did NOT set flag.
(command-flag 3 flag)
Sets command flag to flag (same as (command-flag 0 flag)) and
returns TRUE if the last flag was NOT flag (same as (command-flag 2
flag)).
(command-flag 4 ignored)
Generates and returns a new command flag that can be used by
routines you write.
See also: me.mh for predefined command flags.
(compare-marks [mark1 mark2]) [[NUMBER NUMBER] : NUMBER]
Returns: 1 (dot on same line as mark), 2 (dot above mark),
3 (dot below mark).
See also: region-stats.
(complete selector "prompt") [NUMBER STRING : STRING]
(complete selector "prompt" list) [NUMBER STRING LIST: STRING]
Works the same as (ask) but allows command completion. The response
is returned.
Selector: bitwise OR the lists you want to complete:
Bit Value List
--- ----- ----
0 0x01 Obsolete, not used.
1 0x02 Program names
2 0x04 Mutt keywords
3 0x08 Buffer names
4 0x10 System variables
5 0x20 File names
6 0x40 Sorted list of words
7 0x80 Don't ask
For example: Get a file path, using file name completion and insert
it at the dot:
(defun insert-file-name
{ (insert-text (complete 0x20 "file name: ")) })
To complete from an arbitrary list of words, use list. The list must
be sorted (the first word in the list must be the "smallest"
(alphabetically). For example:
(list words)
(insert-object words 0 "one" "three" "two")
(complete 0x40 "Pick one: " words)
To complete a word without querying, use
(complete (bit-or 0x80 selector) word-to-complete [list])
The word is completed as far as possible and returned.
See also: ask (in mutt2.doc), prime-ask.
(create-bag [immortal]) [[BOOLEAN] : NUMBER]
Create a bag and return its id. Whenever you need to do something
with this new bag, use its id.
The immortal flag controls how a bag is treated at garbage collection
time. If TRUE, the bag won't be garbage collected and you have to
use free-bag to get rid of the bag.
The cut buffer always has an id of 0 and is created by ME at startup.
See also: free-bag, the discussion about garbage collection.
(create-buffer name [flags]) [STRING [NUMBER] : NUMBER]
Create a buffer and return its id. Whenever you need to do something
with this new buffer, use its id.
The name can be anything you want - it can be empty, contain blanks,
be the same as other buffer names, etc. Since the buffer is referred
to by its id, there is no confusion. Where the confusion comes in
is when the user wants to deal with the buffer - in that case, you
might want to use something reasonable for the name.
See buffer-flags for info on those. Remember to set the immortal bit
if you want the buffer to hang around.
create-buffer-hook is called.
See also: attached-buffer, buffer-flags, free-buffer, the discussion
about garbage collection, create-buffer-hook.
(create-buffer-var type name [name ...]) [NUMBER STRING ... : VOID]
Create one or more buffer variables with a given type.
Supported types:
NUMBER 0x03
STRING 0x08
LIST 0x09
Buffer local variables are variables that live in a buffer. This
allows you to store localized data in a buffer - two buffers can
have variables of the same name that contain different data (or even
data with different types). This is useful when you need one
variable to hold different data for each buffer (such as with mark
rings - each buffer has a different ring but the mark ring code is
the same for all buffers).
Buffer vars live and die with the buffer. When the buffer is freed,
all the buffer vars are too. This is the only way to remove buffer
vars from a buffer.
If a buffer var named <name> already exists, create-buffer-var doesn't
do anything. It should at least check to see if the types match.
See also: buffer-var, markring.mut
(create-keymap) [ : NUMBER]
(create-keymap keymap-to-duplicate) [NUMBER : NUMBER]
(create-keymap)
Create a keymap.
(create-keymap id)
Create a keymap by copying an existing keymap. The new keymap has a
copy of all the data in the other keymap.
Returns the id of the created keymap.
Notes:
Keymaps can't be freed.
See also: bind-key, install-keymap, clear-keymap.
(create-mark [immortal]) [[BOOLEAN] : NUMBER]
Create a mark and return its id. Whenever you need to do something
with this new mark, use its id. Marks are always created in the
current buffer and are invalid (ie not marking anything) when
created.
The immortal flag controls how a mark is treated at garbage collection
time. If TRUE, the mark won't be garbage collected and you have use
free-mark to get rid of the mark.
When a buffer is created, two marks are allocated in it: the dot (id
0) and the mark (id 1). They are always in the buffer can be used
just like any other mark. They can't be freed.
See also: free-mark, the discussion about garbage collection and marks.
(create-process) [ : NUMBER]
(create-process command) [STRING : NUMBER]
Create a process that will run concurrently with ME. Command is
passed to the compute server for parsing and running. The process
communicates to your Mutt program via the process-hook hook.
(create-process) will establish a connection to the compute server.
You can use it to determine if it is available (returns -1 if the
compute server is not available, something != -1 if it is).
Notes:
The compute server is not built into ME - it is also a separate
process. For this reason (and others), only Unix supports
the compute server. It needs to be running before create-process
is called. The socket name for ME is "$HOME/.ME2.socket".
You can have many processes running. Your Mutt programs will have
to keep track of the process ids to be able to track each process.
Returns:
Process id. -1 if can't create a process. This id will be used by
process-hook when the process sends messages to Mutt programs.
See also: process-hook, documentation on the compute server
(comserver.doc).
(current-buffer) [zip : NUMBER]
(current-buffer buffer-id [display-buffer]) [NUMBER [BOOLEAN] : NUMBER]
Return the id of the current buffer.
To change the current buffer, pass in the id. If you want the new
current buffer to be displayed in the current window, pass
display-buffer as TRUE. The current window will be sync'ed with the
buffer (ie the window dot will be in the same place as the buffer
dot).
If you change the current buffer without displaying it, the windows
will be unaffected by anything that happens in the buffer - ie you
would not be able to see anything happening on the screen. When
the program finishes running, the buffers and windows will be synced
up to what they were before the program ran.
If you change the current buffer and the new current buffer is
displayed in a non-current window, changes you make to the buffer
might not be reflected in that window. See "update" for more on
this.
See also: create-buffer, buffer-modified, buffer-name, buffers,
file-name, update.
(current-column [column]) [[NUMBER] : NUMBER]
With no argument, returns the column after the dot. Otherwise, the
dot is set to column.
(beginning-of-line) is 1.
When you set the current-column, the dot will get as close as possible
to the position you specify, subject to:
- the dot will not leave the current line.
- because of tabs and such, the dot may not be in the column you
specify but will be BEFORE the character that would have caused
the dot to be beyond the specified position.
The new dot column is returned.
If you wish to force the dot to be in column n, use (current-column n)
(to-col n).
(current-directory) [ : STRING]
(current-directory directory) [STRING : BOOLEAN]
(current-directory) returns the current directory (eg "/users/craig").
(current-directory "tools") attempts to set the current directory to
tools. Returns TRUE if successful, FALSE otherwise.
See also: dir.mut for examples.
(current-line) [ : BOOLEAN]
(current-line n) [NUMBER : BOOLEAN]
(current-line) returns the line number the dot is in, in the current
buffer. The first line of the buffer is 1.
(current-line n):
Move the dot to the beginning of the nth line in the current buffer.
If n is negative, got the nth line from the end of the buffer.
Returns FALSE is try to move off either end of the buffer. In that
case the dot is left at the buffer edge it tried to move across
(at the start of the line).
Notes: Line 0 does not really exist so (current-line 0) returns
FALSE. If you ignore the error, (current-line 0) is the same as
(current-line 1).
(current-window [n]) [[NUMBER] : NUMBER]
Return the id of the current window. The windows are numbered 0,
1, ... (windows)-1 where window 0 is the top window on the screen.
If changing the current window then:
The current buffer is changed to the one being displayed in window
n. For example, if the current buffer is "foo" and window 0 is
displaying buffer "bar", (current-window 0) also changes the
current buffer to "bar".
The window dot is copied into the buffer dot ie the current buffer
is sync'ed with the current window. Thus a buffer will track
window changes BUT NOT vice versa.
If you change windows and need the screen cursor to be moved to the
new window, use (update). You need to do this (for example), if you
want (window-row) to work after the change.
See also: attached-buffer, windows, update, (next-window),
(previous-window) (in me3.doc).
(delete-region [mark1 [mark2]] [[NUMBER [NUMBER]] : VOID]
(delete-region) is the same as (delete-region THE-DOT THE-MARK)
(delete-region mark) is the same as (delete-region mark THE-MARK )
(delete-region mark1 mark2)
Delete the region between mark1 and mark2. The region is not saved.
Errors:
One or more of the marks is invalid.
Ran out of memory.
(do-undo) [zip : NUMBER]
If undo is turned on for this buffer, undo the last block of changes.
Returns:
0 : Nothing happened (despite my best efforts)
1 : Something happened (ie something was undid)
2 : Problems of some unknow nature
See also: buffer-flags, create-buffer, create-buffer-hook.
(EoB) [zip : BOOLEAN]
True if the cursor is at the end of the buffer. Note that end of
buffer is the empty line you get to with (end-of-buffer).
See also: BoB.
(erase-rectangle delete) [BOOLEAN : VOID]
Delete or clear the region-rectangle. If delete is TRUE, the text in
the rectangle is removed, otherwise it is set to blanks (short lines
are not extended).
The dot is left at the upper left corner of the rectangle and the mark
is at the lower right corner.
The region-rectangle is the rectangle that has the dot at one corner
and the mark at the opposite corner.
See also: append-to-bag, register-stats.
(exe-key keycode) [NUMBER : BOOLEAN]
Execute a key gotten by get-key. This is the same as pressing that
key combo on the keyboard.
Returns TRUE if the key was executable.
Notes:
key-pressed is set to the key being executed.
arg-flag is set to FALSE and arg-prefix is set to 1.
See also: arg-flag, arg-prefix, get-key, key-pressed.
(file-exists file-name) [STRING : BOOLEAN]
Returns TRUE if file-name exists on disk. If (file-exists file-name)
returns TRUE then (visit-file file-name) should also return TRUE.
(file-name buffer-id) [NUMBER : STRING]
(file-name buffer-id new-name) [NUMBER STRING : BOOLEAN]
(file-name file-name [search-path]) [STRING [STRING] : STRING]
(file-name buffer-id) [NUMBER : STRING]
Return the name of the file attached to a buffer. If a file is NOT
attached, returns "".
(file-name -1) returns the name of the file attached to the current
buffer.
(file-name buffer-id new-name)
With new-name, attach a new name for the file attached to the
current buffer. Returns TRUE is everything went as expected.
Wildcards are expanded.
(file-name file-name [search-path])
See if file-name can be opened. If search-path exists, it is used
to try and find file-name. Search-path has the same form as the
ME3 environment variable (same format as the PATH environment
variable on your OS) and the search is the same as UNIX $PATH
searches.
Returns: "" if file-name not found, otherwise a string that can be
used in functions (it will have have a path prepended to it).
(file-name file-name "")
Don't use a search path. This is pretty much the same as
file-exists.
(file-name file-name)
Use the same search path as ME does when loading Mutt code. See
load-code.
See also: buffer-name, file-exists, load-code.
(file-to-bag file-name bag-id) [STRING NUMBER : BOOLEAN]
Copy the contents of a file to a bag. The old contents of the bag are
cleared.
If bag-id is bad, the program aborts.
If some kind of error occurs (can't open file-name or can't copy all
of file-name into bag), FALSE is returned so you can clean up if
necessary.
See also: bag-to-file, bag-to-string
(file-to-buffer file-name) [STRING : BOOLEAN]
(file-to-buffer file-name lines-read) [STRING pointer-to-NUMBER : BOOLEAN]
(file-to-buffer file-name lines-read error-code)
[STRING pointer-to-NUMBER pointer-to-NUMBER : BOOLEAN]
Insert the contents of a file into the current buffer at the dot.
Returns:
TRUE is all OK, lines is set to the number of lines read and
error-code is set to 0.
FALSE if couldn't successfully read, error_code is set to one of:
1 File not found.
2 End of file.
3 Error of some kind.
4 Bad file name.
5 No memory.
Notes:
The dot is left after the insert, marks before.
Wildcards (*, ~, etc) in file-name are expanded.
Buffer changed flag is cleared.
See also: buffer-to-file, clear-buffer, insert-text, insert-bag.
(forward-char n) [NUMBER : BOOLEAN]
Move the dot forward n characters (backwards if n < 0).
Returns TRUE if all OK, FALSE if try move off the edge of the buffer
(the dot is left at the closest edge).
(forward-line n) [NUMBER : BOOLEAN]
Move the dot forward n lines (backwards if n < 0).
The dot is left at column one.
Returns TRUE if all OK, FALSE if try move off the edge of the buffer
(the dot is left at the closest edge).
(forward-word n) [NUMBER : BOOLEAN]
Move the dot forward n words (backwards if n < 0).
Returns TRUE if all OK, FALSE if try move off the edge of the buffer
(the dot is left at the closest edge).
(free-bag bag-id ...) [[NUMBER [NUMBER ...]] : VOID]
Free zero or more bags and their contents. It is always a good idea
to free bags after you use them (to save space, etc) but you only
really have to if the bag is immortal. Mortal bags will be garbage
collected after your program has finished running.
Note:
While it possible to free the cut-buffer (id 0), it is a bad idea
(and probably a bug). Lots of people assume (yeah, I know what
they say about that) that the cut buffer exists and just use it.
If you do free it, expect fire works.
See also: create-bag.
(free-buffer buffer-id) [NUMBER : NUMBER]
Free a buffer and all its contents, keys, marks and other resources.
If not freed, mortal buffers will be garbage collected.
free-buffer-hook is called.
See also: create-buffer.
(free-mark mark-id ...) [[NUMBER [NUMBER ...]] : VOID]
Free zero or more marks. It is always a good idea to free marks after
you use them (to save space, etc) but you only really have to if the
mark is immortal. Mortal marks will be garbage collected after your
program has finished running.
You can't free the dot (id 0) or the mark (id 1).
See also: create-mark.
(free-window [n]) [[NUMBER] : BOOLEAN]
Remove the nth window from the screen. If no arg, remove the current
window. n == -1 means the current window.
If there is only one window on screen, it is not deleted and FALSE is
returned otherwise TRUE is returned.
See also: (split-window), (delete-other-windows) (in me3.doc).
(get-key) [zip : NUMBER]
Wait for and grab the next ME key combo pressed. These have a rather
strange format so it is a good idea to print out the ones you need
with (insert-text (get-key)). If you look at the hex values you
might see a pattern.
key combo get-key value
CR C-M 333 (0x014D)
f1 F-1 2097 (0x0831)
a 97 (0x0061)
A 65 (0x0041)
^A C-A 321 (0x0141)
^XA ^Xa C-XA 1089 (0x0441)
^X^A C-XC-A 1345 (0x0541)
M-A 577 (0x0241)
See also: exe-key, getchar.
(get-matched sub-string) [STRING : STRING]
Return the RE substitution of the last (re-search-xxx) or
(looking-at).
See regexp.doc for syntax of the sub string.
eg if (re-search-forward 'f\w*r') matched "foobar" then (get-matched "&")
returns "foobar".
See also: (looking-at), (re-string), (re-search-forward),
(re-search-reverse).
(getchar) [zip : STRING]
Get a character from the keyboard with no echo. This is different from
get-key in that the string is the ASCII value of the next key hit. You
should only use this for real raw input.
See also: get-key.
(getenv environment-variable-name) [STRING : STRING]
Get the value of a environment variable.
Returns "" if not found.
For example: (getenv "SHELL") might return "D:/MUSH.EXE".
(goto-mark mark-id) [NUMBER : BOOLEAN]
Move the dot to the mark whos id is mark-id.
Returns FALSE if mark-id doesn't exist or the mark is invalid (hasn't
been set or has been cleared).
See also: create-mark, set-mark, swap-marks.
(insert-bag bag-id) [NUMBER : VOID]
Insert the contents of a bag at the dot in the current buffer.
Bag 0 is the cut buffer. (insert-bag 0) is the same as (yank).
If the bag contains a rectangle, the upper left corner of the
rectangle will be at the dot.
The dot is left after the insert, marks before.
See also: create-bag, append-to-bag, clear-bag, bag-stats,
bag-to-file, file-to-bag, file-to-buffer.
(insert-text stuff) [STRINGs|NUMBERs|BOOLEANS|VOIDs : VOID]
Same as msg but the string is inserted into the current buffer.
eg (insert-text "foo = " foo)
The dot is left after the insert, marks before.
See also: insert-bag, file-to-buffer, msg (in mutt2.doc).
(install-keymap keymap-id [where-to-install]) [NUMBER [NUMBER] : NUMBER]
Installing a keymap:
(install-keymap id 0) Install the global keymap.
(install-keymap id 1) Install the keymap as the local keymap in the
current buffer.
If id is 2, the NULL keymap (an always empty keymap, always exists)
is installed.
Notes:
You can install the same keymap in several buffers (and as the
global keymap). The drawback is a (bind-key) will affect all
the buffers sharing the keymap.
If (bind-key) has to create a local keymap (because one hasn't
been installed before bind-key was run), it will be a short
lived keymap - the keymap will be freed when the buffer is freed
or a local keymap is installed. Otherwise, it is a normal
buffer but can be a pain because if you swapping keymaps (for
example for modes), the keymap might disappear.
The global keymap is created when ME starts (so you don't have to
create it). You can install a new keymap over it if you want to.
If you install a new temporary global keymap (ie you will be
switching between two (or more) global keymaps), be careful of
(load-code) (and autoloading). If the loaded code binds keys
(in the global keymap), it could very well put the keys in the
wrong global keymap.
Keymaps can't be freed (from a program).
Getting the keymap id:
(install-keymap 0) Return the id of the global keymap.
(install-keymap 1) Return the id of the local keymap. 2 if there
is no local keymap installed.
(install-keymap 2) Always returns 2.
(install-keymap n) Returns n if there is a keymap with an id of n,
otherwise -1.
See also: bind-key, clear-keymap, create-keymap.
(is-space) [zip : BOOLEAN]
TRUE if character under cursor is a space or tab.
(key-bound-to keystroke-string) [STRING : STRING]
Tell what command a key is bound to.
For example, (key-bound-to "^A") returns "beginning-of-line".
If the key is not bound, key-bound-to returns "".
The typical Emacs function to tell what a key is bound to is:
describe-key ;; what is a key bound to
{
(string key bind)
(key (ask "Key: "))
(if (== "" (bind (key-bound-to key)))(msg key " is not bound.")
(msg key " is bound to " bind))
})
For Mutt programmer types, a handy program is:
deref-key ;; insert name of the function bound to a key
{
(string key bind)
(key (ask "Key: "))
(if (!= "" (bind (key-bound-to key)))(insert-text bind))
})
This allows programming using keys rather than remembering command
names.
See also: complete.
(key-pressed) [zip : NUMBER]
Returns the keycode of the key pressed to invoke the currently
executing program.
Note: exe-key sets this.
See also: exe-key, picture-self-insert in picture.mut for an example.
(keystroke-macro command) [NUMBER : BOOLEAN]
(keystroke-macro 12 [n]) [NUMBER : BOOLEAN]
(keystroke-macro 13) [NUMBER : NUMBER]
Manage keyboard macros. A keyboard macro is a sequence of key presses.
(keystroke-macro 10)
Start recording a keyboard macro. Returns FALSE if already
recording a macro.
(keystroke-macro 11)
Stop recording a macro. The keysequence has been stored and can
be replayed. Returns FALSE if not recording a macro.
(keystroke-macro 12 [n])
Run a keyboard macro n times (default is 0 times). If any of the
macro parts errors, the macro is stopped. Returns FALSE if
recording or error running the macro.
(keystroke-macro 13)
Returns the macro state:
0 : Macro is off (not recording). Can be replayed.
1 : Macro is recording.
2 : Macro is playing.
(key-waiting [number-of-seconds-to-wait]) [[NUMBER] : BOOLEAN]
Returns TRUE if a user pressed key is sitting in the input buffer.
You can also specify the number of seconds to wait for a key to be
pressed. If a key is pressed during the wait, (key-waiting)
immediately returns TRUE. If no key is pressed and the time is up,
FALSE is returned.
Note: (key-waiting) is the same as (key-waiting 0).
Warning: There are limits to how long you can wait. Due to many
factors, you should limit number-of-seconds-to-wait to less than
32401 (9 hours).
See also: getchar, get-key.
(list-keys buffer-id word flags keymap ...)
[NUMBER STRING NUMBER [NUMBER NUMBER ...] : BOOLEAN]
Insert a list of programs (and the keys bound to them), functions and
system variables that match word into a buffer. Keys are listed
from from the keymaps.
Input:
buffer-id : Id of the buffer to insert the text into.
word: Match word. If "", the all names will match. Otherwise,
only those names that have word in them will be listed. Case
matters, wildcards are not used.
flags: Selects which lists to insert. An bit-or of:
Bit List
--- ----
1 Programs and the keys bound to them
2 Functions (the functions in this file eg list-keys)
4 System Variables (eg tab-stops)
8 Only list programs that have keys bound to them.
keymaps: Ids of the keymaps to search for keys in (if flags has the
1 bit set).
Returns: TRUE if everything went OK, FALSE if ran out of memory.
(load-code file-name [complain [check-first]])
[STRING [BOOLEAN [BOOLEAN]] : BOOLEAN]
Load a Mutt executable code file compiled with the Mutt compiler (MC2).
Where the file is searched for is controlled by the environment
variable "ME3". If it doesn't exist, ME uses a default search path.
The search path is parsed just like the UNIX ksh PATH variable:
If code-file-name has a slash in it, the search path is not used.
Everything between separators (":" on UNIX, ";" on MS-DOS) is a path.
If you want to search the current directory first, you can put a
separator at the start of the path. Eg ":/me3" instead of
".:/me3".
If you want to search the current directory last, you can put a
separator at the end of the path. Eg "/me3:" instead of
"/me3:.".
(Otherwise, you need to use "." to search the current directory.
Eg "/me3:.:/mutt").
It is OK if a directory in the search path doesn't exist.
MS-DOS only:
"/" and "\" are treated the same way - as "\".
If code-file-name starts with a drive (eg "A:"), the ME3 path is
not searched.
For example: ME3=$HOME/mutt:.:/usr/local/lib/mutt
When (load-code "foo") is done, ME will try to load
"$HOME/mutt/foo.mco", "./foo.mco" and
"/usr/local/lib/mutt/foo.mco" in succession.
Default search paths:
For Unix: "$HOME:/usr/local/me3:/usr/contrib/me3"
For MS-DOS: "C:/me3"
If a search path doesn't exist or $ME3 is "", the search behavior
is the same as if the search path was ".".
If complain is TRUE (the default), a message is printed if file-name
is not found.
If check-first is TRUE (the default is FALSE), ME checks to see if
file-name has already been loaded. If it has, it is not loaded
again.
Notes:
The extension (on the code file) MUST be ".mco" but you don't have
to type it in (ie I'll change it to ".mco" no matter what it is).
Warnings:
A program should NOT try to load it self or the file it is defined
in (eg if foo is defined in bar.mut, foo should not try to (load
"bar"). This is because the old bar is discarded (to make room
for the new code) before foo finishes running (ie foo is thrown
away). Depending on the OS, this may work but your asking for
trouble if you do it.
If a code file is loaded that has the same name (ignoring path) as
an already loaded code file, it overwrites the old code. All keys
bound to functions in the old code are removed. See autoload.mut
for more about loading and late binding.
(looking-at RE-string) [STRING : BOOLEAN]
(looking-at RE-string move) [STRING BOOLEAN : BOOLEAN]
(looking-at RE-string move return-count) [STRING BOOLEAN BOOLEAN : NUMBER]
Test to see if the text following the dot matches a regular
expression. TRUE if it does.
See regexp.doc for syntax of the pattern string.
Example:
If the text following the dot is "foobar" then (looking-at 'f\w*r')
returns TRUE.
You can retrieve the matched info with get-matched.
If move is TRUE and there is a match, the dot is moved over the match.
If return-count is TRUE, the number of characters matched is returned.
This is zero if there is no match.
Remember that if you use the "string" form, "\" & "^" MUST be quoted:
"\\", "\^" if you don't want strange results. You can
avoid this problem by using ' instead of ". (See mutt2.doc).
See also: get-matched, re-string.
(mark-valid mark-id) [NUMBER : BOOLEAN]
Return TRUE if a mark is "valid" - it exists in the current buffer and
has been set.
See also: create-mark, set-mark.
(make-unique-buffer-name base-name) basic.mut [STRING : STRING]
The routine creates a unique buffer name. If no buffer has base-name
as its name, base-name is returned. Otherwise, <1>, <2>, etc is
appended until a unique name is found.
(modify-syntax-entry modify-string) [STRING : STRING]
Modify the syntax table that is used by things that deal with words, etc.
eg (forward-word) or (re-search-forward).
String has the form: <type><characters to modify> where type is "w" if
characters are parts of words, "W" if characters are not parts of words.
eg (modify-syntax-entry "W0123456789") sez numbers are not parts of words
(modify-syntax-entry "w-") sez "-" is part of a word.
Default parts of words are: A-Za-z0123456789$'_
Returns: modify-string.
(move-cursor row column [text [clear-to-end-of-line]])
[NUMBER NUMBER [NUMBER [NUMBER]] : VOID]
Move the hardware cursor to (row,column).
Row and column are both start at zero.
Move-cursor does not change the dot.
If text, it is written on to the screen at the cursor. The next
(update) OR control returning to the main input loop will cause the
text to disappear.
If clear-to-end-of-line is TRUE (default is FALSE), anything after the
text (on the line) is cleared.
See also: puts.
(nth-buffer [n]) [NUMBER : NUMBER]
Return the id the of the nth buffer. Buffers are in a list, sorted
alphabetically, so (nth-buffer 0) is the buffer with the "smallest"
alphabetical name.
(nth-buffer) returns the count of the current buffer ie return n where
(nth-buffer n) is the id of the current-buffer or find n where
(== (nth-buffer n) (current-buffer)) is TRUE.
(OS-command command [prompt]) [STRING [STRING]] : BOOLEAN]
Give a command to the OS (usually a shell) to process. For example,
"ls". If there is a prompt AND (ask-user), when the command is done
and control returns to ME, the prompt is printed and ME waits for a
Return or Newline to be typed. The screen is refreshed in this
case, otherwise it is unchanged (you need to do an (update) if you
want force a refresh).
Returns:
TRUE is everything went OK, FALSE if the command didn't work for
some reason (OS dependent).
See also: OS-filter, OS-shell.
(OS-filter filter-name)
(OS-filter filter-name in-bag-id)
(OS-filter filter-name in-bag-id out_bag-id)
(OS-filter filter-name in-bag-id out_bag-id insert-output-at-dot)
[STRING [NUMBER [NUMBER [BOOLEAN]]]] : BOOLEAN]
If no input bag or output bag, you can use -1 for the id.
Uses the Operating System to filter text. On Unix and MS-DOS, this is
"filter-name <text_in >text_out".
in-bag-id contains the text_in to be run through the filter. If id is
-1, there is no standard in for the filter. Useful if you just want
stuff like the output of ls or grep.
out-bag-id will contain the transformed input text (text_out). If id
is -1, the filter output is ignored (unless insert-output-at-dot is
TRUE). Useful when the filter creates its own files (such as
uudecode or uncompress).
If insert-output-at-dot is TRUE, the output of the filter is also
inserted into the current buffer at the dot. The insertion is done
by file-to-buffer, so the dot is left after the insert, marks before.
OS-filter uses up to 2 files to hold the input and output of the
filter.
On UNIX, these are put in /tmp. On other systems, they are put in
the current directory. You can change the directory with a
environment variable.
UNIX : $TMP is used to hold the directory. eg /v0/users/craig
Note that ME adds a trailing "/" to the name.
MS-DOS : TMP is used. If you have a RAM disk configured as drive
D and want the files put in the root:
SET TMP=D:
Note that ME adds a trailing "/" to the name.
See also: OS-command, OS-shell.
(OS-shell [flags]) [[NUMBER]] : BOOLEAN]
Fork a shell. ME waits until the shell exits and then resumes the
editing session.
Flags: Implementation dependent.
On Unix, flags == 1 means use job control and put ME into the
background.
See also: OS-command, OS-filter.
(pgm-exists program-name) [STRING : BOOLEAN]
Returns TRUE if there is a program named program-name. Can be used to
check if a code file has been loaded (the program is defined in the
file).
For example:
(if (pgm-exists "c-mode-hook") (c-mode-hook))
or
(if (pgm-exists "c-mode-hook") (floc "c-mode-hook"()))
This second example avoids the possibility of c-mode-hook being
hard linked (ie it can be late bound). Not needed in most cases.
(popup-buffer buffer-id [row column]) bstats.mut
[NUMBER [NUMBER NUMBER] : NUMBER]
Display a buffer in another window, creating a window if need be.
If the buffer is already in a window, nothing is done.
Input:
buffer-id : id of the buffer to be displayed
Optional:
row : row to put the dot on.
column : column to put the dot at.
If row and column not passed in, dot is not moved.
Output:
Id of the window that is showing the buffer.
(prefix-key n [new-prefix]) [NUMBER [STRING] : STRING]
Get or set the nth prefix key. Returns the prefix keycode in ASCII
form.
n Notes
- -----
0 The META prefix. Default is C-[ (ESCAPE).
1 Default is C-X.
2 open
3 open
META is a prefix so it can be overloaded (mimiced by) another key.
A consequence of this is you cannot prefix a METAed key when a META
key is a prefix. For example, C-XM-P is OK but M-XM-P is not.
If you have a real META key, you can turn off prefix key 0.
Prefix keys 2 and 3 are open - use them for anything you like.
To turn off a prefix key, set it to "S-" or some other impossible
keycode (like "S-0").
(prepend-to-bag <numbers>) basic.mut
Same as append-to-bag except the text is prepended instead of appended.
(prime-ask [text]) [[stuff] : STRING]
(prime-ask) Reset the prime.
(prime-ask text)
All the args are concatenated and the result is used as the first
user input during the next ask or complete (if they query the
user) - it is as if the user types in the text. For example:
(prime-ask "This " "is a" " test")
(ask "Yes: ")
When run, the user will see:
Yes: This is a test
If Return is pressed, ask will return "This is a test".
Notes:
Since the prime is not reset until an ask actually queries the user,
you want to reset it after you call ask (with (prime-ask)). Using
the example above, if the (ask) got the answer from the arg list
(ie it didn't have to query the user), the prime is not reset and
will be used at the next (unknown) ask (unless it is overwritten).
See also: complete, ask.
(puts string) [STRINGs|NUMBERs : STRING]
Send a string to the terminal. ME does not see this - (update) won't
remove text unless the screen is marked as garbage.
Useful for sending escape sequences to the terminal (eg defining
function keys), creating popup windows or just doodling on the
screen.
See also: move-cursor, insert-text, msg, popup.mut
(re-search-forward regular-expression-search-pattern) [STRING : BOOLEAN]
Search from the dot forward for text that matches the regular
expression. If a match is found, the dot is left after the last
matched character.
Returns TRUE if a match is found.
See also: re-search-reverse, search-forward, search.mut, regexp.doc.
(re-search-replace search-pattern replace-pattern)
[STRING STRING : BOOLEAN]
Search for (from the dot to the end of the buffer) and replace every
occurrence of search-pattern with replace-pattern. re-search-forward
is used to search and get-matched is called at every match to create
the replacement text.
If re-search-replace is successful, the dot is unmoved and the mark is
left after the last replace. If it fails, the mark is at the start
of the search and the dot is left where the failure occurred.
Returns TRUE if at least one replace was done, FALSE if search-pattern
was not found.
See also: search-replace, qr.mut, re-search-forward, get-matched,
regexp.doc.
(re-search-reverse regular-expression-search-pattern) [STRING : BOOLEAN]
Search from the dot backwards (towards the start of the buffer) for
text that matches the regular expression. If a match is found, the
dot is left before the first matched character (ie the cursor is on
the first matched character.
The match algorithm is:
- Backup a character.
- Does the RE match the characters after the dot (remember the dot
is between two characters). This is the same as (looking-at
search-pattern).
Yes: done, leave the dot where it is.
No: repeat until a match is found or run into the start of the
buffer.
Returns TRUE if a match is found.
See also: re-search-forward, search-reverse, search.mut, regexp.doc.
(re-string RE-pattern string) [STRING STRING : BOOLEAN]
Test to see if a string matches a regular expression.
Returns TRUE if it does.
You can retrieve the matched info with get-matched.
See regexp.doc for syntax of the pattern string.
See also: get-matched, looking-at.
(read-clock data) [BLOB : VOID]
Read the time and date and put them in a structure.
(small-int month day year hh mm ss) ;; TimeInfo
(read-clock (floc month))
See also: date.mut for lots of routines that manipulate this data.
(region-stats pointer-to-data [mark1 [mark2 [goto-top-mark]]])
[BLOB [NUMBER [NUMBER [BOOLEAN]]] : VOID]
Get stats on the region. pointer-to-data is a pointer the data area
that the stats are put into:
(byte type) (small-int ulcol width height) (int size) ;; RegionInfo
type: 1 (dot on same line as mark), 2 (dot above mark), 3 (dot
below mark). This is the same info as (compare-dot-and-mark).
ulcol: upper left column of the region-rectangle.
width, height: of the region-rectangle.
size: Number of characters in the region.
Mark1 and mark2 default to the dot (0) and the mark (1).
If goto-top-mark is TRUE, the dot is moved to the upper left corner
of the region. Default is FALSE.
For example:
get-region-stats
{
(byte type)(small-int ulcol width height)(int size) ;; RegionInfo
(region-stats (loc type))
(msg
(switch type
1 "Dot and mark on same line."
2 "Dot above mark."
3 "Dot below mark."
)
" Upper left column:" ulcol
" Width:" width " Height:" height " Size:" size
)
})
See also: compare-marks.
(require Mutt-module Mutt-code-file) require.mut [STRING STRING : zip]
Lisp like require. This routine lets Mutt programs require that
certain modules or routines be loaded.
For example: If MAIN contains (require "foo" "bar.mut") or (require
"foo" "bar")), when your program is loaded it will load foo.mco if
it hasn't been already or routine foo is not present.
See also: require.mut for better docuemtation.
(run-pgm-on-block pointer-to-code [args]) runblock.mut [BLOB : SOMETHING]
Run code on each line of a block. Any args are passed to code. Code
should NOT delete or add lines and shouldn't move off the current
line.
See also: runblock.mut.
(save-excursion code [args]) basic.mut [defun pointer [any] : any]
Save the current point and buffer, calls code (passing it all the
args) then restores the buffer and point and returns what code
returned.
See also: save-point for examples.
(save-point code [args]) basic.mut [defun pointer [any] : any]
This routine saves the current point, calls code (passing it all the
args) then restores the point and returns what code returned.
For example:
1> (defun to-the-moon (bool up)
{ (if up (beginning-of-buffer)(end-of-buffer)) })
2> (msg (save-point (floc to-the-moon) FALSE))
When the code at 2> is run, the call (to-the-moon FALSE) is made.
to-the-moon moves the point to the end of the buffer and returns
TRUE and returns to save-point. save-point then moves the point
back to where it was (before to-the-moon was called) and returns
TRUE.
The same example using anon defuns:
2> (msg (save-point
{{ (if (arg 0) (beginning-of-buffer)(end-of-buffer)) }} FALSE))
Note that this is bit more cryptic because you have to use the
(arg n) notation for passed in arguments.
Notes:
When using anon defuns, it can get very confusing because the anon
routine can't access the variables of the enclosing defun. You
have to remember to pass in the variable and access them via (arg).
See also: save-excursion.
(scroll-window window-id n [z]) [NUMBER NUMBER [NUMBER] : BOOLEAN]
Move the text in a window. window-id == -1 means move the current
window.
(scroll-window window-id n)
Move the nth window up (or down) by n lines If the dot moves off the
screen, it is left at the edge closest to where it moved off.
(scroll-window window-id dummy n)
Reposition window dot to the nth line from the top (or bottom if n
is negative) of the current window. If n is 0, the window is
centered. Dummy is ignored.
(search-forward search-pattern) [STRING : BOOLEAN]
Search from the dot forward for text that matches search-pattern. If
a match is found, the dot is left after the last matched character.
Returns TRUE if a match is found.
See also: search-reverse, re-search-forward, search.mut.
(search-replace search-pattern replace-pattern)
[STRING STRING : BOOLEAN]
Search for (from the dot to the end of the buffer) and replace every
occurrence of search-pattern with replace-pattern. search-forward is
used to search for a match. Matched text is replaced verbatim with
replace-pattern.
If search-replace is successful, the dot is unmoved and the mark is
left after the last replace. If it fails, the mark is at the start
of the search and the dot is left where the failure occurred.
Returns TRUE if at least one replace was done, FALSE if search-pattern
was not found.
See also: re-search-replace, qr.mut, search-forward.
(search-reverse search-pattern) [STRING : BOOLEAN]
Search from the dot backwards (towards the start of the buffer) for
search-pattern. If a match is found, the dot is left before the
first matched character (ie the cursor is on the first matched
character.
The match algorithm is:
- Backup a character.
- Does search-pattern match the characters after the dot (remember
the dot is between two characters).
Yes: done, leave the dot where it is.
No: repeat until a match is found or run into the start of the
buffer.
Returns TRUE if a match is found.
See also: re-search-forward, search-forward, search.mut, regexp.doc.
(set-mark [mark-id]) [[NUMBER] : !!!???]
Set a mark to match the dot. The default is mark 1 (the mark).
See also: create-mark, goto-mark, swap-marks, markring.mut.
(split-window [window-id]) [[NUMBER] : BOOLEAN]
(split-window) same as (split-window -1)
(split-window window-id)
Split (in half) a window vertically (-1 means the current window).
A window smaller than 3 lines can not be split.
The new window is put after window-being-split. This way, if
splitting the current window, the current window always remains on
top.
This command trys to leave the two windows showing identical chunks of
the buffer. If the dot is not in the chunk, the redisplay code will
recenter the dot.
Returns:
TRUE if everything went as expected.
FALSE (and window not split) if window to small to split or not
enough memory.
See also: window-length, windows.
(stop-ME level) [NUMBER : VOID]
(stop-ME 0)
Halt all running programs, turn off keyboard macros, etc. This is
the way to stop what ever is running, clean up and return the ME
main loop. stop-ME-hook will be called.
(stop-ME 1)
Close the display (which will cause leave-ME-hook to be called) and
exit back to the OS. No asking is done. stop-ME-hook will be
called.
See also: leave-ME-hook, stop-ME-hook.
(swap-marks [mark1-id mark2-id]) [[NUMBER NUMBER] : NUMBER]
Exchange the locations that two marks point to. If you (swap-marks 0
1) (the default case, same as (swap-marks)), the dot will move to
where the mark was and vice versa. Doing it again will return the
marks to their original values ie (swap-mark a b)(swap-mark a b) is
a no op. If you are moving the dot, the other mark must be valid
(ie have been set). Remember that clear-buffer resets all marks
(except the dot). If you do this, your program will die but ME will
be OK.
See also: goto-mark
(sysvar sysvar-name [value]) [STRING [NUMBER] : NUMBER]
Access or set a sysvar. This enables a program to give the user
access to sysvars.
Example:
(string sysvar-name 50)(sysvar-name "HELP")
(sysvar sysvar-name) gets the current value of HELP and
(sysvar sysvar-name 0) sets it to zero.
See also: sysvar.mut for coding examples.
(to-col column) [NUMBER : NUMBER]
Insert space until the dot is at column. If the dot is at or past
column, nothing happens.
Returns column.
If the sysvar tab-stops is zero then tabs and blanks are used,
otherwise only blanks are used as space.
(update) [ : VOID]
(update update-the-screen) [BOOLEAN : VOID]
(update update-the-screen screen-is-garbage) [BOOLEAN BOOLEAN : VOID]
(update) or if update-the-screen is TRUE, the areas of the screen that
are out of date are redrawn. Does not affect the minibuffer.
Different from (refresh-screen) in that the refresh occurs now,
rather than waiting for the program to end.
If update-the-screen is FALSE, just sync the buffer and window.
Forces the current window dot to match the current buffer dot IF the
current window is displaying the current buffer.
If screen-is-garbage is TRUE, the screen is marked as garbage and is
the entire screen is cleared and redrawn (if update-the-screen is
FALSE this will happen later). This also clears the minibuffer.
Notes:
Keys in the typeahead buffer will keep the refresh from completing
(ME will finish up later when it has more time).
Redrawing the screen can take a long time (from the computers point
of view anyway). If screen is up to date, this is quick (usually
only the cursor is moved).
It is important to realize that windows and buffers are independent.
Changing a buffer does not mean that a window displaying the
buffer always reflects those changes. This is usually only a
problem when a program wants a window displaying a buffer to track
the changes the program is making to that buffer. Here are the
rules for programs:
- Windows and buffers have their own dots. Changes to a buffer
dot does not change the window dot.
- If you make changes to a buffer and then want to make changes
to the window displaying that buffer, you usually want to do a
(update FALSE) after the buffer changes and before the window
changes. If you don't do this, the window dot will be in a
different place than the buffer dot and the window probably
won't be showing what you expected. Make sure the current
window is displaying the buffer you are changing.
See also: current-buffer, current-window.
(window-ledge [n [left-edge]]) [[NUMBER [NUMBER]] : NUMBER]
(window-ledge) Same as (window-ledge -1).
(window-ledge n)
Return the left edge of the nth window. If n == -1, the current
window is used.
(window-ledge n left-edge)
Set the left edge for the nth window and return the value.
Notes:
The window will display only the text starting at column left-edge.
The first column is 0 (not 1 as it is for (current-column)).
If horizontal-scroll is enabled and setting window-ledge causes the
cursor to move off screen, the display routines will reset the
left edge so that the cursor is on screen. Turning off
horizontal-scroll will prevent this, otherwise, you will need to
move the cursor to a column in
(left-edge, left-edge + screen-width].
With this command you can scroll windows manually (ie without using
the cursor).
The current screen column can be calculated by:
(- (current-column)(window-ledge -1))
See also: horizontal-scroll.
(window-length [n [new-length]]) [[NUMBER [NUMBER]]: NUMBER]
(window-length) Same as (window-length -1)
(window-length n)
Return the length of the nth window (n == -1 means current window).
Note that the length does not include the mode line. If there is
only one window then
(window-length -1) == (window-length 0) == (- (screen-length) 1).
(window-length n new-length)
Resize the nth window to the new size (if there is more than one
window and the new size won't cause the window to get too big or
small). The new window size is returned.
(window-row) [zip : NUMBER]
Return the row the dot is on in the current window. The top row of a
window is 1. Note that this is not the screen row (unless the
current window is the top most one).
Note: It is the display routines that figure out the window-row. If
called when the display is out of sync (such as a program doing
display manipulation) this could very well be incorrect. (update)
can force a display sync.
Example:
(defun move-dot-to-top-of-window
{
(forward-line (- 1 (window-row)))
})
(windows) [zip : NUMBER]
Return the number of windows on the screen. Windows are numbered 0 ..
(- (windows) 1).
See also: current-window.
(yesno prompt) [STRINGs|NUMBERs|BOOLEANs|VOIDs : BOOLEAN]
Show the prompt (with " [y/n]? " appended) and wait for [Y, y, N, or n]
CR to be typed. Returns TRUE on Y or y. The program aborts on ^G.
Simular to (ask).
Notes:
If not interactive (ie the user is not asked), only "y" or "Y" will
return TRUE.
Use (ask-user) to force user prompting.
See (ask) for potential problems.
========================================================================
== SYSTEM VARIABLES (sysvars) ==
========================================================================
System vars are used like any other var - (sysvar) returns its value and
(sysvar value) sets it to value.
Most sysvars are global - they effect all buffers, windows, etc. Some
sysvars are buffer local - they only effect a single buffer. When you
set a local sysvar, it is set for the current buffer. If you want to set
these to something other than the default for every buffer, do so in
create-buffer-hook.
Unless otherwise noted, all sysvars are global.
(beep [volume]) [[NUMBER] : NUMBER]
(beep)
Ring the bell at the current volume and return the current volume.
(beep 0)
Turn off the bell, ie set the volume to zero and return the current
volume.
(beep -1)
Return the current volume.
(beep volume)
Set the bell volume and return the current it. Currently, the only
volume is on (non-zero) or off (0).
Initial value: 1
(case-fold-search [ignore-case]) [[NUMBER] : NUMBER]
Affects searching (query-replace, search-forward, search-reverse).
If 1, case is ignored.
Initial value: 1
(complete-key [keycode]) [[NUMBER] : NUMBER]
This is the keycode that controls command completion.
It is initialized to space (32).
(complete-key) returns the current value.
To change it, use the keycode. See get-key.
For example:
To set the complete key to tab (C-I), use (complete-key 0x149) or
(complete-key 329).
For space, use (complete-key 32).
For control A (C-A), use (complete-key 321).
(HELP [help-level]) Set the help level [[NUMBER] : NUMBER]
(HELP) returns the current setting.
(HELP n) sets the level to n and returns n.
Help level:
0 : no help
1 : gimme help (if you make typo in (ME-command)
(describe-bindings) will be executed).
Initial value: 1
(horizontal-scroll [step-size]) [[NUMBER] : NUMBER]
This sysvar controls horizontal scrolling - moving text left and right
on the screen. If 0, horizontal scrolling is disabled, otherwise
the horizontal scrolling rate is set to step-size. When the screen
has to scroll, it will move in chunks in order to reduce the amount
screen thrashing. Change it to best suit your hardware and
preferences.
The range for step-size is [0 : screen-width). If you set it outside
of this range, you are asking for many unpleasant surprises.
See also: window-ledge.
(modeline-color [color]) [[STRING] : STRING]
Change or get the the mode line color.
The current color is returned.
Note that the color values are display dependent.
In general, the colors are specified as "foreground:background" where
the foreground color is the color of the text and the background
color is the color of the area the text is on. For example,
"green:black" would be green characters written on black paper.
Parsing rules:
"foreground:background" : Change both. If one (or both) of the
colors is invalid, it is not changed (but the other might be).
"foreground" : Just change the foreground color.
"foreground:" : Just change the foreground color.
":background" : Just change the background color. Might not work
on Unix.
For IBM PCs, the color choices are:
Forground: black, blue, green, cyan, red, magenta, brown,
lightgrey, darkgrey, lightblue, lightgreen, lightcyan, lightred,
magenta, yellow, white.
Background: black, blue, green, cyan, red, magenta, brown,
lightgrey.
These may not make sense for noncolor displays.
For Unix system (or monochrome systems) the choices are white and
black. "black:white" is inverse video. Only the foreground color
is looked at.
See also: text-color.
(overstrike [value]) [[NUMBER] : NUMBER]
Overstrike is the mode opposite of insert (the default mode). Overstrike
mode is very much a bag on the side of ME and ment only for occasional
use.
The following are different in overstrike mode:
- The tab key is disabled but you can still set the tab stops.
- <CR> sends you the start of the next line.
- Backspace is the same as backward-character.
- The mode line.
- self-insert don't, they overstrike.
Initial value: 0
(screen-length [new-screen-length]) [[NUMBER] : NUMBER]
Change the size of the physical screen. This allows the same ME code
to run on different size screens.
For example, say ME came configured for a HP150 (which has 24 screen
lines) and you wanted to run it on a HP110 (which has 16 lines). To
change the screen size: (screen-length 16).
Range: [3 : 400]. If you change this to be longer that the screen
really is, it is hard to edit.
See also: errata file.
(screen-width [new-screen-width]) [[NUMBER] : NUMBER]
Change the physical screen width.
Range: [15 : 500]
(tab-stops [tab-size]) Local [[NUMBER] : NUMBER]
If given an argument then set the tab stops to every nth column. This
is a buffer local variable.
If n == 0 use the tab character.
If n > 1 use spaces to simulate the tab character.
Initial value: 0
(text-color [color]) [[STRING] : STRING]
Change or get the the text color.
The current color is returned.
Note that the color values are display dependent.
See also: modeline-color for color values.
(word-wrap [wrap-column]) Local [[NUMBER] : NUMBER]
Setting word-wrap > 0 turns it on, 0 turns it off.
Initial value: 0
When ME decides it is time to word wrap, it does a (exe-key "^M")
which executes whatever is bound to the Enter key. This also
provides a hook if your program wants to do something at that time.
This is a buffer local variable.
========================================================================
== Hooks ==
========================================================================
Hooks are Mutt programs that are called by ME when it thinks somebody
else might be interested in what its about to do. They allow the Mutt
programmer to modify ME's behavior. If a hook is not defined, it is not
called (ie ME doesn't really care if you don't want to tell it what to
do).
Notes:
There may be more than one routine that is sharing the hook call. See
the hook support in hook.mut (documented in package.doc). If you
want your code to be a "good citizen" and interact "nicely" with
other Mutt code (that uses hooks), it is important that you use
(register-hook) and DON'T define a routine that takes over the hook
(ie don't defun create-buffer-hook). key-pressed-hook is the
exception. me.mh has the constants used by register-hook.
In general, if you switch buffers, you should switch back so that
other routines sharing this hook will have the correct current
buffer when they are called.
Some hook names are in all upper case (for example,
ICLEAR-BUFFER-HOOK). This means the hook is not called from within
ME but is called from hook.mut and can only be accessed though
(register-hook). Otherwise it acts like any other hook.
If a hook name starts with an "I", it means the hook is called for
interactive buffers. The hook that doesn't have the leading "I" is
called first (for all buffers) and then the interactive hook is
called if the buffer is marked interactive. Interactive buffers are
those buffers ment for human interaction. See buffer-flags and
create-buffer for what makes a buffer interactive.
For examples of how hooks are used, see hook.mut and alamode.mut.
(clear-buffer-hook) [zip : zip]
This is called when a buffer is cleared. It is NOT called if
(free-buffer-hook) is being called for the same buffer. That is,
free-buffer calls clear-buffer but in that case, clear-buffer-hook
won't be called. Use free-buffer-hook in that case.
Register with
(register-hook CLEAR-BUFFER-HOOK name-of-your-routine).
See also: ICLEAR-BUFFER-HOOK.
(COMMAND-LINE-HOOK command-line-arg) [STRING : BOOLEAN]
Called when a command line argument needs to be processed by somebody.
Return: TRUE if you process it, else FALSE.
See also: cmdline.mut in package.doc.
(create-buffer-hook) [zip : zip]
This is called when a buffer is created and allows a Mutt program to
set up a buffer.
Register with
(register-hook CREATE-BUFFER-HOOK name-of-your-routine).
BUGS:
Does not get called for "*scratch*" (the default buffer created when
ME starts up) because it is created before any Mutt code is loaded
or run.
If you want it called for *scratch* then put (create-buffer-hook)
into the load time code of myme.mut. Note that if you delete
*scratch* in the MAIN of myme.mut then you will not need to do this
because *scratch* will be recreated if no other buffers exist.
Also, if you read in a files, create-buffer-hook will be called.
See also: create-buffer, ICREATE-BUFFER-HOOK.
(enter-ME-hook) [zip : zip]
When ME starts up and opens the display, it calls this hook. For
example, (OS-command) calls this after the shell command is run and
returns control to ME.
Note:
This is not called when ME is first run because it would be called
before any Mutt programs were loaded. If you need that
functionality, do it with MAIN routines.
Register with (register-hook ENTER-ME-HOOK name-of-your-routine).
See also: leave-ME-hook.
(free-buffer-hook) [zip : zip]
This is called when a buffer is freed.
Register with
(register-hook FREE-BUFFER-HOOK name-of-your-routine).
See also: IFREE-BUFFER-HOOK.
(ICLEAR-BUFFER-HOOK) [zip : zip]
This is the clear-buffer-hook for interactive buffers.
clear-buffer-hook is called for all buffers, ICLEAR-BUFFER-HOOK is
only called for interactive buffers.
Register with
(register-hook ICLEAR-BUFFER-HOOK name-of-your-routine).
See also: clear-buffer-hook.
(ICREATE-BUFFER-HOOK) [zip : zip]
This is called when a interactive buffer is created and allows a Mutt
program to set up a buffer. Interactive buffers are those buffers
ment for human interaction. Since most Mutt buffer-created code
only cares about interactive buffers (why set a buffer mode if
nobody will ever use it?) and lots of non-interactive buffers are
created, using this hook will reduce work ME has to do (and a few
other things that I'm having a hard time explaining).
Register with
(register-hook ICREATE-BUFFER-HOOK name-of-your-routine).
See also: buffer-flags, create-buffer-hook, IREAD-BUFFER-HOOK,
hook.mut.
(idle-hook ticks-since-not-idle) [NUMBER : ZIP]
This hook is called every tick while ME thinks it is idle. During
each idle "session", the ticks accumulate. ie the first call is
(idle-hook 1), the next is (idle-hook 2), etc while nothing is
happening. If something happens, the tick is reset.
Notes:
A tick is about one second - it can vary from machine to machine,
even during the idle "session".
"Nothing happening" means ME is waiting for a keypress, but not in a
(ask).
(IFREE-BUFFER-HOOK) [zip : zip]
This is the free-buffer-hook for interactive buffers.
Register with
(register-hook IFREE-BUFFER-HOOK name-of-your-routine).
See also: free-buffer-hook.
(IREAD-FILE-HOOK) [zip : zip]
This hook is called after a file has been read into the current
buffer and the current buffer is interactive.
The dot is at the beginning of the buffer.
Register with (register-hook IREAD-FILE-HOOK name-of-your-routine).
See also: read-file-hook, ICREATE-BUFFER-HOOK, hook.mut.
(key-pressed-hook key) [NUMBER : zip]
This is called when the user presses a key in the main loop (ie
key-pressed-hook is not called from the following: get-key,
exe-key, anything that queries the user in the mini buffer). The
key is passed to the hook. See get-key for the format of a key.
After the hook has finished, the key is executed.
Notes:
This hook is not supported by register-hook. It really slows things
down to do so and is not used much.
For example:
If the user presses "a", (key-pressed-hook 0x61) is called and then
"a" is inserted.
Pressing ^X^F causes (key-pressed-hook 0x546) to be called. After
the hook returns, visit-file is called. Any keys pressed while in
visit-file will NOT trigger the hook.
See also: key-pressed.
(leave-ME-hook) [zip : zip]
Called when the display is being closed in preparation for leaving ME.
This is when you quit ME or do something with a shell.
Register with (register-hook LEAVE-ME-HOOK name-of-your-routine).
See also: enter-ME-hook.
(modeline-hook) [zip : STRING]
This hook is called when a window needs a new modeline. Whatever the
hook returns is put into the modeline. The last character of the
return value is repeated to the end of the modeline.
For example:
(defun modeline-hook
{ (concat "ME is editing " (buffer-name -1) " -") })
If the current buffer is foo, then the modeline line will look like:
"ME is editing foo --------------------------------------"
Notes:
The modelines for windows are not updated until ME thinks that the
modeline needs to be updated. A good way to do this for a buffer
is: (buffer-flags -1 Mode).
The last character is repeated because it makes life easier on the
hook (it doesn't have to know about the physical display).
Not supported by register-hook. It doesn't make sense to chain this
hook. If you need to have your own modeline for a buffer, do it
with a buffer variable (see modeline.mut). If you don't like the
modeline format, change modeline.mut.
See also: modeline.mut for examples.
(overstrike-toggle-hook) [ZIP : ZIP]
If the value of (overstrike) changes, this hook is called.
This hook is not handled by (register-hook).
See also: overstrike.
(process-hook pid OUTPUT-STDOUT text) [NUMBER 1 STRING : ]
(process-hook pid OUTPUT-STDERR text) [NUMBER 2 STRING : ]
(process-hook pid PROCESS-DONE exit-status) [NUMBER 0 NUMBER : ]
(process-hook pid ERROR error-code) [NUMBER 3 NUMBER : ]
where PROCESS-DONE == 0, OUTPUT-STDOUT == 1, OUTPUT-STDERR == 2,
ERROR == 3.
This hook is used by external processes (created by create-process)
talk to Mutt programs.
Since multiple processes can be running, you need to use the hook
management facilities in hook.mut so that other Mutt programs can
manage their own processes.
Remember the id of the process you create so that you can tell if the
hook is for you.
ERROR codes are:
CS_ERROR_SERVER_DIED 0
For some reason, the compute server is going to stop running very
soon.
CS_ERROR_PROTOCOL 1
ME sent garbage to the compute server.
CS_ERROR_READ 2
ME read garbage from the compute server.
All these errors result in all processes terminating, not just
yours. You will have to start over and recreate them. If you see
an ERROR event, ignore the pid and treat handle the error
because this is the last event your pid will get (until it is
recreated).
Register with (register-hook PROCESS-HOOK name-of-your-routine).
See also: create-process, hook.mut, compile.mut, comserver.doc.
(read-file-hook) [zip : zip]
This hook is called after a file has been read into the current
buffer.
The dot is at the beginning of the buffer.
Register with (register-hook READ-FILE-HOOK name-of-your-routine).
See also: IREAD-FILE-HOOK, visit-file and read-file (in me3.doc).
(start-ME-up)
Called just before ME starts up it main loop. This allows your
built in programs to initialize themselves with MAIN routines, ME to
call programs after they have been initialized (for example,
version-hook) and then finish up getting ready to go (for example,
process the command line).
(stop-ME-hook n) [NUMBER : zip]
This hook is called when (stop-ME x) is called.
(stop-ME 0) causes (stop-ME-hook 0).
(stop-ME 1) causes (stop-ME-hook 1).
If ME is stopped by a (catchable) signal or some other externally
caused shut down, (stop-ME-hook 2) is called. If you catch this, be
very careful - ME is in an unknown state. Your program should do
the minimum needed. If it should terminate due to an error or call
(stop-ME 0), ME might not exit.
Note: It is not called when a program is stopped because of an error.
See also: stop-ME, leave-ME-hook.
(version-hook) [lots : zip]
Called when ME starts up (but before start-ME-up is called) to pass
versioning information to programs.
Notes:
This is called multiple times during startup as the various
subcomponents send out version info.
========================================================================
== Miscellaneous ==
========================================================================