home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / e20313in.zip / emacs / 20.3.1 / emx / patches.emx < prev    next >
Text File  |  1996-08-19  |  139KB  |  4,716 lines

  1. diff -c emacs-19\lib-src\etags.c:1.1.1.33 emacs-19\lib-src\etags.c:1.45
  2. *** emacs-19\lib-src\etags.c:1.1.1.33    Sun Aug 18 23:21:48 1996
  3. --- emacs-19\lib-src\etags.c    Sun Aug 18 23:21:48 1996
  4. ***************
  5. *** 18,23 ****
  6. --- 18,25 ----
  7.   along with this program; if not, write to the Free Software Foundation,
  8.   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  9.   
  10. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  11.   /*
  12.    * Authors:
  13.    *    Ctags originally by Ken Arnold.
  14. ***************
  15. *** 70,75 ****
  16. --- 72,81 ----
  17.   #include <sys/types.h>
  18.   #include <sys/stat.h>
  19.   
  20. + #ifdef EMX
  21. + #include <string.h>
  22. + #endif /* EMX */
  23.   #if !defined (S_ISREG) && defined (S_IFREG)
  24.   # define S_ISREG(m)    (((m) & S_IFMT) == S_IFREG)
  25.   #endif
  26. ***************
  27. *** 114,120 ****
  28.   #define    intoken(arg)    (_itk[arg])    /* T if char can be in token    */
  29.   #define    endtoken(arg)    (_etk[arg])    /* T if char ends tokens    */
  30.   
  31. ! #ifdef DOS_NT
  32.   # define absolutefn(fn) (fn[0] == '/' \
  33.                || (fn[1] == ':' && fn[2] == '/'))
  34.   #else
  35. --- 120,126 ----
  36.   #define    intoken(arg)    (_itk[arg])    /* T if char can be in token    */
  37.   #define    endtoken(arg)    (_etk[arg])    /* T if char ends tokens    */
  38.   
  39. ! #if defined (DOS_NT) || defined (EMX)
  40.   # define absolutefn(fn) (fn[0] == '/' \
  41.                || (fn[1] == ':' && fn[2] == '/'))
  42.   #else
  43. ***************
  44. *** 715,720 ****
  45. --- 721,730 ----
  46.   
  47.     progname = argv[0];
  48.   
  49. + #ifdef EMX
  50. +   _wildcard (&argc, &argv);
  51. + #endif /* EMX */
  52.     /* Allocate enough no matter what happens.  Overkill, but each one
  53.        is small. */
  54.     argbuffer = xnew (argc, argument);
  55. ***************
  56. *** 4332,4337 ****
  57. --- 4342,4357 ----
  58.   char *
  59.   etags_getcwd ()
  60.   {
  61. + #ifdef EMX
  62. +   char cwd[270];
  63. +   int i;
  64. +   getcwd (cwd, sizeof (cwd));
  65. +   i = strlen (cwd);
  66. +   if (i > 0 && cwd[i-1] == '/')
  67. +     cwd[i-1] = 0;
  68. +   return strdup (cwd);
  69. + #else /* not EMX */
  70.   #ifdef MSDOS
  71.     char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS.  */
  72.   
  73. ***************
  74. *** 4370,4375 ****
  75. --- 4390,4396 ----
  76.     return path.buffer;
  77.   #endif /* not HAVE_GETCWD */
  78.   #endif /* not MSDOS */
  79. + #endif /* not EMX */
  80.   }
  81.   
  82.   /* Return a newly allocated string containing the filename
  83. diff -c emacs-19\lib-src\hexl.c:1.1.1.7 emacs-19\lib-src\hexl.c:1.22
  84. *** emacs-19\lib-src\hexl.c:1.1.1.7    Sun Aug 18 23:21:48 1996
  85. --- emacs-19\lib-src\hexl.c    Sun Aug 18 23:21:48 1996
  86. ***************
  87. *** 1,3 ****
  88. --- 1,5 ----
  89. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  90.   #include <stdio.h>
  91.   #include <ctype.h>
  92.   #ifdef DOS_NT
  93. ***************
  94. *** 35,40 ****
  95. --- 37,47 ----
  96.   
  97.     progname = *argv++; --argc;
  98.   
  99. + #ifdef EMX
  100. +     setvbuf (stdin, NULL, _IOFBF, BUFSIZ);
  101. +     setvbuf (stdout, NULL, _IOFBF, BUFSIZ);
  102. + #endif /* EMX */
  103.     /*
  104.      ** -hex        hex dump
  105.      ** -oct        Octal dump
  106. ***************
  107. *** 148,153 ****
  108. --- 155,163 ----
  109.         _setmode (fileno (stdout), O_BINARY);
  110.   #endif
  111.   #endif
  112. + #ifdef EMX
  113. +       _fsetmode (stdout, "b");
  114. + #endif /* EMX */
  115.         for (;;)
  116.           {
  117.             register int i, c, d;
  118. ***************
  119. *** 197,202 ****
  120. --- 207,215 ----
  121.         _setmode (fileno (fp), O_BINARY);
  122.   #endif
  123.   #endif
  124. + #ifdef EMX
  125. +       _fsetmode (fp, "b");
  126. + #endif /* EMX */
  127.         address = 0;
  128.         string[0] = ' ';
  129.         string[17] = '\0';
  130. diff -c emacs-19\lib-src\make-docfile.c:1.1.1.16 emacs-19\lib-src\make-docfile.c:1.32
  131. *** emacs-19\lib-src\make-docfile.c:1.1.1.16    Sun Aug 18 23:21:48 1996
  132. --- emacs-19\lib-src\make-docfile.c    Sun Aug 18 23:21:50 1996
  133. ***************
  134. *** 18,23 ****
  135. --- 18,25 ----
  136.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  137.   Boston, MA 02111-1307, USA.  */
  138.   
  139. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  140.   /* The arguments given to this program are all the C and Lisp source files
  141.    of GNU Emacs.  .elc and .el and .c files are allowed.
  142.    A .o file can also be specified; the .c file it was made from is used.
  143. ***************
  144. *** 45,50 ****
  145. --- 47,56 ----
  146.   #include <direct.h>
  147.   #endif /* WINDOWSNT */
  148.   
  149. + #ifdef EMX
  150. + #define READ_TEXT "rt"
  151. + #define READ_BINARY "rb"
  152. + #else /* not EMX */
  153.   #ifdef DOS_NT
  154.   #define READ_TEXT "rt"
  155.   #define READ_BINARY "rb"
  156. ***************
  157. *** 52,57 ****
  158. --- 58,64 ----
  159.   #define READ_TEXT "r"
  160.   #define READ_BINARY "r"
  161.   #endif /* not DOS_NT */
  162. + #endif /* not EMX */
  163.   
  164.   int scan_file ();
  165.   int scan_lisp_file ();
  166. ***************
  167. *** 131,136 ****
  168. --- 138,146 ----
  169.     _fmode = O_BINARY;
  170.     _setmode (fileno (stdout), O_BINARY);
  171.   #endif /* WINDOWSNT */
  172. + #ifdef EMX
  173. +   _wildcard (&argc, &argv);
  174. + #endif /* EMX */
  175.   
  176.     /* If first two args are -o FILE, output to FILE.  */
  177.     i = 1;
  178. ***************
  179. *** 152,157 ****
  180. --- 162,171 ----
  181.   
  182.     if (outfile == 0)
  183.       fatal ("No output file specified", "");
  184. + #ifdef EMX
  185. +   _fsetmode (outfile, "b");
  186. + #endif /* EMX */
  187.   
  188.     first_infile = i;
  189.     for (; i < argc; i++)
  190. diff -c emacs-19\lib-src\profile.c:1.1.1.7 emacs-19\lib-src\profile.c:1.17
  191. *** emacs-19\lib-src\profile.c:1.1.1.7    Sun Aug 18 23:21:50 1996
  192. --- emacs-19\lib-src\profile.c    Sun Aug 18 23:21:50 1996
  193. ***************
  194. *** 20,25 ****
  195. --- 20,26 ----
  196.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  197.   Boston, MA 02111-1307, USA.  */
  198.   
  199. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  200.   
  201.   /**
  202.    **  To be run as an emacs process. Input string that starts with:
  203. ***************
  204. *** 83,88 ****
  205. --- 84,92 ----
  206.   main ()
  207.   {
  208.     int c;
  209. + #ifdef EMX
  210. +   setvbuf (stdout, NULL, _IOLBF, BUFSIZ);
  211. + #endif
  212.     while ((c = getchar ()) != EOF)
  213.       {
  214.         switch (c)
  215. diff -c emacs-19\lisp\ange-ftp.el:1.1.1.33 emacs-19\lisp\ange-ftp.el:1.13
  216. *** emacs-19\lisp\ange-ftp.el:1.1.1.33    Sun Aug 18 23:22:10 1996
  217. --- emacs-19\lisp\ange-ftp.el    Sun Aug 18 23:22:10 1996
  218. ***************
  219. *** 1,5 ****
  220. --- 1,7 ----
  221.   ;;; ange-ftp.el --- transparent FTP support for GNU Emacs
  222.   
  223. + ;;; Modified for emx by Eberhard Mattes, Aug 1996
  224.   ;; Copyright (C) 1989,90,91,92,93,94,95,96  Free Software Foundation, Inc.
  225.   
  226.   ;; Author: Andy Norman (ange@hplb.hpl.hp.com)
  227. ***************
  228. *** 2854,2860 ****
  229.         ;; If name starts with //, preserve that, for apollo system.
  230.         (if (not (string-match "^//" name))
  231.             (progn
  232. !         (setq name (ange-ftp-real-expand-file-name name))
  233.   
  234.           (if (string-match "^//" name)
  235.               (setq name (substring name 1)))))
  236. --- 2856,2862 ----
  237.         ;; If name starts with //, preserve that, for apollo system.
  238.         (if (not (string-match "^//" name))
  239.             (progn
  240. !         (setq name (ange-ftp-remote-expand-file-name name))
  241.   
  242.           (if (string-match "^//" name)
  243.               (setq name (substring name 1)))))
  244. ***************
  245. *** 2863,2871 ****
  246.         (ange-ftp-replace-name-component n name))
  247.         
  248.         ;; non-ange-ftp name.  Just expand normally.
  249. !       (if (eq (string-to-char n) ?/)
  250.         (ange-ftp-real-expand-file-name n)
  251. !     (ange-ftp-real-expand-file-name
  252.        (ange-ftp-real-file-name-nondirectory n)
  253.        (ange-ftp-real-file-name-directory n))))))
  254.   
  255. --- 2865,2873 ----
  256.         (ange-ftp-replace-name-component n name))
  257.         
  258.         ;; non-ange-ftp name.  Just expand normally.
  259. !       (if (file-name-absolute-p n)
  260.         (ange-ftp-real-expand-file-name n)
  261. !     (ange-ftp-remote-expand-file-name
  262.        (ange-ftp-real-file-name-nondirectory n)
  263.        (ange-ftp-real-file-name-directory n))))))
  264.   
  265. ***************
  266. *** 2879,2885 ****
  267.                 (setq name (substring name (1- (match-end 0))))))))
  268.       (cond ((eq (string-to-char name) ?~)
  269.          (ange-ftp-real-expand-file-name name))
  270. !       ((eq (string-to-char name) ?/)
  271.          (ange-ftp-canonize-filename name))
  272.         ((zerop (length name))
  273.          (ange-ftp-canonize-filename (or default default-directory)))
  274. --- 2881,2887 ----
  275.                 (setq name (substring name (1- (match-end 0))))))))
  276.       (cond ((eq (string-to-char name) ?~)
  277.          (ange-ftp-real-expand-file-name name))
  278. !       ((file-name-absolute-p name)
  279.          (ange-ftp-canonize-filename name))
  280.         ((zerop (length name))
  281.          (ange-ftp-canonize-filename (or default default-directory)))
  282. ***************
  283. *** 3957,3962 ****
  284. --- 3959,3968 ----
  285.                 inhibit-file-name-handlers))))
  286.       (inhibit-file-name-operation operation))
  287.       (apply operation args)))
  288. + (defun ange-ftp-remote-expand-file-name (name &optional default)
  289. +   (let ((remote-expand-file-name t))
  290. +     (ange-ftp-real-expand-file-name name default)))
  291.   
  292.   (defun ange-ftp-real-file-name-directory (&rest args)
  293.     (ange-ftp-run-real-handler 'file-name-directory args))
  294. diff -c emacs-19\lisp\compile.el:1.1.1.33 emacs-19\lisp\compile.el:1.41
  295. *** emacs-19\lisp\compile.el:1.1.1.33    Sun Aug 18 23:22:12 1996
  296. --- emacs-19\lisp\compile.el    Sun Aug 18 23:22:12 1996
  297. ***************
  298. *** 1,5 ****
  299. --- 1,7 ----
  300.   ;;; compile.el --- run compiler as inferior of Emacs, parse error messages.
  301.   
  302. + ;;; Modified for emx by Eberhard Mattes, Aug 1996
  303.   ;; Copyright (C) 1985, 86, 87, 93, 94, 1995, 1996 Free Software Foundation, Inc.
  304.   
  305.   ;; Author: Roland McGrath <roland@prep.ai.mit.edu>
  306. ***************
  307. *** 442,447 ****
  308. --- 444,450 ----
  309.       ;; Start the compilation.
  310.       (if (fboundp 'start-process)
  311.           (let* ((process-environment (cons "EMACS=t" process-environment))
  312. +            (process-connection-type nil) ; emx
  313.              (proc (start-process-shell-command (downcase mode-name)
  314.                                 outbuf
  315.                                 command)))
  316. diff -c emacs-19\lisp\dired-aux.el:1.1.1.24 emacs-19\lisp\dired-aux.el:1.14
  317. *** emacs-19\lisp\dired-aux.el:1.1.1.24    Sun Aug 18 23:22:12 1996
  318. --- emacs-19\lisp\dired-aux.el    Sun Aug 18 23:22:12 1996
  319. ***************
  320. *** 1,5 ****
  321. --- 1,7 ----
  322.   ;;; dired-aux.el --- less commonly used parts of dired  -*-byte-compile-dynamic: t;-*-
  323.   
  324. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  325.   ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
  326.   
  327.   ;; Author: Sebastian Kremer <sk@thp.uni-koeln.de>.
  328. ***************
  329. *** 117,123 ****
  330.   (defun dired-do-chgrp (&optional arg)
  331.     "Change the group of the marked (or next ARG) files."
  332.     (interactive "P")
  333. !   (if (memq system-type '(ms-dos windows-nt))
  334.         (error "chgrp not supported on this system."))
  335.     (dired-do-chxxx "Group" "chgrp" 'chgrp arg))
  336.   
  337. --- 119,125 ----
  338.   (defun dired-do-chgrp (&optional arg)
  339.     "Change the group of the marked (or next ARG) files."
  340.     (interactive "P")
  341. !   (if (memq system-type '(ms-dos windows-nt emx))
  342.         (error "chgrp not supported on this system."))
  343.     (dired-do-chxxx "Group" "chgrp" 'chgrp arg))
  344.   
  345. ***************
  346. *** 125,131 ****
  347.   (defun dired-do-chown (&optional arg)
  348.     "Change the owner of the marked (or next ARG) files."
  349.     (interactive "P")
  350. !   (if (memq system-type '(ms-dos windows-nt))
  351.         (error "chown not supported on this system."))
  352.     (dired-do-chxxx "Owner" dired-chown-program 'chown arg))
  353.   
  354. --- 127,133 ----
  355.   (defun dired-do-chown (&optional arg)
  356.     "Change the owner of the marked (or next ARG) files."
  357.     (interactive "P")
  358. !   (if (memq system-type '(ms-dos windows-nt emx))
  359.         (error "chown not supported on this system."))
  360.     (dired-do-chxxx "Owner" dired-chown-program 'chown arg))
  361.   
  362. diff -c emacs-19\lisp\facemenu.el:1.1.1.13 emacs-19\lisp\facemenu.el:1.17
  363. *** emacs-19\lisp\facemenu.el:1.1.1.13    Sun Aug 18 23:22:14 1996
  364. --- emacs-19\lisp\facemenu.el    Sun Aug 18 23:22:14 1996
  365. ***************
  366. *** 1,6 ****
  367. --- 1,7 ----
  368.   ;;; facemenu.el --- create a face menu for interactively adding fonts to text
  369.   
  370.   ;; Copyright (c) 1994, 1995, 1996 Free Software Foundation, Inc.
  371. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  372.   
  373.   ;; Author: Boris Goldowsky <boris@gnu.ai.mit.edu>
  374.   ;; Keywords: faces
  375. ***************
  376. *** 491,497 ****
  377.   color names mean.  It returns nil if the colors differ or if it can't
  378.   determine the correct answer."
  379.     (cond ((equal a b) t)
  380. !     ((and (or (eq window-system 'x) (eq window-system 'win32))
  381.             (equal (x-color-values a) (x-color-values b))))
  382.       ((eq window-system 'pc)
  383.        (and (x-color-defined-p a) (x-color-defined-p b)
  384. --- 492,498 ----
  385.   color names mean.  It returns nil if the colors differ or if it can't
  386.   determine the correct answer."
  387.     (cond ((equal a b) t)
  388. !     ((and (memq window-system '(x win32 pm))
  389.             (equal (x-color-values a) (x-color-values b))))
  390.       ((eq window-system 'pc)
  391.        (and (x-color-defined-p a) (x-color-defined-p b)
  392. diff -c emacs-19\lisp\faces.el:1.1.1.31 emacs-19\lisp\faces.el:1.47
  393. *** emacs-19\lisp\faces.el:1.1.1.31    Sun Aug 18 23:22:14 1996
  394. --- emacs-19\lisp\faces.el    Sun Aug 18 23:22:14 1996
  395. ***************
  396. *** 1,6 ****
  397. --- 1,7 ----
  398.   ;;; faces.el --- Lisp interface to the c "face" structure
  399.   
  400.   ;; Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
  401. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  402.   
  403.   ;; This file is part of GNU Emacs.
  404.   
  405. ***************
  406. *** 365,371 ****
  407.           (setq frames (cdr frames)))
  408.         (setq global-face-data (cons (cons name face) global-face-data)))
  409.       ;; when making a face after frames already exist
  410. !     (if (or (eq window-system 'x) (eq window-system 'win32))
  411.           (make-face-x-resource-internal face))
  412.       ;; add to menu
  413.       (if (fboundp 'facemenu-add-new-face)
  414. --- 366,372 ----
  415.           (setq frames (cdr frames)))
  416.         (setq global-face-data (cons (cons name face) global-face-data)))
  417.       ;; when making a face after frames already exist
  418. !     (if (memq window-system '(x win32 pm))
  419.           (make-face-x-resource-internal face))
  420.       ;; add to menu
  421.       (if (fboundp 'facemenu-add-new-face)
  422. ***************
  423. *** 379,385 ****
  424.     (cond ((null frame)
  425.        (let ((frames (frame-list)))
  426.          (while frames
  427. !          (if (or (eq (framep (car frames)) 'x) (eq (framep (car frames)) 'win32))
  428.            (make-face-x-resource-internal (face-name face)
  429.                           (car frames) set-anyway))
  430.            (setq frames (cdr frames)))))
  431. --- 380,386 ----
  432.     (cond ((null frame)
  433.        (let ((frames (frame-list)))
  434.          (while frames
  435. !          (if (memq (framep (car frames)) '(x win32 pm))
  436.            (make-face-x-resource-internal (face-name face)
  437.                           (car frames) set-anyway))
  438.            (setq frames (cdr frames)))))
  439. ***************
  440. *** 1259,1265 ****
  441.         (setq colors (cdr colors)))))))
  442.   
  443.   ;; If we are already using x-window frames, initialize faces for them.
  444. ! (if (or (eq (framep (selected-frame)) 'x) (eq (framep (selected-frame)) 'win32))
  445.       (face-initialize))
  446.   
  447.   (provide 'faces)
  448. --- 1260,1266 ----
  449.         (setq colors (cdr colors)))))))
  450.   
  451.   ;; If we are already using x-window frames, initialize faces for them.
  452. ! (if (memq (framep (selected-frame)) '(x win32 pm))
  453.       (face-initialize))
  454.   
  455.   (provide 'faces)
  456. diff -c emacs-19\lisp\files.el:1.1.1.40 emacs-19\lisp\files.el:1.52
  457. *** emacs-19\lisp\files.el:1.1.1.40    Sun Aug 18 23:22:16 1996
  458. --- emacs-19\lisp\files.el    Sun Aug 18 23:22:16 1996
  459. ***************
  460. *** 1,5 ****
  461. --- 1,7 ----
  462.   ;;; files.el --- file input and output commands for Emacs
  463.   
  464. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  465.   ;; Copyright (C) 1985, 86, 87, 92, 93,
  466.   ;;         94, 95, 1996 Free Software Foundation, Inc.
  467.   
  468. ***************
  469. *** 659,666 ****
  470.                  (= (aref filename 0) ?/)))
  471.            ;; MS-DOS root directories can come with a drive letter;
  472.            ;; Novell Netware allows drive letters beyond `Z:'.
  473. !          (not (and (or (eq system-type 'ms-dos)
  474. !                (eq system-type 'windows-nt))
  475.                  (save-match-data
  476.                (string-match "^[a-zA-`]:/$" filename)))))
  477.       (setq filename
  478. --- 661,667 ----
  479.                  (= (aref filename 0) ?/)))
  480.            ;; MS-DOS root directories can come with a drive letter;
  481.            ;; Novell Netware allows drive letters beyond `Z:'.
  482. !          (not (and (memq system-type '(ms-dos windows-nt emx))
  483.                  (save-match-data
  484.                (string-match "^[a-zA-`]:/$" filename)))))
  485.       (setq filename
  486. ***************
  487. *** 821,826 ****
  488. --- 822,833 ----
  489.                             0 (match-beginning 0))))
  490.            (not (member logical find-file-not-true-dirname-list)))
  491.              (setq buffer-file-name buffer-file-truename))
  492. +       ;; On OS/2, we want to store the file's extended attributes in
  493. +       ;; `extended-attributes'.
  494. +       (and (eq system-type 'emx)
  495. +            (condition-case ()
  496. +            (setq extended-attributes (get-ea-list filename))
  497. +          (error nil)))
  498.         (if find-file-visit-truename
  499.             (setq buffer-file-name
  500.               (setq filename
  501. ***************
  502. *** 1896,1901 ****
  503. --- 1903,1913 ----
  504.         ;; If the auto-save file was recent before this command,
  505.         ;; delete it now.
  506.         (delete-auto-save-file-if-necessary recent-save)
  507. +       ;; Write extended attributes
  508. +       (and (eq system-type 'emx)
  509. +            (condition-case ()
  510. +            (put-ea-list buffer-file-name extended-attributes t t)
  511. +          (error nil)))
  512.         ;; Support VC `implicit' locking.
  513.         (vc-after-save)
  514.         (run-hooks 'after-save-hook))
  515. diff -c emacs-19\lisp\hexl.el:1.1.1.21 emacs-19\lisp\hexl.el:1.24
  516. *** emacs-19\lisp\hexl.el:1.1.1.21    Sun Aug 18 23:22:18 1996
  517. --- emacs-19\lisp\hexl.el    Sun Aug 18 23:22:18 1996
  518. ***************
  519. *** 1,5 ****
  520. --- 1,7 ----
  521.   ;;; hexl.el --- edit a file in a hex dump format using the hexl filter.
  522.   
  523. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  524.   ;; Copyright (C) 1989, 1994 Free Software Foundation, Inc.
  525.   
  526.   ;; Author: Keith Gabryelski <ag@wheaties.ai.mit.edu>
  527. ***************
  528. *** 256,262 ****
  529.     "Edit file FILENAME in hexl-mode.
  530.   Switch to a buffer visiting file FILENAME, creating one in none exists."
  531.     (interactive "fFilename: ")
  532. !   (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
  533.         (find-file-binary filename)
  534.       (find-file filename))
  535.     (if (not (eq major-mode 'hexl-mode))
  536. --- 258,264 ----
  537.     "Edit file FILENAME in hexl-mode.
  538.   Switch to a buffer visiting file FILENAME, creating one in none exists."
  539.     (interactive "fFilename: ")
  540. !   (if (memq system-type '(ms-dos windows-nt emx))
  541.         (find-file-binary filename)
  542.       (find-file filename))
  543.     (if (not (eq major-mode 'hexl-mode))
  544. diff -c emacs-19\lisp\hippie-exp.el:1.1.1.7 emacs-19\lisp\hippie-exp.el:1.2
  545. *** emacs-19\lisp\hippie-exp.el:1.1.1.7    Sun Aug 18 23:22:18 1996
  546. --- emacs-19\lisp\hippie-exp.el    Sun Aug 18 23:22:18 1996
  547. ***************
  548. *** 1,5 ****
  549. --- 1,7 ----
  550.   ;;; hippie-exp.el --- expand text trying various ways to find its expansion.
  551.   
  552. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  553.   ;; Copyright (C) 1992 Free Software Foundation, Inc.
  554.   
  555.   ;; Author: Anders Holst <aho@sans.kth.se>
  556. ***************
  557. *** 445,451 ****
  558.   (defvar he-file-name-chars
  559.     (cond ((memq system-type '(vax-vms axp-vms))
  560.        "-a-zA-Z0-9_/.,~^#$+=:\\[\\]")
  561. !     ((memq system-type '(ms-dos windows-nt))
  562.        "-a-zA-Z0-9_/.,~^#$+=:\\\\")
  563.       (t                ;; More strange file formats ?
  564.        "-a-zA-Z0-9_/.,~^#$+="))
  565. --- 447,453 ----
  566.   (defvar he-file-name-chars
  567.     (cond ((memq system-type '(vax-vms axp-vms))
  568.        "-a-zA-Z0-9_/.,~^#$+=:\\[\\]")
  569. !     ((memq system-type '(ms-dos windows-nt emx))
  570.        "-a-zA-Z0-9_/.,~^#$+=:\\\\")
  571.       (t                ;; More strange file formats ?
  572.        "-a-zA-Z0-9_/.,~^#$+="))
  573. ***************
  574. *** 493,499 ****
  575.             (string= (substring name-part 0 2) "[."))
  576.            (concat (substring dir-part 0 -1) (substring name-part 1))
  577.          (concat dir-part name-part)))
  578. !     ((memq system-type '(ms-dos ms-windows))
  579.        (if (and (string-match "\\\\" dir-part)
  580.             (not (string-match "/" dir-part))
  581.             (= (aref name-part (1- (length name-part))) ?/))
  582. --- 495,501 ----
  583.             (string= (substring name-part 0 2) "[."))
  584.            (concat (substring dir-part 0 -1) (substring name-part 1))
  585.          (concat dir-part name-part)))
  586. !     ((memq system-type '(ms-dos ms-windows emx))
  587.        (if (and (string-match "\\\\" dir-part)
  588.             (not (string-match "/" dir-part))
  589.             (= (aref name-part (1- (length name-part))) ?/))
  590. diff -c emacs-19\lisp\info.el:1.1.1.35 emacs-19\lisp\info.el:1.47
  591. *** emacs-19\lisp\info.el:1.1.1.35    Sun Aug 18 23:22:18 1996
  592. --- emacs-19\lisp\info.el    Sun Aug 18 23:22:18 1996
  593. ***************
  594. *** 1,5 ****
  595. --- 1,7 ----
  596.   ;;; info.el --- info package for Emacs.
  597.   
  598. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  599.   ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
  600.   
  601.   ;; Maintainer: FSF
  602. ***************
  603. *** 76,82 ****
  604.             (not (file-exists-p alternative))
  605.             ;; On DOS/NT, we use movable executables always,
  606.             ;; and we must always find the Info dir at run time.
  607. !           (if (or (eq system-type 'ms-dos) (eq system-type 'windows-nt))
  608.             nil
  609.           ;; Use invocation-directory for Info only if we used it for
  610.           ;; exec-directory also.
  611. --- 78,84 ----
  612.             (not (file-exists-p alternative))
  613.             ;; On DOS/NT, we use movable executables always,
  614.             ;; and we must always find the Info dir at run time.
  615. !           (if (memq system-type '(ms-dos windows-nt emx))
  616.             nil
  617.           ;; Use invocation-directory for Info only if we used it for
  618.           ;; exec-directory also.
  619. ***************
  620. *** 128,148 ****
  621.     "Non-nil if Emacs was started solely as an Info browser.")
  622.   
  623.   (defvar Info-suffix-list
  624. !   (if (eq system-type 'ms-dos)
  625. !       '( (".gz"      . "gunzip")
  626. !      (".z"       . "gunzip")
  627. !      (".inf"     . nil)
  628. !      (""         . nil))
  629. !     '( (".info.Z"  . "uncompress")
  630. !        (".info.Y"  . "unyabba")
  631. !        (".info.gz" . "gunzip")
  632. !        (".info.z"  . "gunzip")
  633. !        (".info"    . nil)
  634. !        (".Z"       . "uncompress")
  635. !        (".Y"       . "unyabba")
  636. !        (".gz"      . "gunzip")
  637. !        (".z"       . "gunzip")
  638. !        (""         . nil)))
  639.     "List of file name suffixes and associated decoding commands.
  640.   Each entry should be (SUFFIX . STRING); the file is given to
  641.   the command as standard input.  If STRING is nil, no decoding is done.
  642. --- 130,164 ----
  643.     "Non-nil if Emacs was started solely as an Info browser.")
  644.   
  645.   (defvar Info-suffix-list
  646. !   (cond ((eq system-type 'ms-dos)
  647. !          '( (".gz"      . "gunzip")
  648. !             (".z"       . "gunzip")
  649. !             (".inf"     . nil)
  650. !             (""         . nil)))
  651. !         ((eq system-type 'emx)
  652. !          '( (".info.Z"  . "gunzip")
  653. !             (".info.gz" . "gunzip")
  654. !             (".info.z"  . "gunzip")
  655. !             (".info"    . nil)
  656. !             (".inf.Z"   . "gunzip")
  657. !             (".inf.gz"  . "gunzip")
  658. !             (".inf.z"   . "gunzip")
  659. !             (".inf"     . nil)
  660. !             (".Z"       . "gunzip")
  661. !             (".z"       . "gunzip")
  662. !             (".gz"      . "gunzip")
  663. !             (""         . nil)))
  664. !         (t
  665. !          '( (".info.Z"  . "uncompress")
  666. !             (".info.Y"  . "unyabba")
  667. !             (".info.gz" . "gunzip")
  668. !             (".info.z"  . "gunzip")
  669. !             (".info"    . nil)
  670. !             (".Z"       . "uncompress")
  671. !             (".Y"       . "unyabba")
  672. !             (".gz"      . "gunzip")
  673. !             (".z"       . "gunzip")
  674. !             (""         . nil))))
  675.     "List of file name suffixes and associated decoding commands.
  676.   Each entry should be (SUFFIX . STRING); the file is given to
  677.   the command as standard input.  If STRING is nil, no decoding is done.
  678. ***************
  679. *** 1615,1621 ****
  680.     (make-local-variable 'Info-tag-table-marker)
  681.     (make-local-variable 'Info-history)
  682.     (make-local-variable 'Info-index-alternatives)
  683. !   (if (memq (framep (selected-frame)) '(x pc))
  684.         (progn
  685.       (make-face 'info-node)
  686.       (make-face 'info-menu-5)
  687. --- 1631,1637 ----
  688.     (make-local-variable 'Info-tag-table-marker)
  689.     (make-local-variable 'Info-history)
  690.     (make-local-variable 'Info-index-alternatives)
  691. !   (if (memq (framep (selected-frame)) '(x pc pm))
  692.         (progn
  693.       (make-face 'info-node)
  694.       (make-face 'info-menu-5)
  695. diff -c emacs-19\lisp\jka-compr.el:1.1.1.13 emacs-19\lisp\jka-compr.el:1.8
  696. *** emacs-19\lisp\jka-compr.el:1.1.1.13    Sun Aug 18 23:22:18 1996
  697. --- emacs-19\lisp\jka-compr.el    Sun Aug 18 23:22:18 1996
  698. ***************
  699. *** 1,6 ****
  700. --- 1,7 ----
  701.   ;;; jka-compr.el --- reading/writing/loading compressed files
  702.   
  703.   ;; Copyright (C) 1993, 1994  Free Software Foundation, Inc.
  704. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  705.   
  706.   ;; Author: jka@ece.cmu.edu (Jay K. Adams)
  707.   ;; Keywords: data
  708. ***************
  709. *** 467,472 ****
  710. --- 468,474 ----
  711.             (notfound nil)
  712.             (local-copy
  713.              (jka-compr-run-real-handler 'file-local-copy (list filename)))
  714. +           (binary-process-output binary-process-output)
  715.             local-file
  716.             size start)
  717.   
  718. ***************
  719. *** 475,480 ****
  720. --- 477,494 ----
  721.         (and
  722.          visit
  723.          (setq buffer-file-name filename))
  724. +       (and (eq system-type 'emx)
  725. +            visit
  726. +            (emx-binary-mode-p
  727. +         (if (jka-compr-info-strip-extension info)
  728. +             (save-match-data
  729. +               (substring filename 0
  730. +                  (string-match (jka-compr-info-regexp info)
  731. +                            filename)))
  732. +           filename))
  733. +            (setq binary-process-output t
  734. +              emx-binary-mode t))
  735.   
  736.         (unwind-protect        ; to make sure local-copy gets deleted
  737.   
  738. diff -c emacs-19\lisp\loadup.el:1.1.1.16 emacs-19\lisp\loadup.el:1.34
  739. *** emacs-19\lisp\loadup.el:1.1.1.16    Sun Aug 18 23:22:24 1996
  740. --- emacs-19\lisp\loadup.el    Sun Aug 18 23:22:24 1996
  741. ***************
  742. *** 1,5 ****
  743. --- 1,7 ----
  744.   ;;; loadup.el --- load up standardly loaded Lisp files for Emacs.
  745.   
  746. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  747.   ;; Copyright (C) 1985, 1986, 1992, 1994 Free Software Foundation, Inc.
  748.   
  749.   ;; Maintainer: FSF
  750. ***************
  751. *** 124,129 ****
  752. --- 126,135 ----
  753.         (garbage-collect)
  754.         (load "disp-table") ; needed to setup ibm-pc char set, see internal.el
  755.         (garbage-collect)))
  756. + (if (eq system-type 'emx)
  757. +     (progn
  758. +       (garbage-collect)
  759. +       (load "emx-patch")))
  760.   (if (fboundp 'atan)    ; preload some constants and 
  761.       (progn        ; floating pt. functions if 
  762.         (garbage-collect)    ; we have float support.
  763. ***************
  764. *** 152,157 ****
  765. --- 158,166 ----
  766.   ;; based on the executables that now exist.
  767.   (if (and (or (equal (nth 3 command-line-args) "dump")
  768.            (equal (nth 4 command-line-args) "dump"))
  769. +      (not (and (eq system-type 'emx)
  770. +            (setq emacs-version (concat emacs-version "."
  771. +                            emx-emacs-version))))
  772.        (not (eq system-type 'ms-dos)))
  773.       (let* ((base (concat "emacs-" emacs-version "."))
  774.          (files (file-name-all-completions base default-directory))
  775. ***************
  776. *** 177,183 ****
  777.       (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  778.                  "-"
  779.                  (substring name (match-end 0)))))
  780. !       (if (memq system-type '(ms-dos windows-nt))
  781.         (setq name (expand-file-name
  782.                 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
  783.       (setq name (concat (expand-file-name "../etc/DOC-") name))
  784. --- 186,192 ----
  785.       (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  786.                  "-"
  787.                  (substring name (match-end 0)))))
  788. !       (if (memq system-type '(ms-dos windows-nt emx))
  789.         (setq name (expand-file-name
  790.                 (if (fboundp 'x-create-frame) "DOC-X" "DOC") "../etc"))
  791.       (setq name (concat (expand-file-name "../etc/DOC-") name))
  792. ***************
  793. *** 212,218 ****
  794.                    (substring name (match-end 0)))))
  795.       (if (eq system-type 'ms-dos)
  796.           (message "Dumping under the name emacs")
  797. !       (message "Dumping under names emacs and %s" name)))
  798.         (condition-case ()
  799.         (delete-file "emacs")
  800.       (file-error nil))
  801. --- 221,231 ----
  802.                    (substring name (match-end 0)))))
  803.       (if (eq system-type 'ms-dos)
  804.           (message "Dumping under the name emacs")
  805. !       (if (eq system-type 'emx)
  806. !           (message "Dumping under the name %s"
  807. !                (if (fboundp 'x-create-frame)
  808. !                "emacsx" "emacs"))
  809. !         (message "Dumping under names emacs and %s" name))))
  810.         (condition-case ()
  811.         (delete-file "emacs")
  812.       (file-error nil))
  813. ***************
  814. *** 220,229 ****
  815.         ;; confused people installing Emacs (they'd install the file
  816.         ;; under the name `xemacs'), and it's inconsistent with every
  817.         ;; other GNU product's build process.
  818. !       (dump-emacs "emacs" "temacs")
  819.         (message "%d pure bytes used" pure-bytes-used)
  820.         ;; Recompute NAME now, so that it isn't set when we dump.
  821. !       (if (not (memq system-type '(ms-dos windows-nt)))
  822.         (let ((name (concat "emacs-" emacs-version)))
  823.           (while (string-match "[^-+_.a-zA-Z0-9]+" name)
  824.             (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  825. --- 233,245 ----
  826.         ;; confused people installing Emacs (they'd install the file
  827.         ;; under the name `xemacs'), and it's inconsistent with every
  828.         ;; other GNU product's build process.
  829. !       (if (and (eq system-type 'emx)
  830. !            (fboundp 'x-create-frame))
  831. !       (dump-emacs "emacsx" "temacsx")
  832. !     (dump-emacs "emacs" "temacs"))
  833.         (message "%d pure bytes used" pure-bytes-used)
  834.         ;; Recompute NAME now, so that it isn't set when we dump.
  835. !       (if (not (memq system-type '(ms-dos windows-nt emx)))
  836.         (let ((name (concat "emacs-" emacs-version)))
  837.           (while (string-match "[^-+_.a-zA-Z0-9]+" name)
  838.             (setq name (concat (downcase (substring name 0 (match-beginning 0)))
  839. diff -c emacs-19\lisp\menu-bar.el:1.1.1.38 emacs-19\lisp\menu-bar.el:1.49
  840. *** emacs-19\lisp\menu-bar.el:1.1.1.38    Sun Aug 18 23:22:24 1996
  841. --- emacs-19\lisp\menu-bar.el    Sun Aug 18 23:22:24 1996
  842. ***************
  843. *** 1,6 ****
  844. --- 1,7 ----
  845.   ;;; menu-bar.el --- define a default menu bar.
  846.   
  847.   ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
  848. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  849.   
  850.   ;; Author: RMS
  851.   ;; Keywords: internal
  852. ***************
  853. *** 449,455 ****
  854.   
  855.   (defun menu-bar-update-buffers-1 (elt)
  856.     (cons (format
  857. !      (format "%%%ds  %%s%%s  %%s" menu-bar-update-buffers-maxbuf)
  858.        (cdr elt)
  859.        (if (buffer-modified-p (car elt))
  860.            "*" " ")
  861. --- 450,458 ----
  862.   
  863.   (defun menu-bar-update-buffers-1 (elt)
  864.     (cons (format
  865. !          (if (eq window-system 'pm)
  866. !              "%s\t%s%s  %s"
  867. !            (format "%%%ds  %%s%%s  %%s" menu-bar-update-buffers-maxbuf))
  868.        (cdr elt)
  869.        (if (buffer-modified-p (car elt))
  870.            "*" " ")
  871. ***************
  872. *** 528,533 ****
  873. --- 531,538 ----
  874.                   (setq maxlen (length (car (car alist))))))
  875.                (setq tail (cdr tail)))
  876.                  (setq alist (nreverse alist))
  877. +                (if (eq window-system 'pm)
  878. +               (setq maxlen 0))
  879.                  ;; Make the menu item for list-buffers
  880.                  ;; or reuse the one we already have.
  881.                  ;; The advantage in reusing one
  882. diff -c emacs-19\lisp\mouse.el:1.1.1.37 emacs-19\lisp\mouse.el:1.20
  883. *** emacs-19\lisp\mouse.el:1.1.1.37    Sun Aug 18 23:22:24 1996
  884. --- emacs-19\lisp\mouse.el    Sun Aug 18 23:22:24 1996
  885. ***************
  886. *** 2,7 ****
  887. --- 2,9 ----
  888.   
  889.   ;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
  890.   
  891. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  892.   ;; Maintainer: FSF
  893.   ;; Keywords: hardware
  894.   
  895. ***************
  896. *** 402,410 ****
  897.       ;; If mark is highlighted, no need to bounce the cursor.
  898.       ;; On X, we highlight while dragging, thus once again no need to bounce.
  899.       (or transient-mark-mode
  900. !     (eq (framep (selected-frame)) 'x)
  901. !     (eq (framep (selected-frame)) 'pc)
  902. !     (eq (framep (selected-frame)) 'win32)
  903.       (sit-for 1))
  904.       (push-mark)
  905.       (set-mark (point))
  906. --- 404,410 ----
  907.       ;; If mark is highlighted, no need to bounce the cursor.
  908.       ;; On X, we highlight while dragging, thus once again no need to bounce.
  909.       (or transient-mark-mode
  910. !     (memq (framep (selected-frame)) '(x pc win32 pm))
  911.       (sit-for 1))
  912.       (push-mark)
  913.       (set-mark (point))
  914. diff -c emacs-19\lisp\server.el:1.1.1.20 emacs-19\lisp\server.el:1.30
  915. *** emacs-19\lisp\server.el:1.1.1.20    Sun Aug 18 23:22:26 1996
  916. --- emacs-19\lisp\server.el    Sun Aug 18 23:22:26 1996
  917. ***************
  918. *** 2,7 ****
  919. --- 2,9 ----
  920.   
  921.   ;; Copyright (C) 1986, 1987, 1992, 1994, 1995 Free Software Foundation, Inc.
  922.   
  923. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  924.   ;; Author: William Sommerfeld <wesommer@athena.mit.edu>
  925.   ;; Keywords: processes
  926.   
  927. ***************
  928. *** 77,82 ****
  929. --- 79,87 ----
  930.   (defvar server-program (expand-file-name "emacsserver" exec-directory)
  931.     "*The program to use as the edit server.")
  932.   
  933. + (defvar server-request-hook nil
  934. +   "*List of hooks to call when processing a request for the Emacs server.")
  935.   (defvar server-visit-hook nil
  936.     "*List of hooks to call when visiting a file for the Emacs server.")
  937.   
  938. ***************
  939. *** 211,223 ****
  940.                 (cons (list arg lineno)
  941.                   files))
  942.               (setq lineno 1))))
  943. !           (server-visit-files files client)
  944. !           ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
  945. !           (setq server-clients (cons client server-clients))
  946. !           (server-switch-buffer (nth 1 client))
  947. !           (run-hooks 'server-switch-hook)
  948. !           (message (substitute-command-keys
  949. !             "When done with a buffer, type \\[server-edit]")))))))
  950.     ;; Save for later any partial line that remains.
  951.     (setq server-previous-string string))
  952.   
  953. --- 216,231 ----
  954.                 (cons (list arg lineno)
  955.                   files))
  956.               (setq lineno 1))))
  957. !           (run-hooks 'server-request-hook)
  958. !           (if (null files)
  959. !           nil
  960. !         (server-visit-files files client)
  961. !         ;; CLIENT is now a list (CLIENTNUM BUFFERS...)
  962. !         (setq server-clients (cons client server-clients))
  963. !         (server-switch-buffer (nth 1 client))
  964. !         (run-hooks 'server-switch-hook)
  965. !         (message (substitute-command-keys
  966. !               "When done with a buffer, type \\[server-edit]."))))))))
  967.     ;; Save for later any partial line that remains.
  968.     (setq server-previous-string string))
  969.   
  970. diff -c emacs-19\lisp\startup.el:1.1.1.32 emacs-19\lisp\startup.el:1.28
  971. *** emacs-19\lisp\startup.el:1.1.1.32    Sun Aug 18 23:22:26 1996
  972. --- emacs-19\lisp\startup.el    Sun Aug 18 23:22:26 1996
  973. ***************
  974. *** 1,5 ****
  975. --- 1,7 ----
  976.   ;;; startup.el --- process Emacs shell arguments
  977.   
  978. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  979.   ;; Copyright (C) 1985, 86, 92, 94, 95, 1996 Free Software Foundation, Inc.
  980.   
  981.   ;; Maintainer: FSF
  982. ***************
  983. *** 378,384 ****
  984.       (and window-setup-hook
  985.            (run-hooks 'window-setup-hook))
  986.       (or menubar-bindings-done
  987. !         (if (or (eq window-system 'x) (eq window-system 'win32))
  988.           (precompute-menubar-bindings)))))))
  989.   
  990.   ;; Precompute the keyboard equivalents in the menu bar items.
  991. --- 380,386 ----
  992.       (and window-setup-hook
  993.            (run-hooks 'window-setup-hook))
  994.       (or menubar-bindings-done
  995. !         (if (memq window-system '(x win32 pm))
  996.           (precompute-menubar-bindings)))))))
  997.   
  998.   ;; Precompute the keyboard equivalents in the menu bar items.
  999. ***************
  1000. *** 535,541 ****
  1001.     (if (fboundp 'frame-initialize)
  1002.         (frame-initialize))
  1003.     ;; If frame was created with a menu bar, set menu-bar-mode on.
  1004. !   (if (or (not (or (eq window-system 'x) (eq window-system 'win32)))
  1005.         (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
  1006.         (menu-bar-mode t))
  1007.   
  1008. --- 537,543 ----
  1009.     (if (fboundp 'frame-initialize)
  1010.         (frame-initialize))
  1011.     ;; If frame was created with a menu bar, set menu-bar-mode on.
  1012. !   (if (or (not (memq window-system '(x win32 pm)))
  1013.         (> (cdr (assq 'menu-bar-lines (frame-parameters))) 0))
  1014.         (menu-bar-mode t))
  1015.   
  1016. ***************
  1017. *** 687,693 ****
  1018.            (setq window-setup-hook nil)
  1019.            ;; Do this now to avoid an annoying delay if the user
  1020.            ;; clicks the menu bar during the sit-for.
  1021. !          (if (or (eq window-system 'x) (eq window-system 'win32))
  1022.            (precompute-menubar-bindings))
  1023.            (setq menubar-bindings-done t)
  1024.            (unwind-protect
  1025. --- 689,695 ----
  1026.            (setq window-setup-hook nil)
  1027.            ;; Do this now to avoid an annoying delay if the user
  1028.            ;; clicks the menu bar during the sit-for.
  1029. !          (if (memq window-system '(x win32 pm))
  1030.            (precompute-menubar-bindings))
  1031.            (setq menubar-bindings-done t)
  1032.            (unwind-protect
  1033. diff -c emacs-19\lisp\subr.el:1.1.1.33 emacs-19\lisp\subr.el:1.12
  1034. *** emacs-19\lisp\subr.el:1.1.1.33    Sun Aug 18 23:22:28 1996
  1035. --- emacs-19\lisp\subr.el    Sun Aug 18 23:22:28 1996
  1036. ***************
  1037. *** 1,6 ****
  1038. --- 1,7 ----
  1039.   ;;; subr.el --- basic lisp subroutines for Emacs
  1040.   
  1041.   ;; Copyright (C) 1985, 1986, 1992, 1994, 1995 Free Software Foundation, Inc.
  1042. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  1043.   
  1044.   ;; This file is part of GNU Emacs.
  1045.   
  1046. ***************
  1047. *** 771,777 ****
  1048.     (if (eq system-type 'ms-dos)
  1049.         ;; MS-DOS shells don't have quoting, so don't do any.
  1050.         argument
  1051. !     (if (eq system-type 'windows-nt)
  1052.       (concat "\"" argument "\"")
  1053.         ;; Quote everything except POSIX filename characters.
  1054.         ;; This should be safe enough even for really weird shells.
  1055. --- 772,778 ----
  1056.     (if (eq system-type 'ms-dos)
  1057.         ;; MS-DOS shells don't have quoting, so don't do any.
  1058.         argument
  1059. !     (if (memq system-type '(windows-nt emx))
  1060.       (concat "\"" argument "\"")
  1061.         ;; Quote everything except POSIX filename characters.
  1062.         ;; This should be safe enough even for really weird shells.
  1063. diff -c emacs-19\lisp\tar-mode.el:1.1.1.22 emacs-19\lisp\tar-mode.el:1.11
  1064. *** emacs-19\lisp\tar-mode.el:1.1.1.22    Sun Aug 18 23:22:28 1996
  1065. --- emacs-19\lisp\tar-mode.el    Sun Aug 18 23:22:28 1996
  1066. ***************
  1067. *** 1,6 ****
  1068. --- 1,7 ----
  1069.   ;;; tar-mode.el --- simple editing of tar files from GNU emacs
  1070.   
  1071.   ;; Copyright (C) 1990, 1991, 1993, 1994, 1995 Free Software Foundation, Inc.
  1072. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  1073.   
  1074.   ;; Author: Jamie Zawinski <jwz@lucid.com>
  1075.   ;; Created: 04 Apr 1990
  1076. ***************
  1077. *** 725,730 ****
  1078. --- 726,741 ----
  1079.           (set-buffer buffer)
  1080.           (insert-buffer-substring tar-buffer start end)
  1081.           (goto-char 0)
  1082. +         (if (eq system-type 'emx)
  1083. +             (progn
  1084. +               (setq emx-binary-mode (emx-binary-mode-p name))
  1085. +               (or emx-binary-mode
  1086. +               (save-excursion
  1087. +                 (if (not (search-forward "\r\n" nil t))
  1088. +                 (setq emx-binary-mode t)
  1089. +                   (replace-match "\n" t t)
  1090. +                   (while (search-forward "\r\n" nil t)
  1091. +                 (replace-match "\n" t t)))))))
  1092.           (setq buffer-file-name
  1093.                 (expand-file-name (concat tarname ":" name)))
  1094.           (setq buffer-file-truename
  1095. ***************
  1096. *** 1071,1077 ****
  1097.     (save-excursion
  1098.     (let ((subfile (current-buffer))
  1099.       (subfile-size (buffer-size))
  1100. !     (descriptor tar-superior-descriptor))
  1101.       (set-buffer tar-superior-buffer)
  1102.       (let* ((tokens (tar-desc-tokens descriptor))
  1103.          (start (tar-desc-data-start descriptor))
  1104. --- 1082,1091 ----
  1105.     (save-excursion
  1106.     (let ((subfile (current-buffer))
  1107.       (subfile-size (buffer-size))
  1108. !     (descriptor tar-superior-descriptor)
  1109. !     binary)
  1110. !     (if (eq system-type 'emx)
  1111. !     (setq binary emx-binary-mode))
  1112.       (set-buffer tar-superior-buffer)
  1113.       (let* ((tokens (tar-desc-tokens descriptor))
  1114.          (start (tar-desc-data-start descriptor))
  1115. ***************
  1116. *** 1092,1097 ****
  1117. --- 1106,1120 ----
  1118.         ;; insert the new data...
  1119.         (goto-char data-start)
  1120.         (insert-buffer subfile)
  1121. +       (and (eq system-type 'emx)
  1122. +            (not binary)
  1123. +            (not (emx-binary-mode-p name))
  1124. +            (save-excursion
  1125. +          (let ((end (make-marker)))
  1126. +            (set-marker end (+ data-start subfile-size))
  1127. +            (while (search-forward "\n" end t)
  1128. +              (replace-match "\r\n" t t))
  1129. +            (setq subfile-size (- end data-start)))))
  1130.         ;;
  1131.         ;; pad the new data out to a multiple of 512...
  1132.         (let ((subfile-size-pad (ash (ash (+ subfile-size 511) -9) 9)))
  1133. diff -c emacs-19\lisp\vc.el:1.1.1.34 emacs-19\lisp\vc.el:1.33
  1134. *** emacs-19\lisp\vc.el:1.1.1.34    Sun Aug 18 23:22:30 1996
  1135. --- emacs-19\lisp\vc.el    Sun Aug 18 23:22:30 1996
  1136. ***************
  1137. *** 1,5 ****
  1138. --- 1,7 ----
  1139.   ;;; vc.el --- drive a version-control system from within Emacs
  1140.   
  1141. + ;; Modified for emx by Eberhard Mattes, Aug 1996
  1142.   ;; Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
  1143.   
  1144.   ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
  1145. ***************
  1146. *** 194,199 ****
  1147. --- 196,203 ----
  1148.   (defvar vc-comment-ring-index nil)
  1149.   (defvar vc-last-comment-match nil)
  1150.   
  1151. + (defvar vc-exec-suffix (if (eq system-type 'emx) ".exe"))
  1152.   ;; Back-portability to Emacs 18
  1153.   
  1154.   (defun file-executable-p-18 (f)
  1155. ***************
  1156. *** 369,375 ****
  1157.        (function 
  1158.         (lambda (s)
  1159.           (if s
  1160. !         (let ((full (concat s "/" name)))
  1161.             (if (file-executable-p full)
  1162.                 (progn
  1163.               (setq vc-binary-assoc
  1164. --- 373,379 ----
  1165.        (function 
  1166.         (lambda (s)
  1167.           (if s
  1168. !         (let ((full (concat s "/" name vc-exec-suffix)))
  1169.             (if (file-executable-p full)
  1170.                 (progn
  1171.               (setq vc-binary-assoc
  1172. diff -c emacs-19\src\Makefile.in:1.1.1.9 emacs-19\src\Makefile.in:1.16
  1173. *** emacs-19\src\Makefile.in:1.1.1.9    Sun Aug 18 23:22:42 1996
  1174. --- emacs-19\src\Makefile.in    Sun Aug 18 23:22:42 1996
  1175. ***************
  1176. *** 18,23 ****
  1177. --- 18,25 ----
  1178.   # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1179.   # Boston, MA 02111-1307, USA.
  1180.   
  1181. + # Modified for emx by Eberhard Mattes, Aug 1996
  1182.   # Here are the things that we expect ../configure to edit.
  1183.   srcdir=@srcdir@
  1184.   VPATH=@srcdir@
  1185. ***************
  1186. *** 289,295 ****
  1187. --- 291,301 ----
  1188.   #ifdef HAVE_MENUS
  1189.   
  1190.   /* Include xmenu.o in the list of X object files.  */
  1191. + #ifdef HAVE_PM
  1192. + XOBJ= pmterm.o pmfns.o pmselect.o pmfaces.o xfaces.o
  1193. + #else
  1194.   XOBJ= xterm.o xfns.o xfaces.o xselect.o xrdb.o
  1195. + #endif
  1196.   
  1197.   /* The X Menu stuff is present in the X10 distribution, but missing
  1198.      from X11.  If we have X10, just use the installed library;
  1199. ***************
  1200. *** 488,493 ****
  1201. --- 494,505 ----
  1202.   #define MSDOS_OBJ
  1203.   #endif
  1204.   
  1205. + #ifdef EMX
  1206. + #define EMX_OBJ emxdep.o
  1207. + #else
  1208. + #define EMX_OBJ
  1209. + #endif
  1210.   
  1211.   /* lastfile must follow all files
  1212.      whose initialized data areas should be dumped as pure by dump-emacs.  */
  1213. ***************
  1214. *** 502,514 ****
  1215.       abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
  1216.       process.o callproc.o \
  1217.       region-cache.o \
  1218. !     doprnt.o strftime.o MKTIME_OBJ GETLOADAVG_OBJ MSDOS_OBJ
  1219.   
  1220.   /* Object files used on some machine or other.
  1221.      These go in the DOC file on all machines
  1222.      in case they are needed there.  */
  1223.   SOME_MACHINE_OBJECTS = sunfns.o dosfns.o msdos.o intervals.o textprop.o \
  1224.     xterm.o xfns.o xfaces.o xmenu.o xselect.o xrdb.o
  1225.   
  1226.   
  1227.   #ifdef TERMINFO
  1228. --- 514,536 ----
  1229.       abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
  1230.       process.o callproc.o \
  1231.       region-cache.o \
  1232. !     doprnt.o strftime.o MKTIME_OBJ GETLOADAVG_OBJ MSDOS_OBJ EMX_OBJ
  1233.   
  1234.   /* Object files used on some machine or other.
  1235.      These go in the DOC file on all machines
  1236.      in case they are needed there.  */
  1237. + #ifdef EMX
  1238. + #ifdef HAVE_PM
  1239. + SOME_MACHINE_OBJECTS = emxdep.o intervals.o textprop.o \
  1240. +   pmfaces.o pmfns.o pmselect.o pmterm.o xfaces.o xmenu.o
  1241. + #else
  1242. + SOME_MACHINE_OBJECTS = emxdep.o intervals.o textprop.o \
  1243. +   xterm.o xfns.o xfaces.o xmenu.o xselect.o xrdb.o
  1244. + #endif
  1245. + #else
  1246.   SOME_MACHINE_OBJECTS = sunfns.o dosfns.o msdos.o intervals.o textprop.o \
  1247.     xterm.o xfns.o xfaces.o xmenu.o xselect.o xrdb.o
  1248. + #endif
  1249.   
  1250.   
  1251.   #ifdef TERMINFO
  1252. ***************
  1253. *** 597,602 ****
  1254. --- 619,630 ----
  1255.   #define VMS_SUPPORT
  1256.   #endif
  1257.   
  1258. + #ifdef EMX
  1259. + #define EMX_SUPPORT ${lispsource}emx-patch.elc ${lispsource}emx-funcs.elc ${lispsource}emx-keys.el
  1260. + #else /* not EMX */
  1261. + #define EMX_SUPPORT
  1262. + #endif /* not EMX */
  1263.   #ifdef MSDOS
  1264.   #define MSDOS_SUPPORT ${lispsource}ls-lisp.elc ${lispsource}disp-table.elc ${lispsource}dos-fns.elc
  1265.   #else
  1266. ***************
  1267. *** 651,656 ****
  1268. --- 679,685 ----
  1269.       ${lispsource}vc-hooks.elc \
  1270.       ${lispsource}ediff-hook.elc \
  1271.       VMS_SUPPORT \
  1272. +     EMX_SUPPORT \
  1273.       MSDOS_SUPPORT \
  1274.       WINNT_SUPPORT \
  1275.       ${lispsource}window.elc \
  1276. diff -c emacs-19\src\buffer.c:1.1.1.36 emacs-19\src\buffer.c:1.49
  1277. *** emacs-19\src\buffer.c:1.1.1.36    Sun Aug 18 23:22:44 1996
  1278. --- emacs-19\src\buffer.c    Sun Aug 18 23:22:44 1996
  1279. ***************
  1280. *** 19,24 ****
  1281. --- 19,25 ----
  1282.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1283.   Boston, MA 02111-1307, USA.  */
  1284.   
  1285. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1286.   
  1287.   #include <sys/types.h>
  1288.   #include <sys/stat.h>
  1289. ***************
  1290. *** 454,459 ****
  1291. --- 455,464 ----
  1292.   reset_buffer (b)
  1293.        register struct buffer *b;
  1294.   {
  1295. + #ifdef EMX
  1296. +   b->emx_binary_mode = Qnil;
  1297. +   b->extended_attributes = Qnil;
  1298. + #endif /* EMX */
  1299.     b->filename = Qnil;
  1300.     b->file_truename = Qnil;
  1301.     b->directory = (current_buffer) ? current_buffer->directory : Qnil;
  1302. ***************
  1303. *** 3385,3390 ****
  1304. --- 3390,3399 ----
  1305.   #ifdef DOS_NT
  1306.     buffer_defaults.buffer_file_type = Qnil; /* TEXT */
  1307.   #endif
  1308. + #ifdef EMX
  1309. +   buffer_defaults.emx_binary_mode = Qnil;
  1310. +   buffer_defaults.extended_attributes = Qnil;
  1311. + #endif /* EMX */
  1312.     XSETFASTINT (buffer_defaults.fill_column, 70);
  1313.     XSETFASTINT (buffer_defaults.left_margin, 0);
  1314.     buffer_defaults.cache_long_line_scans = Qnil;
  1315. ***************
  1316. *** 3414,3419 ****
  1317. --- 3423,3432 ----
  1318.     XSETINT (buffer_local_flags.file_truename, -1);
  1319.     XSETINT (buffer_local_flags.invisibility_spec, -1);
  1320.     XSETINT (buffer_local_flags.file_format, -1);
  1321. + #ifdef EMX
  1322. +   XSETINT (buffer_local_flags.emx_binary_mode, -1);
  1323. +   XSETINT (buffer_local_flags.extended_attributes, -1);
  1324. + #endif /* EMX */
  1325.   
  1326.     XSETFASTINT (buffer_local_flags.mode_line_format, 1);
  1327.     XSETFASTINT (buffer_local_flags.abbrev_mode, 2);
  1328. ***************
  1329. *** 3474,3479 ****
  1330. --- 3487,3493 ----
  1331.   
  1332.     Fset_buffer (Fget_buffer_create (build_string ("*scratch*")));
  1333.   
  1334. + #ifndef EMX
  1335.     /* If PWD is accurate, use it instead of calling getwd.  This is faster
  1336.        when PWD is right, and may avoid a fatal error.  */
  1337.     if ((pwd = getenv ("PWD")) != 0 && IS_DIRECTORY_SEP (*pwd)
  1338. ***************
  1339. *** 3485,3490 ****
  1340. --- 3499,3509 ----
  1341.       strcpy (buf, pwd);
  1342.     else if (getwd (buf) == 0)
  1343.       fatal ("`getwd' failed: %s\n", buf);
  1344. + #else /* EMX */
  1345. +   if (_getcwd2 (buf, MAXPATHLEN) == 0)
  1346. +     fatal ("`_getcwd2' failed\n");
  1347. +   _nls_strlwr (buf);
  1348. + #endif /* EMX */
  1349.   
  1350.   #ifndef VMS
  1351.     /* Maybe this should really use some standard subroutine
  1352. ***************
  1353. *** 3985,3990 ****
  1354. --- 4004,4022 ----
  1355.     DEFVAR_LISP ("kill-buffer-query-functions", &Vkill_buffer_query_functions,
  1356.       "List of functions called with no args to query before killing a buffer.");
  1357.     Vkill_buffer_query_functions = Qnil;
  1358. + #ifdef EMX
  1359. +   DEFVAR_PER_BUFFER ("emx-binary-mode", ¤t_buffer->emx_binary_mode, Qnil,
  1360. +     "*Non-nil means read and write files in `binary mode'.\n\
  1361. + nil means use `text mode'.  This variable is emx-specific.\n\
  1362. + Automatically becomes buffer-local when set in any fashion.");
  1363. +   DEFVAR_PER_BUFFER ("extended-attributes",
  1364. +                      ¤t_buffer->extended_attributes, Qnil,
  1365. +     "Extended attributes of buffer visited by current buffer.\n\
  1366. + This variable is emx-specific.  Automatically becomes buffer-local\n\
  1367. + when set in any fashion.");
  1368. + #endif /* EMX */
  1369.   
  1370.     defsubr (&Sbuffer_live_p);
  1371.     defsubr (&Sbuffer_list);
  1372. diff -c emacs-19\src\buffer.h:1.1.1.12 emacs-19\src\buffer.h:1.18
  1373. *** emacs-19\src\buffer.h:1.1.1.12    Sun Aug 18 23:22:44 1996
  1374. --- emacs-19\src\buffer.h    Sun Aug 18 23:22:44 1996
  1375. ***************
  1376. *** 18,23 ****
  1377. --- 18,25 ----
  1378.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1379.   Boston, MA 02111-1307, USA.  */
  1380.   
  1381. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1382.   
  1383.   #ifdef USE_TEXT_PROPERTIES
  1384.   #define SET_PT(position) (set_point ((position), current_buffer))
  1385. ***************
  1386. *** 308,313 ****
  1387. --- 310,321 ----
  1388.       /* nil: text, t: binary.
  1389.          This value is meaningful only on certain operating systems.  */
  1390.       Lisp_Object buffer_file_type;
  1391. + #ifdef EMX
  1392. +     /* nil: text mode, t: binary mode.  */
  1393. +     Lisp_Object emx_binary_mode;
  1394. +     /* Extended attributes.  */
  1395. +     Lisp_Object extended_attributes;
  1396. + #endif /* EMX */
  1397.   
  1398.       /* Case table for case-conversion in this buffer.
  1399.          This char-table maps each char into its lower-case version.  */
  1400. diff -c emacs-19\src\callproc.c:1.1.1.27 emacs-19\src\callproc.c:1.52
  1401. *** emacs-19\src\callproc.c:1.1.1.27    Sun Aug 18 23:22:46 1996
  1402. --- emacs-19\src\callproc.c    Sun Aug 18 23:22:46 1996
  1403. ***************
  1404. *** 18,23 ****
  1405. --- 18,24 ----
  1406.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1407.   Boston, MA 02111-1307, USA.  */
  1408.   
  1409. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1410.   
  1411.   #include <signal.h>
  1412.   #include <errno.h>
  1413. ***************
  1414. *** 84,89 ****
  1415. --- 85,97 ----
  1416.   
  1417.   #define max(a, b) ((a) > (b) ? (a) : (b))
  1418.   
  1419. + #ifdef EMX
  1420. + extern Lisp_Object find_program_name_handler ();
  1421. + extern Lisp_Object Qprogram_name_handler_alist;
  1422. + extern Lisp_Object Vprogram_name_handler_alist;
  1423. + static Lisp_Object Qcall_process;
  1424. + #endif /* EMX */
  1425.   #ifdef DOS_NT
  1426.   /* When we are starting external processes we need to know whether they
  1427.      take binary input (no conversion) or text input (\n is converted to
  1428. ***************
  1429. *** 220,225 ****
  1430. --- 228,247 ----
  1431.   #endif
  1432.     CHECK_STRING (args[0], 0);
  1433.   
  1434. + #ifdef EMX
  1435. +   {
  1436. +     Lisp_Object handler;
  1437. +     handler = find_program_name_handler (args[0]);
  1438. +     if (!NILP (handler))
  1439. +       return call3 (handler,
  1440. +                     Fcons (Qcall_process, Flist (3, args + 1)),
  1441. +                     args[0],
  1442. +                     nargs >= 5 ? Flist (nargs - 4, args + 4) : Qnil);
  1443. +   }
  1444. +   check_process_priority ();
  1445. + #endif /* EMX */
  1446.     error_file = Qt;
  1447.   
  1448.   #ifndef subprocesses
  1449. ***************
  1450. *** 363,368 ****
  1451. --- 385,393 ----
  1452.       {
  1453.   #ifndef MSDOS
  1454.         pipe (fd);
  1455. + #ifdef EMX
  1456. +       emx_proc_output_pipe (fd[0]);
  1457. + #endif /* EMX */
  1458.   #endif
  1459.   #if 0
  1460.         /* Replaced by close_process_descs */
  1461. ***************
  1462. *** 450,455 ****
  1463. --- 475,485 ----
  1464.   #ifdef WINDOWSNT
  1465.       pid = child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
  1466.   #else  /* not WINDOWSNT */
  1467. + #ifdef EMX
  1468. +     if (fd[0] >= 0)
  1469. +       fcntl (fd[0], F_SETFD, 1);
  1470. +     pid = emx_child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
  1471. + #else /* not EMX */
  1472.       pid = vfork ();
  1473.   
  1474.       if (pid == 0)
  1475. ***************
  1476. *** 463,468 ****
  1477. --- 493,499 ----
  1478.   #endif /* USG */
  1479.       child_setup (filefd, fd1, fd_error, new_argv, 0, current_dir);
  1480.         }
  1481. + #endif /* not EMX */
  1482.   #endif /* not WINDOWSNT */
  1483.   
  1484.       /* The MSDOS case did this already.  */
  1485. ***************
  1486. *** 483,489 ****
  1487. --- 514,524 ----
  1488.       {
  1489.         if (fd[0] >= 0)
  1490.       close (fd[0]);
  1491. + #ifndef EMX
  1492.         report_file_error ("Doing vfork", Qnil);
  1493. + #else /* EMX */
  1494. +       report_file_error ("Running process", Qnil);
  1495. + #endif
  1496.       }
  1497.   
  1498.     if (INTEGERP (buffer))
  1499. ***************
  1500. *** 600,608 ****
  1501. --- 635,649 ----
  1502.   delete_temp_file (name)
  1503.        Lisp_Object name;
  1504.   {
  1505. + #ifndef EMX
  1506.     /* Use Fdelete_file (indirectly) because that runs a file name handler.
  1507.        We did that when writing the file, so we should do so when deleting.  */
  1508.     internal_delete_file (name);
  1509. + #else /* EMX */
  1510. +   /* TODO: call file name handler, see above. */
  1511. +   if (unlink (XSTRING (name)->data) != 0 && errno == EACCES)
  1512. +     emx_async_delete_add (XSTRING (name)->data);
  1513. + #endif /* EMX */
  1514.   }
  1515.   
  1516.   DEFUN ("call-process-region", Fcall_process_region, Scall_process_region,
  1517. ***************
  1518. *** 635,641 ****
  1519. --- 676,686 ----
  1520.   #ifdef DOS_NT
  1521.     char *tempfile;
  1522.   #else
  1523. + #ifndef EMX
  1524.     char tempfile[20];
  1525. + #else /* EMX */
  1526. +   char tempfile[260];
  1527. + #endif /* EMX */
  1528.   #endif
  1529.     int count = specpdl_ptr - specpdl;
  1530.   #ifdef DOS_NT
  1531. ***************
  1532. *** 661,671 ****
  1533. --- 706,728 ----
  1534.   #endif
  1535.   #else /* not DOS_NT */
  1536.   
  1537. + #ifdef EMX
  1538. +   extern char *tempnam ();
  1539. +   char *t = tempnam ("/tmp", "em");
  1540. +   if (t)
  1541. +     {
  1542. +       strcpy (tempfile, t);
  1543. +       free (t);
  1544. +     }
  1545. +   else
  1546. +     strcpy (tempfile, "/tmp/emXXXXXX");
  1547. + #else /* not EMX */
  1548.   #ifdef VMS
  1549.     strcpy (tempfile, "tmp:emacsXXXXXX.");
  1550.   #else
  1551.     strcpy (tempfile, "/tmp/emacsXXXXXX");
  1552.   #endif
  1553. + #endif /* not EMX */
  1554.   #endif /* not DOS_NT */
  1555.   
  1556.     mktemp (tempfile);
  1557. ***************
  1558. *** 693,698 ****
  1559. --- 750,756 ----
  1560.   }
  1561.   
  1562.   #ifndef VMS /* VMS version is in vmsproc.c.  */
  1563. + #ifndef EMX /* emx version is in emxdep.c */
  1564.   
  1565.   /* This is the last thing run in a newly forked inferior
  1566.      either synchronous or asynchronous.
  1567. ***************
  1568. *** 934,939 ****
  1569. --- 992,999 ----
  1570.       }
  1571.   }
  1572.   
  1573. + #endif /* not EMX */
  1574.   static int
  1575.   getenv_internal (var, varlen, value, valuelen)
  1576.        char *var;
  1577. ***************
  1578. *** 1037,1044 ****
  1579. --- 1097,1109 ----
  1580.       {
  1581.         /* Add to the path the lib-src subdir of the installation dir.  */
  1582.         Lisp_Object tem;
  1583. + #ifdef EMX
  1584. +       tem = Fexpand_file_name (build_string ("bin"),
  1585. +                    Vinstallation_directory);
  1586. + #else /* not EMX */
  1587.         tem = Fexpand_file_name (build_string ("lib-src"),
  1588.                      Vinstallation_directory);
  1589. + #endif /* not EMX */
  1590.         if (NILP (Fmember (tem, Vexec_path)))
  1591.       {
  1592.   #ifndef DOS_NT
  1593. ***************
  1594. *** 1051,1059 ****
  1595. --- 1116,1132 ----
  1596.         /* Maybe use ../etc as well as ../lib-src.  */
  1597.         if (data_dir == 0)
  1598.       {
  1599. + #ifdef EMX
  1600. +       tem = Fexpand_file_name (build_string ("data"),
  1601. +                    Vinstallation_directory);
  1602. + #else /* not EMX */
  1603.         tem = Fexpand_file_name (build_string ("etc"),
  1604.                      Vinstallation_directory);
  1605. + #endif /* not EMX */
  1606.         Vdoc_directory = Ffile_name_as_directory (tem);
  1607. + #ifdef EMX
  1608. +       Vdata_directory = Vdoc_directory;
  1609. + #endif /* EMX */
  1610.       }
  1611.       }
  1612.   
  1613. ***************
  1614. *** 1122,1127 ****
  1615. --- 1195,1204 ----
  1616.   
  1617.   syms_of_callproc ()
  1618.   {
  1619. + #ifdef EMX
  1620. +   Qcall_process = intern ("call-process");
  1621. +   staticpro (&Qcall_process);
  1622. + #endif /* EMX */
  1623.   #ifdef DOS_NT
  1624.     Qbuffer_file_type = intern ("buffer-file-type");
  1625.     staticpro (&Qbuffer_file_type);
  1626. diff -c emacs-19\src\cmds.c:1.1.1.22 emacs-19\src\cmds.c:1.19
  1627. *** emacs-19\src\cmds.c:1.1.1.22    Sun Aug 18 23:22:46 1996
  1628. --- emacs-19\src\cmds.c    Sun Aug 18 23:22:46 1996
  1629. ***************
  1630. *** 18,23 ****
  1631. --- 18,24 ----
  1632.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1633.   Boston, MA 02111-1307, USA.  */
  1634.   
  1635. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1636.   
  1637.   #include <config.h>
  1638.   #include "lisp.h"
  1639. ***************
  1640. *** 422,427 ****
  1641. --- 423,432 ----
  1642.     for (n = 0200; n < 0240; n++)
  1643.       initial_define_key (global_map, n, "self-insert-command");
  1644.   #endif
  1645. + #ifdef EMX
  1646. +   for (n = 0200; n < 0240; n++)
  1647. +     initial_define_key (global_map, n, "self-insert-command");
  1648. + #endif /* EMX */
  1649.     for (n = 0240; n < 0400; n++)
  1650.       initial_define_key (global_map, n, "self-insert-command");
  1651.   
  1652. diff -c emacs-19\src\dired.c:1.1.1.19 emacs-19\src\dired.c:1.30
  1653. *** emacs-19\src\dired.c:1.1.1.19    Sun Aug 18 23:22:46 1996
  1654. --- emacs-19\src\dired.c    Sun Aug 18 23:22:46 1996
  1655. ***************
  1656. *** 18,23 ****
  1657. --- 18,24 ----
  1658.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1659.   Boston, MA 02111-1307, USA.  */
  1660.   
  1661. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1662.   
  1663.   #include <config.h>
  1664.   
  1665. ***************
  1666. *** 368,377 ****
  1667. --- 369,383 ----
  1668.                   XSTRING (file)->size))
  1669.           continue;
  1670.   
  1671. + #ifdef EMX
  1672. +           /* Speed hack. */
  1673. +       directoryp = (dp->d_attr & 0x10);
  1674. + #else /* not EMX */
  1675.             if (file_name_completion_stat (dirname, dp, &st) < 0)
  1676.               continue;
  1677.   
  1678.             directoryp = ((st.st_mode & S_IFMT) == S_IFDIR);
  1679. + #endif /* not EMX */
  1680.         tem = Qnil;
  1681.             if (directoryp)
  1682.           {
  1683. ***************
  1684. *** 646,651 ****
  1685. --- 652,660 ----
  1686.     if (lstat (XSTRING (filename)->data, &s) < 0)
  1687.       return Qnil;
  1688.   
  1689. + #ifdef EMX
  1690. +   s.st_uid = getuid ();
  1691. + #endif /* not EMX */
  1692.     switch (s.st_mode & S_IFMT)
  1693.       {
  1694.       default:
  1695. diff -c emacs-19\src\dispextern.h:1.1.1.10 emacs-19\src\dispextern.h:1.27
  1696. *** emacs-19\src\dispextern.h:1.1.1.10    Sun Aug 18 23:22:46 1996
  1697. --- emacs-19\src\dispextern.h    Sun Aug 18 23:22:46 1996
  1698. ***************
  1699. *** 18,23 ****
  1700. --- 18,25 ----
  1701.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1702.   Boston, MA 02111-1307, USA.  */
  1703.   
  1704. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1705.   #ifndef _DISPEXTERN_H_
  1706.   #define _DISPEXTERN_H_
  1707.   
  1708. ***************
  1709. *** 26,32 ****
  1710. --- 28,39 ----
  1711.   extern int display_completed;
  1712.   
  1713.   #ifdef HAVE_X_WINDOWS
  1714. + #ifndef HAVE_PM
  1715.   #include <X11/Xlib.h>
  1716. + #else /* HAVE_PM */
  1717. + #include "pmlib.h"
  1718. + #endif /* HAVE_PM */
  1719.   #endif
  1720.   
  1721.   #ifdef MSDOS
  1722. diff -c emacs-19\src\dispnew.c:1.1.1.35 emacs-19\src\dispnew.c:1.51
  1723. *** emacs-19\src\dispnew.c:1.1.1.35    Sun Aug 18 23:22:46 1996
  1724. --- emacs-19\src\dispnew.c    Sun Aug 18 23:22:46 1996
  1725. ***************
  1726. *** 18,23 ****
  1727. --- 18,24 ----
  1728.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1729.   Boston, MA 02111-1307, USA.  */
  1730.   
  1731. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1732.   
  1733.   #include <signal.h>
  1734.   
  1735. ***************
  1736. *** 46,54 ****
  1737. --- 47,63 ----
  1738.   #include "syssignal.h"
  1739.   
  1740.   #ifdef HAVE_X_WINDOWS
  1741. + #ifndef HAVE_PM
  1742.   #include "xterm.h"
  1743. + #else /* HAVE_PM */
  1744. + #include "pmterm.h"
  1745. + #endif /* HAVE_PM */
  1746.   #endif    /* HAVE_X_WINDOWS */
  1747.   
  1748. + #ifdef EMX
  1749. + extern void emx_resize_vio (int *pheight, int *pwidth);
  1750. + #endif /* EMX */
  1751.   #ifdef HAVE_NTGUI
  1752.   #include "w32term.h"
  1753.   #endif /* HAVE_NTGUI */
  1754. ***************
  1755. *** 104,109 ****
  1756. --- 113,122 ----
  1757.   
  1758.   int baud_rate;
  1759.   
  1760. + /* Minimum length of a run of matching characters to be skipped in output. */
  1761. + int min_skip_run = 1;
  1762.   /* nil or a symbol naming the window system under which emacs is
  1763.      running ('x is the only current possibility).  */
  1764.   
  1765. ***************
  1766. *** 562,567 ****
  1767. --- 575,589 ----
  1768.   
  1769.   /* Like bcopy except never gets confused by overlap.  */
  1770.   
  1771. + #ifdef EMX
  1772. + void
  1773. + safe_bcopy (from, to, size)
  1774. +      char *from, *to;
  1775. +      int size;
  1776. + {
  1777. +   bcopy (from, to, size);
  1778. + }
  1779. + #else /* not EMX */
  1780.   void
  1781.   safe_bcopy (from, to, size)
  1782.        char *from, *to;
  1783. ***************
  1784. *** 614,619 ****
  1785. --- 636,642 ----
  1786.       }
  1787.       }
  1788.   }     
  1789. + #endif /* not EMX */
  1790.   
  1791.   /* Rotate a vector of SIZE bytes right, by DISTANCE bytes.
  1792.      DISTANCE may be negative.  */
  1793. ***************
  1794. *** 1672,1678 ****
  1795.     /* If there's no i/d char, quickly do the best we can without it.  */
  1796.     if (!char_ins_del_ok)
  1797.       {
  1798. !       int i,j;
  1799.   
  1800.   #if 0
  1801.         if (FRAME_X_P (frame))
  1802. --- 1695,1701 ----
  1803.     /* If there's no i/d char, quickly do the best we can without it.  */
  1804.     if (!char_ins_del_ok)
  1805.       {
  1806. !       int i,j,k,more;
  1807.   
  1808.   #if 0
  1809.         if (FRAME_X_P (frame))
  1810. ***************
  1811. *** 1698,1706 ****
  1812.         if (i >= olen || nbody[i] != obody[i])    /* A non-matching char. */
  1813.           {
  1814.             cursor_to (vpos, i);
  1815. !           for (j = 1; (i + j < nlen &&
  1816. !                (i + j >= olen || nbody[i+j] != obody[i+j]));
  1817. !            j++);
  1818.   
  1819.             /* Output this run of non-matching chars.  */ 
  1820.             write_glyphs (nbody + i, j);
  1821. --- 1721,1745 ----
  1822.         if (i >= olen || nbody[i] != obody[i])    /* A non-matching char. */
  1823.           {
  1824.             cursor_to (vpos, i);
  1825. !               j = 1;
  1826. !               do
  1827. !                 {
  1828. !                   more = 0;
  1829. !                   while (i + j < nlen
  1830. !                          && (i + j >= olen || nbody[i+j] != obody[i+j]))
  1831. !                     j++;
  1832. !                   /* Include matching chars in the run unless there
  1833. !                      are min_skip_run or more consecutive matching chars
  1834. !                      or no non-matching chars follow. */
  1835. !                   for (k = j; (i + k < nlen &&
  1836. !                                !(i + k >= olen || nbody[i+k] != obody[i+k]));
  1837. !                        k++);
  1838. !                   if (k != j && k - j < min_skip_run
  1839. !                       && (i + k >= olen || nbody[i+k] != obody[i+k]))
  1840. !                     {
  1841. !                       j = k; more = 1;
  1842. !                     }
  1843. !                 } while (more);
  1844.   
  1845.             /* Output this run of non-matching chars.  */ 
  1846.             write_glyphs (nbody + i, j);
  1847. ***************
  1848. *** 2140,2145 ****
  1849. --- 2179,2190 ----
  1850.     /* Round up to the smallest acceptable size.  */
  1851.     check_frame_size (frame, &newheight, &newwidth);
  1852.   
  1853. + #ifdef EMX
  1854. +   /* Try to resize the VIO window. */
  1855. +   if (FRAME_TERMCAP_P (frame) && !pretend)
  1856. +     emx_resize_vio (&newheight, &newwidth);
  1857. + #endif /* EMX */
  1858.     /* If we're not changing the frame size, quit now.  */
  1859.     if (newheight == FRAME_HEIGHT (frame)
  1860.         && newwidth == FRAME_WIDTH (frame))
  1861. ***************
  1862. *** 2490,2495 ****
  1863. --- 2535,2547 ----
  1864.        try to use X, and die with an error message if that doesn't work.  */
  1865.   
  1866.   #ifdef HAVE_X_WINDOWS
  1867. + #ifdef HAVE_PM
  1868. +   if (!inhibit_window_system && display_arg)
  1869. +     {
  1870. +       Vwindow_system = intern ("pm");
  1871. +       return;
  1872. +     }
  1873. + #else /* not HAVE_PM */
  1874.     if (! display_arg)
  1875.       {
  1876.         char *display;
  1877. ***************
  1878. *** 2501,2506 ****
  1879. --- 2553,2559 ----
  1880.   
  1881.         display_arg = (display != 0 && *display != 0);
  1882.       }
  1883. + #endif /* not HAVE_PM */
  1884.   
  1885.     if (!inhibit_window_system && display_arg)
  1886.       {
  1887. ***************
  1888. *** 2640,2645 ****
  1889. --- 2693,2702 ----
  1890.       "Display table to use for buffers that specify none.\n\
  1891.   See `buffer-display-table' for more information.");
  1892.     Vstandard_display_table = Qnil;
  1893. +   DEFVAR_INT ("min-skip-run", &min_skip_run,
  1894. +     "Minimum run length required for skipping matching characters in output.\n\
  1895. + This is used for tuning output.");
  1896.   
  1897.     /* Initialize `window-system', unless init_display already decided it.  */
  1898.   #ifdef CANNOT_DUMP
  1899. diff -c emacs-19\src\doc.c:1.1.1.18 emacs-19\src\doc.c:1.28
  1900. *** emacs-19\src\doc.c:1.1.1.18    Sun Aug 18 23:22:48 1996
  1901. --- emacs-19\src\doc.c    Sun Aug 18 23:22:48 1996
  1902. ***************
  1903. *** 18,23 ****
  1904. --- 18,24 ----
  1905.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1906.   Boston, MA 02111-1307, USA.  */
  1907.   
  1908. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1909.   
  1910.   #include <config.h>
  1911.   
  1912. ***************
  1913. *** 135,141 ****
  1914. --- 136,146 ----
  1915.         name = (char *) XSTRING (file)->data;
  1916.       }
  1917.   
  1918. + #ifdef EMX
  1919. +   fd = open (name, O_RDONLY | O_BINARY, 0);
  1920. + #else /* not EMX */
  1921.     fd = open (name, O_RDONLY, 0);
  1922. + #endif /* not EMX */
  1923.     if (fd < 0)
  1924.       {
  1925.   #ifndef CANNOT_DUMP
  1926. ***************
  1927. *** 456,462 ****
  1928. --- 461,471 ----
  1929.   #endif /* VMS4_4 */
  1930.   #endif /* VMS */
  1931.   
  1932. + #ifdef EMX
  1933. +   fd = open (name, O_RDONLY | O_BINARY, 0);
  1934. + #else /* not EMX */
  1935.     fd = open (name, O_RDONLY, 0);
  1936. + #endif /* not EMX */
  1937.     if (fd < 0)
  1938.       report_file_error ("Opening doc string file",
  1939.                  Fcons (build_string (name), Qnil));
  1940. diff -c emacs-19\src\editfns.c:1.1.1.36 emacs-19\src\editfns.c:1.39
  1941. *** emacs-19\src\editfns.c:1.1.1.36    Sun Aug 18 23:22:48 1996
  1942. --- emacs-19\src\editfns.c    Sun Aug 18 23:22:48 1996
  1943. ***************
  1944. *** 18,23 ****
  1945. --- 18,24 ----
  1946.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1947.   Boston, MA 02111-1307, USA.  */
  1948.   
  1949. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1950.   
  1951.   #include <sys/types.h>
  1952.   
  1953. ***************
  1954. *** 107,113 ****
  1955. --- 108,120 ----
  1956.     if (NILP (tem))
  1957.       pw = (struct passwd *) getpwnam (XSTRING (Vuser_login_name)->data);
  1958.     
  1959. + #ifndef EMX
  1960.     p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown");
  1961. + #else /* EMX */
  1962. +   p = (unsigned char *) getenv("USERFULLNAME");
  1963. +   if (!p)
  1964. +     p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown");
  1965. + #endif /* EMX */
  1966.     q = (unsigned char *) index (p, ',');
  1967.     Vuser_full_name = make_string (p, q ? q - p : strlen (p));
  1968.     
  1969. diff -c emacs-19\src\emacs.c:1.1.1.34 emacs-19\src\emacs.c:1.66
  1970. *** emacs-19\src\emacs.c:1.1.1.34    Sun Aug 18 23:22:48 1996
  1971. --- emacs-19\src\emacs.c    Sun Aug 18 23:22:48 1996
  1972. ***************
  1973. *** 18,23 ****
  1974. --- 18,24 ----
  1975.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  1976.   Boston, MA 02111-1307, USA.  */
  1977.   
  1978. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  1979.   
  1980.   #include <signal.h>
  1981.   #include <errno.h>
  1982. ***************
  1983. *** 166,171 ****
  1984. --- 167,186 ----
  1985.         shut_down_emacs (sig, 0, Qnil);
  1986.       }
  1987.   
  1988. + #ifdef EMX
  1989. +   /* Simply returning will cause a core dump for fatal signals; that's
  1990. +      what we want.  If we called kill(), the core dump would not be
  1991. +      very helpful, because the stack backtrace would not work (we are
  1992. +      in a signal handler!).  On the other hand, SIGKILL is sent by
  1993. +      another process and we don't want to continue after delivery of
  1994. +      SIGKILL. */
  1995. + #ifndef POSIX_SIGNALS
  1996. +   signal (fatal_error_code, SIG_ACK);
  1997. + #endif
  1998. +   if (fatal_error_code != SIGKILL && fatal_error_code != SIGTERM)
  1999. +     return;
  2000. + #endif /* EMX */
  2001.   #ifdef VMS
  2002.     LIB$STOP (SS$_ABORT);
  2003.   #else
  2004. ***************
  2005. *** 180,185 ****
  2006. --- 195,213 ----
  2007.   #endif /* not VMS */
  2008.   }
  2009.   
  2010. + #ifdef EMX
  2011. + SIGTYPE
  2012. + break_signal (sig)
  2013. +      int sig;
  2014. + {
  2015. + #ifndef POSIX_SIGNALS
  2016. +   signal (sig, SIG_ACK);
  2017. + #endif
  2018. +   Vquit_flag = Qt;
  2019. +   raise (SIGINT);
  2020. + }
  2021. + #endif /* EMX */
  2022.   #ifdef SIGDANGER
  2023.   
  2024.   /* Handler for SIGDANGER.  */
  2025. ***************
  2026. *** 244,249 ****
  2027. --- 272,284 ----
  2028.            not including lisp and info.  */
  2029.         tem = Fexpand_file_name (build_string ("lib-src"), dir);
  2030.         lib_src_exists = Ffile_exists_p (tem);
  2031. + #ifdef EMX
  2032. +       if (NILP (lib_src_exists))
  2033. +         {
  2034. +           tem = Fexpand_file_name (build_string ("bin"), dir);
  2035. +           lib_src_exists = Ffile_exists_p (tem);
  2036. +         }
  2037. + #endif /* EMX */
  2038.         if (!NILP (lib_src_exists))
  2039.           {
  2040.             tem = Fexpand_file_name (build_string ("etc"), dir);
  2041. ***************
  2042. *** 259,264 ****
  2043. --- 294,306 ----
  2044.         /* See if dir's parent contains those subdirs.  */
  2045.         tem = Fexpand_file_name (build_string ("../lib-src"), dir);
  2046.         lib_src_exists = Ffile_exists_p (tem);
  2047. + #ifdef EMX
  2048. +       if (NILP (lib_src_exists))
  2049. +         {
  2050. +           tem = Fexpand_file_name (build_string ("../bin"), dir);
  2051. +           lib_src_exists = Ffile_exists_p (tem);
  2052. +         }
  2053. + #endif /* EMX */
  2054.         if (!NILP (lib_src_exists))
  2055.           {
  2056.             tem = Fexpand_file_name (build_string ("../etc"), dir);
  2057. ***************
  2058. *** 430,435 ****
  2059. --- 472,482 ----
  2060.     extern int errno;
  2061.     extern sys_nerr;
  2062.   
  2063. + #ifdef EMX
  2064. +   /* Expand wildcards on the command line. */
  2065. +   _wildcard (&argc, &argv);
  2066. + #endif /* EMX */
  2067.   #ifdef LINUX_SBRK_BUG
  2068.     __sbrk (1);
  2069.   #endif
  2070. ***************
  2071. *** 478,483 ****
  2072. --- 525,535 ----
  2073.     }
  2074.   #endif /* NeXT */
  2075.   
  2076. + #ifdef EMX
  2077. +   emx_setup ();
  2078. +   _nls_init ();                 /* Call before emx_exec_name! */
  2079. +   emx_exec_name (&argv[0]);
  2080. + #endif /* EMX */
  2081.   #ifdef VMS
  2082.     /* If -map specified, map the data file in */
  2083.     {
  2084. ***************
  2085. *** 607,612 ****
  2086. --- 659,669 ----
  2087.         exit (0);
  2088.       }
  2089.   
  2090. + #ifdef HAVE_PM
  2091. +   if (argmatch (argv, argc, "-pm", "--pm", 4, NULL, &skip_args))
  2092. +     display_arg = 1;
  2093. + #endif /* HAVE_PM */
  2094.   #ifdef HAVE_X_WINDOWS
  2095.     /* Stupid kludge to catch command-line display spec.  We can't
  2096.        handle this argument entirely in window system dependent code
  2097. ***************
  2098. *** 649,654 ****
  2099. --- 706,721 ----
  2100.     }
  2101.   #endif
  2102.   
  2103. + #ifdef EMX
  2104. +   if (!display_arg || inhibit_window_system)
  2105. +     {
  2106. +       static char pid[40];
  2107. +       sprintf (pid, "EMACS_PID=%d", getpid ());
  2108. +       putenv (pid);
  2109. +     }
  2110. + #endif /* EMX */
  2111.     if (! noninteractive)
  2112.       {
  2113.   #ifdef BSD_PGRPS
  2114. ***************
  2115. *** 758,763 ****
  2116. --- 825,833 ----
  2117.         signal (SIGSOUND, fatal_error_signal);
  2118.         signal (SIGMSG, fatal_error_signal);
  2119.   #endif /* AIX */
  2120. + #ifdef EMX
  2121. +       signal (SIGBREAK, break_signal);
  2122. + #endif /* EMX */
  2123.       }
  2124.   
  2125.     noninteractive1 = noninteractive;
  2126. ***************
  2127. *** 1027,1032 ****
  2128. --- 1097,1105 ----
  2129.     { "-t", "--terminal", 90, 1 },
  2130.     { "-d", "--display", 80, 1 },
  2131.     { "-display", 0, 80, 1 },
  2132. + #ifdef HAVE_PM
  2133. +   { "-pm", "--pm", 80, 0 },
  2134. + #endif /* HAVE_PM */
  2135.     { "-nw", "--no-windows", 70, 0 },
  2136.     { "-batch", "--batch", 60, 0 },
  2137.     { "-q", "--no-init-file", 50, 0 },
  2138. ***************
  2139. *** 1310,1315 ****
  2140. --- 1383,1402 ----
  2141.   #endif /* HAVE_X_WINDOWS */
  2142.   #endif
  2143.   
  2144. + #ifdef HAVE_PM
  2145. + /* Under OS/2, however, pmemacs.exe is better than the Presentation
  2146. +    Manager at closing multiple windows at once. */
  2147. + #ifdef HAVE_X_WINDOWS
  2148. +   /* It's not safe to call intern here.  Maybe we are crashing.  */
  2149. +   if (!noninteractive && SYMBOLP (Vwindow_system)
  2150. +       && XSYMBOL (Vwindow_system)->name->size == 2
  2151. +       && XSYMBOL (Vwindow_system)->name->data[0] == 'p'
  2152. +       && XSYMBOL (Vwindow_system)->name->data[1] == 'm'
  2153. +       && ! no_x)
  2154. +     pm_shutdown ();
  2155. + #endif /* HAVE_X_WINDOWS */
  2156. + #endif /* HAVE_PM */
  2157.   #ifdef SIGIO
  2158.     /* There is a tendency for a SIGIO signal to arrive within exit,
  2159.        and cause a SIGHUP because the input descriptor is already closed.  */
  2160. ***************
  2161. *** 1437,1442 ****
  2162. --- 1524,1540 ----
  2163.       path = (char *) getenv (evarname);
  2164.     else
  2165.       path = 0;
  2166. + #ifdef EMX
  2167. +   if (path)
  2168. +     {
  2169. +       char *p = path;
  2170. +       path = alloca (strlen (p) + 1);
  2171. +       strcpy (path, p);
  2172. +       for (p = path; *p != 0; ++p)
  2173. +         if (*p == '\\')
  2174. +           *p = '/';
  2175. +     }
  2176. + #endif /* EMX */
  2177.     if (!path)
  2178.       path = defalt;
  2179.     lpath = Qnil;
  2180. diff -c emacs-19\src\fileio.c:1.1.1.35 emacs-19\src\fileio.c:1.72
  2181. *** emacs-19\src\fileio.c:1.1.1.35    Sun Aug 18 23:22:50 1996
  2182. --- emacs-19\src\fileio.c    Sun Aug 18 23:22:50 1996
  2183. ***************
  2184. *** 18,23 ****
  2185. --- 18,25 ----
  2186.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  2187.   Boston, MA 02111-1307, USA.  */
  2188.   
  2189. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  2190.   #include <config.h>
  2191.   
  2192.   #include <sys/types.h>
  2193. ***************
  2194. *** 130,135 ****
  2195. --- 132,156 ----
  2196.   #endif
  2197.   #endif
  2198.   
  2199. + #ifdef EMX
  2200. + #include <stdlib.h>
  2201. + #include <fcntl.h>
  2202. + #include <sys/ead.h>
  2203. + extern Lisp_Object Femx_binary_mode_p ();
  2204. + extern Lisp_Object emx_expand_file_name ();
  2205. + extern Lisp_Object emx_get_original_case_string ();
  2206. + static unsigned long emx_size (Lisp_Object, Lisp_Object, Lisp_Object, int);
  2207. + void emx_fix_longname (const char *fname);
  2208. + void emx_fix_ead_longname (_ead ead, const char *fname);
  2209. + extern int fb_start (int fd, off_t *size);
  2210. + extern int fb_close ();
  2211. + extern long fb_lseek ();
  2212. + extern int fb_read ();
  2213. + #define close(a)        fb_close (a)
  2214. + #define lseek(a,b,c)    fb_lseek (a, b, c)
  2215. + #define read(a,b,c)     fb_read (a, b, c)
  2216. + #endif /* EMX */
  2217.   #ifndef O_WRONLY
  2218.   #define O_WRONLY 1
  2219.   #endif
  2220. ***************
  2221. *** 687,693 ****
  2222.   #else
  2223.     if (slen > 1
  2224.         && IS_DIRECTORY_SEP (dst[slen - 1])
  2225. ! #ifdef DOS_NT
  2226.         && !IS_ANY_SEP (dst[slen - 2])
  2227.   #endif
  2228.         )
  2229. --- 708,714 ----
  2230.   #else
  2231.     if (slen > 1
  2232.         && IS_DIRECTORY_SEP (dst[slen - 1])
  2233. ! #if defined (DOS_NT) || defined (EMX)
  2234.         && !IS_ANY_SEP (dst[slen - 2])
  2235.   #endif
  2236.         )
  2237. ***************
  2238. *** 745,750 ****
  2239. --- 766,805 ----
  2240.        Lisp_Object prefix;
  2241.   {
  2242.     Lisp_Object val;
  2243. + #ifdef EMX
  2244. +   char drv_name[3], fsname[64], *p, *q;
  2245. +   int i, drive;
  2246. +   /* Check if PREFIX is on an HPFS drive. */
  2247. +   CHECK_STRING (prefix, 0);
  2248. +   p = XSTRING (prefix)->data;
  2249. +   drive = _fngetdrive (p);
  2250. +   if (drive == 0)
  2251. +     drive = _getdrive ();
  2252. +   drv_name[0] = (char)drive;
  2253. +   drv_name[1] = ':';
  2254. +   drv_name[2] = 0;
  2255. +   if (_filesys (drv_name, fsname, sizeof (fsname)) != 0
  2256. +       || strcmp (fsname, "HPFS") != 0)
  2257. +     {
  2258. +       /* It's not on an HPFS drive.  Keep only the first two
  2259. +          characters of the last component of PREFIX to restrict the
  2260. +          length of the last component to 8 characters.  */
  2261. +       q = p;
  2262. +       while (*p != 0)
  2263. +         {
  2264. +           if (IS_DIRECTORY_SEP (*p) || *p == ':')
  2265. +             q = p + 1;
  2266. +           ++p;
  2267. +         }
  2268. +       p = XSTRING (prefix)->data;
  2269. +       i = q - p;
  2270. +       if (XSTRING (prefix)->size - i > 2)
  2271. +         prefix = make_string (XSTRING (prefix)->data, i + 2);
  2272. +     }
  2273. + #endif /* EMX */
  2274.   #ifdef MSDOS
  2275.     /* Don't use too many characters of the restricted 8+3 DOS
  2276.        filename space.  */
  2277. ***************
  2278. *** 860,865 ****
  2279. --- 915,931 ----
  2280.     name = FILE_SYSTEM_CASE (name);
  2281.   #endif
  2282.   
  2283. + #ifdef EMX
  2284. +   {
  2285. +     Lisp_Object tem;
  2286. +     tem = emx_expand_file_name (name,
  2287. +                                 (!NILP (default_directory) ? default_directory
  2288. +                                  : current_buffer->directory));
  2289. +     if (!NILP (tem))
  2290. +       return tem;
  2291. +   }
  2292. + #endif /* EMX */
  2293.     nm = XSTRING (name)->data;
  2294.   
  2295.   #ifdef DOS_NT
  2296. ***************
  2297. *** 1782,1787 ****
  2298. --- 1848,1859 ----
  2299.   
  2300.     for (p = nm; p != endp; p++)
  2301.       {
  2302. + #ifdef EMX
  2303. +       if (p != nm && IS_DIRECTORY_SEP (p[-1])
  2304. +           && (p[0] == '~'
  2305. +               || _fngetdrive (p)
  2306. +               || (IS_DIRECTORY_SEP (p[0]) && p - 1 != nm)))
  2307. + #else /* not EMX */
  2308.         if ((p[0] == '~'
  2309.   #if defined (APOLLO) || defined (WINDOWSNT)
  2310.          /* // at start of file name is meaningful in Apollo and
  2311. ***************
  2312. *** 1797,1802 ****
  2313. --- 1869,1875 ----
  2314.             || p[-1] == ':' || p[-1] == ']' || p[-1] == '>'
  2315.   #endif /* VMS */
  2316.             || IS_DIRECTORY_SEP (p[-1])))
  2317. + #endif /* not EMX */
  2318.       {
  2319.         nm = p;
  2320.         substituted = 1;
  2321. ***************
  2322. *** 1922,1927 ****
  2323. --- 1995,2006 ----
  2324.     /* If /~ or // appears, discard everything through first slash. */
  2325.   
  2326.     for (p = xnm; p != x; p++)
  2327. + #ifdef EMX
  2328. +     if (p != xnm && IS_DIRECTORY_SEP (p[-1])
  2329. +         && (p[0] == '~'
  2330. +             || _fngetdrive (p)
  2331. +             || (IS_DIRECTORY_SEP (p[0]) && p - 1 != xnm)))
  2332. + #else /* not EMX */
  2333.       if ((p[0] == '~'
  2334.   #if defined (APOLLO) || defined (WINDOWSNT)
  2335.        || (IS_DIRECTORY_SEP (p[0]) && p - 1 != xnm)
  2336. ***************
  2337. *** 1930,1935 ****
  2338. --- 2009,2015 ----
  2339.   #endif /* not (APOLLO || WINDOWSNT) */
  2340.        )
  2341.       && p != nm && IS_DIRECTORY_SEP (p[-1]))
  2342. + #endif /* not EMX */
  2343.         xnm = p;
  2344.   #ifdef DOS_NT
  2345.       else if (IS_DRIVE (p[0]) && p[1] == ':'
  2346. ***************
  2347. *** 2061,2066 ****
  2348. --- 2141,2151 ----
  2349.       RETURN_UNGCPRO (call5 (handler, Qcopy_file, file, newname,
  2350.                  ok_if_already_exists, keep_date));
  2351.   
  2352. + #ifdef EMX
  2353. +   file = emx_get_original_case_string (file);
  2354. +   newname = emx_get_original_case_string (newname);
  2355. + #endif /* EMX */
  2356.     if (NILP (ok_if_already_exists)
  2357.         || INTEGERP (ok_if_already_exists))
  2358.       barf_or_query_if_file_exists (newname, "copy to it",
  2359. ***************
  2360. *** 2071,2076 ****
  2361. --- 2156,2164 ----
  2362.     ifd = open (XSTRING (file)->data, O_RDONLY);
  2363.     if (ifd < 0)
  2364.       report_file_error ("Opening input file", Fcons (file, Qnil));
  2365. + #ifdef EMX
  2366. +   setmode (ifd, O_BINARY);
  2367. + #endif /* EMX */
  2368.   
  2369.     record_unwind_protect (close_file_unwind, make_number (ifd));
  2370.   
  2371. ***************
  2372. *** 2106,2117 ****
  2373. --- 2194,2211 ----
  2374.     /* Create the copy file with the same record format as the input file */
  2375.     ofd = sys_creat (XSTRING (newname)->data, 0666, ifd);
  2376.   #else
  2377. + #ifdef EMX
  2378. +   ofd = open (XSTRING (newname)->data,
  2379. +               O_WRONLY | O_TRUNC | O_CREAT | O_BINARY | O_SIZE, 0666,
  2380. +               (unsigned long)(input_file_statable_p ? st.st_size : 0));
  2381. + #else /* not EMX */
  2382.   #ifdef MSDOS
  2383.     /* System's default file type was set to binary by _fmode in emacs.c.  */
  2384.     ofd = creat (XSTRING (newname)->data, S_IREAD | S_IWRITE);
  2385.   #else /* not MSDOS */
  2386.     ofd = creat (XSTRING (newname)->data, 0666);
  2387.   #endif /* not MSDOS */
  2388. + #endif /* not EMX */
  2389.   #endif /* VMS */
  2390.     if (ofd < 0)
  2391.       report_file_error ("Opening output file", Fcons (newname, Qnil));
  2392. ***************
  2393. *** 2153,2158 ****
  2394. --- 2247,2269 ----
  2395.   #endif /* MSDOS */
  2396.       }
  2397.   
  2398. + #ifdef EMX
  2399. +   /* Copy extended attributes.  */
  2400. +   if (_osmode == OS2_MODE)
  2401. +     {
  2402. +       _ead ead = _ead_create ();
  2403. +       if (ead != NULL)
  2404. +         {
  2405. +           if (_ead_read (ead, NULL, ifd, 0) == 0)
  2406. +             {
  2407. +               emx_fix_ead_longname (ead, XSTRING (newname)->data);
  2408. +               _ead_write (ead, XSTRING (newname)->data, -1, 0);
  2409. +             }
  2410. +           _ead_destroy (ead);
  2411. +         }
  2412. +     }
  2413. + #endif /* EMX */
  2414.     close (ifd);
  2415.   
  2416.     /* Discard the unwind protects.  */
  2417. ***************
  2418. *** 2264,2269 ****
  2419. --- 2375,2384 ----
  2420.   #endif
  2421.     Lisp_Object handler;
  2422.     struct gcpro gcpro1, gcpro2;
  2423. + #ifdef EMX
  2424. +   Lisp_Object file1, newname1;
  2425. +   int rc;
  2426. + #endif /* EMX */
  2427.   
  2428.     GCPRO2 (file, newname);
  2429.     CHECK_STRING (file, 0);
  2430. ***************
  2431. *** 2282,2295 ****
  2432. --- 2397,2427 ----
  2433.   
  2434.     if (NILP (ok_if_already_exists)
  2435.         || INTEGERP (ok_if_already_exists))
  2436. + #ifdef EMX
  2437. +     if (NILP (Fstring_equal (file, newname)))
  2438. + #endif /* EMX */
  2439.       barf_or_query_if_file_exists (newname, "rename to it",
  2440.                     INTEGERP (ok_if_already_exists), 0);
  2441. + #ifdef EMX
  2442. +   file1 = file; newname1 = newname;
  2443. +   file = emx_get_original_case_string (file);
  2444. +   newname = emx_get_original_case_string (newname);
  2445. +   rc = rename (XSTRING (file)->data, XSTRING (newname)->data);
  2446. +   if (rc < 0 && (errno == EEXIST || errno == EACCES)
  2447. +       && NILP (Fstring_equal (file1, newname1)))
  2448. +     {
  2449. +       remove (XSTRING (newname)->data);
  2450. +       rc = rename (XSTRING (file)->data, XSTRING (newname)->data);
  2451. +     }
  2452. +   if (rc < 0)
  2453. + #else /* not EMX */
  2454.   #ifndef BSD4_1
  2455.     if (0 > rename (XSTRING (file)->data, XSTRING (newname)->data))
  2456.   #else
  2457.     if (0 > link (XSTRING (file)->data, XSTRING (newname)->data)
  2458.         || 0 > unlink (XSTRING (file)->data))
  2459.   #endif
  2460. + #endif /* not EMX */
  2461.       {
  2462.         if (errno == EXDEV)
  2463.       {
  2464. ***************
  2465. *** 2310,2315 ****
  2466. --- 2442,2451 ----
  2467.       report_file_error ("Renaming", Flist (2, &file));
  2468.   #endif
  2469.       }
  2470. + #ifdef EMX
  2471. +   else if (_osmode == OS2_MODE)
  2472. +     emx_fix_longname (XSTRING (newname)->data);
  2473. + #endif /* EMX */
  2474.     UNGCPRO;
  2475.     return Qnil;
  2476.   }
  2477. ***************
  2478. *** 2516,2521 ****
  2479. --- 2652,2661 ----
  2480.   #ifdef DOS_NT
  2481.         || (IS_DRIVE (*ptr) && ptr[1] == ':' && IS_DIRECTORY_SEP (ptr[2]))
  2482.   #endif
  2483. + #ifdef EMX
  2484. +       || *ptr == '\\'
  2485. +       || (_fngetdrive (ptr) && IS_DIRECTORY_SEP (ptr[2]))
  2486. + #endif /* EMX */
  2487.         )
  2488.       return Qt;
  2489.     else
  2490. ***************
  2491. *** 2528,2533 ****
  2492. --- 2668,2679 ----
  2493.   check_executable (filename)
  2494.        char *filename;
  2495.   {
  2496. + #ifdef EMX
  2497. +   struct stat st;
  2498. +   if (stat (filename, &st) < 0)
  2499. +     return 0;
  2500. +   return (st.st_mode & S_IXUSR) ? 1 : 0;
  2501. + #else /* not EMX */
  2502.   #ifdef DOS_NT
  2503.     int len = strlen (filename);
  2504.     char *suffix;
  2505. ***************
  2506. *** 2554,2559 ****
  2507. --- 2700,2706 ----
  2508.     return (access (filename, 1) >= 0);
  2509.   #endif
  2510.   #endif /* not DOS_NT */
  2511. + #endif /* not EMX */
  2512.   }
  2513.   
  2514.   /* Return nonzero if file FILENAME exists and can be written.  */
  2515. ***************
  2516. *** 2644,2649 ****
  2517. --- 2791,2800 ----
  2518.     if (!NILP (handler))
  2519.       return call2 (handler, Qfile_readable_p, absname);
  2520.   
  2521. + #ifdef EMX
  2522. +   /* Cannot open directories with open().  */
  2523. +   return (access (XSTRING (absname)->data, 4) >= 0) ? Qt : Qnil;
  2524. + #else /* not EMX */
  2525.   #ifdef DOS_NT
  2526.     /* Under MS-DOS and Windows, open does not work for directories.  */
  2527.     if (access (XSTRING (absname)->data, 0) == 0)
  2528. ***************
  2529. *** 2656,2661 ****
  2530. --- 2807,2813 ----
  2531.     close (desc);
  2532.     return Qt;
  2533.   #endif /* not DOS_NT */
  2534. + #endif /* not EMX */
  2535.   }
  2536.   
  2537.   /* Having this before file-symlink-p mysteriously caused it to be forgotten
  2538. ***************
  2539. *** 3050,3055 ****
  2540. --- 3202,3214 ----
  2541.       if ((fd = open (XSTRING (filename)->data, O_RDONLY)) < 0)
  2542.         goto badopen;
  2543.   
  2544. + #ifdef EMX
  2545. +   if (NILP (current_buffer->emx_binary_mode))
  2546. +     current_buffer->emx_binary_mode = Femx_binary_mode_p (filename);
  2547. +   if (!NILP (current_buffer->emx_binary_mode))
  2548. +     setmode (fd, O_BINARY);
  2549. + #endif /* EMX */
  2550.     /* Replacement should preserve point as it preserves markers.  */
  2551.     if (!NILP (replace))
  2552.       record_unwind_protect (restore_point_unwind, Fpoint_marker ());
  2553. ***************
  2554. *** 3093,3098 ****
  2555. --- 3252,3263 ----
  2556.         del_range_1 (BEGV, ZV, 0);
  2557.       }
  2558.   #else /* not DOS_NT */
  2559. + #ifdef EMX
  2560. +   if (!NILP (replace) && NILP (current_buffer->emx_binary_mode)
  2561. +       && fb_start (fd, &st.st_size) != 0)
  2562. +     error ("IO error reading %s: %s",
  2563. +        XSTRING (filename)->data, strerror (errno));
  2564. + #endif /* EMX */
  2565.     if (!NILP (replace))
  2566.       {
  2567.         unsigned char buffer[1 << 14];
  2568. ***************
  2569. *** 3416,3421 ****
  2570. --- 3581,3590 ----
  2571.     int visiting, quietly;
  2572.     struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
  2573.     struct buffer *given_buffer;
  2574. + #ifdef EMX
  2575. +   int binary;
  2576. +   unsigned long size;
  2577. + #endif /* EMX */
  2578.   #ifdef DOS_NT
  2579.     int buffer_file_type
  2580.       = NILP (current_buffer->buffer_file_type) ? O_TEXT : O_BINARY;
  2581. ***************
  2582. *** 3491,3496 ****
  2583. --- 3660,3671 ----
  2584.       lock_file (lockname);
  2585.   #endif /* CLASH_DETECTION */
  2586.   
  2587. + #ifdef EMX
  2588. +   binary = ((!STRINGP (start) && !NILP (current_buffer->emx_binary_mode))
  2589. +             || !NILP (Femx_binary_mode_p (filename)));
  2590. +   filename = emx_get_original_case_string (filename);
  2591. + #endif /* EMX */
  2592.     fn = XSTRING (filename)->data;
  2593.     desc = -1;
  2594.     if (!NILP (append))
  2595. ***************
  2596. *** 3547,3552 ****
  2597. --- 3722,3736 ----
  2598.         desc = creat (fn, 0666);
  2599.         }
  2600.   #else /* not VMS */
  2601. + #ifdef EMX
  2602. +   {
  2603. +     /* Set initial file size to avoid fragmentation. */
  2604. +     size = emx_size (start, end, annotations, binary);
  2605. +     desc = open (fn, O_WRONLY | O_TRUNC | O_CREAT | O_SIZE,
  2606. +                  auto_saving ? auto_save_mode_bits : 0666, size);
  2607. +     append = Qnil;
  2608. +   }
  2609. + #else /* not EMX */
  2610.   #ifdef DOS_NT
  2611.     desc = open (fn,
  2612.              O_WRONLY | O_TRUNC | O_CREAT | buffer_file_type,
  2613. ***************
  2614. *** 3554,3559 ****
  2615. --- 3738,3744 ----
  2616.   #else  /* not DOS_NT */
  2617.     desc = creat (fn, auto_saving ? auto_save_mode_bits : 0666);
  2618.   #endif /* not DOS_NT */
  2619. + #endif /* not EMX */
  2620.   #endif /* not VMS */
  2621.   
  2622.     UNGCPRO;
  2623. ***************
  2624. *** 3567,3572 ****
  2625. --- 3752,3761 ----
  2626.   #endif /* CLASH_DETECTION */
  2627.         report_file_error ("Opening output file", Fcons (filename, Qnil));
  2628.       }
  2629. + #ifdef EMX
  2630. +   if (binary)
  2631. +     setmode (desc, O_BINARY);
  2632. + #endif /* EMX */
  2633.   
  2634.     record_unwind_protect (close_file_unwind, make_number (desc));
  2635.   
  2636. ***************
  2637. *** 3877,3882 ****
  2638. --- 4066,4140 ----
  2639.     return 0;
  2640.   }
  2641.   
  2642. + #ifdef EMX
  2643. + static unsigned long
  2644. + a_size (addr, len, pos, annot, binary)
  2645. +      register char *addr;
  2646. +      register int len;
  2647. +      int pos;
  2648. +      Lisp_Object *annot;
  2649. +      int binary;
  2650. + {
  2651. +   unsigned long size;
  2652. +   int i;
  2653. +   size = len;
  2654. +   if (!binary)
  2655. +     {
  2656. +       if (!EQ (current_buffer->selective_display, Qt))
  2657. +         {
  2658. +           for (i = 0; i < len; ++i)
  2659. +             if (addr[i] == '\n')
  2660. +               ++size;
  2661. +         }
  2662. +       else
  2663. +         for (i = 0; i < len; ++i)
  2664. +           if (addr[i] == '\n' || addr[i] == '\015')
  2665. +             ++size;
  2666. +     }
  2667. +   /* TODO: annotations */
  2668. +   return size;
  2669. + }
  2670. + static unsigned long
  2671. + emx_size (start, end, annotations, binary)
  2672. +      Lisp_Object start, end, annotations;
  2673. +      int binary;
  2674. + {
  2675. +   unsigned long size;
  2676. +   struct gcpro gcpro1;
  2677. +   int start1, end1, tem;
  2678. +   /* START and END are already protected. */
  2679. +   GCPRO1 (annotations);
  2680. +   if (STRINGP (start))
  2681. +     size = a_size (XSTRING (start)->data, XSTRING (start)->size, 0,
  2682. +                    &annotations, binary);
  2683. +   else if (XINT (start) != XINT (end))
  2684. +     {
  2685. +       start1 = XINT (start);
  2686. +       end1 = XINT (end);
  2687. +       size = 0;
  2688. +       if (XINT (start) < GPT)
  2689. +         size += a_size (&FETCH_CHAR (start1), min (GPT, end1) - start1, start1,
  2690. +                         &annotations, binary);
  2691. +       if (XINT (end) > GPT)
  2692. +     {
  2693. +       tem = max (start1, GPT);
  2694. +           size += a_size (&FETCH_CHAR (tem), end1 - tem, tem,
  2695. +                           &annotations, binary);
  2696. +     }
  2697. +     }
  2698. +   else
  2699. +     size = a_size ("", 0, XINT (start), &annotations, binary);
  2700. +   UNGCPRO;
  2701. +   return size;
  2702. + }
  2703. + #endif /* EMX */
  2704.   DEFUN ("verify-visited-file-modtime", Fverify_visited_file_modtime,
  2705.     Sverify_visited_file_modtime, 1, 1, 0,
  2706.     "Return t if last mod time of BUF's visited file matches what BUF records.\n\
  2707. ***************
  2708. *** 3999,4008 ****
  2709. --- 4257,4273 ----
  2710.     else
  2711.       auto_save_mode_bits = 0666;
  2712.   
  2713. + #ifndef EMX
  2714.     return
  2715. + #endif /* EMX */
  2716.       Fwrite_region (Qnil, Qnil,
  2717.              current_buffer->auto_save_file_name,
  2718.              Qnil, Qlambda, Qnil);
  2719. + #ifdef EMX
  2720. +   Fput_ea_list (Fexpand_file_name (current_buffer->auto_save_file_name, Qnil),
  2721. +                 current_buffer->extended_attributes, Qt);
  2722. +   return Qnil;
  2723. + #endif /* EMX */
  2724.   }
  2725.   
  2726.   static Lisp_Object
  2727. ***************
  2728. *** 4058,4063 ****
  2729. --- 4323,4331 ----
  2730.       {
  2731.         Lisp_Object listfile;
  2732.         listfile = Fexpand_file_name (Vauto_save_list_file_name, Qnil);
  2733. + #ifdef EMX
  2734. +       listfile = emx_get_original_case_string (listfile);
  2735. + #endif /* EMX */
  2736.   #ifdef DOS_NT
  2737.         listdesc = open (XSTRING (listfile)->data,
  2738.                  O_WRONLY | O_TRUNC | O_CREAT | O_TEXT,
  2739. diff -c emacs-19\src\frame.c:1.1.1.33 emacs-19\src\frame.c:1.42
  2740. *** emacs-19\src\frame.c:1.1.1.33    Sun Aug 18 23:22:50 1996
  2741. --- emacs-19\src\frame.c    Sun Aug 18 23:22:50 1996
  2742. ***************
  2743. *** 18,23 ****
  2744. --- 18,25 ----
  2745.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  2746.   Boston, MA 02111-1307, USA.  */
  2747.   
  2748. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  2749.   #include <config.h>
  2750.   
  2751.   #include <stdio.h>
  2752. ***************
  2753. *** 83,88 ****
  2754. --- 85,94 ----
  2755.   Lisp_Object Qbuffer_predicate;
  2756.   Lisp_Object Qtitle;
  2757.   
  2758. + #ifdef HAVE_PM
  2759. + Lisp_Object Qpm;
  2760. + #endif /* HAVE_PM */
  2761.   Lisp_Object Vterminal_frame;
  2762.   Lisp_Object Vdefault_frame_alist;
  2763.   
  2764. ***************
  2765. *** 125,130 ****
  2766. --- 131,141 ----
  2767.     Qtitle = intern ("title");
  2768.     staticpro (&Qtitle);
  2769.   
  2770. + #ifdef HAVE_PM
  2771. +   Qpm = intern ("pm");
  2772. +   staticpro (&Qpm);
  2773. + #endif /* HAVE_PM */
  2774.     DEFVAR_LISP ("default-frame-alist", &Vdefault_frame_alist,
  2775.       "Alist of default values for frame creation.\n\
  2776.   These may be set in your init file, like this:\n\
  2777. ***************
  2778. *** 212,217 ****
  2779. --- 223,229 ----
  2780.     "Return non-nil if OBJECT is a frame.\n\
  2781.   Value is t for a termcap frame (a character-only terminal),\n\
  2782.   `x' for an Emacs frame that is really an X window,\n\
  2783. + `pm' for an Emacs frame that is really a Presentation Manager window,\n\
  2784.   `pc' for a direct-write MS-DOS frame.\n\
  2785.   See also `frame-live-p'.")
  2786.     (object)
  2787. ***************
  2788. *** 224,230 ****
  2789. --- 236,246 ----
  2790.       case output_termcap:
  2791.         return Qt;
  2792.       case output_x_window:
  2793. + #ifdef HAVE_PM
  2794. +       return Qpm;
  2795. + #else /* not HAVE_PM */
  2796.         return Qx;
  2797. + #endif /* not HAVE_PM */
  2798.       case output_win32:
  2799.         return Qwin32;
  2800.       case output_msdos_raw:
  2801. diff -c emacs-19\src\keyboard.c:1.1.1.48 emacs-19\src\keyboard.c:1.85
  2802. *** emacs-19\src\keyboard.c:1.1.1.48    Sun Aug 18 23:22:54 1996
  2803. --- emacs-19\src\keyboard.c    Sun Aug 18 23:22:54 1996
  2804. ***************
  2805. *** 18,23 ****
  2806. --- 18,25 ----
  2807.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  2808.   Boston, MA 02111-1307, USA.  */
  2809.   
  2810. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  2811.   /* Allow config.h to undefine symbols found here.  */
  2812.   #include <signal.h>
  2813.   
  2814. ***************
  2815. *** 54,60 ****
  2816. --- 56,66 ----
  2817.   
  2818.   /* This is to get the definitions of the XK_ symbols.  */
  2819.   #ifdef HAVE_X_WINDOWS
  2820. + #ifdef HAVE_PM
  2821. + #include "pmterm.h"
  2822. + #else /* not HAVE_PM */
  2823.   #include "xterm.h"
  2824. + #endif /* not HAVE_PM */
  2825.   #endif
  2826.   
  2827.   #ifdef HAVE_NTGUI
  2828. ***************
  2829. *** 519,525 ****
  2830. --- 525,535 ----
  2831.   /* If we support a window system, turn on the code to poll periodically
  2832.      to detect C-g.  It isn't actually used when doing interrupt input.  */
  2833.   #ifdef HAVE_WINDOW_SYSTEM
  2834. + /* pmemacs sends SIGINT to Emacs when C-g is hit.  We don't have to
  2835. +    poll. */
  2836. + #ifndef HAVE_PM
  2837.   #define POLL_FOR_INPUT
  2838. + #endif /* not HAVE_PM */
  2839.   #endif
  2840.   
  2841.   /* Non-nil enables Column Number mode.  */
  2842. ***************
  2843. *** 2305,2310 ****
  2844. --- 2315,2323 ----
  2845.     do_mouse_tracking = old_value;
  2846.     if (NILP (old_value))
  2847.       {
  2848. + #ifdef HAVE_PM
  2849. +       pm_mouse_tracking (0);
  2850. + #endif /* HAVE_PM */
  2851.         /* Redisplay may have been preempted because there was input
  2852.        available, and it assumes it will be called again after the
  2853.        input has been processed.  If the only input available was
  2854. ***************
  2855. *** 2331,2338 ****
  2856. --- 2344,2365 ----
  2857.   
  2858.     record_unwind_protect (tracking_off, do_mouse_tracking);
  2859.   
  2860. + #ifdef HAVE_PM
  2861. +   if (NILP (do_mouse_tracking))
  2862. +     {
  2863. +       Lisp_Object tail, frame;
  2864. +       FOR_EACH_FRAME (tail, frame)
  2865. +         XFRAME (frame)->mouse_moved = 0;
  2866. +     }
  2867. + #endif /* HAVE_PM */
  2868.     do_mouse_tracking = Qt;
  2869.   
  2870. + #ifdef HAVE_PM
  2871. +   pm_mouse_tracking (1);
  2872. + #endif /* HAVE_PM */
  2873.     val = Fprogn (args);
  2874.     return unbind_to (count, val);
  2875.   }
  2876. ***************
  2877. *** 3548,3553 ****
  2878. --- 3575,3583 ----
  2879.   static char *lispy_mouse_names[] =
  2880.   {
  2881.     "mouse-1", "mouse-2", "mouse-3", "mouse-4", "mouse-5"
  2882. + #ifdef HAVE_PM
  2883. +   , "drop-file", "drop-color"
  2884. + #endif /* HAVE_PM */
  2885.   };
  2886.   
  2887.   /* Scroll bar parts.  */
  2888. ***************
  2889. *** 3805,3810 ****
  2890. --- 3835,3857 ----
  2891.   
  2892.       start_pos_ptr = &XVECTOR (button_down_location)->contents[button];
  2893.   
  2894. + #ifdef HAVE_PM
  2895. +         if (event->modifiers == 0)
  2896. +           {
  2897. +             Lisp_Object head;
  2898. +             head = modify_event_symbol (button,
  2899. +                                         event->modifiers,
  2900. +                                         Qmouse_click, Qnil,
  2901. +                                         lispy_mouse_names, &mouse_syms,
  2902. +                                         (sizeof (lispy_mouse_names)
  2903. +                                          / sizeof (lispy_mouse_names[0])));
  2904. +         return Fcons (head,
  2905. +               Fcons (position,
  2906. +                  Qnil));
  2907. +           }
  2908. + #endif /* HAVE_PM */
  2909.       start_pos = *start_pos_ptr;
  2910.       *start_pos_ptr = Qnil;
  2911.   
  2912. ***************
  2913. *** 4971,4976 ****
  2914. --- 5018,5027 ----
  2915.   void
  2916.   reinvoke_input_signal ()
  2917.   {
  2918. + #ifdef HAVE_PM
  2919. +   while (read_avail_input (1) > 0)
  2920. +     ;
  2921. + #endif /* HAVE_PM */
  2922.   #ifdef SIGIO
  2923.     kill (getpid (), SIGIO);
  2924.   #endif
  2925. ***************
  2926. *** 7365,7370 ****
  2927. --- 7416,7428 ----
  2928.     /* Must preserve main program's value of errno.  */
  2929.     int old_errno = errno;
  2930.   
  2931. + #ifdef EMX
  2932. +   /* Under emx with non-POSIX signals, a signal is blocked until
  2933. +      acknowledged. */
  2934. + #ifndef POSIX_SIGNALS
  2935. +   signal (SIGINT, SIG_ACK);
  2936. + #endif
  2937. + #else /* not EMX */
  2938.   #ifdef USG
  2939.     if (!read_socket_hook && NILP (Vwindow_system))
  2940.       {
  2941. ***************
  2942. *** 7374,7379 ****
  2943. --- 7432,7438 ----
  2944.         signal (SIGQUIT, interrupt_signal);
  2945.       }
  2946.   #endif /* USG */
  2947. + #endif /* not EMX */
  2948.   
  2949.     cancel_echoing ();
  2950.   
  2951. ***************
  2952. *** 7406,7411 ****
  2953. --- 7465,7474 ----
  2954.         printf ("you can continue or abort.\n");
  2955.   #endif /* not VMS */
  2956.   #endif /* not SIGTSTP */
  2957. + #ifdef EMX
  2958. +       /* Still required??? */
  2959. +       Vquit_flag = Qnil;
  2960. + #endif */ EMX */
  2961.   #ifdef MSDOS
  2962.         /* We must remain inside the screen area when the internal terminal
  2963.        is used.  Note that [Enter] is not echoed by dos.  */
  2964. ***************
  2965. *** 7705,7711 ****
  2966. --- 7768,7781 ----
  2967.   
  2968.     kbd_buffer_frame_or_window
  2969.       = Fmake_vector (make_number (KBD_BUFFER_SIZE), Qnil);
  2970. + #ifdef HAVE_PM
  2971. +   /* Use SIGINT even if window-system is non-nil; pmemacs sends SIGINT
  2972. +      when C-g is typed.  */
  2973. +   if (!noninteractive && !read_socket_hook)
  2974. + #else /* not HAVE_PM */
  2975.     if (!noninteractive && !read_socket_hook && NILP (Vwindow_system))
  2976. + #endif /* not HAVE_PM */
  2977.       {
  2978.         signal (SIGINT, interrupt_signal);
  2979.   #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
  2980. diff -c emacs-19\src\lread.c:1.1.1.32 emacs-19\src\lread.c:1.46
  2981. *** emacs-19\src\lread.c:1.1.1.32    Sun Aug 18 23:22:56 1996
  2982. --- emacs-19\src\lread.c    Sun Aug 18 23:22:56 1996
  2983. ***************
  2984. *** 19,24 ****
  2985. --- 19,25 ----
  2986.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  2987.   Boston, MA 02111-1307, USA.  */
  2988.   
  2989. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  2990.   
  2991.   #include <config.h>
  2992.   #include <stdio.h>
  2993. ***************
  2994. *** 92,97 ****
  2995. --- 93,103 ----
  2996.   /* This is used to build the load history. */
  2997.   Lisp_Object Vcurrent_load_list;
  2998.   
  2999. + #ifdef EMX
  3000. + /* Try replacing `-' with `_' in `load' if this is non-zero. */
  3001. + int emx_cdrom_load;
  3002. + #endif /* EMX */
  3003.   /* Name of file actually being read by `load'.  */
  3004.   Lisp_Object Vload_file_name;
  3005.   
  3006. ***************
  3007. *** 412,417 ****
  3008. --- 418,444 ----
  3009.         GCPRO1 (file);
  3010.         fd = openp (Vload_path, file, !NILP (nosuffix) ? "" : ".elc:.el:",
  3011.             &found, 0);
  3012. + #ifdef EMX
  3013. +       /* If the file was not found and emx-cdrom-load is non-nil, try
  3014. +          again, replacing `-' with `_'. */
  3015. +       if (fd < 0 && emx_cdrom_load)
  3016. +         {
  3017. +           int len = XSTRING (file)->size;
  3018. +           char *new_file = alloca (len + 1);
  3019. +           int i, ok = 0;
  3020. +           memcpy (new_file, XSTRING (file)->data, len);
  3021. +           new_file[len] = 0;
  3022. +           for (i = 0; i < len; ++i)
  3023. +             if (new_file[i] == '-')
  3024. +               {
  3025. +                 new_file[i] = '_'; ok = 1;
  3026. +               }
  3027. +           if (ok)
  3028. +             fd = openp (Vload_path, build_string (new_file),
  3029. +                         !NILP (nosuffix) ? "" : ".elc:.el:", &found, 0);
  3030. +         }
  3031. + #endif /* EMX */
  3032.         UNGCPRO;
  3033.       }
  3034.   
  3035. ***************
  3036. *** 2426,2431 ****
  3037. --- 2453,2464 ----
  3038.     DEFVAR_LISP ("current-load-list", &Vcurrent_load_list,
  3039.       "Used for internal purposes by `load'.");
  3040.     Vcurrent_load_list = Qnil;
  3041. + #ifdef EMX
  3042. +   DEFVAR_BOOL ("emx-cdrom-load", &emx_cdrom_load,
  3043. +     "*Non-nil if `load' should try again if the file is not found,\n\
  3044. + replacing `-' with `_' in the file name.");
  3045. + #endif /* EMX */
  3046.   
  3047.     DEFVAR_LISP ("load-read-function", &Vload_read_function,
  3048.       "Function used by `load' and `eval-region' for reading expressions.\n\
  3049. diff -c emacs-19\src\process.c:1.1.1.41 emacs-19\src\process.c:1.70
  3050. *** emacs-19\src\process.c:1.1.1.41    Sun Aug 18 23:22:58 1996
  3051. --- emacs-19\src\process.c    Sun Aug 18 23:22:58 1996
  3052. ***************
  3053. *** 19,24 ****
  3054. --- 19,25 ----
  3055.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3056.   Boston, MA 02111-1307, USA.  */
  3057.   
  3058. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3059.   
  3060.   #include <signal.h>
  3061.   
  3062. ***************
  3063. *** 44,49 ****
  3064. --- 45,54 ----
  3065.   #include <unistd.h>
  3066.   #endif
  3067.   
  3068. + #ifdef EMX
  3069. + #include <stdlib.h>
  3070. + #endif /* EMX */
  3071.   #ifdef WINDOWSNT
  3072.   #include <stdlib.h>
  3073.   #include <fcntl.h>
  3074. ***************
  3075. *** 104,109 ****
  3076. --- 109,121 ----
  3077.   #include "commands.h"
  3078.   #include "frame.h"
  3079.   
  3080. + #ifdef EMX
  3081. + extern Lisp_Object find_program_name_handler ();
  3082. + extern Lisp_Object Qprogram_name_handler_alist;
  3083. + extern Lisp_Object Vprogram_name_handler_alist;
  3084. + static Lisp_Object Qstart_process;
  3085. + #endif /* EMX */
  3086.   Lisp_Object Qprocessp;
  3087.   Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed;
  3088.   Lisp_Object Qlast_nonmenu_event;
  3089. ***************
  3090. *** 213,219 ****
  3091. --- 225,233 ----
  3092.   /* If we support a window system, turn on the code to poll periodically
  3093.      to detect C-g.  It isn't actually used when doing interrupt input.  */
  3094.   #ifdef HAVE_WINDOW_SYSTEM
  3095. + #ifndef HAVE_PM
  3096.   #define POLL_FOR_INPUT
  3097. + #endif /* not HAVE_PM */
  3098.   #endif
  3099.   
  3100.   /* Mask of bits indicating the descriptors that we wait for input on.  */
  3101. ***************
  3102. *** 389,394 ****
  3103. --- 403,413 ----
  3104.        end of the ptys.  */
  3105.     int failed_count = 0;
  3106.   
  3107. + #ifdef EMX
  3108. +   if (_osmode != OS2_MODE || _emx_rev < 37)
  3109. +     return -1;
  3110. + #endif /* EMX */
  3111.   #ifdef PTY_ITERATION
  3112.     PTY_ITERATION
  3113.   #else
  3114. ***************
  3115. *** 413,418 ****
  3116. --- 432,438 ----
  3117.       if (fstat (fd, &stb) < 0)
  3118.         return -1;
  3119.   #else /* not IRIS */
  3120. + #ifndef EMX
  3121.       if (stat (pty_name, &stb) < 0)
  3122.         {
  3123.           failed_count++;
  3124. ***************
  3125. *** 421,426 ****
  3126. --- 441,447 ----
  3127.         }
  3128.       else
  3129.         failed_count = 0;
  3130. + #endif /* not EMX */
  3131.   #ifdef O_NONBLOCK
  3132.       fd = open (pty_name, O_RDWR | O_NONBLOCK, 0);
  3133.   #else
  3134. ***************
  3135. *** 438,443 ****
  3136. --- 459,465 ----
  3137.   #else
  3138.               sprintf (pty_name, "/dev/tty%c%x", c, i);
  3139.   #endif /* no PTY_TTY_NAME_SPRINTF */
  3140. + #ifndef EMX
  3141.   #ifndef UNIPLUS
  3142.           if (access (pty_name, 6) != 0)
  3143.             {
  3144. ***************
  3145. *** 449,454 ****
  3146. --- 471,477 ----
  3147.   #endif /* IRIS */
  3148.             }
  3149.   #endif /* not UNIPLUS */
  3150. + #endif /* not EMX */
  3151.           setup_pty (fd);
  3152.           return fd;
  3153.         }
  3154. ***************
  3155. *** 1026,1031 ****
  3156. --- 1049,1072 ----
  3157.     register int i;
  3158.     int count = specpdl_ptr - specpdl;
  3159.   
  3160. + #ifdef EMX
  3161. +   {
  3162. +     Lisp_Object handler;
  3163. +     emx_setup_start_process (); /* Calls specbind() */
  3164. +     handler = find_program_name_handler (args[2]);
  3165. +     if (!NILP (handler))
  3166. +       return unbind_to (count,
  3167. +                         call3 (handler,
  3168. +                                Fcons (Qstart_process, Flist (2, args + 0)),
  3169. +                                args[2],
  3170. +                                Flist (nargs - 3, args + 3)));
  3171. +   }
  3172. +   if (_osmode == DOS_MODE)
  3173. +     error ("start-process not supported under MS-DOS");
  3174. +   check_process_priority ();
  3175. + #endif /* EMX */
  3176.     buffer = args[1];
  3177.     if (!NILP (buffer))
  3178.       buffer = Fget_buffer_create (buffer);
  3179. ***************
  3180. *** 1046,1051 ****
  3181. --- 1087,1096 ----
  3182.   
  3183.       GCPRO2 (buffer, current_dir);
  3184.   
  3185. + #ifdef EMX
  3186. +     current_dir = Fexpand_file_name (current_dir, Qnil);
  3187. + #endif /* EMX */
  3188.       current_dir 
  3189.         = expand_and_dir_to_file (Funhandled_file_name_directory (current_dir),
  3190.                   Qnil);
  3191. ***************
  3192. *** 1088,1096 ****
  3193. --- 1133,1145 ----
  3194.     new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
  3195.   
  3196.     /* If program file name is not absolute, search our path for it */
  3197. + #ifdef EMX
  3198. +   if (!_fnisabs (XSTRING (program)->data))
  3199. + #else /* not EMX */
  3200.     if (!IS_DIRECTORY_SEP (XSTRING (program)->data[0])
  3201.         && !(XSTRING (program)->size > 1
  3202.          && IS_DEVICE_SEP (XSTRING (program)->data[1])))
  3203. + #endif /* not EMX */
  3204.       {
  3205.         struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
  3206.   
  3207. ***************
  3208. *** 1227,1232 ****
  3209. --- 1276,1286 ----
  3210.   
  3211.     if (inchannel >= 0)
  3212.       {
  3213. + #ifdef EMX
  3214. +       /* Make another descriptor for the pty, to be able to use
  3215. +          different O_BINARY settings for reading and writing.  */
  3216. +       outchannel = dup (inchannel);
  3217. + #endif 
  3218.   #ifndef USG 
  3219.         /* On USG systems it does not work to open the pty's tty here
  3220.              and then close and reopen it in the child.  */
  3221. ***************
  3222. *** 1264,1269 ****
  3223. --- 1318,1328 ----
  3224.       }
  3225.   #endif /* not SKTPAIR */
  3226.   
  3227. + #ifdef EMX
  3228. +   emx_proc_output_pipe (inchannel);
  3229. +   emx_proc_input_pipe (outchannel);
  3230. + #endif /* EMX */
  3231.   #if 0
  3232.     /* Replaced by close_process_descs */
  3233.     set_exclusive_use (inchannel);
  3234. ***************
  3235. *** 1481,1486 ****
  3236. --- 1540,1549 ----
  3237.   #endif
  3238.   #endif /* HAVE_PTYS */
  3239.   
  3240. + #ifdef EMX
  3241. +     pid = emx_child_setup (xforkin, xforkout, xforkout,
  3242. +                                new_argv, 1, current_dir);
  3243. + #else /*  not EMX */
  3244.       signal (SIGINT, SIG_DFL);
  3245.       signal (SIGQUIT, SIG_DFL);
  3246.   
  3247. ***************
  3248. *** 1512,1517 ****
  3249. --- 1575,1581 ----
  3250.       child_setup (xforkin, xforkout, xforkout,
  3251.                new_argv, 1, current_dir);
  3252.   #endif /* not WINDOWSNT */
  3253. + #endif /* not EMX */
  3254.         }
  3255.       environ = save_environ;
  3256.     }
  3257. ***************
  3258. *** 1590,1596 ****
  3259. --- 1654,1664 ----
  3260.   
  3261.     /* Now generate the error if vfork failed.  */
  3262.     if (pid < 0)
  3263. + #ifndef EMX
  3264.       report_file_error ("Doing vfork", Qnil);
  3265. + #else /* EMX */
  3266. +     report_file_error ("Starting process", Qnil);
  3267. + #endif /* EMX */
  3268.   }
  3269.   #endif /* not VMS */
  3270.   
  3271. ***************
  3272. *** 1862,1867 ****
  3273. --- 1930,1936 ----
  3274.   {
  3275.   #ifndef WINDOWSNT
  3276.     int i;
  3277. + #ifndef EMX
  3278.     for (i = 0; i < MAXDESC; i++)
  3279.       {
  3280.         Lisp_Object process;
  3281. ***************
  3282. *** 1876,1881 ****
  3283. --- 1945,1954 ----
  3284.           close (out);
  3285.       }
  3286.       }
  3287. + #else /* EMX */
  3288. +       for (i = 3; i < MAXDESC; i++)
  3289. +         fcntl (i, F_SETFD, 1);
  3290. + #endif /* EMX */
  3291.   #endif
  3292.   }
  3293.   
  3294. ***************
  3295. *** 2475,2480 ****
  3296. --- 2548,2557 ----
  3297.       }
  3298.   #else /* not VMS */
  3299.   
  3300. + #ifdef EMX
  3301. +   fcntl (channel, F_SETFL, O_NDELAY);
  3302. + #endif /* EMX */
  3303.     if (proc_buffered_char[channel] < 0)
  3304.       nchars = read (channel, chars, sizeof (chars));
  3305.     else
  3306. ***************
  3307. *** 3454,3468 ****
  3308. --- 3531,3552 ----
  3309.           EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
  3310.       }
  3311.   
  3312. + #ifdef EMX
  3313. +       emx_async_delete_now ();
  3314. + #endif /* EMX */
  3315.         /* On some systems, we must return right away.
  3316.        If any more processes want to signal us, we will
  3317.        get another signal.
  3318.        Otherwise (on systems that have WNOHANG), loop around
  3319.        to use up all the processes that have something to tell us.  */
  3320. + #if defined (EMX) && !defined (POSIX_SIGNALS)
  3321. +       signal (signo, SIG_ACK);
  3322. + #else /* not EMX, or POSIX_SIGNALS */
  3323.   #if defined (USG) && ! (defined (HPUX) && defined (WNOHANG)) || defined (WINDOWSNT)
  3324.   #ifdef USG
  3325.         signal (signo, sigchld_handler);
  3326.   #endif
  3327. + #endif /* not EMX, or POSIX_SIGNALS*/
  3328.         errno = old_errno;
  3329.         return;
  3330.   #endif /* USG, but not HPUX with WNOHANG */
  3331. ***************
  3332. *** 3728,3733 ****
  3333. --- 3812,3821 ----
  3334.   
  3335.   syms_of_process ()
  3336.   {
  3337. + #ifdef EMX
  3338. +   Qstart_process = intern ("start-process");
  3339. +   staticpro (&Qstart_process);
  3340. + #endif /* EMX */
  3341.   #ifdef HAVE_SOCKETS
  3342.     stream_process = intern ("stream");
  3343.   #endif
  3344. diff -c emacs-19\src\sysdep.c:1.1.1.35 emacs-19\src\sysdep.c:1.49
  3345. *** emacs-19\src\sysdep.c:1.1.1.35    Sun Aug 18 23:23:00 1996
  3346. --- emacs-19\src\sysdep.c    Sun Aug 18 23:23:00 1996
  3347. ***************
  3348. *** 18,23 ****
  3349. --- 18,24 ----
  3350.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3351.   Boston, MA 02111-1307, USA.  */
  3352.   
  3353. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3354.   
  3355.   #include <signal.h>
  3356.   #include <setjmp.h>
  3357. ***************
  3358. *** 545,550 ****
  3359. --- 546,554 ----
  3360.     s.main.c_cc[VTIME] = 0;    /* wait forever for at least 1 character  */
  3361.   #endif
  3362.   
  3363. + #ifdef EMX
  3364. +   s.main.c_lflag |= IDEFAULT;   /* Disable termio */
  3365. + #endif /* EMX */
  3366.     s.main.c_lflag |= ICANON;    /* Enable erase/kill and eof processing */
  3367.     s.main.c_cc[VEOF] = 04;    /* insure that EOF is Control-D */
  3368.     s.main.c_cc[VERASE] = CDISABLE;    /* disable erase processing */
  3369. ***************
  3370. *** 678,688 ****
  3371. --- 682,696 ----
  3372.   
  3373.   #else /* No SIGTSTP or USG_JOBCTRL */
  3374.   
  3375. + #ifdef EMX
  3376. +   system ("");
  3377. + #else /* not EMX */
  3378.   /* On a system where suspending is not implemented,
  3379.      instead fork a subshell and let it talk directly to the terminal
  3380.      while we wait.  */
  3381.     sys_subshell ();
  3382.   
  3383. + #endif /* not EMX */
  3384.   #endif /* no USG_JOBCTRL */
  3385.   #endif /* no SIGTSTP */
  3386.   #endif /* not VMS */
  3387. ***************
  3388. *** 1277,1282 ****
  3389. --- 1285,1294 ----
  3390.         tty.main.c_iflag &= ~ISTRIP;    /* don't strip 8th bit on input */
  3391.   #endif
  3392.         tty.main.c_lflag &= ~ECHO;    /* Disable echo */
  3393. + #ifdef EMX
  3394. +       tty.main.c_iflag |= IDELETE;      /* Backspace key should send DEL */
  3395. +       tty.main.c_lflag &= ~IDEFAULT;    /* Enable termio */
  3396. + #endif /* EMX */
  3397.         tty.main.c_lflag &= ~ICANON;    /* Disable erase/kill processing */
  3398.   #ifdef IEXTEN
  3399.         tty.main.c_lflag &= ~IEXTEN;    /* Disable other editing characters.  */
  3400. ***************
  3401. *** 1497,1502 ****
  3402. --- 1509,1519 ----
  3403.   #else
  3404.     setbuf (stdout, _sobuf);
  3405.   #endif
  3406. + #ifdef EMX
  3407. +   _fsetmode (stdout, "b");
  3408. + #endif /* EMX */
  3409.   #ifdef HAVE_WINDOW_SYSTEM
  3410.     /* Emacs' window system on MSDOG uses the `internal terminal' and therefore
  3411.        needs the initialization code below.  */
  3412. ***************
  3413. *** 1581,1589 ****
  3414. --- 1598,1613 ----
  3415.   #ifdef MSDOS
  3416.     *widthp = ScreenCols ();
  3417.     *heightp = ScreenRows ();
  3418. + #else
  3419. + #ifdef EMX
  3420. +   int sz[2];
  3421. +   _scrsize (sz);
  3422. +   *widthp = sz[0]; *heightp = sz[1];
  3423.   #else /* system doesn't know size */
  3424.     *widthp = 0;
  3425.     *heightp = 0;
  3426. + #endif /* not EMX */
  3427.   #endif
  3428.   
  3429.   #endif /* not VMS */
  3430. ***************
  3431. *** 2181,2186 ****
  3432. --- 2205,2211 ----
  3433.         hostname = (char *) alloca (hostname_size);
  3434.       }
  3435.   #ifdef HAVE_SOCKETS
  3436. + #ifndef EMX
  3437.     /* Turn the hostname into the official, fully-qualified hostname.
  3438.        Don't do this if we're going to dump; this can confuse system
  3439.        libraries on some machines and make the dumped emacs core dump. */
  3440. ***************
  3441. *** 2232,2237 ****
  3442. --- 2257,2263 ----
  3443.   #endif
  3444.       }
  3445.       }
  3446. + #endif /* not EMX */
  3447.   #endif /* HAVE_SOCKETS */
  3448.     Vsystem_name = build_string (hostname);
  3449.   #endif /* HAVE_GETHOSTNAME */
  3450. diff -c emacs-19\src\syssignal.h:1.1.1.14 emacs-19\src\syssignal.h:1.9
  3451. *** emacs-19\src\syssignal.h:1.1.1.14    Sun Aug 18 23:23:00 1996
  3452. --- emacs-19\src\syssignal.h    Sun Aug 18 23:23:00 1996
  3453. ***************
  3454. *** 18,23 ****
  3455. --- 18,25 ----
  3456.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3457.   Boston, MA 02111-1307, USA.  */
  3458.   
  3459. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3460.   #ifdef POSIX_SIGNALS
  3461.   
  3462.   /* Don't #include <signal.h>.  That header should always be #included
  3463. ***************
  3464. *** 142,148 ****
  3465. --- 144,154 ----
  3466.   #ifdef WINDOWSNT
  3467.   #define EMACS_KILLPG(gid, signo) (kill (gid, signo))
  3468.   #else
  3469. + #ifdef EMX
  3470. + #define EMACS_KILLPG(gid, signo) emx_killpg ((gid), (signo))
  3471. + #else /* not EMX */
  3472.   #define EMACS_KILLPG(gid, signo) (kill   (-(gid), (signo)))
  3473. + #endif /* not EMX */
  3474.   #endif
  3475.   #endif
  3476.   
  3477. diff -c emacs-19\src\term.c:1.1.1.20 emacs-19\src\term.c:1.28
  3478. *** emacs-19\src\term.c:1.1.1.20    Sun Aug 18 23:23:00 1996
  3479. --- emacs-19\src\term.c    Sun Aug 18 23:23:00 1996
  3480. ***************
  3481. *** 18,23 ****
  3482. --- 18,24 ----
  3483.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3484.   Boston, MA 02111-1307, USA.  */
  3485.   
  3486. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3487.   
  3488.   #include <config.h>
  3489.   #include <stdio.h>
  3490. ***************
  3491. *** 344,349 ****
  3492. --- 345,353 ----
  3493.     OUTPUT_IF (TS_end_keypad_mode);
  3494.     OUTPUT_IF (TS_end_visual_mode);
  3495.     OUTPUT_IF (TS_end_termcap_modes);
  3496. + #ifdef EMX
  3497. +   _fsetmode (stdout, "t");
  3498. + #endif /* EMX */
  3499.     /* Output raw CR so kernel can track the cursor hpos.  */
  3500.     /* But on magic-cookie terminals this can erase an end-standout marker and
  3501.        cause the rest of the frame to be in standout, so move down first.  */
  3502. diff -c emacs-19\src\termcap.c:1.1.1.13 emacs-19\src\termcap.c:1.27
  3503. *** emacs-19\src\termcap.c:1.1.1.13    Sun Aug 18 23:23:02 1996
  3504. --- emacs-19\src\termcap.c    Sun Aug 18 23:23:02 1996
  3505. ***************
  3506. *** 16,21 ****
  3507. --- 16,23 ----
  3508.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3509.   Boston, MA 02111-1307, USA.  */
  3510.   
  3511. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3512.   /* Emacs config.h may rename various library functions such as malloc.  */
  3513.   #ifdef HAVE_CONFIG_H
  3514.   #include <config.h>
  3515. ***************
  3516. *** 365,370 ****
  3517. --- 367,377 ----
  3518.   static int compare_contin ();
  3519.   static int name_match ();
  3520.   
  3521. + #ifdef EMX
  3522. + #define valid_filename_p(fn) (IS_DIRECTORY_SEP (*(fn)) || _fngetdrive (fn))
  3523. + #else /* not EMX */
  3524.   #ifdef VMS
  3525.   
  3526.   #include <rmsdef.h>
  3527. ***************
  3528. *** 404,409 ****
  3529. --- 411,417 ----
  3530.   #endif
  3531.   
  3532.   #endif /* !VMS */
  3533. + #endif /* not EMX */
  3534.   
  3535.   /* Find the termcap entry data for terminal type NAME
  3536.      and store it in the block that BP points to.
  3537. diff -c emacs-19\src\termhooks.h:1.1.1.16 emacs-19\src\termhooks.h:1.30
  3538. *** emacs-19\src\termhooks.h:1.1.1.16    Sun Aug 18 23:23:02 1996
  3539. --- emacs-19\src\termhooks.h    Sun Aug 18 23:23:02 1996
  3540. ***************
  3541. *** 19,24 ****
  3542. --- 19,26 ----
  3543.   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  3544.   Boston, MA 02111-1307, USA.  */
  3545.   
  3546. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3547.   
  3548.   /* Miscellanea.   */
  3549.   
  3550. ***************
  3551. *** 307,313 ****
  3552. --- 309,319 ----
  3553.   
  3554.   /* This is used in keyboard.c, to tell how many buttons we will need
  3555.      to track the positions of.  */
  3556. + #ifdef HAVE_PM
  3557. + #define NUM_MOUSE_BUTTONS (5+2)
  3558. + #else /* not HAVE_PM */
  3559.   #define NUM_MOUSE_BUTTONS (5)
  3560. + #endif /* not HAVE_PM */
  3561.   
  3562.   /* Bits in the modifiers member of the input_event structure.
  3563.      Note that reorder_modifiers assumes that the bits are in canonical
  3564. diff -c emacs-19\src\xfaces.c:1.1.1.30 emacs-19\src\xfaces.c:1.60
  3565. *** emacs-19\src\xfaces.c:1.1.1.30    Sun Aug 18 23:23:04 1996
  3566. --- emacs-19\src\xfaces.c    Sun Aug 18 23:23:04 1996
  3567. ***************
  3568. *** 20,25 ****
  3569. --- 20,27 ----
  3570.   
  3571.   /* This is derived from work by Lucid (some parts very loosely so).  */
  3572.   
  3573. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3574.   #include <sys/types.h>
  3575.   #include <sys/stat.h>
  3576.   
  3577. ***************
  3578. *** 29,35 ****
  3579. --- 31,42 ----
  3580.   #ifdef HAVE_FACES
  3581.   
  3582.   #ifdef HAVE_X_WINDOWS
  3583. + #ifdef HAVE_PM
  3584. + #include "pmterm.h"
  3585. + #include "pmemacs.h"
  3586. + #else /* not HAVE_PM */
  3587.   #include "xterm.h"
  3588. + #endif /* not HAVE_PM */
  3589.   #endif
  3590.   #ifdef MSDOS
  3591.   #include "dosfns.h"
  3592. ***************
  3593. *** 56,62 ****
  3594. --- 63,71 ----
  3595.   
  3596.   #else
  3597.   
  3598. + #ifndef HAVE_PM
  3599.   #include <X11/Xos.h>
  3600. + #endif /* not HAVE_PM */
  3601.   
  3602.   #endif
  3603.   #endif /* HAVE_X_WINDOWS */
  3604. ***************
  3605. *** 218,223 ****
  3606. --- 227,234 ----
  3607.   #ifdef HAVE_X_WINDOWS
  3608.   /* Given a computed face, construct its graphics context if necessary.  */
  3609.   
  3610. + #ifndef HAVE_PM
  3611.   struct face *
  3612.   intern_face (f, face)
  3613.        struct frame *f;
  3614. ***************
  3615. *** 267,272 ****
  3616. --- 278,328 ----
  3617.     return face;
  3618.   }
  3619.   
  3620. + #else /* HAVE_PM */
  3621. + struct face *
  3622. + intern_face (f, face)
  3623. +      struct frame *f;
  3624. +      struct face *face;
  3625. + {
  3626. +   pm_request pmr;
  3627. +   char *name;
  3628. +   if (face->gc)
  3629. +     return face;
  3630. +   BLOCK_INPUT;
  3631. +   if (face->foreground != FACE_DEFAULT)
  3632. +     pmr.face.foreground = face->foreground;
  3633. +   else
  3634. +     pmr.face.foreground = f->output_data.x->foreground_color;
  3635. +   if (face->background != FACE_DEFAULT)
  3636. +     pmr.face.background = face->background;
  3637. +   else
  3638. +     pmr.face.background = f->output_data.x->background_color;
  3639. +   if (face->font && (int)face->font != FACE_DEFAULT)
  3640. +     name = face->font->name;
  3641. +   else
  3642. +     name = f->output_data.x->font->name;
  3643. +   pmr.face.name_length = strlen (name);
  3644. +   pmr.face.underline = face->underline;
  3645. +   pmr.face.serial = pm_serial++;
  3646. +   pmr.face.header.type = PMR_FACE;
  3647. +   pmr.face.header.frame = (unsigned long)f;
  3648. +   pm_send (&pmr, sizeof (pmr));
  3649. +   pm_send (name, pmr.face.name_length);
  3650. +   if (pm_receive (pmr.face.serial, &face->gc, 0, 0) == 0)
  3651. +     face->gc = 0;
  3652. +   UNBLOCK_INPUT;
  3653. +   return face;
  3654. + }
  3655. + #endif /* HAVE_PM */
  3656.   /* Clear out all graphics contexts for all computed faces
  3657.      except for the default and mode line faces.
  3658.      This should be done from time to time just to avoid
  3659. ***************
  3660. *** 384,389 ****
  3661. --- 440,446 ----
  3662.        struct frame *f;
  3663.        unsigned long pixel;
  3664.   {
  3665. + #ifndef HAVE_PM
  3666.     Colormap cmap;
  3667.     Display *dpy = FRAME_X_DISPLAY (f);
  3668.     int class = FRAME_X_DISPLAY_INFO (f)->visual->class;
  3669. ***************
  3670. *** 422,427 ****
  3671. --- 479,485 ----
  3672.         XFreeColors (dpy, cmap, &pixel, 1, (unsigned long)0);
  3673.         UNBLOCK_INPUT;
  3674.       }
  3675. + #endif /* not HAVE_PM */
  3676.   }
  3677.   
  3678.   DEFUN ("pixmap-spec-p", Fpixmap_spec_p, Spixmap_spec_p, 1, 1, 0,
  3679. ***************
  3680. *** 460,465 ****
  3681. --- 518,526 ----
  3682.        Lisp_Object name;
  3683.        unsigned int *w_ptr, *h_ptr;
  3684.   {
  3685. + #ifdef HAVE_PM
  3686. +   return FACE_DEFAULT;
  3687. + #else /* not HAVE_PM */
  3688.     int bitmap_id;
  3689.     Lisp_Object tem;
  3690.   
  3691. ***************
  3692. *** 501,506 ****
  3693. --- 562,568 ----
  3694.     *h_ptr = x_bitmap_height (f, bitmap_id);
  3695.   
  3696.     return bitmap_id;
  3697. + #endif /* not HAVE_PM */
  3698.   }
  3699.   
  3700.   #else /* !HAVE_X_WINDOWS */
  3701. ***************
  3702. *** 740,749 ****
  3703. --- 802,815 ----
  3704.   same_size_fonts (font1, font2)
  3705.        XFontStruct *font1, *font2;
  3706.   {
  3707. + #ifndef HAVE_PM
  3708.     XCharStruct *bounds1 = &font1->min_bounds;
  3709.     XCharStruct *bounds2 = &font2->min_bounds;
  3710.   
  3711.     return (bounds1->width == bounds2->width);
  3712. + #else /* HAVE_PM */
  3713. +   return 1;
  3714. + #endif /* HAVE_PM */
  3715.   }
  3716.   
  3717.   /* Update the line_height of frame F according to the biggest font in
  3718. ***************
  3719. *** 1162,1169 ****
  3720. --- 1228,1237 ----
  3721.         face->font = (XFontStruct *)1 ;
  3722.   #else
  3723.         XFontStruct *font = load_font (f, attr_value);
  3724. + #ifndef HAVE_PM
  3725.         if (face->font != f->output_data.x->font)
  3726.       unload_font (f, face->font);
  3727. + #endif /* not HAVE_PM */
  3728.         face->font = font;
  3729.         if (frame_update_line_height (f))
  3730.       x_set_window_size (f, 0, f->width, f->height);
  3731. diff -c emacs-19\src\xmenu.c:1.1.1.35 emacs-19\src\xmenu.c:1.86
  3732. *** emacs-19\src\xmenu.c:1.1.1.35    Sun Aug 18 23:23:06 1996
  3733. --- emacs-19\src\xmenu.c    Sun Aug 18 23:23:06 1996
  3734. ***************
  3735. *** 30,35 ****
  3736. --- 30,37 ----
  3737.   
  3738.   /* Rewritten for clarity and GC protection by rms in Feb 94.  */
  3739.   
  3740. + /* Modified for emx by Eberhard Mattes, Aug 1996 */
  3741.   /* On 4.3 this loses if it comes after xterm.h.  */
  3742.   #include <signal.h>
  3743.   #include <config.h>
  3744. ***************
  3745. *** 44,49 ****
  3746. --- 46,55 ----
  3747.   #include "puresize.h"
  3748.   #include "buffer.h"
  3749.   
  3750. + #ifdef HAVE_PM
  3751. + #include "pmterm.h"
  3752. + #include "pmemacs.h"
  3753. + #else /* not HAVE_PM */
  3754.   #ifdef MSDOS
  3755.   #include "msdos.h"
  3756.   #endif
  3757. ***************
  3758. *** 53,58 ****
  3759. --- 59,65 ----
  3760.      if this is not done before the other system files.  */
  3761.   #include "xterm.h"
  3762.   #endif
  3763. + #endif /* not HAVE_PM */
  3764.   
  3765.   /* Load sys/types.h if not already loaded.
  3766.      In some systems loading it twice is suicidal.  */
  3767. ***************
  3768. *** 62,67 ****
  3769. --- 69,75 ----
  3770.   
  3771.   #include "dispextern.h"
  3772.   
  3773. + #ifndef HAVE_PM
  3774.   #ifdef HAVE_X_WINDOWS
  3775.   #ifdef USE_X_TOOLKIT
  3776.   #include <X11/Xlib.h>
  3777. ***************
  3778. *** 77,82 ****
  3779. --- 85,91 ----
  3780.   #include "../oldXMenu/XMenu.h"
  3781.   #endif /* not USE_X_TOOLKIT */
  3782.   #endif /* HAVE_X_WINDOWS */
  3783. + #endif /* not HAVE_PM */
  3784.   
  3785.   #define min(x,y) (((x) < (y)) ? (x) : (y))
  3786.   #define max(x,y) (((x) > (y)) ? (x) : (y))
  3787. ***************
  3788. *** 96,101 ****
  3789. --- 105,116 ----
  3790.   
  3791.   extern Lisp_Object Vdefine_key_rebound_commands;
  3792.   
  3793. + #ifdef HAVE_PM
  3794. + static int pm_menu_button;
  3795. + static int pm_align_menu_key_descriptions;
  3796. + static int pm_popup_menu_align_top;
  3797. + #endif /* HAVE_PM */
  3798.   extern Lisp_Object Voverriding_local_map;
  3799.   extern Lisp_Object Voverriding_local_map_menu_flag;
  3800.   
  3801. ***************
  3802. *** 105,112 ****
  3803. --- 120,129 ----
  3804.   
  3805.   #ifdef USE_X_TOOLKIT
  3806.   extern void set_frame_menubar ();
  3807. + #ifndef HAVE_PM
  3808.   extern void process_expose_from_menu ();
  3809.   extern XtAppContext Xt_app_con;
  3810. + #endif /* not HAVE_PM */
  3811.   
  3812.   static Lisp_Object xdialog_show ();
  3813.   void popup_get_selection ();
  3814. ***************
  3815. *** 182,187 ****
  3816. --- 199,205 ----
  3817.   int pending_menu_activation;
  3818.   
  3819.   #ifdef USE_X_TOOLKIT
  3820. + #ifndef HAVE_PM
  3821.   
  3822.   /* Return the frame whose ->output_data.x->id equals ID, or 0 if none.  */
  3823.   
  3824. ***************
  3825. *** 206,211 ****
  3826. --- 224,230 ----
  3827.     return 0;
  3828.   }
  3829.   
  3830. + #endif /* not HAVE_PM */
  3831.   #endif
  3832.   
  3833.   /* Initialize the menu_items structure if we haven't already done so.
  3834. ***************
  3835. *** 419,426 ****
  3836. --- 438,455 ----
  3837.         if (!NILP (savedkey))
  3838.       {
  3839.         descrip = Fkey_description (savedkey);
  3840. + #ifndef HAVE_PM
  3841.         descrip = concat2 (make_string ("  (", 3), descrip);
  3842.         descrip = concat2 (descrip, make_string (")", 1));
  3843. + #else /* HAVE_PM */
  3844. +       if (pm_align_menu_key_descriptions)
  3845. +         descrip = concat2 (make_string ("\t", 1), descrip);
  3846. +       else
  3847. +         {
  3848. +           descrip = concat2 (make_string ("  (", 3), descrip);
  3849. +           descrip = concat2 (descrip, make_string (")", 1));
  3850. +         }
  3851. + #endif /* HAVE_PM */
  3852.       }
  3853.       }
  3854.   
  3855. ***************
  3856. *** 784,789 ****
  3857. --- 813,821 ----
  3858.     struct gcpro gcpro1;
  3859.   
  3860.   #ifdef HAVE_MENUS
  3861. + #ifdef HAVE_PM
  3862. +   pm_menu_button = 0;
  3863. + #endif /* HAVE_PM */
  3864.     if (! NILP (position))
  3865.       {
  3866.         check_x ();
  3867. ***************
  3868. *** 827,832 ****
  3869. --- 859,867 ----
  3870.             tem = Fcar (Fcdr (Fcdr (tem))); /* POSN_WINDOW_POSN (tem) */
  3871.             x = Fcar (tem);
  3872.             y = Fcdr (tem);
  3873. + #ifdef HAVE_PM
  3874. +           pm_menu_button = pm_event_button (position);
  3875. + #endif /* HAVE_PM */
  3876.           }
  3877.       }
  3878.   
  3879. ***************
  3880. *** 1071,1076 ****
  3881. --- 1106,1112 ----
  3882.   
  3883.   #ifdef USE_X_TOOLKIT
  3884.   
  3885. + #ifndef HAVE_PM
  3886.   /* Loop in Xt until the menu pulldown or dialog popup has been
  3887.      popped down (deactivated).  This is used for x-popup-menu
  3888.      and x-popup-dialog; it is not used for the menu bar any more.
  3889. ***************
  3890. *** 1211,1216 ****
  3891. --- 1247,1253 ----
  3892.     /* Ignore this if we get it a second time.  */
  3893.     f->output_data.x->saved_menu_event->type = 0;
  3894.   }
  3895. + #endif /* not HAVE_PM */
  3896.   
  3897.   /* Detect if a dialog or menu has been posted.  */
  3898.   
  3899. ***************
  3900. *** 1220,1226 ****
  3901.     return popup_activated_flag;
  3902.   }
  3903.   
  3904.   /* This callback is invoked when the user selects a menubar cascade
  3905.      pushbutton, but before the pulldown menu is posted.  */
  3906.   
  3907. --- 1257,1263 ----
  3908.     return popup_activated_flag;
  3909.   }
  3910.   
  3911. ! #ifndef HAVE_PM
  3912.   /* This callback is invoked when the user selects a menubar cascade
  3913.      pushbutton, but before the pulldown menu is posted.  */
  3914.   
  3915. ***************
  3916. *** 1232,1237 ****
  3917. --- 1269,1275 ----
  3918.   {
  3919.     popup_activated_flag = 1;
  3920.   }
  3921. + #endif /* not HAVE_PM */
  3922.   
  3923.   /* This callback is called from the menu bar pulldown menu
  3924.      when the user makes a selection.
  3925. ***************
  3926. *** 1245,1251 ****
  3927. --- 1283,1293 ----
  3928.        XtPointer client_data;
  3929.   {
  3930.     Lisp_Object prefix, entry;
  3931. + #ifdef HAVE_PM
  3932. +   FRAME_PTR f = (FRAME_PTR) id;
  3933. + #else /* not HAVE_PM */
  3934.     FRAME_PTR f = menubar_id_to_frame (id);
  3935. + #endif /* not HAVE_PM */
  3936.     Lisp_Object vector;
  3937.     Lisp_Object *subprefix_stack;
  3938.     int submenu_depth = 0;
  3939. ***************
  3940. *** 1317,1322 ****
  3941. --- 1359,1365 ----
  3942.       }
  3943.   }
  3944.   
  3945. + #ifndef HAVE_PM
  3946.   /* This callback is invoked when a dialog or menu is finished being
  3947.      used and has been unposted.  */
  3948.   
  3949. ***************
  3950. *** 1833,1838 ****
  3951. --- 1876,1882 ----
  3952.   
  3953.     UNBLOCK_INPUT;
  3954.   }
  3955. + #endif /* not HAVE_PM */
  3956.   
  3957.   /* Called from Fx_create_frame to create the initial menubar of a frame
  3958.      before it is mapped, so that the window is mapped with the menubar already
  3959. ***************
  3960. *** 1852,1857 ****
  3961. --- 1896,1902 ----
  3962.   /* Get rid of the menu bar of frame F, and free its storage.
  3963.      This is used when deleting a frame, and when turning off the menu bar.  */
  3964.   
  3965. + #ifndef HAVE_PM
  3966.   void
  3967.   free_frame_menubar (f)
  3968.        FRAME_PTR f;
  3969. ***************
  3970. *** 1869,1874 ****
  3971. --- 1914,1920 ----
  3972.       }
  3973.   }
  3974.   
  3975. + #endif /* not HAVE_PM */
  3976.   #endif /* USE_X_TOOLKIT */
  3977.   
  3978.   /* xmenu_show actually displays a menu using the panes and items in menu_items
  3979. ***************
  3980. *** 1887,1892 ****
  3981. --- 1933,1939 ----
  3982.      ERROR is a place to store an error message string in case of failure.
  3983.      (We return nil on failure, but the value doesn't actually matter.)  */
  3984.   
  3985. + #ifndef HAVE_PM
  3986.   #ifdef USE_X_TOOLKIT
  3987.   
  3988.   /* We need a unique id for each widget handled by the Lucid Widget
  3989. ***************
  3990. *** 2690,2695 ****
  3991. --- 2737,3315 ----
  3992.   
  3993.   #endif /* not USE_X_TOOLKIT */
  3994.   
  3995. + #else /* HAVE_PM */
  3996. + static int pmmenu_count;
  3997. + static int pmmenu_alloc;
  3998. + static pm_menu *pmmenu_menu;
  3999. + static int pmmenu_str_size;
  4000. + static int pmmenu_str_alloc;
  4001. + static char *pmmenu_str;
  4002. + static void pmmenu_add (const pm_menu *pmm)
  4003. + {
  4004. +   if (pmmenu_count >= pmmenu_alloc)
  4005. +     {
  4006. +       pmmenu_alloc += 512;
  4007. +       pmmenu_menu = (pm_menu *)xrealloc (pmmenu_menu,
  4008. +                                          pmmenu_alloc * sizeof (pm_menu));
  4009. +     }
  4010. +   pmmenu_menu[pmmenu_count++] = *pmm;
  4011. + }
  4012. + /* Copy S to D, replacing ~  characters with ~~. */
  4013. + static void tilde_expand (char *d, const char *s)
  4014. + {
  4015. +   while (*s != 0)
  4016. +     {
  4017. +       if (*s == '~')
  4018. +         *d++ = *s;
  4019. +       *d++ = *s++;
  4020. +     }
  4021. +   *d = 0;
  4022. + }
  4023. + /* Compute the length of string S.  If TILDE is true, count ~
  4024. +    characters twice.  Store the length to *LEN.  Return true if TILDE
  4025. +    is true and there are any ~ characters. */
  4026. + static int tilde_len (int *len, const char *s, int tilde)
  4027. + {
  4028. +   int nc = 0, nt = 0;
  4029. +   if (tilde)
  4030. +     while (*s != 0)
  4031. +       {
  4032. +         if (*s == '~')
  4033. +           ++nt;
  4034. +         ++nc; ++s;
  4035. +       }
  4036. +   else
  4037. +     nc = strlen (s);
  4038. +   *len = nc + nt;
  4039. +   return nt != 0;
  4040. + }
  4041. + /* Add the concatenation of S1 and S2 to the string pool for sending
  4042. +    it to pmemacs.exe.  Replace ~ with ~~ if TILDE is true.  Return the
  4043. +    offset of the string. */
  4044. + static int pmmenu_add_str (const char *s1, const char *s2, int tilde)
  4045. + {
  4046. +   int len1, len2;
  4047. +   int result = pmmenu_str_size;
  4048. +   if (tilde_len (&len1, s1, tilde))
  4049. +     {
  4050. +       char *tem = alloca (len1 + 1);
  4051. +       tilde_expand (tem, s1);
  4052. +       s1 = tem;
  4053. +     }
  4054. +   if (tilde_len (&len2, s2, tilde))
  4055. +     {
  4056. +       char *tem = alloca (len2 + 1);
  4057. +       tilde_expand (tem, s2);
  4058. +       s2 = tem;
  4059. +     }
  4060. +   ++len2;            /* Include the terminating null character */
  4061. +   while (pmmenu_str_size + len1 + len2 > pmmenu_str_alloc)
  4062. +     {
  4063. +       pmmenu_str_alloc += 4096;
  4064. +       pmmenu_str = (char *)xrealloc (pmmenu_str, pmmenu_str_alloc);
  4065. +     }
  4066. +   bcopy (s1, pmmenu_str + pmmenu_str_size, len1);
  4067. +   bcopy (s2, pmmenu_str + pmmenu_str_size + len1, len2);
  4068. +   pmmenu_str_size += len1 + len2;
  4069. +   return result;
  4070. + }
  4071. + /* Return true if NAME looks like a menu separator string.  */
  4072. + static int menu_sep_p (Lisp_Object name)
  4073. + {
  4074. +   const char *p;
  4075. +   if (!STRINGP (name))
  4076. +     return 0;
  4077. +   for (p = XSTRING (name)->data; *p != 0; ++p)
  4078. +     if (*p != ' ' && *p != '-')
  4079. +       return 0;
  4080. +   return 1;
  4081. + }
  4082. + static void
  4083. + make_pmmenu (int i, int menubarp, int keymaps)
  4084. + {
  4085. +   pm_menu pmm;
  4086. +   int submenu_depth = 0;
  4087. +   int sel = 0;
  4088. +   while (i < menu_items_used)
  4089. +     {
  4090. +       if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
  4091. +     {
  4092. +           pmm.type = PMMENU_PUSH;
  4093. +           pmmenu_add (&pmm);
  4094. +           submenu_depth++;
  4095. +           i++;
  4096. +     }
  4097. +       else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
  4098. +     {
  4099. +           pmm.type = PMMENU_POP;
  4100. +           pmmenu_add (&pmm);
  4101. +           --submenu_depth;
  4102. +       i++;
  4103. +     }
  4104. +       else if (EQ (XVECTOR (menu_items)->contents[i], Qt)
  4105. +            && submenu_depth != 0)
  4106. +     i += MENU_ITEMS_PANE_LENGTH;
  4107. +       /* Ignore a nil in the item list.
  4108. +      It's meaningful only for dialog boxes.  */
  4109. +       else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
  4110. +     i += 1;
  4111. +       else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
  4112. +     {
  4113. +       /* Create a new pane.  */
  4114. +       Lisp_Object pane_name, prefix;
  4115. +       char *pane_string;
  4116. +       pane_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_NAME];
  4117. +       prefix = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
  4118. +       pane_string = (NILP (pane_name)
  4119. +              ? "" : (char *) XSTRING (pane_name)->data);
  4120. +       /* If there is just one top-level pane, put all its items directly
  4121. +          under the top-level menu.  */
  4122. +       if (menu_items_n_panes == 1)
  4123. +         pane_string = "";
  4124. +       /* If the pane has a meaningful name,
  4125. +          make the pane a top-level menu item
  4126. +          with its items as a submenu beneath it.  */
  4127. +       if (!keymaps && strcmp (pane_string, ""))
  4128. +         {
  4129. +           if (keymaps && !NILP (prefix))
  4130. +         pane_string++;
  4131. +               pmm.type = PMMENU_SUB;
  4132. +               pmm.item = 0;
  4133. +               pmm.str_offset = pmmenu_add_str (pane_string, "", 1);
  4134. +               pmm.enable = 1;
  4135. +               pmmenu_add (&pmm);
  4136. +         }
  4137. +       i += MENU_ITEMS_PANE_LENGTH;
  4138. +     }
  4139. +       else
  4140. +     {
  4141. +       /* Create a new item within current pane.  */
  4142. +       Lisp_Object item_name, enable, descrip, value, def;
  4143. +       item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
  4144. +       value = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
  4145. +       enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
  4146. +       descrip
  4147. +         = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_EQUIV_KEY];
  4148. +       def = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_DEFINITION];
  4149. +       /* Check for separator lines.  */
  4150. +       if (menu_sep_p (item_name) && NILP (def))
  4151. +         {
  4152. +           /* The code processing the value returned by pmemacs
  4153. +                  does not check for separators, therefore we must
  4154. +                  update `sel' even for separators.  */
  4155. +           ++sel;
  4156. +           pmm.type = PMMENU_SEP;
  4157. +         }
  4158. +       else
  4159. +         {
  4160. +           pmm.type = PMMENU_ITEM;
  4161. +           pmm.item = (menubarp ? i : ++sel);
  4162. +           pmm.str_offset
  4163. +         = pmmenu_add_str (XSTRING (item_name)->data,
  4164. +                   (NILP (descrip) ? ""
  4165. +                    : (char*)XSTRING (descrip)->data),
  4166. +                   1);
  4167. +           pmm.enable = !NILP (enable);
  4168. +         }
  4169. +       pmmenu_add (&pmm);
  4170. +       i += MENU_ITEMS_ITEM_LENGTH;
  4171. +     }
  4172. +     }
  4173. +   pmm.type = PMMENU_END;
  4174. +   pmmenu_add (&pmm);
  4175. + }
  4176. + static Lisp_Object
  4177. + xmenu_show (f, x, y, for_click, keymaps, title, error)
  4178. +      FRAME_PTR f;
  4179. +      int x, y;
  4180. +      int for_click;
  4181. +      int keymaps;
  4182. +      Lisp_Object title;
  4183. +      char **error;
  4184. + {
  4185. +   int i, sel, serial;
  4186. +   Lisp_Object *subprefix_stack
  4187. +     = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
  4188. +   int submenu_depth = 0;
  4189. +   pm_request pmr;
  4190. +   pm_menu pmm;
  4191. +   *error = 0;
  4192. +   if (menu_items_n_panes == 0)
  4193. +     return Qnil;
  4194. +   if (menu_items_used <= MENU_ITEMS_PANE_LENGTH)
  4195. +     {
  4196. +       *error = "Empty menu";
  4197. +       return Qnil;
  4198. +     }
  4199. +   pmmenu_count = 0; pmmenu_str_size = 0;
  4200. +   make_pmmenu (0, 0, keymaps);
  4201. +   BLOCK_INPUT;
  4202. +   pmr.popupmenu.header.type = PMR_POPUPMENU;
  4203. +   pmr.popupmenu.header.frame = (unsigned long)f;
  4204. +   pmr.popupmenu.serial = serial = pm_serial++;
  4205. +   pmr.popupmenu.x = x;
  4206. +   pmr.popupmenu.y = y;
  4207. +   pmr.popupmenu.align_top = pm_popup_menu_align_top;
  4208. +   pmr.popupmenu.button = pm_menu_button;
  4209. +   pmr.popupmenu.count = pmmenu_count;
  4210. +   pmr.popupmenu.size = pmmenu_count * sizeof (pm_menu) + pmmenu_str_size;
  4211. +   pm_send (&pmr, sizeof (pmr));
  4212. +   pm_send (pmmenu_menu, pmmenu_count * sizeof (pm_menu));
  4213. +   pm_send (pmmenu_str, pmmenu_str_size);
  4214. +   if (pm_receive (serial, &sel, NULL, 1) == NULL)
  4215. +     sel = 0;
  4216. +   UNBLOCK_INPUT;
  4217. +   /* Find the selected item, and its pane, to return the proper value. */
  4218. +   if (sel != 0)
  4219. +     {
  4220. +       Lisp_Object prefix, entry;
  4221. +       prefix = Qnil;
  4222. +       i = 0;
  4223. +       while (i < menu_items_used)
  4224. +         {
  4225. +           if (EQ (XVECTOR (menu_items)->contents[i], Qnil))
  4226. +             {
  4227. +               subprefix_stack[submenu_depth++] = prefix;
  4228. +               prefix = entry;
  4229. +               i++;
  4230. +             }
  4231. +           else if (EQ (XVECTOR (menu_items)->contents[i], Qlambda))
  4232. +             {
  4233. +               prefix = subprefix_stack[--submenu_depth];
  4234. +               i++;
  4235. +             }
  4236. +           else if (EQ (XVECTOR (menu_items)->contents[i], Qt))
  4237. +             {
  4238. +               prefix
  4239. +                 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_PANE_PREFIX];
  4240. +               i += MENU_ITEMS_PANE_LENGTH;
  4241. +         }
  4242. +           /* Ignore a quote in the item list.
  4243. +              It's meaningful only for dialog boxes.  */
  4244. +           else if (EQ (XVECTOR (menu_items)->contents[i], Qquote))
  4245. +             i += 1;
  4246. +       else
  4247. +         {
  4248. +               entry
  4249. +                 = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_VALUE];
  4250. +           if (--sel == 0)
  4251. +         {
  4252. +           if (keymaps != 0)
  4253. +             {
  4254. +               int j;
  4255. +               entry = Fcons (entry, Qnil);
  4256. +               if (!NILP (prefix))
  4257. +             entry = Fcons (prefix, entry);
  4258. +               for (j = submenu_depth - 1; j >= 0; j--)
  4259. +             if (!NILP (subprefix_stack[j]))
  4260. +               entry = Fcons (subprefix_stack[j], entry);
  4261. +             }
  4262. +           return entry;
  4263. +         }
  4264. +           i += MENU_ITEMS_ITEM_LENGTH;
  4265. +         }
  4266. +     }
  4267. +     }
  4268. +   return Qnil;
  4269. + }
  4270. + static Lisp_Object
  4271. + xdialog_show (f, keymaps, title, error)
  4272. +      FRAME_PTR f;
  4273. +      int keymaps;
  4274. +      Lisp_Object title;
  4275. +      char **error;
  4276. + {
  4277. +   int nb_buttons = 0;
  4278. +   int i, sel;
  4279. +   pm_request pmr;
  4280. +   pm_menu pmm;
  4281. +   *error = NULL;
  4282. +   if (menu_items_n_panes > 1)
  4283. +     {
  4284. +       *error = "Multiple panes in dialog box";
  4285. +       return Qnil;
  4286. +     }
  4287. +   pmmenu_count = 0; pmmenu_str_size = 0;
  4288. +   if (XSTRING (title)->size != 0)
  4289. +     {
  4290. +       pmm.type = PMMENU_TITLE;
  4291. +       pmm.item = 0;
  4292. +       pmm.str_offset = pmmenu_add_str (XSTRING (title)->data, "", 0);
  4293. +       pmm.enable = 0;
  4294. +       pmmenu_add (&pmm);
  4295. +     }
  4296. +   /* Loop over all panes and items, filling in the tree.  */
  4297. +   i = MENU_ITEMS_PANE_LENGTH;
  4298. +   while (i < menu_items_used)
  4299. +     {
  4300. +     
  4301. +       /* Create a new item within current pane.  */
  4302. +       Lisp_Object item_name, enable;
  4303. +       item_name = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_NAME];
  4304. +       enable = XVECTOR (menu_items)->contents[i + MENU_ITEMS_ITEM_ENABLE];
  4305. +     
  4306. +       if (NILP (item_name))
  4307. +         {
  4308. +           *error = "Submenu in dialog items";
  4309. +           return Qnil;
  4310. +         }
  4311. +       if (EQ (item_name, Qquote))
  4312. +         {
  4313. +           /* This is the boundary between left-side elts
  4314. +              and right-side elts.  */
  4315. +           i++;
  4316. +           continue;
  4317. +         }
  4318. +       if (nb_buttons >= 10)
  4319. +         {
  4320. +           *error = "Too many dialog items";
  4321. +           return Qnil;
  4322. +         }
  4323. +       pmm.type = PMMENU_ITEM;
  4324. +       pmm.item = i + 1;
  4325. +       pmm.str_offset = pmmenu_add_str (XSTRING (item_name)->data, "", 0);
  4326. +       pmm.enable = !NILP (enable);
  4327. +       pmmenu_add (&pmm);
  4328. +       nb_buttons++;
  4329. +       i += MENU_ITEMS_ITEM_LENGTH;
  4330. +     }
  4331. +   pmm.type = PMMENU_END;
  4332. +   pmmenu_add (&pmm);
  4333. +   BLOCK_INPUT;
  4334. +   pmr.dialog.header.type = PMR_DIALOG;
  4335. +   pmr.dialog.header.frame = (unsigned long)f;
  4336. +   pmr.dialog.serial = pm_serial++;
  4337. +   pmr.dialog.buttons = nb_buttons;
  4338. +   pmr.dialog.count = pmmenu_count;
  4339. +   pmr.dialog.size = pmmenu_count * sizeof (pm_menu) + pmmenu_str_size;
  4340. +   pm_send (&pmr, sizeof (pmr));
  4341. +   pm_send (pmmenu_menu, pmmenu_count * sizeof (pm_menu));
  4342. +   pm_send (pmmenu_str, pmmenu_str_size);
  4343. +   if (pm_receive (pmr.dialog.serial, &sel, NULL, 1) == NULL)
  4344. +     sel = 0;
  4345. +   UNBLOCK_INPUT;
  4346. +   if (sel == 0)
  4347. +     return Qnil;
  4348. +   return XVECTOR (menu_items)->contents[sel - 1 + MENU_ITEMS_ITEM_VALUE];
  4349. + }
  4350. + static void
  4351. + single_submenu (item_key, item_name, maps)
  4352. +      Lisp_Object item_key, item_name, maps;
  4353. + {
  4354. +   int i;
  4355. +   int submenu_depth = 0;
  4356. +   Lisp_Object length;
  4357. +   int len;
  4358. +   Lisp_Object *mapvec;
  4359. +   int previous_items = menu_items_used;
  4360. +   pm_menu pmm;
  4361. +   char *name;
  4362. +   length = Flength (maps);
  4363. +   len = XINT (length);
  4364. +   /* Convert the list MAPS into a vector MAPVEC.  */
  4365. +   mapvec = (Lisp_Object *) alloca (len * sizeof (Lisp_Object));
  4366. +   for (i = 0; i < len; i++)
  4367. +     {
  4368. +       mapvec[i] = Fcar (maps);
  4369. +       maps = Fcdr (maps);
  4370. +     }
  4371. +   menu_items_n_panes = 0;
  4372. +   /* Loop over the given keymaps, making a pane for each map.
  4373. +      But don't make a pane that is empty--ignore that map instead.  */
  4374. +   for (i = 0; i < len; i++)
  4375. +     single_keymap_panes (mapvec[i], item_name, item_key, 0);
  4376. +   name = STRINGP (item_name) ? (char *) XSTRING (item_name)->data : "???";
  4377. +   pmm.type = PMMENU_TOP;
  4378. +   pmm.item = 0;
  4379. +   pmm.str_offset = pmmenu_add_str (name, "", 1);
  4380. +   pmm.enable = 1;
  4381. +   pmmenu_add (&pmm);
  4382. +   make_pmmenu (previous_items, 1, 0);
  4383. + }
  4384. + static void
  4385. + update_frame_menubar (f)
  4386. +      FRAME_PTR f;
  4387. + {
  4388. + }
  4389. + void
  4390. + set_frame_menubar (f, first_time, deep_p)
  4391. +      FRAME_PTR f;
  4392. +      int first_time;
  4393. +      int deep_p;
  4394. + {
  4395. +   pm_request pmr;
  4396. +   pm_menu pmm;
  4397. +   Lisp_Object tail, items;
  4398. +   int i;
  4399. +   struct buffer *prev = current_buffer;
  4400. +   Lisp_Object buffer;
  4401. +   int specpdl_count = specpdl_ptr - specpdl;
  4402. +   int previous_menu_items_used = f->menu_bar_items_used;
  4403. +   Lisp_Object *previous_items
  4404. +     = (Lisp_Object *) alloca (previous_menu_items_used
  4405. +                               * sizeof (Lisp_Object));
  4406. +   buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
  4407. +   specbind (Qinhibit_quit, Qt);
  4408. +   /* Don't let the debugger step into this code because it is not
  4409. +      reentrant.  */
  4410. +   specbind (Qdebug_on_next_call, Qnil);
  4411. +   record_unwind_protect (Fstore_match_data, Fmatch_data ());
  4412. +   if (NILP (Voverriding_local_map_menu_flag))
  4413. +     {
  4414. +       specbind (Qoverriding_terminal_local_map, Qnil);
  4415. +       specbind (Qoverriding_local_map, Qnil);
  4416. +     }
  4417. +   set_buffer_internal_1 (XBUFFER (buffer));
  4418. +   /* Run the Lucid hook.  */
  4419. +   call1 (Vrun_hooks, Qactivate_menubar_hook);
  4420. +   /* If it has changed current-menubar from previous value, really
  4421. +      recompute the menubar from the value.  */
  4422. +   if (! NILP (Vlucid_menu_bar_dirty_flag))
  4423. +     call0 (Qrecompute_lucid_menubar);
  4424. +   safe_run_hooks (Qmenu_bar_update_hook);
  4425. +   FRAME_MENU_BAR_ITEMS (f) = menu_bar_items (FRAME_MENU_BAR_ITEMS (f));
  4426. +   items = FRAME_MENU_BAR_ITEMS (f);
  4427. +   inhibit_garbage_collection ();
  4428. +   /* Save the frame's previous menu bar contents data.  */
  4429. +   bcopy (XVECTOR (f->menu_bar_vector)->contents, previous_items,
  4430. +          previous_menu_items_used * sizeof (Lisp_Object));
  4431. +   /* Fill in the current menu bar contents.  */
  4432. +   menu_items = f->menu_bar_vector;
  4433. +   menu_items_allocated = XVECTOR (menu_items)->size;
  4434. +   init_menu_items ();
  4435. +   pmmenu_count = 0; pmmenu_str_size = 0;
  4436. +   for (i = 0; i < XVECTOR (items)->size; i += 4)
  4437. +     {
  4438. +       Lisp_Object key, string, maps;
  4439. +       key = XVECTOR (items)->contents[i];
  4440. +       string = XVECTOR (items)->contents[i + 1];
  4441. +       maps = XVECTOR (items)->contents[i + 2];
  4442. +       if (NILP (string))
  4443. +     break;
  4444. +       single_submenu (key, string, maps);
  4445. +     }
  4446. +   finish_menu_items ();
  4447. +   set_buffer_internal_1 (prev);
  4448. +   unbind_to (specpdl_count, Qnil);
  4449. +   /* If there has been no change in the Lisp-level contents of the
  4450. +      menu bar, skip redisplaying it.  Just exit.  */
  4451. +   for (i = 0; i < previous_menu_items_used; i++)
  4452. +     if (menu_items_used == i
  4453. +         || (previous_items[i] != XVECTOR (menu_items)->contents[i]))
  4454. +       break;
  4455. +   if (i == menu_items_used && i == previous_menu_items_used)
  4456. +     {
  4457. +       menu_items = Qnil;
  4458. +       return;
  4459. +     }
  4460. +   f->menu_bar_vector = menu_items;
  4461. +   f->menu_bar_items_used = menu_items_used;
  4462. +   menu_items = Qnil;
  4463. +   BLOCK_INPUT;
  4464. +   pmm.type = PMMENU_END;
  4465. +   pmmenu_add (&pmm);
  4466. +   pmr.menubar.header.type = PMR_MENUBAR;
  4467. +   pmr.menubar.header.frame = (unsigned long)f;
  4468. +   pmr.menubar.entries = pmmenu_count;
  4469. +   pmr.menubar.size = pmmenu_count * sizeof (pm_menu) + pmmenu_str_size;
  4470. +   pm_send (&pmr, sizeof (pmr));
  4471. +   pm_send (pmmenu_menu, pmmenu_count * sizeof (pm_menu));
  4472. +   pm_send (pmmenu_str, pmmenu_str_size);
  4473. +   update_frame_menubar (f);
  4474. +   UNBLOCK_INPUT;
  4475. + }
  4476. + void pm_menubar_selection (FRAME_PTR f, int sel)
  4477. + {
  4478. +   menubar_selection_callback (0, (LWLIB_ID)f, sel);
  4479. + }
  4480. + x_activate_menubar (f)
  4481. +      FRAME_PTR f;
  4482. + {
  4483. + }
  4484. + #endif /* HAVE_PM */
  4485.   #endif /* HAVE_MENUS */
  4486.   
  4487.   syms_of_xmenu ()
  4488. ***************
  4489. *** 2697,2702 ****
  4490. --- 3317,3338 ----
  4491.     staticpro (&menu_items);
  4492.     menu_items = Qnil;
  4493.   
  4494. + #ifdef HAVE_PM
  4495. +   DEFVAR_BOOL ("pm-align-menu-key-descriptions",
  4496. +                &pm_align_menu_key_descriptions,
  4497. +     "*Non-nil means align key descriptions in menus.\n\
  4498. + nil means put key descriptions directly after the title of a\n\
  4499. + menu item, in parentheses.  You should set this variable\n\
  4500. + in your startup file because it is ignored after computing\n\
  4501. + the keyboard equivalents for menus.");
  4502. +   pm_align_menu_key_descriptions = 1;
  4503. +   DEFVAR_BOOL ("pm-popup-menu-align-top", &pm_popup_menu_align_top,
  4504. +     "*Non-nil means put the top item of a popup menu at the mouse position.\n\
  4505. + nil means put the bottom item of a popup menu at the mouse position.");
  4506. +   pm_popup_menu_align_top = 1;
  4507. + #endif /* HAVE_PM */
  4508.     Qmenu_alias = intern ("menu-alias");
  4509.     staticpro (&Qmenu_alias);
  4510.   
  4511. ***************
  4512. *** 2704,2710 ****
  4513. --- 3340,3348 ----
  4514.     staticpro (&Qdebug_on_next_call);
  4515.   
  4516.   #ifdef USE_X_TOOLKIT
  4517. + #ifndef HAVE_PM
  4518.     widget_id_tick = (1<<16);    
  4519. + #endif /* not HAVE_PM */
  4520.     next_menubar_widget_id = 1;
  4521.   #endif
  4522.   
  4523.