home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
util
/
edit
/
jade
/
man
/
jade.info-6
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-10-16
|
49KB
|
973 lines
This is Info file jade.info, produced by Makeinfo-1.55 from the input
file jade.texi.
START-INFO-DIR-ENTRY
* Jade: (jade). An editor for X11 and AmigaDOS
END-INFO-DIR-ENTRY
This is Edition 1.3, last updated 7 October 1994, of `The Jade
Manual', for Jade, Version 3.2.
Jade is a text editor for X11 (on Unix) and the Amiga.
Copyright 1993, 1994 John Harper.
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided that
the entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
File: jade.info, Node: Macro Expansion, Next: Compiling Macros, Prev: Defining Macros, Up: Macros
Macro Expansion
---------------
When a macro call is detected (*note List Forms::.) the function
which is the cdr of the macro's definition (*note Defining Macros::.)
is applied to the macro call's arguments. Unlike in a function call,
the arguments are *not evaluated*, the actual forms are the arguments
to the macro's expansion function. This is so these forms can be
rearranged by the macro's expansion function to create the new form
which will be evaluated.
There is a function which performs macro expansion, its main use is
to let the Lisp compiler expand macro calls at compile time.
- Function: macroexpand FORM &optional ENVIRONMENT
If FORM is a macro call `macroexpand' will expand that call by
calling the macro's expansion function (the cdr of the macro
definition). If this expansion is another macro call the process
is repeated until an expansion is obtained which is not a macro
call, this form is then returned.
The optional ENVIRONMENT argument is an alist of macro definitions
to use as well as the existing macros; this is mainly used for
compiling purposes.
(defmacro when (condition &rest body)
"Evaluates CONDITION, if it's non-`nil' evaluates the BODY
forms."
(list 'if condition (cons 'progn body)))
=> when
(macroexpand '(when x (setq foo bar)))
=> (if x (progn (setq foo bar)))
File: jade.info, Node: Compiling Macros, Prev: Macro Expansion, Up: Macros
Compiling Macros
----------------
Although it may seem odd that macros return a form to produce a
result and not simply the result this is their most important feature.
It allows the expansion and the evaluation of the expansion to happen
at different times.
The Lisp compiler makes use of this; when it comes across a macro
call in a form it is compiling it uses the `macroexpand' function to
produce the expansion of that form which it then compiles straight into
the object code. Obviously this is good for performance (why evaluate
the expansion every time it is needed when once will do?).
Some rules do need to be observed to make this work properly:
* When the compiler compiles a file it remembers the macros which
have been defined by that file; it can only expand a macro call if
the definition of the macro appears before the macro call itself
(it can't read your mind).
* The macro expansion function (i.e. the definition of the macro)
should not have any side effects or evaluate its arguments (the
value of a symbol at compile-time probably won't be the same as
its value at run-time).
* Macros which are defined by another file must be loaded so they
can be recognised. Use the `require' function, the compiler will
evaluate any top-level `require' forms it sees to bring in any
macro definitions used.
File: jade.info, Node: Streams, Next: Loading, Prev: Macros, Up: Programming Jade
Streams
=======
A "stream" is a Lisp object which is either a data sink (an "output
stream") or a data source (an "input stream"). In Jade all streams
produce or consume sequences of 8-bit characters.
Streams are very flexible, functions using streams for their input
and output do not need to know what type of stream it is. For example
the Lisp reader (the `read' function) takes an input stream as its one
argument, it then reads characters from this stream until it has parsed
a whole object. This stream could be a file, a position in a buffer, a
function or even a string; the `read' function can not tell the
difference.
- Function: streamp OBJECT
This function returns `t' if its argument is a stream.
* Menu:
* Input Streams:: Types of input stream
* Output Streams:: Types of output stream
* Input Functions:: Functions to read from streams
* Output Functions:: How to output to a stream
File: jade.info, Node: Input Streams, Next: Output Streams, Up: Streams
Input Streams
-------------
These are the possible types of input stream, for the functions which
use them see *Note Input Functions::.
`FILE'
Characters are read from the file object FILE, for the functions
which manipulate file objects see *Note Files::.
`MARK'
The marker MARK points to the next character that will be read.
Each time a character is read the position that MARK points to will
be advanced to the following character. *Note Marks::.
`BUFFER'
Reads from the position of the cursor in the buffer BUFFER. This
position is advanced as characters are read.
`(BUFFER . POSITION)'
Characters are read from the position POSITION in the buffer
BUFFER. POSITION is advanced to the next character as each
character is read.
`FUNCTION'
Each time an input character is required the FUNCTION is called
with no arguments. It should return the character read (an
integer) or `nil' if for some reason no character is available.
FUNCTION should also be able to `unread' one character. When this
happens the function will be called with one argument -- the value
of the last character read. The function should arrange it so that
the next time it is called it returns this character. A possible
implementation could be,
(defvar ms-unread-char nil
"If non-nil the character which was pushed back.")
(defun my-stream (&optional unread-char)
(if unread-char
(setq ms-unread-char unread-char)
(if ms-unread-char
(prog1
ms-unread-char
(setq ms-unread-char nil))
;; Normal case -- read and return a character from somewhere
...
`nil'
Read from the stream stored in the variable `standard-input'.
It is also possible to use a string as an input stream. The string to
be read from must be applied to the `make-string-input-stream' function
and the result from this function used as the input stream.
- Function: make-string-input-stream STRING &optional START
Returns an input stream which will supply the characters of the
string STRING in order starting with the character at position
START (or from position zero if this argument is undefined).
(read (make-string-input-stream "(1 . 2)"))
=> (1 . 2)
- Variable: standard-input
The input stream which is used when no other is specified or is
`nil'.
File: jade.info, Node: Output Streams, Next: Input Functions, Prev: Input Streams, Up: Streams
Output Streams
--------------
These are the different types of output stream, for the functions
which use them see *Note Output Functions::.
`FILE'
Writes to the file object FILE. *Note Files::.
`MARK'
Writes to the position pointed to by the marked MARK, then
advances the position of the mark.
`BUFFER'
Writes to BUFFER at the position of the cursor in that buffer,
which is then advanced.
`(BUFFER . POSITION)'
POSITION in the buffer BUFFER. POSITION is then moved over the
written text.
`(BUFFER . t)'
Writes to the end of the buffer BUFFER.
`FUNCTION'
The function FUNCTION is called with one argument, eithe