MS-DOS-specific featuers of Win-Emacs
*************************************

This file is taken from Demacs version 1.2.0.


Features
********



File Type: Text or Binary Translation
=====================================



Translation Mode
----------------

On MS-DOS file systems, a line is ended with CR (0x0d)/LF (0x0a)
characters and a file is ended with a `Ctrl-Z' character. But on the UNIX
file system, a line is ended with only an LF character, and end of data means
end of file.

Win-Emacs provides two translation modes:

   * Text mode translation
   * Binary mode translation

With text mode translation, on reading, CR/LF codes are translated to LF
and reading is terminated as soon as `Ctrl-Z' appears. On writing, CR is
added to LR and `Ctrl-Z' is added to the end of file.

With binary mode translation, no code is translated.

Win-Emacs supports these two translation modes, and manages them on each
buffer. You can find current the translation mode of the buffer from the file
type mnemonic on the mode line.

     --**-Emacs: demacs.tex   (T:Texinfo)--42%---------------
                               ^

File type mnemonic means

`T'
     Text mode translation.
`B'
     Binary mode translation.

We call this translation mode which is managed on each buffer "file
type".



Win-Emacs Buffer Management
---------------------------



File Type of Each Buffer
........................

The file type of each buffer is stored in buffer-local `file-type' variable. 
To set the value of `file-type' use the `set-file-type' function.

The default value of `file-type' is the value of `default-file-type'
variable. To set its value, use the `set-default-file-type' function.

## Local Variable: file-type
     `0'
          Text mode translation.
     `1'
          Binary mode translation.

## Command: set-file-type TYPE &optional BUFFER
     This function sets buffer-local `file-type' variable of BUFFER to
     TYPE. The argument BUFFER defaults to the current buffer. The value
     of TYPE is one of following.
     `0' or `'text' or `"text"'
          Specify the buffer's file type as text mode.
     `1' or `'binary' or `"binary"'
          Specify the buffer's file type as binary mode.

## Global Variable: default-file-type
     The value of this global variable is the default value of
     buffer-local `file-type' variable.

## Command: set-default-file-type TYPE
     This function sets the value of `default-file-type' variable to
     TYPE. The value of TYPE is one of following.
     `0' or `'text' or `"text"'
          Specify the buffer's file type as text mode, by default.
     `1' or `'binary' or `"binary"'
          Specify the buffer's file type as binary mode, by default.



Buffer Creation
...............

When creating a new buffer, Win-Emacs sets the buffer's local variable
`file-type' to the value of the `default-file-type' variable.



Reading Files into Win-Emacs Buffers
------------------------------------

Using the `define-file-name-file-type' function, you can define the file
type associated with a file name.

For example, 

     (define-file-name-file-type "\\.mem$" 'binary)

specifies that the file type of files having extention `.mem' is binary.

