variable ADD_NEWLINE

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.

variable MAX_HITS

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

TAB_DEFAULT , USE_TABS

function autosave

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

setbuf_info , autosaveall

See also

MAX_HITS

function autosaveall

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

autosave , setbuf_info

See also

MAX_HITS

function buffer_list

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

getbuf_info , whatbuf

function buffer_visible

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

bufferp , nwindows

function bufferp

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

setbuf , getbuf_info

function bury_buffer

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

sw2buf , getbuf_info

function check_buffers

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

file_time_compare , file_changed_on_disk

function delbuf

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

whatbuf , bufferp , sw2buf

function getbuf_info

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

setbuf_info , whatbuf

function pop2buf

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

whatbuf , pop2buf_whatbuf , setbuf , sw2buf , nwindows

function pop2buf_whatbuf

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

pop2buf , whatbuf

function set_buffer_umask

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.

function set_mode

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

whatmode, getbuf_info , setbuf_info.

function setbuf

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

sw2buf , pop2buf , whatbuf , pop2buf_whatbuf

function setbuf_info

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

getbuf_info , setbuf , whatbuf

function sw2buf

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

setbuf , pop2buf , bufferp

function what_mode

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

set_mode , getbuf_info , setbuf_info

function whatbuf

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

getbuf_info , bufferp

function write_buffer

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

write_region_to_file , setbuf_info