home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / msdos / winemacs / readme.dos < prev    next >
Encoding:
Text File  |  1993-06-08  |  9.9 KB  |  286 lines

  1. MS-DOS-SPECIFIC FEATURES OF WIN-EMACS
  2.  
  3.  
  4. A.  FILE TYPE (TEXT OR BINARY)
  5.  
  6. The standard format for text files in MS-DOS is to signal the end of a
  7. line with two characters, CR (ASCII 13) and LF (ASCII 10), and to mark
  8. the end of the file with a ^Z character.  It is desirable to be able
  9. to edit files that follow these conventions; however, in order to edit
  10. binary files (such as .EXE files), it is important to be able to
  11. specify exactly which bytes are written out to the file.  To this end,
  12. Win-Emacs provides two modes for editing files, TEXT TRANSLATION MODE
  13. and BINARY TRANSLATION MODE.
  14.  
  15. When reading in a file in text translation mode, Win-Emacs treats each
  16. CR followed by a LF, and each LF character alone, as marking the end
  17. of a line, and stops reading the file when a ^Z character is
  18. encountered.  When writing a file in text translation mode, Win-Emacs
  19. writes a CR followed by a LF at the end of each line, and writes a ^Z
  20. character at the end of the file.
  21.  
  22. When reading in a file in binary translation mode, Win-Emacs simply
  23. treats each LF as marking the end of a line and continues reading
  24. until the physical end-of-file is encountered.  When writing out a
  25. file in binary translation mode, Win-Emacs writes a LF at the end of
  26. each line and does not write a ^Z at the end of a file.  If you read
  27. in a text file in binary translation mode, you will likely see a ^M
  28. (CR) character at the end of each line.
  29.  
  30. Every buffer has its own translation-mode setting (also known as the
  31. "file type").  This value is indicated in the modeline: for example,
  32.  
  33.      --**-Emacs: demacs.tex   (T:Texinfo)--42%---------------
  34.                                ^
  35. indicates that the file "demacs.tex" is being edited in Texinfo mode and
  36. text translation mode (notice the "T" before the colon; this would be "B"
  37. for binary translation mode).
  38.  
  39. Win-Emacs determines the translation mode for a file according to the
  40. file's name, and sets the file type of a buffer accordingly when a file
  41. is visited and a new buffer is created for this file, or when a file is
  42. read into an existing buffer.  The buffer's file type can also be set
  43. manually using "set-file-type".  The file type for a buffer can be
  44. determined by reading the buffer-local variable "file-type".
  45.  
  46. Win-Emacs maintains an association list of filename patterns and associated
  47. file types.  Each filename pattern is a regular expression.  At startup
  48. time, the file type association list is specified as follows:
  49.  
  50. (defvar file-name-file-type-alist
  51.   '(
  52.     ("\\.elc$" . 1)
  53.     ("\\.obj$" . 1)
  54.     ("\\.exe$" . 1)
  55.     ("\\.com$" . 1)
  56.     ("\\.lib$" . 1)
  57.     ("[:/].*config.sys" . 0)
  58.     ("\\.sys$" . 1)
  59.     ("\\.chk$" . 1)
  60.     ("\\.dll$" . 1)
  61.     ("\\.bmp$" . 1)
  62.     ("\\.ico$" . 1)
  63.     ("\\.res$" . 1)
  64.     ("\\.pif$" . 1)
  65.     ("\\.sym$" . 1)
  66.     ("\\.scr$" . 1)
  67.     ("\\.fon$" . 1)
  68.     ("\\.fot$" . 1)
  69.     ("\\.ttf$" . 1)
  70.     ))
  71.  
  72. where "1" means binary and "0" means text.  This specifies common
  73. binary-file extensions as referring to binary files, with an exception
  74. made for CONFIG.SYS.  When multiple entries in the association list
  75. match, Win-Emacs takes the first matching one.  If no entries match,
  76. Win-Emacs uses the value in the variable "default-file-type".  You can
  77. add an entry to the end of the association list using
  78. "define-file-name-file-type".
  79.  
  80. The function "find-file-type-from-file-name" determines the file type
  81. for a particular file, according to the procedure outlined above.  This
  82. function is called inside of primitive function "insert-file-contents"
  83. (when reading an existing file) or from the function
  84. "find-file-not-found-set-file-type" (when visiting a non-existent file);
  85. this latter function is appended to the "find-file-not-found-hooks"
  86. variable (a list of functions to be called when visiting a non-existent
  87. file) by the startup code.
  88.  
  89.  
  90. ## Buffer-local variable: file-type
  91.      Specifies the file type of the buffer.   
  92.      `0'
  93.           Text mode translation.
  94.      `1'
  95.           Binary mode translation.
  96.  
  97. ## Command: set-file-type TYPE &optional BUFFER
  98.      This function sets buffer-local `file-type' variable of BUFFER to
  99.      TYPE. The argument BUFFER defaults to the current buffer. The value
  100.      of TYPE is one of following.
  101.      `0' or `'text' or `"text"'
  102.           Specify the buffer's file type as text mode.
  103.      `1' or `'binary' or `"binary"'
  104.           Specify the buffer's file type as binary mode.
  105.  
  106. ## Global variable: default-file-type
  107.      The value of this global variable is the default value of
  108.      buffer-local `file-type' variable.
  109.  
  110. ## Command: set-default-file-type TYPE
  111.      This function sets the value of `default-file-type' variable to
  112.      TYPE. The value of TYPE is one of following.
  113.      `0' or `'text' or `"text"'
  114.           Specify the buffer's file type as text mode, by default.
  115.      `1' or `'binary' or `"binary"'
  116.           Specify the buffer's file type as binary mode, by default.
  117.  
  118. ## Function: define-file-name-file-type FILENAME TYPE
  119.      This function defines the file type associated with a file name.
  120.      FILENAME is a regular expression or `nil'. `nil' matches any file
  121.      name. TYPE is the file type.
  122.  
  123. ## Function: find-file-type-from-file-name FILENAME
  124.      This function returns the file type which is associated with FILENAME
  125.      by the `define-file-name-file-type' function.  If no file type
  126.      is defined, this returns the value of `default-file-type'.
  127.  
  128.  
  129.  
  130.  
  131. B. GENERATING 8086 SOFTWARE INTERRUPTS
  132.  
  133. You can generate an 8086 software interrupt using "int86".  Use this
  134. carefully.
  135.  
  136. One of the arguments to this function is an instance of a special "register"
  137. type, holding the values of all registers upon entry and exit.  Functions
  138. are provided to manipulate register types.
  139.  
  140. For example, the following C function, which gets the current disk number:
  141.  
  142.      int
  143.      GetDisk ()
  144.      {
  145.        union REGS regs;
  146.        regs.h.ah = 0x19;     /* 25 */
  147.        int86 (0x21 /* 33 */, ®s, ®s);
  148.        return regs.h.al;
  149.      }
  150.  
  151. may be written in Win-Emacs as follows:
  152.  
  153.      (defun get-disk ()
  154.        (let ((regs (make-register)))
  155.          (set-register-value regs 'ah 25)    ; 0x19
  156.          (int86 33 regs)                     ; 0x21
  157.          (register-value regs 'al)))
  158.  
  159.  
  160. ## Function: make-register
  161.      Generate an instance of register type.   This is a set of register values
  162.      and is passed to the `int86' function to specify the registers upon
  163.      invocation of the interrupt.
  164.  
  165. ## Function: register-value REGISTER NAME
  166.      Get the value of REGISTER's NAME. NAME is one of the following.
  167.  
  168.      `'ax'
  169.           `ax' register
  170.      `'bx'
  171.           `bx' register
  172.      `'cx'
  173.           `cx' register
  174.      `'dx'
  175.           `dx' register
  176.      `'si'
  177.           `si' register
  178.      `'di'
  179.           `di' register
  180.      `'cflag'
  181.           carry flag
  182.      `'flags'
  183.           flag register
  184.  
  185.      or
  186.  
  187.      `'al'
  188.           lower byte of `ax' register
  189.      `'ah'
  190.           upper byte of `ax' register
  191.      `'bl'
  192.           lower byte of `bx' register
  193.      `'bh'
  194.           upper byte of `bx' register
  195.      `'cl'
  196.           lower byte of `cx' register
  197.      `'ch'
  198.           upper byte of `cx' register
  199.      `'dl'
  200.           lower byte of `dx' register
  201.      `'dh'
  202.           upper byte of `dx' register
  203.  
  204. ## Function: set-register-value REGISTER NAME VALUE
  205.      Set REGISTER's NAME to VALUE. VALUE is an unsigned integer.
  206.  
  207. ## Function: int86 INTNO REGISTER
  208.      Generate 8086 software interrupt of number INTNO with REGISTER (an
  209.      instance of register type) specifying the registers upon invocation
  210.      of the interrupt.  An instance of register type is returned, specifying
  211.      the register values upon return from the interrupt.
  212.  
  213.  
  214.  
  215. C. MS-DOS FILENAMES
  216.  
  217. In MS-DOS, filenames are separated into two parts, called the "base" and the
  218. "extension" and separated by a period.  The base is limited to 8 characters
  219. and the extension to 3.  Filenames are not case-sensitive.  Win-Emacs
  220. automatically converts all filenames to lowercase and truncates their names
  221. to follow MS-DOS constraints.
  222.  
  223.  
  224. C.1 Backup files
  225.  
  226. Backup files, named in Unix by appending a ~, are named in Win-Emacs as
  227. follows:
  228.  
  229. 1) If the extension is fewer than 3 characters, a ~ is added to the extension.
  230. 2) If the extension if 3 characters long, the last character is replaced by
  231.    a ~.
  232.  
  233. Numeric backups are not allowed in Win-Emacs due to the tightness of
  234. MS-DOS filename constraints.
  235.  
  236.  
  237. C.2 Auto-save files
  238.  
  239. Auto-save files, named in Unix by appending and prepending a #, are named
  240. in Win-Emacs as follows:
  241.  
  242. 1) A # is added to the beginning of the base.  If the base is already 8
  243.    characters, the last character is truncated.
  244. 2) If the extension is fewer than 3 characters, a # is added to it; otherwise
  245.    the last character is replaced by a #.
  246.  
  247.  
  248. C.3 Special filename completion feature
  249.  
  250. Normally, pressing TAB when typing in a partial filename will complete the
  251. filename.  As a shortcut to specifying a new filename on a different drive,
  252. you can simply type the drive letter and partial filename after the existing
  253. partial filename and then press TAB.  For example, you type C-x C-f to
  254. visit a file, and are prompted as follows:
  255.  
  256.           Find file: c:/tools/emacs/
  257.  
  258. At this point, if you type "d:/confi" and press TAB, the display becomes:
  259.  
  260.           a:/tools/emacs/d:confi[TAB]  -> d:/config.sys [sole complete]
  261.  
  262. (assuming the file "config.sys" exists in d:/ and no other files
  263. beginning with "confi" exist in the same directory.)
  264.  
  265.  
  266.  
  267. D. LIMITATIONS
  268.  
  269.  
  270. D.1 Interrupting running Lisp code
  271.  
  272. C-g cannot currently interrupt running Lisp code.  Thus, a form like this:
  273.  
  274.           (while t ())
  275.  
  276. cannot be interrupted.  Instead, you should write:
  277.  
  278.           (while (not (input-pending-p)) ())
  279.  
  280.  
  281. D.2 Subprocesses
  282.  
  283. Subprocess support is not currently implemented.  Support for synchronous
  284. subprocesses will likely be added in a near release.  Support for
  285. asynchronous processes is difficult, if not impossible, under Windows.
  286.