By default, the files ending with `.elc', `.obj', `.exe', `.com',
`.lib', `.sys' (except `config.sys'), `.chk', `.o', `.a' and `.out' are
defined as binary file type.

## Function: define-file-name-file-type FILENAME TYPE
     This function defines the file type associated with a file name.
     FILENAME is a regular expression or `nil'. `nil' matches any file
     name. TYPE is the file type.

## Function: find-file-type-from-file-name FILENAME
     This function returns the file type which is associated with FILENAME
     by the `define-file-name-file-type' function.  If no file type
     is defined, this returns the value of `default-file-type'.



Inserting Files into Buffers
............................

When inserting a file into a buffer that is already visiting a file,
Win-Emacs calls the `find-file-type-from-file-name' function with the
file name of the target file as its argument, and sets the file type
of the buffer to the return value from this function.



Visiting Files and Reading
..........................

When visiting a file and reading into a buffer, Win-Emacs calls the
`find-file-type-from-file-name' function with the file name of the
target file as its argument, and sets the file type of the buffer to
the return value from this function.



Creating Files and Visiting
...........................

The `find-file-not-found-set-file-type' function is appended to
the `find-file-not-found-hooks' variable. This means that
`find-file-not-found-set-file-type' is called when the visiting
file does not exist.

This function internally calls the `find-file-type-from-file-name'
function with the target name as its argument and sets the file type
of the buffer to the return value from this function.



Writing Buffers into Files
--------------------------

When writing a buffer into a file, Win-Emacs sets the translation mode to
the file type of the buffer.




8086 Software Interrupt
=======================

Function `int86' generates an 8086 software interrupt.  Use this carefully.

Use this function like this.

     int
     GetDisk ()
     {
       union REGS regs;
       regs.h.ah = 0x19;     /* 25 */
       int86 (0x21 /* 33 */, &regs, &regs);
       return regs.h.al;
     }

This C function to get the current disk number may be written in Win-Emacs
as follows:

     (defun get-disk ()
       (let ((regs (make-register)))
         (set-register-value regs 'ah 25)    ; 0x19
         (int86 33 regs)                     ; 0x21
         (register-value regs 'al)))

## Function: make-register
     Generate an instance of register type.   This is a set of register values
     and is passed to the `int86' function to specify the registers upon
     invocation of the interrupt.

## Function: register-value REGISTER NAME
     Get the value of REGISTER's NAME. NAME is one of the following.

     `'ax'
          `ax' register
     `'bx'
          `bx' register
     `'cx'
          `cx' register
     `'dx'
          `dx' register
     `'si'
          `si' register
     `'di'
          `di' register
     `'cflag'
          carry flag
     `'flags'
          flag register

     or

     `'al'
          lower byte of `ax' register
     `'ah'
          upper byte of `ax' register
     `'bl'
          lower byte of `bx' register
     `'bh'
          upper byte of `bx' register
     `'cl'
          lower byte of `cx' register
     `'ch'
          upper byte of `cx' register
     `'dl'
          lower byte of `dx' register
     `'dh'
          upper byte of `dx' register

## Function: set-register-value REGISTER NAME VALUE
     Set REGISTER's NAME to VALUE. VALUE is an unsigned integer.

## Function: int86 INTNO REGISTER
     Generate 8086 software interrupt of number INTNO with REGISTER (an
     instance of register type) specifying the registers upon invocation
     of the interrupt.  An instance of register type is returned, specifying
     the register values upon return from the interrupt.


Other Win-Emacs Features
========================

  1. Filename Completion

     Win-Emacs provides a special filename completion feature. Filenames may
     include a drive name at the front. For example, we assume the current
     directory is `c:/tools/emacs' and there is a file `d:/config.sys';
     then `C-x C-f' invokes `find-file' function and the function prompts

          Find file: c:/tools/emacs/

     At this point typing `d:/confi' and pressing TAB causes:

          a:/tools/emacs/d:confi^I  -> d:/config.sys [sole complete]

  2. Enhanced Dired

     Dired works without requiring an `ls.exe' program.


Restrictions
************

   * `Ctrl-G' can't generate an interrupt signal. So you can't quit a
     lisp-form like this:

          (while t ())

     You shoud use the following form instead of it.

          (while (not (input-pending-p)) ())

   * Win-Emacs backup filename conventions:

     Base backup filename is made from the following rule.

          foo      ->  foo.~
          foo.c    ->  foo.c~
          foo.tex  ->  foo.te~

     Since the DOS filename rule (8.3) is too tight, numeric backups such as
     `foo.c.~2~' cannot be used.

     Similarly, the auto-save filename is made from the following rule:

          abcdefgh ->  #abcdefg.#
          foo.c    ->  #foo.c#
          foo.tex  ->  #foo.te#



Differences from UNIX Version
*****************************



List of Functions which are not implemented in Win-Emacs
========================================================

     accept-process-output                   process-list
     continue-process                        process-mark
     delete-process                          process-name
     file-locked-p                           process-send-eof
     get-buffer-process                      process-send-region
     get-process                             process-send-string
     interrupt-process                       process-sentinel
     kill-process                            process-status
     list-processes                          processp
     make-symbolic-link                      quit-process
     open-network-stream                     set-process-buffer
     process-buffer                          set-process-filter
     process-command                         set-process-kanji-code
     process-exit-status                     set-process-sentinel
     process-filter                          start-process
     process-id                              stop-process
     process-kanji-code                      waiting-for-user-input-p
     process-kill-without-query



List of Variables which are not implemented in Win-Emacs
========================================================

     delete-exited-processes                 process-connection-type



List of Functions added to Win-Emacs
====================================

     bdos                                    intdos
     define-file-name-file-type              invoke-find-file-type
     demacs-version                          make-register
     disk-free-space                         register-value
     disk-total-space                        set-cursor-mode
     file-type-internal                      set-default-file-type
     file-type-p                             set-file-type
     find-file-not-found-set-file-type       set-keyclick
     find-file-type-from-file-name           set-register-value
     get-cursor-mode                         set-screen-mode
     get-screen-mode                         toggle-pass8-mode
     int86



List of Variables added to Win-Emacs
====================================

     default-file-type                       file-type
     demacs-version                          file-type-alist
     demacs-version-date                     find-file-type
     dos-inhibit-setdisk                     pass8-mode
     dos-machine-type                        register-name-by-byte-alist
     file-name-file-type-alist               register-name-by-word-alist

