Synopsis
Add a newline to a buffer when saving
Usage
Int_Type ADD_NEWLINE
Description
If the value of ADD_NEWLINE is non-zero and the buffer if the
buffer does not end with a newline character, a newline character
will be silently added to the end of a buffer when the buffer is
written out to a file.
Synopsis
Controls the Autosave Interval
Usage
Int_Type MAX_HITS
Description
The value of the MAX_HITS variable specifies how many ``hits''
a buffer can take before it is autosaved. A hit is defined as a
single key sequence that could modify the buffer.
See also
variable TAB
Synopsis
The TAB setting for the current buffer
Usage
Int_Type TAB
Description
The TAB variable specifies the tab setting for the current
buffer.
See also
Synopsis
autosave
Usage
Void autosave ();
Description
The autosave function saves the current buffer in an auto save file
if the buffer has been marked for the auto save operation.
See also
See also
Synopsis
autosaveall
Usage
Void autosaveall ();
Description
This function is like
autosave except that it causes all files
marked for the auto save operation to be auto-saved.
See also
See also
Synopsis
buffer_list
Usage
Integer buffer_list ();
Description
This function returns an integer indicating the number of buffers and
leaves the names of the buffers on the stack. For example, the
following function displays the names of all buffers attached to
files:
define show_buffers ()
{
variable b, str = "", file;
loop (buffer_list ())
{
b = ();
(file,,,) = getbuf_info (b);
if (strlen (file)) str = strcat (str, strcat (" ", b));
}
message (str);
}
See also
Synopsis
buffer_visible
Usage
Integer buffer_visible (String buf);
Description
This function is used to determine whether or not a buffer with name
specified by the string
buf is in a window or not. More explicitly,
it returns the number of windows containing
buf . This means that if
buf does not occupy a window, it returns zero. For Example,
define find_buffer_in_window (buf)
{
!if (buffer_visible (buf)) return 0;
pop2buf (buf);
return 1;
}
is a function that moves to the window containing
buf if
buf is in
a window.
See also
Synopsis
bufferp
Usage
Integer bufferp (String buf);
Description
This function is used to see if a buffer exists or not. If a buffer with
name buf exists, it returns a non-zero value. If it does not exist,
it returns zero.
See also
Synopsis
bury_buffer
Usage
Void bury_buffer (String name);
Description
The bury_buffer function may be used to make it unlikely for the
buffer specified by the paramter name to appear in a window.
See also
Synopsis
Check to see if any buffers have been changed on the disk
Usage
check_buffers ();
Description
The check_buffers function checks to see whether or not any of
the disk files that are associated with the editor's buffers have been
modified since the assocation was made. The buffer flags are
updated accordingly.
See also
Synopsis
delbuf
Usage
Void delbuf (String buf);
Description
delbuf may be used to delete a buffer with the name specified by
buf . If the buffer does not exist, a S-Lang error will be generated.
See also
Synopsis
getbuf_info
Usage
(file, dir, name, flags) = getbuf_info ([ buf ])
String_Type buf; % optional argument -- name of buffer
Int_Type flags; % buffer flags
String_Type name; % name of buffer
String_Type dir; % directory associated with buffer
String_Type file; % name of file associated with buffer (if any).
Description
This function may be used to get some basic information about a
specified buffer. If the optional argument
buf is not
present, the current buffer will be used, otherwise
buf must
be the name of an existing buffer.
The integer that corresponds to the buffer flags are encoded as:
bit 0: (0x001) buffer modified
bit 1: (0x002) auto save mode
bit 2: (0x004) file on disk modified
bit 3: (0x008) read only bit
bit 4: (0x010) overwrite mode
bit 5: (0x020) undo enabled
bit 6: (0x040) buffer buried
bit 7: (0x080) Force save upon exit.
bit 8: (0x100) Do not backup
bit 9: (0x200) File associated with buffer is a binary file
bit 10: (0x400) Add CR to end of lines when writing buffer to disk.
bit 11: (0x800) Abbrev mode
For example,
(file,,,flags) = getbuf_info();
returns the file and the flags associated with the current buffer.
See also
Synopsis
pop2buf
Usage
Void pop2buf (String buf);
Description
The pop2buf function will switch to another window and display the
buffer specified by buf in it. If buf does not exist, it will be
created. If buf already exists in a window, the window containing
buf will become the active one. This function will create a new
window if necessary. All that is guaranteed is that the current
window will continue to display the same buffer before and after the
call to pop2buf .
See also
Synopsis
pop2buf_whatbuf
Usage
String pop2buf_whatbuf (String buf);
Description
This function performs the same function as
pop2buf except that the
name of the buffer that
buf replaced in the window is returned.
This allows one to restore the buffer in window to what it was before
the call to
pop2buf_whatbuf .
See also
Synopsis
set_buffer_umask
Usage
Integer set_buffer_umask (Integer cmask);
Description
The function may be used to set the process file creation mask
for the appropriate operations associated with the current
buffer. This makes it possible to have a buffer-dependent
umask setting. The function takes the desired umask setting and
returns the previous setting. If cmask is zero, the default
process umask setting will be used for operations while the buffer
is current. If cmask is -1, the umask associated with the buffer
will not be changed.
Synopsis
set_mode
Usage
Void set_mode(String mode, Integer flags);
Description
This function sets buffer mode flags and status line mode name.
mode
is a string which is displayed on the status line if the
%m status
line format specifier is used. The second argument,
flags is an
integer with the possible values:
0 : no mode. Very generic
1 : Wrap mode. Lines are automatically wrapped at wrap column.
2 : C mode.
4 : Language mode. Mode does not wrap but is useful for computer
languages.
8 : S-Lang mode
16: Fortran mode highlighting
32: TeX mode highlighting
See also
Synopsis
setbuf
Usage
Void setbuf(String buf);
Description
Changes the default buffer to one named
buf . If the buffer does not
exist, it will be created.
Note: This change only lasts until top
level of editor loop is reached at which point the the buffer
associated with current window will be made the default. That is this
change should only be considered as temporary. To make a long lasting
change, use the function
sw2buf .
See also
Synopsis
setbuf_info
Usage
setbuf_info([ buf, ] file, dir, name, flags)
String_Type buf; % optional argument -- name of buffer
Int_Type flags; % buffer flags
String_Type name; % name of buffer
String_Type dir; % directory associated with buffer
String_Type file; % name of file associated with buffer (if any).
Description
This function may be used to change attributes regarding the buffer
buf . If the optional argument
buf is not present, the
current buffer will be used.
setbuf_info performs the opposite function of the related
function
getbuf_info . Here
file is the name of the file
to be associated with the buffer;
dir is the directory to be
associated with the buffer;
buf is the name to be assigned to
the buffer, and
flags describe the buffer attributes. See
getbuf_info for a discussion of
flags . Note that the
actual file associated with the buffer is located in directory
dir with the name
file . For example, the function
define set_overwrite_mode ()
{
variable dir, file, flags, name;
(file, dir, name, flags) = getbuf_info ();
flags = flags | (1 shl 4);
setbuf_info (file, dir, name, flags);
}
may be used to turn on overwrite mode for the current buffer.
Advanced S-Lang programmers exploit the fact that S-Lang is a stack
based language and simply write the above function as:
define set_overwrite_mode ()
{
setbuf_info (getbuf_info () | 0x10);
}
Here,
(1 shl 4) has been written as the hexidecimal number
0x10 .
See also
Synopsis
sw2buf
Usage
Void sw2buf (String buf);
Description
This function is used to switch to another buffer whose name is
specified by the parameter
buf . If the buffer specified by
buf
does not exist, one will be created.
Note: Unlike
setbuf , the change
to the new buffer is more permanent in the sense that when control
passed back out of S-Lang to the main editor loop, if the current
buffer at that time is the buffer specified here, this buffer will be
attached to the window.
See also
Synopsis
what_mode
Usage
(String name, Integer flags) = Integer what_mode ();
Description
This function may be used to obtain the mode flags and mode name of the
current buffer. See
set_mode for more details.
See also
Synopsis
whatbuf
Usage
String what_buffer();
Description
whatbuf returns the name of the current buffer. It is usually used
in functions when one wants to work with more than one buffer. The
function
setbuf_info may be used to change the name of the buffer.
See also
Synopsis
write_buffer
Usage
Integer write_buffer (String filename);
Description
This function may be used to write the current buffer out to a file
specified by filename . The buffer will then become associated with
that file. The number of lines written to the file is returned. An
error condition will be signaled upon error.
See also