*** ../lemacs-beta6/lisp/version.el	Sat Jul 24 10:25:34 1993
--- lisp/version.el	Tue Jul 27 17:22:19 1993
***************
*** 21,25 ****
  ;; The following line is modified automatically
  ;; by loading inc-version.el, each time a new Emacs is dumped.
! (defconst emacs-version "19.8" "\
  Version numbers of this version of Emacs.")
  
--- 21,25 ----
  ;; The following line is modified automatically
  ;; by loading inc-version.el, each time a new Emacs is dumped.
! (defconst emacs-version "19.208" "\
  Version numbers of this version of Emacs.")
  
*** ../lemacs-beta6/lisp/comint/inf-lisp.el	Thu Apr 15 12:59:37 1993
--- lisp/comint/inf-lisp.el	Sat Jul 24 21:50:33 1993
***************
*** 1,25 ****
! ;; -*-Emacs-Lisp-*- run an external lisp interpreter in an Emacs window
! ;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
  
! ;; This file is part of GNU Emacs.
  
! ;; GNU Emacs is free software; you can redistribute it and/or modify
! ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 2, or (at your option)
! ;; any later version.
! 
! ;; GNU Emacs is distributed in the hope that it will be useful,
! ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
! ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! ;; GNU General Public License for more details.
! 
! ;; You should have received a copy of the GNU General Public License
! ;; along with GNU Emacs; see the file COPYING.  If not, write to
! ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
! 
! ;;; Hacked from tea.el and shell.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
! ;;; Since these modes are built on top of the general command-interpreter-in-
! ;;; a-buffer mode (comint mode), they share a common base functionality, 
  ;;; and a common set of bindings, with all modes derived from comint mode.
  
  ;;; Needs fixin:
--- 1,42 ----
! ;;; inf-lisp.el --- an inferior-lisp mode
! ;;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
  
! ;; Author: Olin Shivers <shivers@cs.cmu.edu>
! ;; Keywords: processes, lisp
  
! ;;; This file is part of GNU Emacs.
! 
! ;;; GNU Emacs is free software; you can redistribute it and/or modify
! ;;; it under the terms of the GNU General Public License as published by
! ;;; the Free Software Foundation; either version 2, or (at your option)
! ;;; any later version.
! 
! ;;; GNU Emacs is distributed in the hope that it will be useful,
! ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
! ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! ;;; GNU General Public License for more details.
! 
! ;;; You should have received a copy of the GNU General Public License
! ;;; along with GNU Emacs; see the file COPYING.  If not, write to
! ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
! 
! ;;; Commentary:
! 
! ;;; Hacked from tea.el by Olin Shivers (shivers@cs.cmu.edu). 8/88
! 
! ;;; This file defines a a lisp-in-a-buffer package (inferior-lisp
! ;;; mode) built on top of comint mode.  This version is more
! ;;; featureful, robust, and uniform than the Emacs 18 version.  The
! ;;; key bindings are also more compatible with the bindings of Hemlock
! ;;; and Zwei (the Lisp Machine emacs).
! 
! ;;; Since this mode is built on top of the general command-interpreter-in-
! ;;; a-buffer mode (comint mode), it shares a common base functionality, 
  ;;; and a common set of bindings, with all modes derived from comint mode.
+ ;;; This makes these modes easier to use.
+ 
+ ;;; For documentation on the functionality provided by comint mode, and
+ ;;; the hooks available for customizing it, see the file comint.el.
+ ;;; For further information on inferior-lisp mode, see the comments below.
  
  ;;; Needs fixin:
***************
*** 32,36 ****
  ;;; .lbin, .mo, .vo, .ao, ...).
  ;;;
! ;;; It would be nice if lisp (and inferior scheme, T, ...) modes
  ;;; had a verbose minor mode wherein sending or compiling defuns, etc.
  ;;; would be reflected in the transcript with suitable comments, e.g.
--- 49,53 ----
  ;;; .lbin, .mo, .vo, .ao, ...).
  ;;;
! ;;; It would be nice if inferior-lisp (and inferior scheme, T, ...) modes
  ;;; had a verbose minor mode wherein sending or compiling defuns, etc.
  ;;; would be reflected in the transcript with suitable comments, e.g.
***************
*** 42,84 ****
  ;;; text to the process? Switch selectable?
  
  (require 'comint)
! (provide 'inf-lisp)
  
! (defvar lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
!   "*What not to save on inferior Lisp's input history
! Input matching this regexp is not saved on the input history in lisp
! mode. Default is whitespace followed by 0 or 1 single-letter :keyword 
  (as in :a, :c, etc.)")
  
- ;;; These commands augment lisp mode, so you can process lisp code in
- ;;; the source files.
- (define-key lisp-mode-map "\C-c\C-f" 'lisp-load-file)
- (define-key lisp-mode-map "\C-c\C-k" 'lisp-compile-file)
- (define-key lisp-mode-map "\M-\C-x"  'lisp-eval-defun) ; Gnu convention
- (define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-region)
- (define-key lisp-mode-map "\C-c\C-x" 'lisp-compile-defun)
- (define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-region)
- 
  (defvar inferior-lisp-mode-map nil)
! (if inferior-lisp-mode-map ()
!   (if (fboundp 'set-keymap-parent)
!       (progn
! 	(setq inferior-lisp-mode-map (copy-keymap shared-lisp-mode-map))
! 	(set-keymap-parent inferior-lisp-mode-map comint-mode-map))
!     (setq inferior-lisp-mode-map (copy-keymap comint-mode-map))
      ;; This used to be done by calling `lisp-mode-commands' in lisp-mode.el
      (define-key inferior-lisp-mode-map "\e\C-q" 'indent-sexp)
      (define-key inferior-lisp-mode-map "\177" 'backward-delete-char-untabify)
!     (define-key inferior-lisp-mode-map "\t" 'lisp-indent-line))
!   (define-key inferior-lisp-mode-map "\e\C-x" 'lisp-send-defun))
  
  (defvar inferior-lisp-program "lisp"
!   "*Program name for invoking an inferior Lisp with `lisp'.
! Optionally, a list of strings the car of which is the programme to run
! and the cdr of which is command line arguments desired.")
  
  (defvar inferior-lisp-load-command "(load \"%s\")\n"
    "*Format-string for building a Lisp expression to load a file.
! This format string should use %s to substitute a file name
  and should result in a Lisp expression that will command the inferior Lisp
  to load that file.  The default works acceptably on most Lisps.
--- 59,152 ----
  ;;; text to the process? Switch selectable?
  
+ ;;; Code:
+ 
  (require 'comint)
! (require 'lisp-mode)
! 
  
! ;;;###autoload
! (defvar inferior-lisp-filter-regexp "\\`\\s *\\(:\\(\\w\\|\\s_\\)\\)?\\s *\\'"
!   "*What not to save on inferior Lisp's input history.
! Input matching this regexp is not saved on the input history in Inferior Lisp
! mode. Default is whitespace followed by 0 or 1 single-letter colon-keyword 
  (as in :a, :c, etc.)")
  
  (defvar inferior-lisp-mode-map nil)
! (cond ((not inferior-lisp-mode-map)
!        (setq inferior-lisp-mode-map (make-sparse-keymap))
!        (set-keymap-name inferior-lisp-mode-map 'inferior-lisp-mode-map)
!        (set-keymap-parent inferior-lisp-mode-map comint-mode-map)
! 
!        ;;>>> ARRGG!  Need multiple parents
!        ;(set-keymap-parent inferior-lisp-mode-map shared-lisp-mode-map)
         ;; This used to be done by calling `lisp-mode-commands' in lisp-mode.el
         (define-key inferior-lisp-mode-map "\e\C-q" 'indent-sexp)
         (define-key inferior-lisp-mode-map "\177" 'backward-delete-char-untabify)
!        (define-key inferior-lisp-mode-map "\t" 'lisp-indent-line)
! 
!        (define-key inferior-lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp)
!        (define-key inferior-lisp-mode-map "\C-c\C-l" 'lisp-load-file)
!        (define-key inferior-lisp-mode-map "\C-c\C-k" 'lisp-compile-file)
!        (define-key inferior-lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
!        (define-key inferior-lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
!        (define-key inferior-lisp-mode-map "\C-c\C-f"
! 	 'lisp-show-function-documentation)
!        (define-key inferior-lisp-mode-map "\C-c\C-v"
! 	 'lisp-show-variable-documentation)))
  
+ ;;; These commands augment Lisp mode, so you can process Lisp code in
+ ;;; the source files.
+ (define-key lisp-mode-map "\M-\C-x"  'lisp-eval-defun)     ; Gnu convention
+ (define-key lisp-mode-map "\C-x\C-e" 'lisp-eval-last-sexp) ; Gnu convention
+ (define-key lisp-mode-map "\C-c\C-e" 'lisp-eval-defun)
+ (define-key lisp-mode-map "\C-c\C-r" 'lisp-eval-region)
+ (define-key lisp-mode-map "\C-c\C-c" 'lisp-compile-defun)
+ (define-key lisp-mode-map "\C-c\C-z" 'switch-to-lisp)
+ (define-key lisp-mode-map "\C-c\C-l" 'lisp-load-file)
+ (define-key lisp-mode-map "\C-c\C-k" 'lisp-compile-file)  ; "kompile" file
+ (define-key lisp-mode-map "\C-c\C-a" 'lisp-show-arglist)
+ (define-key lisp-mode-map "\C-c\C-d" 'lisp-describe-sym)
+ (define-key lisp-mode-map "\C-c\C-f" 'lisp-show-function-documentation)
+ (define-key lisp-mode-map "\C-c\C-v" 'lisp-show-variable-documentation)
+ 
+ ;;; This function exists for backwards compatibility.
+ ;;; Previous versions of this package bound commands to C-c <letter>
+ ;;; bindings, which is not allowed by the gnumacs standard.
+ 
+ ;;;  "This function binds many inferior-lisp commands to C-c <letter> bindings,
+ ;;;where they are more accessible. C-c <letter> bindings are reserved for the
+ ;;;user, so these bindings are non-standard. If you want them, you should
+ ;;;have this function called by the inferior-lisp-load-hook:
+ ;;;    (setq inferior-lisp-load-hook '(inferior-lisp-install-letter-bindings))
+ ;;;You can modify this function to install just the bindings you want."
+ (defun inferior-lisp-install-letter-bindings ()
+   (define-key lisp-mode-map "\C-ce" 'lisp-eval-defun-and-go)
+   (define-key lisp-mode-map "\C-cr" 'lisp-eval-region-and-go)
+   (define-key lisp-mode-map "\C-cc" 'lisp-compile-defun-and-go)
+   (define-key lisp-mode-map "\C-cz" 'switch-to-lisp)
+   (define-key lisp-mode-map "\C-cl" 'lisp-load-file)
+   (define-key lisp-mode-map "\C-ck" 'lisp-compile-file)
+   (define-key lisp-mode-map "\C-ca" 'lisp-show-arglist)
+   (define-key lisp-mode-map "\C-cd" 'lisp-describe-sym)
+   (define-key lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
+   (define-key lisp-mode-map "\C-cv" 'lisp-show-variable-documentation)
+   
+   (define-key inferior-lisp-mode-map "\C-cl" 'lisp-load-file)
+   (define-key inferior-lisp-mode-map "\C-ck" 'lisp-compile-file)
+   (define-key inferior-lisp-mode-map "\C-ca" 'lisp-show-arglist)
+   (define-key inferior-lisp-mode-map "\C-cd" 'lisp-describe-sym)
+   (define-key inferior-lisp-mode-map "\C-cf" 'lisp-show-function-documentation)
+   (define-key inferior-lisp-mode-map "\C-cv"
+     'lisp-show-variable-documentation))
+ 
+ 
+ ;;;###autoload
  (defvar inferior-lisp-program "lisp"
!   "*Program name for invoking an inferior Lisp with for Inferior Lisp mode.")
  
+ ;;;###autoload
  (defvar inferior-lisp-load-command "(load \"%s\")\n"
    "*Format-string for building a Lisp expression to load a file.
! This format string should use `%s' to substitute a file name
  and should result in a Lisp expression that will command the inferior Lisp
  to load that file.  The default works acceptably on most Lisps.
***************
*** 87,95 ****
  but it works only in Common Lisp.")
  
  (defvar inferior-lisp-prompt "^[^> ]*>+:? *"
!   "Regexp to recognise prompts in the inferior Lisp.
  Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl,
! and franz. This variable is used to initialise comint-prompt-regexp in the 
! lisp buffer.
  
  More precise choices:
--- 155,164 ----
  but it works only in Common Lisp.")
  
+ ;;;###autoload
  (defvar inferior-lisp-prompt "^[^> ]*>+:? *"
!   "Regexp to recognise prompts in the Inferior Lisp mode.
  Defaults to \"^[^> ]*>+:? *\", which works pretty good for Lucid, kcl,
! and franz. This variable is used to initialize `comint-prompt-regexp' in the 
! Inferior Lisp buffer.
  
  More precise choices:
***************
*** 96,118 ****
  Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
  franz: \"^\\(->\\|<[0-9]*>:\\) *\"
! kcl: \"^>+ *\"")
  
! (defvar inferior-lisp-mode-hook '() "*Hook for customising lisp mode")
  
  (defun inferior-lisp-mode () 
    "Major mode for interacting with an inferior Lisp process.  
  Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an
! Emacs buffer.  Variable inferior-lisp-program controls which Lisp interpreter
! is run.  Variables inferior-lisp-prompt, lisp-filter-regexp and
! inferior-lisp-load-command can customize this mode for different Lisp
  interpreters.
  
  \\{inferior-lisp-mode-map}
  
! Customization: Entry to this mode runs comint-mode-hook and lisp-mode-hook,
! in that order.
  
  You can send text to the inferior Lisp process from other buffers containing
  Lisp source.  
      lisp-eval-defun sends the current defun to the Lisp process.
      lisp-compile-defun compiles the current defun.
--- 165,230 ----
  Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
  franz: \"^\\(->\\|<[0-9]*>:\\) *\"
! kcl: \"^>+ *\"
  
! This is a fine thing to set in your .emacs file.")
  
+ (defvar inferior-lisp-buffer nil "*The current inferior-lisp process buffer.
+ 
+ MULTIPLE PROCESS SUPPORT
+ ===========================================================================
+ To run multiple Lisp processes, you start the first up
+ with \\[inferior-lisp].  It will be in a buffer named `*inferior-lisp*'.
+ Rename this buffer with \\[rename-buffer].  You may now start up a new
+ process with another \\[inferior-lisp].  It will be in a new buffer,
+ named `*inferior-lisp*'.  You can switch between the different process
+ buffers with \\[switch-to-buffer].
+ 
+ Commands that send text from source buffers to Lisp processes --
+ like `lisp-eval-defun' or `lisp-show-arglist' -- have to choose a process
+ to send to, when you have more than one Lisp process around.  This
+ is determined by the global variable `inferior-lisp-buffer'.  Suppose you
+ have three inferior Lisps running:
+     Buffer              Process
+     foo                 inferior-lisp
+     bar                 inferior-lisp<2>
+     *inferior-lisp*     inferior-lisp<3>
+ If you do a \\[lisp-eval-defun] command on some Lisp source code, 
+ what process do you send it to?
+ 
+ - If you're in a process buffer (foo, bar, or *inferior-lisp*), 
+   you send it to that process.
+ - If you're in some other buffer (e.g., a source file), you
+   send it to the process attached to buffer `inferior-lisp-buffer'.
+ This process selection is performed by function `inferior-lisp-proc'.
+ 
+ Whenever \\[inferior-lisp] fires up a new process, it resets
+ `inferior-lisp-buffer' to be the new process's buffer.  If you only run
+ one process, this does the right thing.  If you run multiple
+ processes, you can change `inferior-lisp-buffer' to another process
+ buffer with \\[set-variable].")
+ 
+ ;;;###autoload
+ (defvar inferior-lisp-mode-hook '() 
+   "*Hook for customizing Inferior Lisp mode.")
+ 
  (defun inferior-lisp-mode () 
    "Major mode for interacting with an inferior Lisp process.  
  Runs a Lisp interpreter as a subprocess of Emacs, with Lisp I/O through an
! Emacs buffer.  Variable `inferior-lisp-program' controls which Lisp interpreter
! is run.  Variables `inferior-lisp-prompt', `inferior-lisp-filter-regexp' and
! `inferior-lisp-load-command' can customize this mode for different Lisp
  interpreters.
  
+ For information on running multiple processes in multiple buffers, see
+ documentation for variable `inferior-lisp-buffer'.
+ 
  \\{inferior-lisp-mode-map}
  
! Customization: Entry to this mode runs the hooks on `comint-mode-hook' and
! `inferior-lisp-mode-hook' (in that order).
  
  You can send text to the inferior Lisp process from other buffers containing
  Lisp source.  
+     switch-to-lisp switches the current buffer to the Lisp process buffer.
      lisp-eval-defun sends the current defun to the Lisp process.
      lisp-compile-defun compiles the current defun.
***************
*** 120,123 ****
--- 232,239 ----
      lisp-compile-region compiles the current region.
  
+     Prefixing the lisp-eval/compile-defun/region commands with
+     a \\[universal-argument] causes a switch to the Lisp process buffer after sending
+     the text.
+ 
  Commands:
  Return after the end of the process' output sends the text from the 
***************
*** 134,149 ****
    (interactive)
    (comint-mode)
!   (use-local-map inferior-lisp-mode-map)
!   (setq major-mode 'inferior-lisp-mode
! 	mode-name "Inferior Lisp"
! 	comint-prompt-regexp inferior-lisp-prompt
! 	comint-get-old-input (function inferior-lisp-get-old-input)
! 	comint-input-filter (function inferior-lisp-input-filter)
! 	comint-input-sentinel 'ignore)
    (lisp-mode-variables t)
    (run-hooks 'inferior-lisp-mode-hook))
  
! (defun inferior-lisp-get-old-input ()
!   "Snarf the sexp ending at point"
    (save-excursion
      (let ((end (point)))
--- 250,266 ----
    (interactive)
    (comint-mode)
!   (setq comint-prompt-regexp inferior-lisp-prompt)
!   (setq major-mode 'inferior-lisp-mode)
!   (setq mode-name "Inferior Lisp")
!   (setq mode-line-process '(": %s"))
    (lisp-mode-variables t)
+   (use-local-map inferior-lisp-mode-map)    ;c-c c-k for "kompile" file
+   (setq comint-get-old-input (function lisp-get-old-input))
+   (setq comint-input-filter (function lisp-input-filter))
+   (setq comint-input-sentinel 'ignore)
    (run-hooks 'inferior-lisp-mode-hook))
  
! (defun lisp-get-old-input ()
!   "Return a string containing the sexp ending at point."
    (save-excursion
      (let ((end (point)))
***************
*** 151,223 ****
        (buffer-substring (point) end))))
  
! (defun inferior-lisp-input-filter (str)
!   "Don't save anything matching lisp-filter-regexp"
!   (not (string-match lisp-filter-regexp str)))
! 
! (defun run-lisp ()
!   "Run an inferior Lisp process, input and output via buffer *lisp*.
! If there is a process already running in *lisp*, just switch to that buffer.
! Takes the program name from the variable inferior-lisp-program.
  \(Type \\[describe-mode] in the process buffer for a list of commands.)"
!   (interactive)
!   (let ((prog inferior-lisp-program) switches
! 	(proc (get-buffer-process "*lisp*")))
!     (if (listp prog) (setq switches (cdr prog) prog (car prog)))
!     (cond ((not (and proc (memq (process-status proc) '(run stop))))
! 	   (set-buffer (apply 'make-comint "lisp" prog nil switches))
! 	   (inferior-lisp-mode))))
!   (switch-to-buffer "*lisp*"))
! 
! (defun lisp-eval-region (start end)
!   "Send the current region to the inferior Lisp process."
!   (interactive "r")
!   ;; i don't like the way all this code depends on the buffer name
!   (let* ((proc (get-buffer-process "*lisp*"))
! 	 (filename (format "/tmp/eme%d.lisp" (process-id proc))))
!     (if (not (and proc (memq (process-status proc) '(run stop))))
! 	(error "No current lisp process")
!       (write-region start end filename nil 'nomessage)
!       (send-string proc (format inferior-lisp-load-command filename))
!       (send-string proc (format "(delete-file %s)\n" filename)))))
! 
! (defun lisp-eval-defun ()
!   "Send the current defun to the inferior Lisp process."
!   (interactive)
    (save-excursion
     (end-of-defun)
     (let ((end (point)))
       (beginning-of-defun)
!      (lisp-eval-region (point) end))))
! 
! ;;; CommonLisp COMPILE sux. 
! (defun lisp-compile-region (start end)
!   "Compile the current region in the inferior Lisp process."
!   ;; deja vu.  code look familiar?
!   (interactive "r")
!   (let* ((proc (get-buffer-process "*lisp*"))
! 	 (filename (format "/tmp/emc%d.lisp" (process-id proc))))
!     (if (not (and proc (memq (process-status proc) '(run stop))))
! 	(error "No current lisp process")
!       (write-region
!        (concat "(funcall (compile nil `(lambda () (progn 'compile "
! 	       (buffer-substring start end)
! 	       "))))\n")
!        nil filename nil 'nomessage)
!       (send-string proc (format inferior-lisp-load-command filename))
!       (send-string proc (format "(delete-file %s)\n" filename)))))
  			 
! (defun lisp-compile-defun ()
!   "Compile the current defun in the inferior Lisp process."
!   (interactive)
    (save-excursion
      (end-of-defun)
      (let ((e (point)))
        (beginning-of-defun)
!       (lisp-compile-region (point) e))))
  
  (defvar lisp-prev-l/c-dir/file nil
!   "Saves the (directory . file) pair used in the last lisp-load-file or
! lisp-compile-file command. Used for determining the default in the 
! next one.")
  
  (defvar lisp-source-modes '(lisp-mode)
--- 268,442 ----
        (buffer-substring (point) end))))
  
! (defun lisp-input-filter (str)
!   "t if STR does not match `inferior-lisp-filter-regexp'."
!   (not (string-match inferior-lisp-filter-regexp str)))
! 
! ;;;###autoload
! (defun inferior-lisp (cmd)
!   "Run an inferior Lisp process, input and output via buffer `*inferior-lisp*'.
! If there is a process already running in `*inferior-lisp*', just switch
! to that buffer.
! With argument, allows you to edit the command line (default is value
! of `inferior-lisp-program').  Runs the hooks from
! `inferior-lisp-mode-hook' (after the `comint-mode-hook' is run).
  \(Type \\[describe-mode] in the process buffer for a list of commands.)"
!   (interactive (list (if current-prefix-arg
! 			 (read-string "Run lisp: " inferior-lisp-program)
! 		       inferior-lisp-program)))
!   (if (not (comint-check-proc "*inferior-lisp*"))
!       (let ((cmdlist (inferior-lisp-args-to-list cmd)))
! 	(set-buffer (apply (function make-comint)
! 			   "inferior-lisp" (car cmdlist) nil (cdr cmdlist)))
! 	(inferior-lisp-mode)))
!   (setq inferior-lisp-buffer "*inferior-lisp*")
!   (switch-to-buffer "*inferior-lisp*"))
! 
! ;;;###autoload
! (define-function 'run-lisp 'inferior-lisp)
! 
! ;;; Break a string up into a list of arguments.
! ;;; This will break if you have an argument with whitespace, as in
! ;;; string = "-ab +c -x 'you lose'".
! (defun inferior-lisp-args-to-list (string)
!   (let ((where (string-match "[ \t]" string)))
!     (cond ((null where) (list string))
! 	  ((not (= where 0))
! 	   (cons (substring string 0 where)
! 		 (inferior-lisp-args-to-list (substring string (+ 1 where)
! 							(length string)))))
! 	  (t (let ((pos (string-match "[^ \t]" string)))
! 	       (if (null pos)
! 		   nil
! 		 (inferior-lisp-args-to-list (substring string pos
! 							(length string)))))))))
! 
! (defun lisp-eval-region (start end &optional and-go)
!   "Send the current region to the inferior Lisp process.
! Prefix argument means switch to the Lisp buffer afterwards."
!   (interactive "r\nP")
!   (comint-send-region (inferior-lisp-proc) start end)
!   (comint-send-string (inferior-lisp-proc) "\n")
!   (if and-go (switch-to-lisp t)))
! 
! (defun lisp-eval-defun (&optional and-go)
!   "Send the current defun to the inferior Lisp process.
! Prefix argument means switch to the Lisp buffer afterwards."
!   (interactive "P")
    (save-excursion
      (end-of-defun)
+     (skip-chars-backward " \t\n\r\f") ;  Makes allegro happy
      (let ((end (point)))
        (beginning-of-defun)
!       (lisp-eval-region (point) end)))
!   (if and-go (switch-to-lisp t)))
  
! (defun lisp-eval-last-sexp (&optional and-go)
!   "Send the previous sexp to the inferior Lisp process.
! Prefix argument means switch to the Lisp buffer afterwards."
!   (interactive "P")
!   (lisp-eval-region (save-excursion (backward-sexp) (point)) (point) and-go))
! 
! ;;; Common Lisp COMPILE sux. 
! (defun lisp-compile-region (start end &optional and-go)
!   "Compile the current region in the inferior Lisp process.
! Prefix argument means switch to the Lisp buffer afterwards."
!   (interactive "r\nP")
!   (comint-send-string
!    (inferior-lisp-proc)
!    (format "(funcall (compile nil `(lambda () (progn 'compile %s))))\n"
! 	   (buffer-substring start end)))
!   (if and-go (switch-to-lisp t)))
! 			 
! (defun lisp-compile-defun (&optional and-go)
!   "Compile the current defun in the inferior Lisp process.
! Prefix argument means switch to the Lisp buffer afterwards."
!   (interactive "P")
    (save-excursion
      (end-of-defun)
+     (skip-chars-backward " \t\n\r\f") ;  Makes allegro happy
      (let ((e (point)))
        (beginning-of-defun)
!       (lisp-compile-region (point) e)))
!   (if and-go (switch-to-lisp t)))
! 
! (defun switch-to-lisp (eob-p)
!   "Switch to the inferior Lisp process buffer.
! With argument, positions cursor at end of buffer."
!   (interactive "P")
!   (if (get-buffer inferior-lisp-buffer)
!       (pop-to-buffer inferior-lisp-buffer)
!     (error "No current inferior Lisp buffer"))
!   (cond (eob-p
! 	 (push-mark)
! 	 (goto-char (point-max)))))
! 
! 
! ;;; Now that lisp-compile/eval-defun/region takes an optional prefix arg,
! ;;; these commands are redundant. But they are kept around for the user
! ;;; to bind if he wishes, for backwards functionality, and because it's
! ;;; easier to type C-c e than C-u C-c C-e.
! 
! (defun lisp-eval-region-and-go (start end)
!   "Send the current region to the inferior Lisp, and switch to its buffer."
!   (interactive "r")
!   (lisp-eval-region start end t))
! 
! (defun lisp-eval-defun-and-go ()
!   "Send the current defun to the inferior Lisp, and switch to its buffer."
!   (interactive)
!   (lisp-eval-defun t))
! 
! (defun lisp-compile-region-and-go (start end)
!   "Compile the current region in the inferior Lisp, and switch to its buffer."
!   (interactive "r")
!   (lisp-compile-region start end t))
  
+ (defun lisp-compile-defun-and-go ()
+   "Compile the current defun in the inferior Lisp, and switch to its buffer."
+   (interactive)
+   (lisp-compile-defun t))
+ 
+ ;;; A version of the form in H. Shevis' soar-mode.el package. Less robust.
+ ;;; (defun lisp-compile-sexp (start end)
+ ;;;   "Compile the s-expression bounded by START and END in the inferior lisp.
+ ;;; If the sexp isn't a DEFUN form, it is evaluated instead."
+ ;;;   (cond ((looking-at "(defun\\s +")
+ ;;; 	 (goto-char (match-end 0))
+ ;;; 	 (let ((name-start (point)))
+ ;;; 	   (forward-sexp 1)
+ ;;; 	   (process-send-string "inferior-lisp"
+ ;;; 				(format "(compile '%s #'(lambda "
+ ;;; 					(buffer-substring name-start
+ ;;; 							  (point)))))
+ ;;; 	 (let ((body-start (point)))
+ ;;; 	   (goto-char start) (forward-sexp 1) ; Can't use end-of-defun.
+ ;;; 	   (process-send-region "inferior-lisp"
+ ;;; 				(buffer-substring body-start (point))))
+ ;;; 	 (process-send-string "inferior-lisp" ")\n"))
+ ;;; 	(t (lisp-eval-region start end)))))
+ ;;; 
+ ;;; (defun lisp-compile-region (start end)
+ ;;;   "Each s-expression in the current region is compiled (if a DEFUN)
+ ;;; or evaluated (if not) in the inferior lisp."
+ ;;;   (interactive "r")
+ ;;;   (save-excursion
+ ;;;     (goto-char start) (end-of-defun) (beginning-of-defun) ; error check
+ ;;;     (if (< (point) start) (error "region begins in middle of defun"))
+ ;;;     (goto-char start)
+ ;;;     (let ((s start))
+ ;;;       (end-of-defun)
+ ;;;       (while (<= (point) end) ; Zip through
+ ;;; 	(lisp-compile-sexp s (point)) ; compiling up defun-sized chunks.
+ ;;; 	(setq s (point))
+ ;;; 	(end-of-defun))
+ ;;;       (if (< s end) (lisp-compile-sexp s end)))))
+ ;;; 
+ ;;; End of HS-style code
+ 
+ 
  (defvar lisp-prev-l/c-dir/file nil
!   "Record last directory and file used in loading or compiling.
! This holds a cons cell of the form `(DIRECTORY . FILE)'
! describing the last `lisp-load-file' or `lisp-compile-file' command.")
  
  (defvar lisp-source-modes '(lisp-mode)
***************
*** 224,238 ****
    "*Used to determine if a buffer contains Lisp source code.
  If it's loaded into a buffer that is in one of these major modes, it's
! considered a lisp source file by lisp-load-file and lisp-compile-file.
  Used by these commands to determine defaults.")
  
  (defun lisp-load-file (file-name)
!   "Load a lisp file into the inferior Lisp process."
    (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file
! 				  lisp-source-modes nil))
    (comint-check-source file-name) ; Check to see if buffer needs saved.
    (setq lisp-prev-l/c-dir/file (cons (file-name-directory    file-name)
  				     (file-name-nondirectory file-name)))
!   (send-string "lisp" (format inferior-lisp-load-command file-name)))
  
  (defun lisp-compile-file (file-name)
--- 443,460 ----
    "*Used to determine if a buffer contains Lisp source code.
  If it's loaded into a buffer that is in one of these major modes, it's
! considered a Lisp source file by `lisp-load-file' and `lisp-compile-file'.
  Used by these commands to determine defaults.")
  
  (defun lisp-load-file (file-name)
!   "Load a Lisp file into the inferior Lisp process."
    (interactive (comint-get-source "Load Lisp file: " lisp-prev-l/c-dir/file
! 				  lisp-source-modes nil))  ; NIL because LOAD
! 					; doesn't need an exact name
    (comint-check-source file-name) ; Check to see if buffer needs saved.
    (setq lisp-prev-l/c-dir/file (cons (file-name-directory    file-name)
  				     (file-name-nondirectory file-name)))
!   (comint-send-string (inferior-lisp-proc)
! 		      (format inferior-lisp-load-command file-name))
!   (switch-to-lisp t))
  
  (defun lisp-compile-file (file-name)
***************
*** 244,246 ****
    (setq lisp-prev-l/c-dir/file (cons (file-name-directory    file-name)
  				     (file-name-nondirectory file-name)))
!   (send-string "lisp" (concat "(compile-file \"" file-name "\"\)\n")))
--- 466,639 ----
    (setq lisp-prev-l/c-dir/file (cons (file-name-directory    file-name)
  				     (file-name-nondirectory file-name)))
!   (comint-send-string (inferior-lisp-proc) (concat "(compile-file \""
! 						   file-name
! 						   "\"\)\n"))
!   (switch-to-lisp t))
! 
! 
! 
! ;;; Documentation functions: function doc, var doc, arglist, and
! ;;; describe symbol.
! ;;; ===========================================================================
! 
! ;;; Command strings
! ;;; ===============
! 
! (defvar lisp-function-doc-command
!   "(let ((fn '%s))
!      (format t \"Documentation for ~a:~&~a\"
! 	     fn (documentation fn 'function))
!      (values))\n"
!   "Command to query inferior Lisp for a function's documentation.")
! 
! (defvar lisp-var-doc-command
!   "(let ((v '%s))
!      (format t \"Documentation for ~a:~&~a\"
! 	     v (documentation v 'variable))
!      (values))\n"
!   "Command to query inferior Lisp for a variable's documentation.")
! 
! (defvar lisp-arglist-command
!   "(let ((fn '%s))
!      (format t \"Arglist for ~a: ~a\" fn (arglist fn))
!      (values))\n"
!   "Command to query inferior Lisp for a function's arglist.")
! 
! (defvar lisp-describe-sym-command
!   "(describe '%s)\n"
!   "Command to query inferior Lisp for a variable's documentation.")
! 
! 
! ;;; Ancillary functions
! ;;; ===================
! 
! ;;; Reads a string from the user.
! (defun lisp-symprompt (prompt default)
!   (list (let* ((prompt (if default
! 			   (format "%s (default %s): " prompt default)
! 			 (concat prompt ": ")))
! 	       (ans (read-string prompt)))
! 	  (if (zerop (length ans)) default ans))))
! 
! 
! ;;; Adapted from function-called-at-point in help.el.
! (defun lisp-fn-called-at-pt ()
!   "Returns the name of the function called in the current call.
! The value is nil if it can't find one."
!   (condition-case nil
!       (save-excursion
! 	(save-restriction
! 	  (narrow-to-region (max (point-min) (- (point) 1000)) (point-max))
! 	  (backward-up-list 1)
! 	  (forward-char 1)
! 	  (let ((obj (read (current-buffer))))
! 	    (and (symbolp obj) obj))))
!     (error nil)))
! 
! 
! ;;; Adapted from variable-at-point in help.el.
! (defun lisp-var-at-pt ()
!   (condition-case ()
!       (save-excursion
! 	(forward-sexp -1)
! 	(skip-chars-forward "'")
! 	(let ((obj (read (current-buffer))))
! 	  (and (symbolp obj) obj)))
!     (error nil)))
! 
! 
! ;;; Documentation functions: fn and var doc, arglist, and symbol describe.
! ;;; ======================================================================
! 
! (defun lisp-show-function-documentation (fn)
!   "Send a command to the inferior Lisp to give documentation for function FN.
! See variable `lisp-function-doc-command'."
!   (interactive (lisp-symprompt "Function doc" (lisp-fn-called-at-pt)))
!   (comint-proc-query (inferior-lisp-proc)
! 		     (format lisp-function-doc-command fn)))
! 
! (defun lisp-show-variable-documentation (var)
!   "Send a command to the inferior Lisp to give documentation for function FN.
! See variable `lisp-var-doc-command'."
!   (interactive (lisp-symprompt "Variable doc" (lisp-var-at-pt)))
!   (comint-proc-query (inferior-lisp-proc) (format lisp-var-doc-command var)))
! 
! (defun lisp-show-arglist (fn)
!   "Send a query to the inferior Lisp for the arglist for function FN.
! See variable `lisp-arglist-command'."
!   (interactive (lisp-symprompt "Arglist" (lisp-fn-called-at-pt)))
!   (comint-proc-query (inferior-lisp-proc) (format lisp-arglist-command fn)))
! 
! (defun lisp-describe-sym (sym)
!   "Send a command to the inferior Lisp to describe symbol SYM.
! See variable `lisp-describe-sym-command'."
!   (interactive (lisp-symprompt "Describe" (lisp-var-at-pt)))
!   (comint-proc-query (inferior-lisp-proc)
! 		     (format lisp-describe-sym-command sym)))
! 
! 
! ;;  "Returns the current inferior Lisp process.
! ;; See variable `inferior-lisp-buffer'."
! (defun inferior-lisp-proc ()
!   (let ((proc (get-buffer-process (if (eq major-mode 'inferior-lisp-mode)
! 				      (current-buffer)
! 				    inferior-lisp-buffer))))
!     (or proc
! 	(error "No current process. See variable inferior-lisp-buffer"))))
! 
! 
! ;;; Do the user's customization...
! ;;;===============================
! (defvar inferior-lisp-load-hook nil
!   "This hook is run when the library `inf-lisp' is loaded.
! This is a good place to put keybindings.")
! 
! (run-hooks 'inferior-lisp-load-hook)
! 
! ;;; CHANGE LOG
! ;;; ===========================================================================
! ;;; 7/21/92 Jim Blandy
! ;;; - Changed all uses of the cmulisp name or prefix to inferior-lisp;
! ;;;   this is now the official inferior lisp package.  Use the global
! ;;;   ChangeLog from now on.
! ;;; 5/24/90 Olin
! ;;; - Split cmulisp and cmushell modes into separate files. 
! ;;;   Not only is this a good idea, it's apparently the way it'll be rel 19.
! ;;; - Upgraded process sends to use comint-send-string instead of
! ;;;   process-send-string.
! ;;; - Explicit references to process "cmulisp" have been replaced with
! ;;;   (cmulisp-proc). This allows better handling of multiple process bufs.
! ;;; - Added process query and var/function/symbol documentation
! ;;;   commands. Based on code written by Douglas Roberts.
! ;;; - Added lisp-eval-last-sexp, bound to C-x C-e.
! ;;;
! ;;; 9/20/90 Olin
! ;;; Added a save-restriction to lisp-fn-called-at-pt. This bug and fix
! ;;; reported by Lennart Staflin.
! ;;;
! ;;; 3/12/90 Olin
! ;;; - lisp-load-file and lisp-compile-file no longer switch-to-lisp.
! ;;;   Tale suggested this.
! ;;; - Reversed this decision 7/15/91. You need the visual feedback.
! ;;;
! ;;; 7/25/91 Olin
! ;;; Changed all keybindings of the form C-c <letter>. These are
! ;;; supposed to be reserved for the user to bind. This affected
! ;;; mainly the compile/eval-defun/region[-and-go] commands.
! ;;; This was painful, but necessary to adhere to the gnumacs standard.
! ;;; For some backwards compatibility, see the 
! ;;;     cmulisp-install-letter-bindings
! ;;; function.
! ;;;
! ;;; 8/2/91 Olin
! ;;; - The lisp-compile/eval-defun/region commands now take a prefix arg,
! ;;;   which means switch-to-lisp after sending the text to the Lisp process.
! ;;;   This obsoletes all the -and-go commands. The -and-go commands are
! ;;;   kept around for historical reasons, and because the user can bind
! ;;;   them to key sequences shorter than C-u C-c C-<letter>.
! ;;; - If M-x cmulisp is invoked with a prefix arg, it allows you to
! ;;;   edit the command line.
! 
! (provide 'inf-lisp)
! 
! ;;; inf-lisp.el ends here
*** ../lemacs-beta6/lisp/comint/comint.el	Thu Jul  8 19:48:35 1993
--- lisp/comint/comint.el	Sat Jul 24 19:55:35 1993
***************
*** 1,9 ****
! ;;; -*-Emacs-Lisp-*- General command interpreter in a window stuff
! ;;; Copyright Olin Shivers (1988).
! ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright
! ;;; notice appearing here to the effect that you may use this code any
! ;;; way you like, as long as you don't charge money for it, remove this
! ;;; notice, or hold me liable for its results.
  
  ;;; The changelog is at the end of this file.
  
--- 1,27 ----
! ;;; comint.el --- general command interpreter in a window stuff
  
+ ;; Copyright (C) 1988, 1990, 1992, 1993 Free Software Foundation, Inc.
+ 
+ ;; Author: Olin Shivers <shivers@cs.cmu.edu>
+ ;; Keywords: processes
+ 
+ ;; This file is part of GNU Emacs.
+ 
+ ;; GNU Emacs is free software; you can redistribute it and/or modify
+ ;; it under the terms of the GNU General Public License as published by
+ ;; the Free Software Foundation; either version 2, or (at your option)
+ ;; any later version.
+ 
+ ;; GNU Emacs is distributed in the hope that it will be useful,
+ ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ ;; GNU General Public License for more details.
+ 
+ ;; You should have received a copy of the GNU General Public License
+ ;; along with GNU Emacs; see the file COPYING.  If not, write to
+ ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ 
+ ;;; Commentary:
+ 
  ;;; The changelog is at the end of this file.
  
***************
*** 12,16 ****
  ;;;     - Olin Shivers (shivers@cs.cmu.edu)
  
- ;;; I hope that this generalizes shell mode, lisp mode, tea mode, soar mode,...
  ;;; This file defines a general command-interpreter-in-a-buffer package
  ;;; (comint mode). The idea is that you can build specific process-in-a-buffer
--- 30,33 ----
***************
*** 21,31 ****
  
  ;;; Several packages are already defined using comint mode:
! ;;; - cmushell.el defines a shell-in-a-buffer mode.
  ;;; - cmulisp.el defines a simple lisp-in-a-buffer mode.
- ;;; Cmushell and cmulisp mode are similar to, and intended to replace,
- ;;; their counterparts in the standard gnu emacs release (in shell.el). 
- ;;; These replacements are more featureful, robust, and uniform than the 
- ;;; released versions. The key bindings in lisp mode are also more compatible
- ;;; with the bindings of Hemlock and Zwei (the Lisp Machine emacs).
  ;;;
  ;;; - The file cmuscheme.el defines a scheme-in-a-buffer mode.
--- 38,43 ----
  
  ;;; Several packages are already defined using comint mode:
! ;;; - shell.el defines a shell-in-a-buffer mode.
  ;;; - cmulisp.el defines a simple lisp-in-a-buffer mode.
  ;;;
  ;;; - The file cmuscheme.el defines a scheme-in-a-buffer mode.
***************
*** 46,61 ****
  ;;; instead of shell-mode, see the notes at the end of this file.
  
- (provide 'comint)
- (defconst comint-version "2.02")
- 
  
  ;;; Brief Command Documentation:
  ;;;============================================================================
! ;;; Comint Mode Commands: (common to all derived modes, like cmushell & cmulisp
  ;;; mode)
  ;;;
! ;;; m-p	    comint-previous-similar-input   Cycle backward in input history
! ;;; m-n	    comint-next-similar-input       Cycle forward
! ;;; c-c r   comint-previous-input-matching  Search backward in input history
  ;;; return  comint-send-input
  ;;; c-a     comint-bol                      Beginning of line; skip prompt.
--- 58,71 ----
  ;;; instead of shell-mode, see the notes at the end of this file.
  
  
  ;;; Brief Command Documentation:
  ;;;============================================================================
! ;;; Comint Mode Commands: (common to all derived modes, like shell & cmulisp
  ;;; mode)
  ;;;
! ;;; m-p	    comint-previous-input    	    Cycle backwards in input history
! ;;; m-n	    comint-next-input  	    	    Cycle forwards
! ;;; m-r     comint-previous-matching-input   Previous input matching a regexp
! ;;; m-s     comint-next-matching-input       Next input that matches
  ;;; return  comint-send-input
  ;;; c-a     comint-bol                      Beginning of line; skip prompt.
***************
*** 66,70 ****
  ;;; c-c c-z comint-stop-subjob	    	    ^z
  ;;; c-c c-\ comint-quit-subjob	    	    ^\
- ;;; c-c c-d comint-send-eof	    	    ^d
  ;;; c-c c-o comint-kill-output		    Delete last batch of process output
  ;;; c-c c-r comint-show-output		    Show last batch of process output
--- 76,79 ----
***************
*** 82,86 ****
  ;;;					suspend your process (with C-c C-z).
  ;;;
! ;;; Bound for RMS -- I prefer the input history stuff, but you might like 'em.
  ;;; m-P	   comint-msearch-input		Search backwards for prompt
  ;;; m-N    comint-psearch-input		Search forwards for prompt
--- 91,96 ----
  ;;;					suspend your process (with C-c C-z).
  ;;;
! ;;; These used to be bound for RMS -- I prefer the input history stuff,
! ;;; but you might like 'em.
  ;;; m-P	   comint-msearch-input		Search backwards for prompt
  ;;; m-N    comint-psearch-input		Search forwards for prompt
***************
*** 90,93 ****
--- 100,108 ----
  ;;; comint-load-hook is run after loading in this package.
  
+ ;;; Code:
+ 
+ (defconst comint-version "2.03")
+ 
+ (require 'ring)
  
  ;;; Buffer Local Variables:
***************
*** 95,103 ****
  ;;; Comint mode buffer local variables:
  ;;;     comint-prompt-regexp    - string       comint-bol uses to match prompt.
! ;;;     comint-last-input-start - marker           ...
  ;;;     comint-last-input-end   - marker       For comint-kill-output command
! ;;;     input-ring-size         - integer      For the input history
! ;;;     input-ring              - ring             mechanism
! ;;;     input-ring-index        - marker           ...
  ;;;     comint-last-input-match - string           ...
  ;;;     comint-get-old-input    - function     Hooks for specific 
--- 110,118 ----
  ;;; Comint mode buffer local variables:
  ;;;     comint-prompt-regexp    - string       comint-bol uses to match prompt.
! ;;;     comint-last-input-start - marker       Handy if inferior always echos
  ;;;     comint-last-input-end   - marker       For comint-kill-output command
! ;;;     comint-input-ring-size  - integer      For the input history
! ;;;     comint-input-ring       - ring             mechanism
! ;;;     comint-input-ring-index - number           ...
  ;;;     comint-last-input-match - string           ...
  ;;;     comint-get-old-input    - function     Hooks for specific 
***************
*** 106,109 ****
--- 121,125 ----
  ;;;     comint-input-send	- function
  ;;;     comint-eol-on-send	- boolean
+ ;;;     comint-process-echoes   - boolean
  
  (defvar comint-prompt-regexp "^"
***************
*** 113,118 ****
  Good choices:
    Canonical Lisp: \"^[^> ]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp)
!   Lucid Common Lisp: \"^\\(>\\|\\(->\\)+\\) *\"
!   franz: \"^\\(->\\|<[0-9]*>:\\) *\"
    kcl: \"^>+ *\"
    shell: \"^[^#$%>]*[#$%>] *\"
--- 129,134 ----
  Good choices:
    Canonical Lisp: \"^[^> ]*>+:? *\" (Lucid, franz, kcl, T, cscheme, oaklisp)
!   Lucid Common Lisp: \"^\\\\(>\\\\|\\\\(->\\\\)+\\\\) *\"
!   franz: \"^\\\\(->\\\\|<[0-9]*>:\\\\) *\"
    kcl: \"^>+ *\"
    shell: \"^[^#$%>]*[#$%>] *\"
***************
*** 121,127 ****
  This is a good thing to set in mode hooks.")
  
! (defvar input-ring-size 30
    "Size of input history ring.")
  
  ;;; Here are the per-interpreter hooks.
  (defvar comint-get-old-input (function comint-get-old-input-default)
--- 137,150 ----
  This is a good thing to set in mode hooks.")
  
! (defvar comint-input-ring-size 30
    "Size of input history ring.")
  
+ (defvar comint-process-echoes nil
+   "*If non-nil, assume that the subprocess echoes any input.
+ If so, delete one copy of the input so that only one copy eventually
+ appears in the buffer. 
+ 
+ This variable is buffer-local.")
+ 
  ;;; Here are the per-interpreter hooks.
  (defvar comint-get-old-input (function comint-get-old-input-default)
***************
*** 129,137 ****
  This function is called when return is typed while the point is in old text.
  It returns the text to be submitted as process input.  The default is
! comint-get-old-input-default, which grabs the current line, and strips off
! leading text matching comint-prompt-regexp")
  
  (defvar comint-input-sentinel (function ignore)
!   "Called on each input submitted to comint mode process by comint-send-input.
  Thus it can, for instance, track cd/pushd/popd commands issued to the csh.")
  
--- 152,160 ----
  This function is called when return is typed while the point is in old text.
  It returns the text to be submitted as process input.  The default is
! `comint-get-old-input-default', which grabs the current line, and strips off
! leading text matching `comint-prompt-regexp'.")
  
  (defvar comint-input-sentinel (function ignore)
!   "Called on each input submitted to comint mode process by `comint-send-input'.
  Thus it can, for instance, track cd/pushd/popd commands issued to the csh.")
  
***************
*** 143,160 ****
  Only inputs answering true to this function are saved on the input
  history list. Default is to save anything longer than two characters
! that isn't all whitespace. If an existing item in the history exactly
! matches the new input, the existing item is removed and the new input
! is added.")
  
  (defvar comint-input-sender (function comint-simple-send)
    "Function to actually send to PROCESS the STRING submitted by user.
! Usually this is just 'comint-simple-send, but if your mode needs to 
! massage the input string, this is your hook. This is called from
! the user command comint-send-input. comint-simple-send just sends
! the string plus a newline.")
! 
! (defvar comint-eol-on-send 'T
!   "If non-nil, then jump to the end of the line before sending input to process.
! See COMINT-SEND-INPUT")
  
  (defvar comint-mode-hook '()
--- 166,181 ----
  Only inputs answering true to this function are saved on the input
  history list. Default is to save anything longer than two characters
! that isn't all whitespace.")
  
  (defvar comint-input-sender (function comint-simple-send)
    "Function to actually send to PROCESS the STRING submitted by user.
! Usually this is just `comint-simple-send', but if your mode needs to 
! massage the input string, put a different function here.
! `comint-simple-send' just sends the string plus a newline.
! This is called from the user command `comint-send-input'.")
! 
! (defvar comint-eol-on-send t
!   "*Non-nil means go to the end of the line before sending input to process.
! See `comint-send-input'.")
  
  (defvar comint-mode-hook '()
***************
*** 163,170 ****
  
  (defvar comint-exec-hook '()
!   "Called each time a process is exec'd by comint-exec.
  This is called after the process is cranked up.  It is useful for things that
! must be done each time a process is executed in a comint-mode buffer (e.g.,
! (process-kill-without-query)). In contrast, the comint-mode-hook is only
  executed once when the buffer is created.")
  
--- 184,191 ----
  
  (defvar comint-exec-hook '()
!   "Called each time a process is exec'd by `comint-exec'.
  This is called after the process is cranked up.  It is useful for things that
! must be done each time a process is executed in a comint mode buffer (e.g.,
! `(process-kill-without-query)'). In contrast, the `comint-mode-hook' is only
  executed once when the buffer is created.")
  
***************
*** 171,180 ****
  (defvar comint-mode-map nil)
  
  ;; buffer locals
  (defvar comint-last-input-start)
  (defvar comint-last-input-end)
! (defvar input-ring)
! (defvar input-ring-index)
  
  (defun comint-mode ()
    "Major mode for interacting with an inferior interpreter.
--- 192,215 ----
  (defvar comint-mode-map nil)
  
+ (defvar comint-ptyp t
+   "True if communications via pty; false if by pipe.  Buffer local.
+ This is to work around a bug in Emacs process signalling.")
+ 
+ ;(defvar comint-last-input-match ""
+ ;  "Last string searched for by comint input history search, for defaulting.
+ ;Buffer local variable.") 
+ 
+ (defvar comint-last-similar-string "" 
+   "The string last used in a similar string search.")
+ 
  ;; buffer locals
+ (defvar comint-input-ring nil)
  (defvar comint-last-input-start)
  (defvar comint-last-input-end)
! (defvar comint-input-ring-index)
! (put 'comint-input-ring 'permanent-local t)
! (put 'comint-ptyp 'permanent-local t)
  
+ 
  (defun comint-mode ()
    "Major mode for interacting with an inferior interpreter.
***************
*** 182,199 ****
  Return at end of buffer sends line as input.
  Return not at end copies rest of line to end and sends it.
! Setting mode variable comint-eol-on-send means jump to the end of the line
  before submitting new input.
  
! This mode is typically customised to create inferior-lisp-mode,
! shell-mode, etc.. This can be done by setting the hooks
! comint-input-sentinel, comint-input-filter, comint-input-sender and
! comint-get-old-input to appropriate functions, and the variable
! comint-prompt-regexp to the appropriate regular expression.
! 
! An input history is maintained of size input-ring-size, and
! can be accessed with the commands comint-next-input [\\[comint-next-input]] and 
! comint-previous-input [\\[comint-previous-input]]. Commands not keybound by
! default are send-invisible, comint-dynamic-complete, and 
! comint-list-dynamic-completions.
  
  If you accidentally suspend your process, use \\[comint-continue-subjob]
--- 217,233 ----
  Return at end of buffer sends line as input.
  Return not at end copies rest of line to end and sends it.
! Setting variable `comint-eol-on-send' means jump to the end of the line
  before submitting new input.
  
! This mode is typically customised to create Inferior Lisp mode,
! Shell mode, etc.  This can be done by setting the hooks
! `comint-input-sentinel', `comint-input-filter', `comint-input-sender' and
! `comint-get-old-input' to appropriate functions, and the variable
! `comint-prompt-regexp' to the appropriate regular expression.
! 
! An input history is maintained of size `comint-input-ring-size', and
! can be accessed with the commands \\[comint-next-input] and \\[comint-previous-input].
! Commands with no default key bindings include `send-invisible',
! `comint-dynamic-complete', and `comint-list-dynamic-completions'.
  
  If you accidentally suspend your process, use \\[comint-continue-subjob]
***************
*** 204,210 ****
  Entry to this mode runs the hooks on comint-mode-hook"
    (interactive)
!   (let ((old-ring (get-input-ring))
! 	(old-ptyp comint-ptyp)) ; preserve across local var kill. gross.
! ;   (kill-all-local-variables) ; Removed 1/15/90 Olin
      (setq major-mode 'comint-mode)
      (setq mode-name "Comint")
--- 238,243 ----
  Entry to this mode runs the hooks on comint-mode-hook"
    (interactive)
!   ;; Do not remove this.  All major modes must do this.
!   (kill-all-local-variables)
    (setq major-mode 'comint-mode)
    (setq mode-name "Comint")
***************
*** 215,226 ****
      (make-local-variable 'comint-last-input-end)
      (setq comint-last-input-end (make-marker))
!     (make-local-variable 'comint-last-input-match)
!     (setq comint-last-input-match "")
      (make-local-variable 'comint-prompt-regexp) ; Don't set; default
!     (make-local-variable 'input-ring-size)      ; ...to global val.
!     (make-local-variable 'input-ring)
!     (setq input-ring nil) ; make sure it has a value here
!     (make-local-variable 'input-ring-index)
!     (setq input-ring-index 0)
      (make-local-variable 'comint-get-old-input)
      (make-local-variable 'comint-input-sentinel)
--- 248,260 ----
    (make-local-variable 'comint-last-input-end)
    (setq comint-last-input-end (make-marker))
! ; (make-local-variable 'comint-last-input-match)
! ; (setq comint-last-input-match "")
!   (make-local-variable 'comint-last-similar-string)
!   (setq comint-last-similar-string nil)
    (make-local-variable 'comint-prompt-regexp) ; Don't set; default
!   (make-local-variable 'comint-input-ring-size)      ; ...to global val.
!   (make-local-variable 'comint-input-ring)
!   (make-local-variable 'comint-input-ring-index)
!   (setq comint-input-ring-index 0)
    (make-local-variable 'comint-get-old-input)
    (make-local-variable 'comint-input-sentinel)
***************
*** 229,247 ****
      (make-local-variable 'comint-eol-on-send)
      (make-local-variable 'comint-ptyp)
!     (setq comint-ptyp old-ptyp)
      (run-hooks 'comint-mode-hook)
!     ;Do this after the hook so the user can mung INPUT-RING-SIZE w/his hook.
!     ;The test is so we don't lose history if we run comint-mode twice in
!     ;a buffer.
!     (set-input-ring (if (ring-p old-ring)
!                          old-ring
! 			 (make-ring input-ring-size)))))
! 
! ;;; The old-ptyp stuff above is because we have to preserve the value of
! ;;; comint-ptyp across calls to comint-mode, in spite of the
! ;;; kill-all-local-variables that it does. Blech. Hopefully, this will all
! ;;; go away when a later release fixes the signalling bug.
! ;;; (Later: I removed the kill-all-local-variables, but have left this
! ;;; other code in place just in case I reverse myself.)
  
  (if comint-mode-map
--- 263,272 ----
    (make-local-variable 'comint-eol-on-send)
    (make-local-variable 'comint-ptyp)
!   (make-local-variable 'comint-exec-hook)
!   (make-local-variable 'comint-process-echoes)
    (run-hooks 'comint-mode-hook)
!   (or comint-input-ring
!       (setq comint-input-ring (make-ring comint-input-ring-size))))
! 
  
  (if comint-mode-map
***************
*** 248,259 ****
      nil
    (setq comint-mode-map (make-sparse-keymap))
!   ;;(define-key comint-mode-map "\ep" 'comint-previous-input)
!   ;;(define-key comint-mode-map "\en" 'comint-next-input)
    (define-key comint-mode-map "\ep" 'comint-previous-similar-input)
    (define-key comint-mode-map "\en" 'comint-next-similar-input)
!   (define-key comint-mode-map "\es" 'comint-previous-similar-input)
    (define-key comint-mode-map "\C-m" 'comint-send-input)
! ;; I've never met anyone who likes this.
! ;;  (define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof)
    (define-key comint-mode-map "\C-a" 'comint-bol)
    (define-key comint-mode-map "\C-c\C-u" 'comint-kill-input)
--- 273,288 ----
      nil
    (setq comint-mode-map (make-sparse-keymap))
!   (set-keymap-name comint-mode-map 'comint-mode-map)
!   (define-key comint-mode-map "\ep" 'comint-previous-input)
!   (define-key comint-mode-map "\en" 'comint-next-input)
!   (define-key comint-mode-map "\er" 'comint-previous-matching-input)
!   (define-key comint-mode-map "\es" 'comint-next-matching-input)
!   ;; better defs for m-n m-p
    (define-key comint-mode-map "\ep" 'comint-previous-similar-input)
    (define-key comint-mode-map "\en" 'comint-next-similar-input)
! 
    (define-key comint-mode-map "\C-m" 'comint-send-input)
! ;;I've never met anyone who likes this.
! ;;(define-key comint-mode-map "\C-d" 'comint-delchar-or-maybe-eof)
    (define-key comint-mode-map "\C-a" 'comint-bol)
    (define-key comint-mode-map "\C-c\C-u" 'comint-kill-input)
***************
*** 262,312 ****
    (define-key comint-mode-map "\C-c\C-z" 'comint-stop-subjob)
    (define-key comint-mode-map "\C-c\C-\\" 'comint-quit-subjob)
-   ;; Retained for compatibility with older shell mode, even though
-   ;; ^D at end of buffer does the same thing.
    (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof)
    (define-key comint-mode-map "\C-c\C-o" 'comint-kill-output)
-   (define-key comint-mode-map "\C-cr"    'comint-previous-input-matching)
    (define-key comint-mode-map "\C-c\C-r" 'comint-show-output)
!   ;;; Here's the prompt-search stuff I installed for RMS to try...
!   (define-key comint-mode-map "\eP" 'comint-msearch-input)
!   (define-key comint-mode-map "\eN" 'comint-psearch-input)
!   (define-key comint-mode-map "\C-cR" 'comint-msearch-input-matching))
! 
! 
! ;;; This function is used to make a full copy of the comint mode map,
! ;;; so that client modes won't interfere with each other. This function
! ;;; isn't necessary in emacs 18.5x, but we keep it around for 18.4x versions.
! (defun full-copy-sparse-keymap (km)
!   "Recursively copy the sparse keymap KM"
!   (cond ((consp km)
! 	 (cons (full-copy-sparse-keymap (car km))
! 	       (full-copy-sparse-keymap (cdr km))))
! 	(t (copy-keymap km))))
! 
! (defun comint-check-proc (buffer-name)
!   "True if there is a process associated w/buffer BUFFER-NAME, and
! it is alive (status RUN or STOP)."
!   (let ((proc (get-buffer-process buffer-name)))
!     (and proc (memq (process-status proc) '(run stop)))))
  
! (defun comint-mark ()
!   "Returns the process-mark of the current buffer."
!   (process-mark (get-buffer-process (current-buffer))))
  
  ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it ()
  ;;; for the second argument (program).
  (defun make-comint (name program &optional startfile &rest switches)
!   (let* ((buffer
! 	  ;; Don't create the buffer in any other mode, since
! 	  ;; we are going to set it to comint-mode.  This fixes
! 	  ;; problems with default mode being text and text-mode-hook
! 	  ;; turning on auto-fill, thus causing shell buffers to be
! 	  ;; in auto-fill, certainly not what the user intended!
! 	  (let ((default-major-mode 'fundamental-mode))
! 	    (get-buffer-create (concat "*" name "*"))))
! 	 (proc (get-buffer-process buffer)))
      ;; If no process, or nuked process, crank up a new one and put buffer in
      ;; comint mode. Otherwise, leave buffer and existing process alone.
!     (cond ((or (not proc) (not (memq (process-status proc) '(run stop))))
  	   (save-excursion
  	     (set-buffer buffer)
--- 291,325 ----
    (define-key comint-mode-map "\C-c\C-z" 'comint-stop-subjob)
    (define-key comint-mode-map "\C-c\C-\\" 'comint-quit-subjob)
    (define-key comint-mode-map "\C-c\C-d" 'comint-send-eof)
    (define-key comint-mode-map "\C-c\C-o" 'comint-kill-output)
    (define-key comint-mode-map "\C-c\C-r" 'comint-show-output)
!   (define-key comint-mode-map "\C-cr"    'comint-previous-input-matching)
!   ;;; prompt-search commands commented out 3/90 -Olin
! ; (define-key comint-mode-map "\eP" 'comint-msearch-input)
! ; (define-key comint-mode-map "\eN" 'comint-psearch-input)
! ; (define-key comint-mode-map "\C-cR" 'comint-msearch-input-matching)
!   )
  
! 
! (defun comint-check-proc (buffer)
!   "True if there is a living process associated w/buffer BUFFER.
! Living means the status is `run' or `stop'.
! BUFFER can be either a buffer or the name of one."
!   (let ((proc (get-buffer-process buffer)))
!     (and proc (memq (process-status proc) '(run stop)))))
  
  ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it ()
  ;;; for the second argument (program).
+ ;;;###autoload
  (defun make-comint (name program &optional startfile &rest switches)
!   "Make a comint process NAME in a buffer, running PROGRAM.
! The name of the buffer is made by surrounding NAME with `*'s.
! If there is already a running process in that buffer, it is not restarted.
! Optional third arg STARTFILE is the name of a file to send the contents of to 
! the process.  Any more args are arguments to PROGRAM."
!   (let ((buffer (get-buffer-create (concat "*" name "*"))))
      ;; If no process, or nuked process, crank up a new one and put buffer in
      ;; comint mode.  Otherwise, leave buffer and existing process alone.
!     (cond ((not (comint-check-proc buffer))
  	   (save-excursion
  	     (set-buffer buffer)
***************
*** 315,329 ****
      buffer))
  
! (fset 'make-shell 'make-comint) ; mostly compatible...
! 
! (defvar comint-ptyp t
!   "True if communications via pty; false if by pipe. Buffer local.
! This is to work around a bug in emacs process signalling.")
  
  (defun comint-exec (buffer name command startfile switches)
!   "Fires up a process in buffer for comint modes.
  Blasts any old process running in the buffer. Doesn't set the buffer mode.
  You can use this to cheaply run a series of processes in the same comint
! buffer. The hook comint-exec-hook is run after each exec."
    (save-excursion
      (set-buffer buffer)
--- 328,338 ----
      buffer))
  
! ;(define-function 'make-shell 'make-comint) ; mostly compatible...
  
  (defun comint-exec (buffer name command startfile switches)
!   "Start up a process in buffer BUFFER for comint modes.
  Blasts any old process running in the buffer.  Doesn't set the buffer mode.
  You can use this to cheaply run a series of processes in the same comint
! buffer.  The hook `comint-exec-hook' is run after each exec."
    (save-excursion
      (set-buffer buffer)
***************
*** 332,335 ****
--- 341,345 ----
      ;; Crank up a new process
      (let ((proc (comint-exec-1 name buffer command switches)))
+       (set-process-filter proc 'comint-filter)
        (make-local-variable 'comint-ptyp)
        (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
***************
*** 341,346 ****
  	     ;;This is guaranteed to wait long enough
  	     ;;but has bad results if the comint does not prompt at all
! 	     ;;	     "(while (= size (buffer-size))"
! 	     ;;	     "  (sleep-for 1))"
  	     ;;I hope 1 second is enough!
  	     (sleep-for 1) 
--- 351,356 ----
  	     ;;This is guaranteed to wait long enough
  	     ;;but has bad results if the comint does not prompt at all
! 	     ;;	     (while (= size (buffer-size))
! 	     ;;	       (sleep-for 1))
  	     ;;I hope 1 second is enough!
  	     (sleep-for 1)
***************
*** 349,355 ****
  	     (setq startfile (buffer-substring (point) (point-max)))
  	     (delete-region (point) (point-max))
! 	     (comint-send-string proc startfile))))
      (run-hooks 'comint-exec-hook)
!     buffer))
  
  ;;; This auxiliary function cranks up the process for comint-exec in
--- 359,365 ----
  	     (setq startfile (buffer-substring (point) (point-max)))
  	     (delete-region (point) (point-max))
! 	     (comint-send-string proc startfile)))
      (run-hooks 'comint-exec-hook)
!     buffer)))
  
  ;;; This auxiliary function cranks up the process for comint-exec in
***************
*** 383,388 ****
  	  (setenv "EMACS"   emv)))))
  	     
- 
- 
  ;; This is just (append new old-env) that compresses out shadowed entries.
  ;; It's also pretty ugly, mostly due to elisp's horrible iteration structures.
--- 393,396 ----
***************
*** 398,402 ****
  		       (substring vv 0 (match-end 0)))))
  	(setq old-env (cdr old-env))
! 	(cond ((not (and var (comint-mem var vars)))
  	       (if var (setq var (cons var vars)))
  	       (setq ans (cons vv ans))))))
--- 406,410 ----
  		       (substring vv 0 (match-end 0)))))
  	(setq old-env (cdr old-env))
! 	(cond ((not (and var (member var vars)))
  	       (if var (setq var (cons var vars)))
  	       (setq ans (cons vv ans))))))
***************
*** 403,438 ****
      (nreverse ans)))
  
- ;;; This should be in emacs, but it isn't.
- (defun comint-mem (item list &optional elt=)
-   "Test to see if ITEM is equal to an item in LIST.
- Option comparison function ELT= defaults to equal."
-   (let ((elt= (or elt= (function equal)))
- 	(done nil))
-     (while (and list (not done))
-       (if (funcall elt= item (car list))
- 	  (setq done list)
- 	  (setq list (cdr list))))
-     done))
- 
  
- ;;; Ring Code
- ;;;============================================================================
- ;;; This code defines a ring data structure. A ring is a 
- ;;;     (hd-index tl-index . vector) 
- ;;; list. You can insert to, remove from, and rotate a ring. When the ring
- ;;; fills up, insertions cause the oldest elts to be quietly dropped.
- ;;;
- ;;; HEAD = index of the newest item on the ring.
- ;;; TAIL = index of the oldest item on the ring.
- ;;;
- ;;; These functions are used by the input history mechanism, but they can
- ;;; be used for other purposes as well.
- 
- 
  ;;; These next four forms are to provide a more persistent means of
  ;;; keeping the buffer history -- they can be disabled by setting
  ;;; use-buffer-local-input-ring to NIL.
! (defvar use-buffer-local-input-ring nil)
! 
  ;;; A list of vectors of the form [<buffer-name> <input-ring>]; these let
  ;;; the input history be associated with the name of the buffer, so that it
--- 411,420 ----
      (nreverse ans)))
  
  
  ;;; These next four forms are to provide a more persistent means of
  ;;; keeping the buffer history -- they can be disabled by setting
  ;;; use-buffer-local-input-ring to NIL.
! ;(defvar use-buffer-local-input-ring nil)
! ;
  ;;; A list of vectors of the form [<buffer-name> <input-ring>]; these let
  ;;; the input history be associated with the name of the buffer, so that it
***************
*** 439,616 ****
  ;;; persists from one instance of the buffer to another (especially useful
  ;;; with gdb buffers), and even one invocation of emacs to another.
! (defvar *buffer-histories-list* nil)
! 
! (defun get-input-ring ()
!   (if use-buffer-local-input-ring
!       (and (boundp 'input-ring)
!            input-ring)
!       (let ((list *buffer-histories-list*)
!             (buffer (current-buffer))
!             (ring nil))
!         (while (and list (not ring))
!           (cond ((eq buffer (get-buffer (aref (car list) 0)))
!                  (aset (car list) 1 buffer)
!                  (setq ring (aref (car list) 2)))
!                 ((eq buffer (aref (car list) 1))
!                  (aset (car list) 0 (buffer-name buffer))
!                  (setq ring (aref (car list) 2))))
!           (setq list (cdr list)))
!         (if (not ring)
!             (set-input-ring nil)
!             ring))))
! 
! (defun set-input-ring (ring-to-use)
!   (if (not (ring-p ring-to-use))
!       (setq ring-to-use (make-ring input-ring-size)))
!   (if use-buffer-local-input-ring
!       (progn
!         (make-local-variable 'input-ring)
!         (setq input-ring ring-to-use))
!       (progn
!         (setq *buffer-histories-list*
!               (cons (vector (buffer-name (current-buffer)) (current-buffer) ring-to-use)
!                     *buffer-histories-list*))
!         ring-to-use)))
! 
! (defun ring-p (x) 
!   "T if X is a ring; NIL otherwise."
!   (and (consp x) (integerp (car x))
!        (consp (cdr x)) (integerp (car (cdr x)))
!        (vectorp (cdr (cdr x)))))
! 
! (defun ring-head (ring)
!   (car ring))
! (defun set-ring-head (ring value)
!   (let ((len (length (cdr (cdr ring)))))
!        (if (or (< value 0)
!                (>= value len))
!            (error (format "Attempt to make head of ring (size = %d) be %d"
!                           len value)))
!        (setcar ring value)))
! 
! (defun ring-tail (ring)
!   (car (cdr ring)))
! (defun set-ring-tail (ring value)
!   (let ((len (length (cdr (cdr ring)))))
!        (if (or (< value 0)
!                (>= value len))
!            (error (format "Attempt to make head of ring (size = %d) be %d"
!                           len value)))
!        (setcar (cdr ring) value)))
! 
! (defun ring-vector (ring)
!   (cdr (cdr ring)))
! 
! (defun make-ring (size)
!   "Make a ring that can contain SIZE elts"
!   (cons 1 (cons 0 (make-vector (+ size 1) nil))))
! 
! (defun ring-plus1 (index veclen)
!   "INDEX+1, with wraparound"
!   (let ((new-index (+ index 1)))
!     (if (= new-index veclen) 0 new-index)))
! 
! (defun ring-minus1 (index veclen)
!   "INDEX-1, with wraparound"
!   (- (if (= 0 index) veclen index) 1))
! 
! (defun ring-plus (index increment veclen)
!   "INDEX+INCREMENT, with wraparound."
!   ;; use comint-mod here as we don't have control over increment
!   ;; arg since this function is called with user-supplied increment
!   (comint-mod (+ index increment) veclen))
! 
! (defun ring-length (ring)
!   "Number of elts in the ring."
!   (let ((hd (ring-head ring)) 
!         (tl (ring-tail ring)) 
!         (siz (length (ring-vector ring))))
!     (let ((len (if (<= hd tl) (+ 1 (- tl hd)) (+ 1 tl (- siz hd)))))
!       (if (= len siz) 0 len))))
! 
! (defun ring-empty-p (ring)
!   (= 0 (ring-length ring)))
! 
! (defun ring-insert-new (ring item)
!   "Insert a new item onto the ring. If the ring is full, dump the oldest
! item to make room."       
!   (let* ((vec (ring-vector ring))  
!          (len (length vec))
! 	 (new-hd (ring-minus1 (ring-head ring) len)))
!     (set-ring-head ring new-hd)
!     (aset vec new-hd item)
!     (if (ring-empty-p ring)                 ;overflow -- dump one off the tail.
!         (set-ring-tail ring (ring-minus1 (ring-tail ring) len)))))
! 
! (defun ring-remove-oldest (ring)
!   "Remove the oldest item retained on the ring."
!   (if (ring-empty-p ring) (error "Ring empty")
!       (let ((tl (ring-tail ring))  
!             (vec (ring-vector ring)))
! 	(set-ring-tail ring (ring-minus1 tl (length vec)))
! 	(aref vec tl))))
! 
! (defun ring-remove-newest (ring)
!   "Remove the newest item retained on the ring."
!   (if (ring-empty-p ring) (error "Ring empty")
!       (let ((hd (ring-head ring))  
!             (vec (ring-vector ring)))
! 	(set-ring-head ring (ring-plus1 hd (length vec)))
! 	(aref vec hd))))
! 
! (defun comint-mod (n m)
!   "Returns N mod M. M is positive. Answer is guaranteed to be non-negative, 
! and less than (the absolute value of) M."
!   (if (= m 0) (if (< n 0) (- n) n)
!     (let ((n (% n m)))
!       (if (>= n 0) n
!         (+ n
!            (if (>= m 0) m (- m)))))))   ; (abs m)
! 
! (defun ring-ref (ring index)
!   (let ((numelts (ring-length ring)))
!     (if (= numelts 0) (error "indexed empty ring")
! 	(let* ((hd (ring-head ring))
!                (tl (ring-tail ring))
!                (vec (ring-vector ring))
! 	       (index (comint-mod index numelts))
! 	       (vec-index (comint-mod (+ index hd) 
! 				      (length vec))))
! 	  (aref vec vec-index)))))
! 
! (defun ring-search-and-destroy (ring victim predicate)
!   "Search for a matching victim in the ring according to predicate
! and destructively remove it if found."
!   (cond ((not (ring-empty-p ring))
! 	 (let* ((hd (ring-head ring))
! 		(tl (ring-tail ring))
! 		(vec (ring-vector ring))
! 		(len (length vec))
! 		(top (if (>= tl hd) (+ tl 1) len))
! 		(i hd)
! 		(done nil))
! 	   (while (and (not done) (< i top))
! 	     (cond ((funcall predicate victim (aref vec i))
! 		    (while (> i hd)
! 		      (aset vec i (aref vec (- i 1)))
! 		      (setq i (- i 1)))
! 		    (set-ring-head ring (ring-plus1 hd len))
! 		    (setq done t)))
! 	     (setq i (+ i 1)))
! 	   (cond ((and (not done) (< tl hd))
! 		  (setq i 0)
! 		  (while (and (not done) (<= i tl))
! 		    (cond ((funcall predicate victim (aref vec i))
! 			   (while (< i tl)
! 			     (aset vec i (aref vec (+ i 1)))
! 			     (setq i (+ i 1)))
! 			   (set-ring-tail ring (ring-minus1 tl len))
! 			   (setq done t)))
! 		    (setq i (+ i 1)))))))))
  
! 
  ;;; Input history retrieval commands
  ;;; M-p -- previous input    M-n -- next input
! ;;; C-c r -- previous input matching
  ;;; ===========================================================================
  
--- 421,462 ----
  ;;; persists from one instance of the buffer to another (especially useful
  ;;; with gdb buffers), and even one invocation of emacs to another.
! ;(defvar *buffer-histories-list* nil)
! ;
! ;(defun get-input-ring ()
! ;  (if use-buffer-local-input-ring
! ;      (and (boundp 'comint-input-ring)
! ;           comint-input-ring)
! ;      (let ((list *buffer-histories-list*)
! ;            (buffer (current-buffer))
! ;            (ring nil))
! ;        (while (and list (not ring))
! ;          (cond ((eq buffer (get-buffer (aref (car list) 0)))
! ;                 (aset (car list) 1 buffer)
! ;                 (setq ring (aref (car list) 2)))
! ;                ((eq buffer (aref (car list) 1))
! ;                 (aset (car list) 0 (buffer-name buffer))
! ;                 (setq ring (aref (car list) 2))))
! ;          (setq list (cdr list)))
! ;        (if (not ring)
! ;            (set-input-ring nil)
! ;            ring))))
! ;
! ;(defun set-input-ring (ring-to-use)
! ;  (if (not (ring-p ring-to-use))
! ;      (setq ring-to-use (make-ring comint-input-ring-size)))
! ;  (if use-buffer-local-input-ring
! ;      (progn
! ;        (make-local-variable 'comint-input-ring)
! ;        (setq comint-input-ring ring-to-use))
! ;      (progn
! ;        (setq *buffer-histories-list*
! ;              (cons (vector (buffer-name (current-buffer)) (current-buffer) ring-to-use)
! ;                    *buffer-histories-list*))
! ;        ring-to-use)))
  
! 
  ;;; Input history retrieval commands
  ;;; M-p -- previous input    M-n -- next input
! ;;; M-C-r -- previous input matching
  ;;; ===========================================================================
  
***************
*** 618,623 ****
    "Cycle backwards through input history."
    (interactive "*p")
!   (let* ((ring (get-input-ring))
!          (len (ring-length ring)))
      (cond ((<= len 0)
  	   (message "Empty input ring")
--- 464,468 ----
    "Cycle backwards through input history."
    (interactive "*p")
!   (let ((len (ring-length comint-input-ring)))
      (cond ((<= len 0)
  	   (message "Empty input ring")
***************
*** 627,645 ****
  	   (ding))
  	  (t
! 	   (cond ((eq last-command 'comint-previous-input)
! 		  (delete-region comint-last-input-start (point)))
! 		 ((eq last-command 'comint-previous-similar-input)
! 		  (delete-region 
! 		   (comint-mark)
! 		   (point)))
! 		 (t                          
! 		  (setq input-ring-index
  			(if (> arg 0) -1
! 			    (if (< arg 0) 1 0)))
!                   (set-marker comint-last-input-start (point))))
! 	   (setq input-ring-index (comint-mod (+ input-ring-index arg) len))
! 	   (message "%d" (1+ input-ring-index))
! 	   (insert (ring-ref ring input-ring-index))
! 	   (setq this-command 'comint-previous-input)))))
  	 
  (defun comint-next-input (arg)
--- 472,488 ----
  	   (ding))
  	  (t
! 	   (delete-region (point)
! 			  (process-mark (get-buffer-process (current-buffer))))
! 	   ;; Initialize the index on the first use of this command
! 	   ;; so that the first M-p gets index 0, and the first M-n gets
! 	   ;; index -1.
! 	   (if (null comint-input-ring-index)
! 	       (setq comint-input-ring-index
  		     (if (> arg 0) -1
! 			 (if (< arg 0) 1 0))))
! 	   (setq comint-input-ring-index
! 		 (ring-mod (+ comint-input-ring-index arg) len))
! 	   (message "%d" (1+ comint-input-ring-index))
! 	   (insert (ring-ref comint-input-ring comint-input-ring-index))))))
  	 
  (defun comint-next-input (arg)
***************
*** 648,685 ****
    (comint-previous-input (- arg)))
  
! (defvar comint-last-input-match ""
!   "Last string searched for by comint input history search, for defaulting.
! Buffer local variable.") 
! 
! (defun comint-previous-input-matching (str)
!   "Searches backwards through input history for substring match."
!   (interactive (let* ((last-command last-command) ; preserve around r-f-m
! 		      (s (read-from-minibuffer 
! 			 (format "Command substring (default %s): "
! 				 comint-last-input-match))))
! 		 (list (if (string= s "") comint-last-input-match s))))
! ; (interactive "sCommand substring: ")
!   (setq comint-last-input-match str) ; update default
!   (if (not (eq last-command 'comint-previous-input))
!       (setq input-ring-index -1))
!   (let* ((ring (get-input-ring))
!          (str (regexp-quote str))
!         (len (ring-length ring))
! 	(n (+ input-ring-index 1)))
!     (while (and (< n len) (not (string-match str (ring-ref ring n))))
!       (setq n (+ n 1)))
!     (cond ((< n len)
! 	   (comint-previous-input (- n input-ring-index)))
! 	  (t (if (eq last-command 'comint-previous-input) 
! 		 (setq this-command 'comint-previous-input))
! 	     (message "Not found.")
! 	     (ding)))))
! 
! 
! ;;; These next three commands are alternatives to the input history commands --
! ;;; comint-next-input, comint-previous-input and 
! ;;; comint-previous-input-matching. They search through the process buffer
! ;;; text looking for occurrences of the prompt. RMS likes them better;
! ;;; I don't.
  
  ;;; comint-msearch-input-matching prompts for a string, not a regexp.
--- 491,560 ----
    (comint-previous-input (- arg)))
  
! (defun comint-previous-matching-input (regexp arg)
!   "Search backwards through input history for match for REGEXP.
! \(Previous history elements are earlier commands.)
! With prefix argument N, search for Nth previous match.
! If N is negative, find the next or Nth next match."
!   (interactive
!    (let* ((minibuffer-history-sexp-flag nil)
! 	  ;; Don't clobber this.
! 	  (last-command last-command)
! 	  (regexp (read-from-minibuffer "Previous input matching (regexp): "
! 					nil
! 					minibuffer-local-map
! 					nil
! 					'minibuffer-history-search-history)))
!      (list (if (string= regexp "")
! 	       (setcar minibuffer-history-search-history
! 		       (nth 1 minibuffer-history-search-history))
! 	     regexp)
! 	   (prefix-numeric-value current-prefix-arg))))
!   (if (null comint-input-ring-index)
!       (setq comint-input-ring-index -1))
!   (let* ((len (ring-length comint-input-ring))
! 	 (motion (if (> arg 0) 1 -1))
! 	 (n comint-input-ring-index))
!     ;; Do the whole search as many times as the argument says.
!     (while (/= arg 0)
!       (let ((prev n))
! 	;; Step once.
! 	(setq n (ring-mod (+ n motion) len))
! 	;; If we haven't reached a match, step some more.
! 	(while (and (< n len)
! 		    (not (string-match regexp (ring-ref comint-input-ring n))))
! 	  (setq n (ring-mod (+ n motion) len))
! 	  ;; If we have gone all the way around in this search, error.
! 	  (if (= n prev)
! 	      (error "Not found"))))
!       (setq arg (if (> arg 0) (1- arg) (1+ arg))))
!     ;; Now that we know which ring element to use,
!     ;; substitute that for the current input.
!     (comint-previous-input (- n comint-input-ring-index))))
! 
! (defun comint-next-matching-input (regexp arg)
!   "Search forwards through input history for match for REGEXP.
! \(Later history elements are more recent commands.)
! With prefix argument N, search for Nth following match.
! If N is negative, find the previous or Nth previous match."
!   (interactive
!    (let ((minibuffer-history-sexp-flag nil)
! 	 ;; Don't clobber this.
! 	 (last-command last-command)
! 	 (regexp (read-from-minibuffer "Previous input matching (regexp): "
! 				       nil
! 				       minibuffer-local-map
! 				       nil
! 				       'minibuffer-history-search-history)))
!      (list (if (string= regexp "")
! 	       (setcar minibuffer-history-search-history
! 		       (nth 1 minibuffer-history-search-history))
! 	     regexp)
! 	   (prefix-numeric-value current-prefix-arg))))
!   (comint-previous-matching-input regexp (- arg)))
! 
! ;;; These next three commands are alternatives to the input history commands
! ;;; They search through the process buffer
! ;;; text looking for occurrences of the prompt.  Bound to M-P, M-N, and C-c R
! ;;; (uppercase P, N, and R) for now. Try'em out. Go with what you like...
  
  ;;; comint-msearch-input-matching prompts for a string, not a regexp.
***************
*** 688,730 ****
  ;;; limits functionality.
  
! (defun comint-psearch-input ()
!   "Search forwards for next occurrence of prompt and skip to end of line.
! \(prompt is anything matching regexp comint-prompt-regexp)"
!   (interactive)
!   (if (re-search-forward comint-prompt-regexp (point-max) t)
!       (end-of-line)
!       (error "No occurrence of prompt found")))
  
! (defun comint-msearch-input ()
!   "Search backwards for previous occurrence of prompt and skip to end of line.
! Search starts from beginning of current line."
!   (interactive)
!   (let ((p (save-excursion
! 	     (beginning-of-line)
! 	     (cond ((re-search-backward comint-prompt-regexp (point-min) t)
! 		    (end-of-line)
! 		    (point))
! 		   (t nil)))))
!     (if p (goto-char p)
! 	(error "No occurrence of prompt found"))))
! 
! (defun comint-msearch-input-matching (str)
!   "Search backwards for occurrence of prompt followed by STRING.
! STRING is prompted for, and is NOT a regular expression."
!   (interactive (let ((s (read-from-minibuffer 
! 			 (format "Command (default %s): "
! 				 comint-last-input-match))))
! 		 (list (if (string= s "") comint-last-input-match s))))
! ; (interactive "sCommand: ")
!   (setq comint-last-input-match str) ; update default
!   (let* ((r (concat comint-prompt-regexp (regexp-quote str)))
! 	 (p (save-excursion
! 	      (beginning-of-line)
! 	      (cond ((re-search-backward r (point-min) t)
! 		     (end-of-line)
! 		     (point))
! 		    (t nil)))))
!     (if p (goto-char p)
! 	(error "No match"))))
  
  ;;;
--- 563,608 ----
  ;;; limits functionality.
  
! ;;; These commands were deemed non-winning and have been commented out.
! ;;; Feel free to re-enable them if you like. -Olin 3/91
  
! ;(defun comint-psearch-input ()
! ;  "Search forwards for next occurrence of prompt and skip to end of line.
! ;\(prompt is anything matching regexp comint-prompt-regexp)"
! ;  (interactive)
! ;  (if (re-search-forward comint-prompt-regexp (point-max) t)
! ;      (end-of-line)
! ;      (error "No occurrence of prompt found")))
! ;
! ;(defun comint-msearch-input ()
! ;  "Search backwards for previous occurrence of prompt and skip to end of line.
! ;Search starts from beginning of current line."
! ;  (interactive)
! ;  (let ((p (save-excursion
! ;	     (beginning-of-line)
! ;	     (cond ((re-search-backward comint-prompt-regexp (point-min) t)
! ;		    (end-of-line)
! ;		    (point))
! ;		   (t nil)))))
! ;    (if p (goto-char p)
! ;	(error "No occurrence of prompt found"))))
! ;
! ;(defun comint-msearch-input-matching (str)
! ;  "Search backwards for occurrence of prompt followed by STRING.
! ;STRING is prompted for, and is NOT a regular expression."
! ;  (interactive (let ((s (read-from-minibuffer 
! ;			 (format "Command (default %s): "
! ;				 comint-last-input-match))))
! ;		 (list (if (string= s "") comint-last-input-match s))))
! ;; (interactive "sCommand: ")
! ;  (setq comint-last-input-match str) ; update default
! ;  (let* ((r (concat comint-prompt-regexp (regexp-quote str)))
! ;	 (p (save-excursion
! ;	      (beginning-of-line)
! ;	      (cond ((re-search-backward r (point-min) t)
! ;		     (end-of-line)
! ;		     (point))
! ;		    (t nil)))))
! ;    (if p (goto-char p)
! ;	(error "No match"))))
  
  ;;;
***************
*** 733,800 ****
  ;;; Reenter input, removing back to the last insert point if it exists. 
  ;;;
- (defvar comint-last-similar-string "" 
-   "The string last used in a similar string search.")
  (defun comint-previous-similar-input (arg)
!   "Reenters the last input that matches the string typed so far.  If repeated 
! successively older inputs are reentered.  If arg is 1, it will go back
! in the history, if -1 it will go forward."
    (interactive "p")
    (if (not (comint-after-pmark-p))
        (error "Not after process mark"))
!   (if (not (eq last-command 'comint-previous-similar-input))
!       (setq input-ring-index -1
! 	    comint-last-similar-string 
  	    (buffer-substring 
!               (comint-mark)
                (point))))
    (let* ((size (length comint-last-similar-string))
!          (ring (get-input-ring))
! 	 (len (ring-length ring))
! 	 (limit (if (= input-ring-index -1)
! 		    (if (= arg 1)
! 			0
! 			(- len 1))
! 		    (ring-plus input-ring-index arg len)))
! 	 (n limit)
! 	 (done nil)
  	 entry)
!     (while (and (not done)
! 		(or (< (length (setq entry (ring-ref ring n))) size)
! 		    (not (string-equal comint-last-similar-string 
  				       (substring entry 0 size)))))
!       (setq n (ring-plus n arg len))
!       (if (= n limit)
! 	  (setq done t)))
!     (cond ((not done)
! 	   (setq input-ring-index n)
! 	   (if (eq last-command 'comint-previous-similar-input)
! 	       (delete-region comint-last-input-start (point)) ; repeat
!                (set-marker comint-last-input-start (point))) ; 1st time
  	   (insert (substring entry size)))
! 	  (t (message "Not found.") (ding) (sit-for 1)))))
  
  (defun comint-next-similar-input (arg)
!   "Reenters the last input that matches the string typed so far.  If repeated 
! successively older inputs are reentered.  If arg is 1, it will go forward
! in the history, if -1 it will go back."
    (interactive "p")
-   (setq this-command 'comint-previous-similar-input)
    (comint-previous-similar-input (- arg)))
  
  (defun comint-send-input () 
!   "Send input to process.  After the process output mark, sends all text
! from the process mark to point as input to the process.  Before the
! process output mark, calls value of variable comint-get-old-input to retrieve
! old input, copies it to the end of the buffer, and sends it.  A terminal
! newline is also inserted into the buffer and sent to the process.  In either
! case, value of variable comint-input-sentinel is called on the input before
! sending it.  The input is entered into the input history ring, if value of
! variable comint-input-filter returns non-nil when called on the input.
  
! If variable comint-eol-on-send is non-nil, then point is moved to the end of
! line before sending the input.
  
! comint-get-old-input, comint-input-sentinel, and comint-input-filter are chosen
! according to the command interpreter running in the buffer. E.g.,
  If the interpreter is the csh,
      comint-get-old-input is the default: take the current line, discard any
--- 611,679 ----
  ;;; Reenter input, removing back to the last insert point if it exists. 
  ;;;
  (defun comint-previous-similar-input (arg)
!   "Fetch the previous (older) input that matches the string typed so far.
! Successive repetitions find successively older matching inputs.
! A prefix argument serves as a repeat count; a negative argument
! fetches following (more recent) inputs."
    (interactive "p")
    (if (not (comint-after-pmark-p))
        (error "Not after process mark"))
!   (if (null comint-input-ring-index)
!       (setq comint-input-ring-index
! 	    (if (> arg 0) -1
! 	      (if (< arg 0) 1 0))))
!   (if (not (or (eq last-command 'comint-previous-similar-input)
! 	       (eq last-command 'comint-next-similar-input)))
!       (setq comint-last-similar-string 
  	    (buffer-substring 
! 	     (process-mark (get-buffer-process (current-buffer)))
  	     (point))))
    (let* ((size (length comint-last-similar-string))
! 	 (len (ring-length comint-input-ring))
! 	 (n (+ comint-input-ring-index arg))
  	 entry)
!     (while (and (< n len) 
! 		(or (< (length (setq entry (ring-ref comint-input-ring n))) size)
! 		    (not (equal comint-last-similar-string 
  				(substring entry 0 size)))))
!       (setq n (+ n arg)))
!     (cond ((< n len)
! 	   (setq comint-input-ring-index n)
! 	   (if (or (eq last-command 'comint-previous-similar-input)
! 		   (eq last-command 'comint-next-similar-input))
! 	       (delete-region (mark) (point)) ; repeat
! 	       (push-mark (point)))	      ; 1st time
  	   (insert (substring entry size)))
! 	  (t (error "Not found")))
!     (message "%d" (1+ comint-input-ring-index))))
  
  (defun comint-next-similar-input (arg)
!   "Fetch the next (newer) input that matches the string typed so far.
! Successive repetitions find successively newer matching inputs.
! A prefix argument serves as a repeat count; a negative argument
! fetches previous (older) inputs."
    (interactive "p")
    (comint-previous-similar-input (- arg)))
  
  (defun comint-send-input () 
!   "Send input to process.
! After the process output mark, sends all text from the process mark to
! point as input to the process.  Before the process output mark, calls value
! of variable `comint-get-old-input' to retrieve old input, copies it to the
! process mark, and sends it.  If variable `comint-process-echoes' is nil,
! a terminal newline is also inserted into the buffer and sent to the process
! \(if it is non-nil, all text from the process mark to point is deleted,
! since it is assumed the remote process will re-echo it).
! 
! The value of variable `comint-input-sentinel' is called on the input
! before sending it.  The input is entered into the input history ring,
! if the value of variable `comint-input-filter' returns non-nil when
! called on the input.
  
! If variable `comint-eol-on-send' is non-nil, then point is moved to the
! end of line before sending the input.
  
! `comint-get-old-input', `comint-input-sentinel', and `comint-input-filter'
! are chosen according to the command interpreter running in the buffer.  E.g.,
  If the interpreter is the csh,
      comint-get-old-input is the default: take the current line, discard any
***************
*** 811,815 ****
          which matches (1) all whitespace (2) :a, :c, etc.
  
! Similarly for Soar, Scheme, etc.."
    (interactive)
    ;; Note that the input string does not include its terminal newline.
--- 690,694 ----
          which matches (1) all whitespace (2) :a, :c, etc.
  
! Similarly for Soar, Scheme, etc."
    (interactive)
    ;; Note that the input string does not include its terminal newline.
***************
*** 816,821 ****
    (let ((proc (get-buffer-process (current-buffer))))
      (if (not proc) (error "Current buffer has no process")
! 	(let* ((ring (get-input-ring))
!                (pmark (process-mark proc))
  	       (pmark-val (marker-position pmark))
  	       (input (if (>= (point) pmark-val)
--- 695,699 ----
    (let ((proc (get-buffer-process (current-buffer))))
      (if (not proc) (error "Current buffer has no process")
! 	(let* ((pmark (process-mark proc))
  	       (pmark-val (marker-position pmark))
  	       (input (if (>= (point) pmark-val)
***************
*** 826,842 ****
  			    (insert copy)
  			    copy))))
! 	  (insert ?\n)
! 	  (cond ((funcall comint-input-filter input)
! 		 (ring-search-and-destroy
! 		   ring input (function string-equal))
! 		 (ring-insert-new ring input)))
  	  (funcall comint-input-sentinel input)
  	  (funcall comint-input-sender proc input)
! 	  (set-marker (process-mark proc) (point))
! 	  (set-marker comint-last-input-end (point))))))
  
  (defun comint-get-old-input-default ()
!   "Default for comint-get-old-input: take the current line, and discard
! any initial text matching comint-prompt-regexp."
    (save-excursion
      (beginning-of-line)
--- 704,762 ----
  			    (insert copy)
  			    copy))))
!           (if comint-process-echoes
!               (delete-region pmark (point))
!             (insert ?\n))
! 	  (if (funcall comint-input-filter input)
! 	      (ring-insert comint-input-ring input))
  	  (funcall comint-input-sentinel input)
  	  (funcall comint-input-sender proc input)
! 	  (setq comint-input-ring-index nil)
! 	  (set-marker comint-last-input-start pmark)
! 	  (set-marker comint-last-input-end (point))
! 	  (set-marker (process-mark proc) (point))))))
! 
! ;; The sole purpose of using this filter for comint processes
! ;; is to keep comint-last-input-end from moving forward
! ;; when output is inserted.
! (defun comint-filter (process string)
!   (let ((obuf (current-buffer))
! 	opoint obeg oend)
!     (set-buffer (process-buffer process))
!     (setq opoint (point))
!     (setq obeg (point-min))
!     (setq oend (point-max))
!     (let ((buffer-read-only nil)
! 	  (nchars (length string)))
!       (widen)
!       (goto-char (process-mark process))
!       (if (<= (point) opoint)
! 	  (setq opoint (+ opoint nchars)))
!       ;; Insert after old_begv, but before old_zv.
!       (if (< (point) obeg)
! 	  (setq obeg (+ obeg nchars)))
!       (if (<= (point) oend)
! 	  (setq oend (+ oend nchars)))
! 
!       (insert-before-markers string)
!       ;; Don't insert initial prompt outside the top of the window.
!       (if (= (window-start (selected-window)) (point))
! 	  (set-window-start (selected-window) (- (point) (length string))))
! 
!       (and comint-last-input-end
! 	   (marker-buffer comint-last-input-end)
! 	   (= (point) comint-last-input-end)
! 	   (set-marker comint-last-input-end
! 		       (- comint-last-input-end nchars)))
!       (set-marker (process-mark process) (point) nil)
!       (force-mode-line-update))
! 
!     (narrow-to-region obeg oend)
!     (goto-char opoint)
!     (set-buffer obuf)))
  
  (defun comint-get-old-input-default ()
!   "Default for `comint-get-old-input'.
! Take the current line, and discard any initial text matching
! `comint-prompt-regexp'."
    (save-excursion
      (beginning-of-line)
***************
*** 847,851 ****
  
  (defun comint-skip-prompt ()
!   "Skip past the text matching regexp comint-prompt-regexp. 
  If this takes us past the end of the current line, don't skip at all."
    (let ((eol (save-excursion (end-of-line) (point))))
--- 767,771 ----
  
  (defun comint-skip-prompt ()
!   "Skip past the text matching regexp `comint-prompt-regexp'.
  If this takes us past the end of the current line, don't skip at all."
    (let ((eol (save-excursion (end-of-line) (point))))
***************
*** 862,866 ****
    ;; services input during execution of lisp commands.
    (let ((proc-pos (marker-position
! 		   (comint-mark))))
      (<= proc-pos (point))))
  
--- 782,786 ----
    ;; services input during execution of lisp commands.
    (let ((proc-pos (marker-position
! 		   (process-mark (get-buffer-process (current-buffer))))))
      (<= proc-pos (point))))
  
***************
*** 868,872 ****
    "Default function for sending to PROC input STRING.
  This just sends STRING plus a newline. To override this,
! set the hook COMINT-INPUT-SENDER."
    (comint-send-string proc string)
    (comint-send-string proc "\n"))
--- 788,792 ----
    "Default function for sending to PROC input STRING.
  This just sends STRING plus a newline. To override this,
! set the hook `comint-input-sender'."
    (comint-send-string proc string)
    (comint-send-string proc "\n"))
***************
*** 878,885 ****
  
  The prompt skip is done by skipping text matching the regular expression
! comint-prompt-regexp, a buffer local variable.
  
! If you don't like this command, reset c-a to beginning-of-line 
! in your hook, comint-mode-hook."
    (interactive "P")
    (beginning-of-line)
--- 798,805 ----
  
  The prompt skip is done by skipping text matching the regular expression
! `comint-prompt-regexp', a buffer local variable.
  
! If you don't like this command, bind C-a to `beginning-of-line' 
! in your hook, `comint-mode-hook'."
    (interactive "P")
    (beginning-of-line)
***************
*** 890,913 ****
  ;;; Just enter m-x send-invisible and type in your line.
  
! (defun comint-read-noecho (prompt)
!   "Prompt the user with argument PROMPT. Read a single line of text
! without echoing, and return it. Note that the keystrokes comprising
! the text can still be recovered (temporarily) with \\[view-lossage]. This
! may be a security bug for some applications."
!   (let ((echo-keystrokes 0)
! 	(answ "")
! 	tem)
!     (if (and (stringp prompt) (not (string= (message prompt) "")))
  	(message prompt))
!     (while (not(or  (= (setq tem (read-char)) ?\^m)
! 		    (= tem ?\n)))
!       (setq answ (concat answ (char-to-string tem))))
!     (message "")
!     answ))
  
  (defun send-invisible (str)
!   "Read a string without echoing, and send it to the process running
! in the current buffer. A new-line is additionally sent. String is not 
! saved on comint input history list.
  Security bug: your string can still be temporarily recovered with
  \\[view-lossage]."
--- 810,865 ----
  ;;; Just enter m-x send-invisible and type in your line.
  
! (defun comint-read-noecho (prompt &optional stars)
!   "Read a single line of text from user without echoing, and return it. 
! Prompt with argument PROMPT, a string.  Optional argument STARS causes
! input to be echoed with '*' characters on the prompt line.  Input ends with
! RET, LFD, or ESC.  DEL or C-h rubs out.  C-u kills line.  C-g aborts (if
! `inhibit-quit' is set because e.g. this function was called from a process
! filter and C-g is pressed, this function returns nil rather than a string).
! 
! Note that the keystrokes comprising the text can still be recovered
! \(temporarily) with \\[view-lossage].  This may be a security bug for some
! applications."
!   (let ((ans "")
! 	(c 0)
! 	(echo-keystrokes 0)
! 	(cursor-in-echo-area t)
!         (done nil))
!     (while (not done)
!       (if stars
!           (message "%s%s" prompt (make-string (length ans) ?*))
          (message prompt))
!       (setq c (read-char))
!       (cond ((= c ?\C-g)
!              ;; This function may get called from a process filter, where
!              ;; inhibit-quit is set.  In later versions of emacs read-char
!              ;; may clear quit-flag itself and return C-g.  That would make
!              ;; it impossible to quit this loop in a simple way, so
!              ;; re-enable it here (for backward-compatibility the check for
!              ;; quit-flag below would still be necessary, so this is seems
!              ;; like the simplest way to do things).
!              (setq quit-flag t
!                    done t))
!             ((or (= c ?\r) (= c ?\n) (= c ?\e))
!              (setq done t))
!             ((= c ?\C-u)
!              (setq ans ""))
!             ((and (/= c ?\b) (/= c ?\177))
!              (setq ans (concat ans (char-to-string c))))
!             ((> (length ans) 0)
!              (setq ans (substring ans 0 -1)))))
!     (if quit-flag
!         ;; Emulate a true quit, except that we have to return a value.
!         (prog1
!             (setq quit-flag nil)
!           (message "Quit")
!           (beep t))
!       (message nil)
!       ans)))
  
  (defun send-invisible (str)
!   "Read a string without echoing.
! Then send it to the process running in the current buffer.  A new-line
! is additionally sent.  String is not saved on comint input history list.
  Security bug: your string can still be temporarily recovered with
  \\[view-lossage]."
***************
*** 918,922 ****
  	(comint-send-string proc
  			    (if (stringp str) str
! 				(comint-read-noecho "Enter non-echoed text")))
  	(comint-send-string proc "\n"))))
  
--- 870,874 ----
  	(comint-send-string proc
  			    (if (stringp str) str
! 				(comint-read-noecho "Non-echoed text: " t)))
  	(comint-send-string proc "\n"))))
  
***************
*** 925,929 ****
  
  (defvar comint-input-chunk-size 512
!   "*Long inputs send to comint processes are broken up into chunks of this size.
  If your process is choking on big inputs, try lowering the value.")
  
--- 877,881 ----
  
  (defvar comint-input-chunk-size 512
!   "*Long inputs are sent to comint processes in chunks of this size.
  If your process is choking on big inputs, try lowering the value.")
  
***************
*** 930,935 ****
  (defun comint-send-string (proc str)
    "Send PROCESS the contents of STRING as input.
! This is equivalent to process-send-string, except that long input strings
! are broken up into chunks of size comint-input-chunk-size. Processes
  are given a chance to output between chunks. This can help prevent processes
  from hanging when you send them long inputs on some OS's."
--- 882,887 ----
  (defun comint-send-string (proc str)
    "Send PROCESS the contents of STRING as input.
! This is equivalent to `process-send-string', except that long input strings
! are broken up into chunks of size `comint-input-chunk-size'.  Processes
  are given a chance to output between chunks. This can help prevent processes
  from hanging when you send them long inputs on some OS's."
***************
*** 945,950 ****
  (defun comint-send-region (proc start end)
    "Sends to PROC the region delimited by START and END.
! This is a replacement for process-send-region that tries to keep
! your process from hanging on long inputs. See comint-send-string."
    (comint-send-string proc (buffer-substring start end)))
  
--- 897,902 ----
  (defun comint-send-region (proc start end)
    "Sends to PROC the region delimited by START and END.
! This is a replacement for `process-send-region' that tries to keep
! your process from hanging on long inputs.  See `comint-send-string'."
    (comint-send-string proc (buffer-substring start end)))
  
***************
*** 955,959 ****
    "Kill all output from interpreter since last input."
    (interactive)
!   (let ((pmark (comint-mark)))
      (kill-region comint-last-input-end pmark)
      (goto-char pmark)    
--- 907,911 ----
    "Kill all output from interpreter since last input."
    (interactive)
!   (let ((pmark (process-mark (get-buffer-process (current-buffer)))))
      (kill-region comint-last-input-end pmark)
      (goto-char pmark)    
***************
*** 1004,1008 ****
    "Kill all text from last stuff output by interpreter to point."
    (interactive)
!   (let* ((pmark (comint-mark))
  	 (p-pos (marker-position pmark)))
      (if (> (point) p-pos)
--- 956,960 ----
    "Kill all text from last stuff output by interpreter to point."
    (interactive)
!   (let* ((pmark (process-mark (get-buffer-process (current-buffer))))
  	 (p-pos (marker-position pmark)))
      (if (> (point) p-pos)
***************
*** 1136,1140 ****
  ;;; if there's a quote on both sides of point on the current line.
  (defun comint-extract-string ()
!   "Returns string around point that starts the current line or nil." 
    (save-excursion
      (let* ((point (point))
--- 1088,1092 ----
  ;;; if there's a quote on both sides of point on the current line.
  (defun comint-extract-string ()
!   "Return string around point that starts the current line, or nil." 
    (save-excursion
      (let* ((point (point))
***************
*** 1217,1223 ****
  ;;; ===========================================================================
  ;;; Useful completion functions, courtesy of the Ergo group.
- ;;; M-<Tab> will complete the filename at the cursor as much as possible
- ;;; M-? will display a list of completions in the help buffer.
- 
  ;;; Three commands:
  ;;; comint-dynamic-complete		Complete filename at point.
--- 1169,1172 ----
***************
*** 1228,1241 ****
  ;;; These are not installed in the comint-mode keymap. But they are
  ;;; available for people who want them. Shell-mode installs them:
! ;;; (define-key cmushell-mode-map "\M-\t" 'comint-dynamic-complete)
! ;;; (define-key cmushell-mode-map "\M-?"  'comint-dynamic-list-completions)))
  ;;;
  ;;; Commands like this are fine things to put in load hooks if you
! ;;; want them present in specific modes. Example:
! ;;; (setq cmushell-load-hook
! ;;;       '((lambda () (define-key lisp-mode-map "\M-\t"
! ;;;				   'comint-replace-by-expanded-filename))))
! ;;;          
! 
  
  (defvar comint-match-partial-pathname-chars "^][<>{}()!#$^&*\\|?`'^ \t\n\r\b")
--- 1177,1185 ----
  ;;; These are not installed in the comint-mode keymap. But they are
  ;;; available for people who want them. Shell-mode installs them:
! ;;; (define-key shell-mode-map "\t" 'comint-dynamic-complete)
! ;;; (define-key shell-mode-map "\M-?"  'comint-dynamic-list-completions)))
  ;;;
  ;;; Commands like this are fine things to put in load hooks if you
! ;;; want them present in specific modes.
  
  (defvar comint-match-partial-pathname-chars "^][<>{}()!#$^&*\\|?`'^ \t\n\r\b")
***************
*** 1242,1246 ****
  
  (defun comint-match-partial-pathname ()
!   "Returns the filename at point or causes an error."
    (save-excursion
      (skip-chars-backward " \t\n\r")
--- 1186,1190 ----
  
  (defun comint-match-partial-pathname ()
!   "Return the filename at point, or signal an error."
    (save-excursion
      (skip-chars-backward " \t\n\r")
***************
*** 1257,1267 ****
  
  (defun comint-replace-by-expanded-filename ()
! "Replace the filename at point with an expanded, canonicalised, and
! completed replacement.
  \"Expanded\" means environment variables (e.g., $HOME) and ~'s are
  replaced with the corresponding directories.  \"Canonicalised\" means ..
  and \. are removed, and the filename is made absolute instead of relative.
! See functions expand-file-name and substitute-in-file-name. See also
! comint-dynamic-complete."
    (interactive)
    (let* ((pathname (comint-match-partial-pathname))
--- 1201,1212 ----
  
  (defun comint-replace-by-expanded-filename ()
!   "Expand the filename at point.
! Replace the filename with an expanded, canonicalised, and completed
!  replacement.
  \"Expanded\" means environment variables (e.g., $HOME) and ~'s are
  replaced with the corresponding directories.  \"Canonicalised\" means ..
  and \. are removed, and the filename is made absolute instead of relative.
! See functions `expand-file-name' and `substitute-in-file-name'.  See also
! `comint-dynamic-complete'."
    (interactive)
    (let* ((pathname (comint-match-partial-pathname))
***************
*** 1271,1278 ****
  					   (or pathdir default-directory))))
      (cond ((null completion)
! 	   (message "No completions of %s." pathname)
  	   (ding))
  	  ((eq completion t)
! 	   (message "Unique completion."))
  	  (t				; this means a string was returned.
  	   (delete-region (match-beginning 0) (match-end 0))
--- 1216,1223 ----
  					   (or pathdir default-directory))))
      (cond ((null completion)
! 	   (message "No completions of %s" pathname)
  	   (ding))
  	  ((eq completion t)
! 	   (message "Unique completion"))
  	  (t				; this means a string was returned.
  	   (delete-region (match-beginning 0) (match-end 0))
***************
*** 1282,1286 ****
  (defun comint-dynamic-complete ()
    "Dynamically complete the filename at point.
! This function is similar to comint-replace-by-expanded-filename, except
  that it won't change parts of the filename already entered in the buffer; 
  it just adds completion characters to the end of the filename."
--- 1227,1231 ----
  (defun comint-dynamic-complete ()
    "Dynamically complete the filename at point.
! This function is similar to `comint-replace-by-expanded-filename', except
  that it won't change parts of the filename already entered in the buffer; 
  it just adds completion characters to the end of the filename."
***************
*** 1292,1299 ****
  					   (or pathdir default-directory))))
      (cond ((null completion)
! 	   (message "No completions of %s." pathname)
  	   (ding))
  	  ((eq completion t)
! 	   (message "Unique completion."))
            ((equal pathnondir completion)
             (comint-dynamic-list-completions t))
--- 1237,1244 ----
  					   (or pathdir default-directory))))
      (cond ((null completion)
! 	   (message "No completions of %s" pathname)
  	   (ding))
  	  ((eq completion t)
! 	   (message "Unique completion"))
            ((equal pathnondir completion)
             (comint-dynamic-list-completions t))
***************
*** 1312,1316 ****
  				     (or pathdir default-directory))))
      (cond ((null completions)
! 	   (message "No completions of %s." pathname)
  	   (ding))
  	  (t
--- 1257,1261 ----
  				     (or pathdir default-directory))))
      (cond ((null completions)
! 	   (message "No completions of %s" pathname)
  	   (ding))
  	  (t
***************
*** 1331,1358 ****
  			 (set-window-configuration conf)
                         (setq unread-command-event ch))))
! 	       ;; v18 GNU Emacs
! 	       (let ((ch (read-char)))
! 		 (if revert-soonest 
! 		     (progn
! 		       (set-window-configuration conf)
! 		       (setq unread-command-char ch))
  		   (if (eq ch ?\ )
  		       (set-window-configuration conf)
! 		     (setq unread-command-char ch))))
! 	       ))))))
! 
! ; Ergo bindings
! ; (global-set-key "\M-\t" 'comint-replace-by-expanded-filename)
! ; (global-set-key "\M-?" 'comint-dynamic-list-completions)
! ; (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete)
  
  ;;; Converting process modes to use comint mode
  ;;; ===========================================================================
! ;;; Several gnu packages (tex-mode, background, dbx, gdb, kermit, prolog, 
! ;;; telnet are some) use the shell package as clients. Most of them would
! ;;; be better off using the comint package, but they predate it. 
! ;;;
! ;;; Altering these packages to use comint mode should greatly
! ;;; improve their functionality, and is fairly easy.
  ;;; 
  ;;; Renaming variables
--- 1276,1290 ----
  			 (set-window-configuration conf)
                         (setq unread-command-event ch))))
!                  ;; v19 FSFmacs
!                  (let ((ch (read-event)))
                     (if (eq ch ?\ )
                         (set-window-configuration conf)
!                        (setq unread-command-events (list ch))))))))))
  
  ;;; Converting process modes to use comint mode
  ;;; ===========================================================================
! ;;; The code in the Emacs 19 distribution has all been modified to use comint
! ;;; where needed.  However, there are `third-party' packages out there that
! ;;; still use the old shell mode.  Here's a guide to conversion.
  ;;;
  ;;; Renaming variables
***************
*** 1360,1365 ****
  ;;; ones:
  ;;; Local variables:
- ;;; 	last-input-end		comint-last-input-end
  ;;; 	last-input-start        comint-last-input-start
  ;;;	shell-prompt-pattern	comint-prompt-regexp
  ;;;     shell-set-directory-error-hook <no equivalent>
--- 1292,1297 ----
  ;;; ones:
  ;;; Local variables:
  ;;; 	last-input-start        comint-last-input-start
+ ;;; 	last-input-end		comint-last-input-end
  ;;;	shell-prompt-pattern	comint-prompt-regexp
  ;;;     shell-set-directory-error-hook <no equivalent>
***************
*** 1379,1388 ****
  ;;;	copy-last-shell-input	Use comint-previous-input/comint-next-input
  ;;;
! ;;; LAST-INPUT-START is no longer necessary because inputs are stored on the
! ;;; input history ring. SHELL-SET-DIRECTORY is gone, its functionality taken
! ;;; over by SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-sentinel.
  ;;; Comint mode does not provide functionality equivalent to 
  ;;; shell-set-directory-error-hook; it is gone.
  ;;; 
  ;;; If you are implementing some process-in-a-buffer mode, called foo-mode, do
  ;;; *not* create the comint-mode local variables in your foo-mode function.
--- 1311,1326 ----
  ;;;	copy-last-shell-input	Use comint-previous-input/comint-next-input
  ;;;
! ;;; SHELL-SET-DIRECTORY is gone, its functionality taken over by
! ;;; SHELL-DIRECTORY-TRACKER, the shell mode's comint-input-sentinel.
  ;;; Comint mode does not provide functionality equivalent to
  ;;; shell-set-directory-error-hook; it is gone.
  ;;;
+ ;;; comint-last-input-start is provided for modes which want to munge
+ ;;; the buffer after input is sent, perhaps because the inferior
+ ;;; insists on echoing the input.  The LAST-INPUT-START variable in
+ ;;; the old shell package was used to implement a history mechanism,
+ ;;; but you should think twice before using comint-last-input-start
+ ;;; for this; the input history ring often does the job better.
+ ;;; 
  ;;; If you are implementing some process-in-a-buffer mode, called foo-mode, do
  ;;; *not* create the comint-mode local variables in your foo-mode function.
***************
*** 1394,1398 ****
  ;;; comint-get-old-input) that need to be different from the defaults.  Call
  ;;; foo-mode-hook, and you're done. Don't run the comint-mode hook yourself;
! ;;; comint-mode will take care of it. The following example, from cmushell.el,
  ;;; is typical:
  ;;; 
--- 1332,1336 ----
  ;;; comint-get-old-input) that need to be different from the defaults.  Call
  ;;; foo-mode-hook, and you're done. Don't run the comint-mode hook yourself;
! ;;; comint-mode will take care of it. The following example, from shell.el,
  ;;; is typical:
  ;;; 
***************
*** 1404,1408 ****
  ;;;   (setq mode-name "Shell")
  ;;;   (cond ((not shell-mode-map)
! ;;; 	     (setq shell-mode-map (copy-keymap comint-mode-map))
  ;;; 	     (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete)
  ;;; 	     (define-key shell-mode-map "\M-?"
--- 1342,1348 ----
  ;;;   (setq mode-name "Shell")
  ;;;   (cond ((not shell-mode-map)
! ;;; 	     (setq shell-mode-map (make-sparse-keymap))
! ;;; 	     (set-keymap-name shell-mode-map 'shell-mode-map)
! ;;;          (setq-keymap-parent shell-mode-map comint-mode-map)
  ;;; 	     (define-key shell-mode-map "\M-\t" 'comint-dynamic-complete)
  ;;; 	     (define-key shell-mode-map "\M-?"
***************
*** 1507,1511 ****
  ;;; - Changed make-variable-buffer-local's to make-local-variable's.
  ;;;   This leaves non-comint-mode buffers alone. Stephane Payrard
! ;;;   reported the sloppy useage.
  ;;; - You can now go from comint-previous-similar-input to
  ;;;   comint-previous-input with no problem.
--- 1447,1451 ----
  ;;; - Changed make-variable-buffer-local's to make-local-variable's.
  ;;;   This leaves non-comint-mode buffers alone. Stephane Payrard
! ;;;   reported the sloppy usage.
  ;;; - You can now go from comint-previous-similar-input to
  ;;;   comint-previous-input with no problem.
***************
*** 1529,1530 ****
--- 1469,1493 ----
  ;;; - Added a hook, comint-exec-hook that is run each time a process
  ;;;   is cranked up. Useful for things like process-kill-without-query.
+ ;;;
+ ;;; These two were pointed out by tale:
+ ;;; - Improved the doc string in comint-send-input a little bit.
+ ;;; - Tweaked make-comint to check process status with comint-check-proc
+ ;;;   instead of equivalent inline code. 
+ ;;;
+ ;;; - Prompt-search history commands have been commented out. I never
+ ;;;   liked them; I don't think anyone used them.
+ ;;; - Made comint-exec-hook a local var, as it should have been.
+ ;;;   (This way, for instance, you can have shell procs kill-w/o-query,
+ ;;;    but let Scheme procs be default.)
+ ;;;
+ ;;; 7/91 Shivers
+ ;;; - Souped up comint-read-noecho with an optional argument, STARS.
+ ;;;   Suggested by mjlx@EAGLE.CNSF.CORNELL.EDU.
+ ;;; - Moved comint-previous-input-matching from C-c r to C-M-r.
+ ;;;   C-c <letter> bindings are reserved for the user.
+ ;;;   These bindings were done by Jim Blandy.
+ ;;; These changes comprise version 2.03.
+ 
+ (provide 'comint)
+ 
+ ;;; comint.el ends here
*** ../lemacs-beta6/lisp/comint/kermit.el	Thu Apr 15 12:59:39 1993
--- lisp/comint/kermit.el	Sat Jul 24 19:07:24 1993
***************
*** 1,6 ****
! ;;Additions to shell mode for use with kermit, etc.
! ;;Feb 1988, Jeff Norden - jeff@colgate.csnet
  ;; Copyright (C) 1988 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,9 ----
! ;;; kermit.el --- additions to shell mode for use with kermit, etc.
! 
  ;; Copyright (C) 1988 Free Software Foundation, Inc.
  
+ ;; Author: Jeff Norden <jeff@colgate.csnet>
+ ;; Created: 15 Feb 1988
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 7,11 ****
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 1, or (at your option)
  ;; any later version.
  
--- 10,14 ----
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 2, or (at your option)
  ;; any later version.
  
***************
*** 19,23 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
! (require 'shell)
  
  ;; I'm not sure, but I think somebody asked about running kermit under shell
--- 22,26 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
! ;;; Commentary
  
  ;; I'm not sure, but I think somebody asked about running kermit under shell
***************
*** 70,73 ****
--- 73,80 ----
  ;; Feb 1988, Jeff Norden - jeff@colgate.csnet
  
+ ;;; Code:
+ 
+ (require 'shell)
+ 
  (defvar kermit-esc-char "\C-\\" "*Kermit's escape char")
  
***************
*** 94,98 ****
    "Like \\[comint-send-input] but end the line with carriage-return."
    (interactive)
!   (comint-send-input "\r"))
  
  ;; This is backwards of what makes sense, but ...
--- 101,106 ----
    "Like \\[comint-send-input] but end the line with carriage-return."
    (interactive)
!   (comint-send-input)
!   (comint-send-string (get-buffer-process (current-buffer)) "\r"))
  
  ;; This is backwards of what makes sense, but ...
***************
*** 137,139 ****
    (set-process-filter (get-buffer-process (current-buffer)) nil))
  
! 
--- 145,147 ----
    (set-process-filter (get-buffer-process (current-buffer)) nil))
  
! ;;; kermit.el ends here
*** ../lemacs-beta6/lisp/comint/shell.el	Tue Jul 13 00:57:04 1993
--- lisp/comint/shell.el	Sat Jul 24 21:53:54 1993
***************
*** 1,9 ****
! ;;; -*-Emacs-Lisp-*- General command interpreter in a window stuff
! ;;; Copyright Olin Shivers (1988).
! ;;; Please imagine a long, tedious, legalistic 5-page gnu-style copyright
! ;;; notice appearing here to the effect that you may use this code any
! ;;; way you like, as long as you don't charge money for it, remove this
! ;;; notice, or hold me liable for its results.
  
  ;;; The changelog is at the end of file.
  
--- 1,26 ----
! ;;; shell.el --- specialized comint.el for running the shell.
! ;;; Copyright (C) 1988, 1993 Free Software Foundation, Inc.
  
+ ;; Author: Olin Shivers <shivers@cs.cmu.edu>
+ ;; Keywords: processes
+ 
+ ;;; This file is part of GNU Emacs.
+ 
+ ;;; GNU Emacs is free software; you can redistribute it and/or modify
+ ;;; it under the terms of the GNU General Public License as published by
+ ;;; the Free Software Foundation; either version 2, or (at your option)
+ ;;; any later version.
+ 
+ ;;; GNU Emacs is distributed in the hope that it will be useful,
+ ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+ ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ ;;; GNU General Public License for more details.
+ 
+ ;;; You should have received a copy of the GNU General Public License
+ ;;; along with GNU Emacs; see the file COPYING.  If not, write to
+ ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ 
+ ;;; Commentary:
+ 
  ;;; The changelog is at the end of file.
  
***************
*** 12,17 ****
  ;;;     - Olin Shivers (shivers@cs.cmu.edu)
  
! ;;; This file defines a shell-in-a-buffer package (shell mode) built on
! ;;; top of comint mode.
  
  ;;; Since this mode is built on top of the general command-interpreter-in-
--- 29,36 ----
  ;;;     - Olin Shivers (shivers@cs.cmu.edu)
  
! ;;; This file defines a a shell-in-a-buffer package (shell mode) built
! ;;; on top of comint mode.  This is actually cmushell with things
! ;;; renamed to replace its counterpart in Emacs 18.  cmushell is more
! ;;; featureful, robust, and uniform than the Emacs 18 version.
  
  ;;; Since this mode is built on top of the general command-interpreter-in-
***************
*** 30,36 ****
  ;;; text to the process? Switch selectable?
  
- (require 'comint)
- (provide 'shell)
- 
  ;; YOUR .EMACS FILE
  ;;=============================================================================
--- 49,52 ----
***************
*** 37,44 ****
  ;; Some suggestions for your .emacs file.
  ;;
! ;; ; Define C-c C-t to run my favorite command in shell mode:
  ;; (setq shell-load-hook
  ;;       '((lambda () 
! ;;           (define-key shell-mode-map "\C-c\C-t" 'favorite-cmd))))
  
  
--- 53,69 ----
  ;; Some suggestions for your .emacs file.
  ;;
! ;; ; If shell lives in some non-standard directory, you must tell emacs
! ;; ; where to get it. This may or may not be necessary.
! ;; (setq load-path (cons (expand-file-name "~jones/lib/emacs") load-path))
! ;;
! ;; ; Autoload shell from file shell.el
! ;; (autoload 'shell "shell"
! ;;           "Run an inferior shell process."
! ;;           t)
! ;;
! ;; ; Define C-c t to run my favorite command in shell mode:
  ;; (setq shell-load-hook
  ;;       '((lambda () 
! ;;           (define-key shell-mode-map "\C-ct" 'favorite-cmd))))
  
  
***************
*** 49,53 ****
  ;;; m-p	    comint-previous-input    	    Cycle backwards in input history
  ;;; m-n	    comint-next-input  	    	    Cycle forwards
! ;;; c-c r   comint-previous-input-matching  Search backwards in input history
  ;;; return  comint-send-input
  ;;; c-a     comint-bol                      Beginning of line; skip prompt.
--- 74,78 ----
  ;;; m-p	    comint-previous-input    	    Cycle backwards in input history
  ;;; m-n	    comint-next-input  	    	    Cycle forwards
! ;;; m-c-r   comint-previous-input-matching  Search backwards in input history
  ;;; return  comint-send-input
  ;;; c-a     comint-bol                      Beginning of line; skip prompt.
***************
*** 67,74 ****
  ;;; Shell Mode Commands:
  ;;;         shell			    Fires up the shell process.
! ;;; tab,m-tab comint-dynamic-complete	    Complete a partial file name
  ;;; m-?     comint-dynamic-list-completions List completions in help buffer
! ;;; 	    shell-resync-dirs		    Resync the buffer's dir stack.
! ;;; 	    shell-dirtrack-toggle           Turn dir tracking on/off.
  ;;;
  ;;; The shell mode hook is shell-mode-hook
--- 92,99 ----
  ;;; Shell Mode Commands:
  ;;;         shell			    Fires up the shell process.
! ;;; tab     comint-dynamic-complete	    Complete a partial file name
  ;;; m-?     comint-dynamic-list-completions List completions in help buffer
! ;;; 	    dirs    			    Resync the buffer's dir stack.
! ;;; 	    dirtrack-toggle                 Turn dir tracking on/off.
  ;;;
  ;;; The shell mode hook is shell-mode-hook
***************
*** 80,83 ****
--- 105,110 ----
  
  ;;; SHELL.EL COMPATIBILITY
+ ;;; Notes from when this was called cmushell, and was not the standard emacs
+ ;;; shell package.
  ;;;============================================================================
  ;;; In brief: this package should have no trouble coexisting with shell.el.
***************
*** 85,90 ****
  ;;; Most customising variables -- e.g., explicit-shell-file-name -- are the
  ;;; same, so the users shouldn't have much trouble. Hooks have different
! ;;; names, however, so you can customise shell mode differently from shell
! ;;; mode. You basically just have to remember to type M-x shell instead of
  ;;; M-x shell.
  ;;; 
--- 112,117 ----
  ;;; Most customising variables -- e.g., explicit-shell-file-name -- are the
  ;;; same, so the users shouldn't have much trouble. Hooks have different
! ;;; names, however, so you can customise shell mode differently from cmushell
! ;;; mode. You basically just have to remember to type M-x cmushell instead of
  ;;; M-x shell.
  ;;; 
***************
*** 94,99 ****
  ;;; (tex-mode, background, dbx, gdb, kermit, monkey, prolog, telnet) are also
  ;;; clients of shell mode. These packages assume detailed knowledge of shell
! ;;; mode internals in ways that are incompatible with shell mode (mostly
! ;;; because of shell mode's greater functionality).  So, unless we are
  ;;; willing to port all of these packages, we can't have this file be a
  ;;; complete replacement for shell.el -- that is, we can't name this file
--- 121,126 ----
  ;;; (tex-mode, background, dbx, gdb, kermit, monkey, prolog, telnet) are also
  ;;; clients of shell mode. These packages assume detailed knowledge of shell
! ;;; mode internals in ways that are incompatible with cmushell mode (mostly
! ;;; because of cmushell mode's greater functionality).  So, unless we are
  ;;; willing to port all of these packages, we can't have this file be a
  ;;; complete replacement for shell.el -- that is, we can't name this file
***************
*** 105,125 ****
  ;;; compatible route, is to make this package non-conflict with shell.el, so
  ;;; both files can be loaded in at the same time. And *that* is why some
! ;;; functions and variables have different names: (shell),
! ;;; shell-mode-map, that sort of thing. All the names have been carefully
! ;;; chosen so that shell.el and shell.el won't tromp on each other.
  
! ;;; Customisation and Buffer Variables
  ;;; ===========================================================================
  ;;; 
  
  ;In loaddefs.el now.
! ;(defconst shell-prompt-pattern
! ;  "^[^#$%>]*[#$%>] *"
  ;  "Regexp to match prompts in the inferior shell.
  ;Defaults to \"^[^#$%>]*[#$%>] *\", which works pretty well.
! ;This variable is used to initialise comint-prompt-regexp in the 
  ;shell buffer.
  ;
! ;This is a fine thing to set in your .emacs file.")
  
  (defvar shell-popd-regexp "popd"
--- 132,156 ----
  ;;; compatible route, is to make this package non-conflict with shell.el, so
  ;;; both files can be loaded in at the same time. And *that* is why some
! ;;; functions and variables have different names: (cmushell),
! ;;; cmushell-mode-map, that sort of thing. All the names have been carefully
! ;;; chosen so that shell.el and cmushell.el won't tromp on each other.
  
! ;;; Customization and Buffer Variables
  ;;; ===========================================================================
  ;;; 
  
+ ;;; Code:
+ 
+ (require 'comint)
+ 
  ;In loaddefs.el now.
! ;;;###autoload
! ;(defvar shell-prompt-pattern "^[^#$%>]*[#$%>] *"
  ;  "Regexp to match prompts in the inferior shell.
  ;Defaults to \"^[^#$%>]*[#$%>] *\", which works pretty well.
! ;This variable is used to initialise `comint-prompt-regexp' in the
  ;shell buffer.
  ;
! ;This is a fine thing to set in your `.emacs' file.")
  
  (defvar shell-popd-regexp "popd"
***************
*** 135,139 ****
    "*If non-nil, is file name to use for explicitly requested inferior shell.")
  
! (defvar explicit-csh-arguments
    (if (eq system-type 'hpux)
        ;; -T persuades HP's csh not to think it is smarter
--- 166,170 ----
    "*If non-nil, is file name to use for explicitly requested inferior shell.")
  
! (defvar explicit-csh-args
    (if (eq system-type 'hpux)
        ;; -T persuades HP's csh not to think it is smarter
***************
*** 144,152 ****
  Value is a list of strings, which may be nil.")
  
- ;;; All the above vars aren't prefixed "shell-" to make them
- ;;; backwards compatible w/shell.el and old .emacs files.
- 
  (defvar shell-dirstack nil
!   "List of directories saved by pushd in this buffer's shell.")
  
  (defvar shell-dirstack-query "dirs"
--- 175,181 ----
  Value is a list of strings, which may be nil.")
  
  (defvar shell-dirstack nil
!   "List of directories saved by pushd in this buffer's shell.
! Thus, this does not include the shell's current directory.")
  
  (defvar shell-dirstack-query "dirs"
***************
*** 155,164 ****
  (defvar shell-mode-map '())
  (if (not shell-mode-map)
-     (let ((map (if (fboundp 'set-keymap-parent)
                     (let ((map (make-keymap)))
                       (set-keymap-parent map comint-mode-map)
                       (set-keymap-name map 'shell-mode-map)
-                      map)
- 		 (copy-keymap comint-mode-map))))
        (define-key map "\M-\t" 'comint-dynamic-complete)
        (define-key map "\t" 'comint-dynamic-complete)
--- 184,190 ----
***************
*** 167,172 ****
  
  (defvar shell-mode-hook '()
!   "*Hook for customising shell mode")
  
  
  ;;; Basic Procedures
--- 193,199 ----
  
  (defvar shell-mode-hook '()
!   "*Hook for customising Shell mode.")
  
+ (defvar shell-last-dir)
  
  ;;; Basic Procedures
***************
*** 180,187 ****
  Return after the end of the process' output sends the text from the 
      end of process to the end of the current line.
! Return before end of process output copies rest of line to end (skipping
!     the prompt) and sends it.
! M-x send-invisible reads a line of text without echoing it, and sends it to
!     the shell.
  
  If you accidentally suspend your process, use \\[comint-continue-subjob]
--- 207,214 ----
  Return after the end of the process' output sends the text from the 
      end of process to the end of the current line.
! Return before end of process output copies the current line (except
!     for the prompt) to the end of the buffer and sends it.
! \\[send-invisible\\] reads a line of text without echoing it, and sends it to
!     the shell.  This is useful for entering passwords.
  
  If you accidentally suspend your process, use \\[comint-continue-subjob]
***************
*** 192,203 ****
  M-x shell-resync-dirs queries the shell and resyncs Emacs' idea of what the 
      current directory stack is.
! M-x shell-dirtrack-toggle turns directory tracking on and off.
  
  \\{shell-mode-map}
! Customisation: Entry to this mode runs the hooks on comint-mode-hook and
! shell-mode-hook (in that order).
  
! Variables shell-cd-regexp, shell-pushd-regexp and shell-popd-regexp are used
! to match their respective commands."
    (interactive)
    (comint-mode)
--- 219,230 ----
  M-x shell-resync-dirs queries the shell and resyncs Emacs' idea of what the 
      current directory stack is.
! M-x dirtrack-toggle turns directory tracking on and off.
  
  \\{shell-mode-map}
! Customisation: Entry to this mode runs the hooks on `comint-mode-hook' and
! `shell-mode-hook' (in that order).
  
! Variables `shell-cd-regexp', `shell-pushd-regexp' and `shell-popd-regexp'
! are used to match their respective commands."
    (interactive)
    (comint-mode)
***************
*** 204,211 ****
    (setq comint-prompt-regexp shell-prompt-pattern)
    (setq major-mode 'shell-mode)
!   (setq mode-name "shell")
    (use-local-map shell-mode-map)
    (make-local-variable 'shell-dirstack)
    (setq shell-dirstack nil)
    (make-local-variable 'shell-dirtrackp)
    (setq shell-dirtrackp t)
--- 231,240 ----
    (setq comint-prompt-regexp shell-prompt-pattern)
    (setq major-mode 'shell-mode)
!   (setq mode-name "Shell")
    (use-local-map shell-mode-map)
    (make-local-variable 'shell-dirstack)
    (setq shell-dirstack nil)
+   (make-local-variable 'shell-last-dir)
+   (setq shell-last-dir nil)
    (make-local-variable 'shell-dirtrackp)
    (setq shell-dirtrackp t)
***************
*** 214,217 ****
--- 243,247 ----
  
  
+ ;;;###autoload
  (defun shell ()
    "Run an inferior shell, with I/O through buffer *shell*.
***************
*** 218,234 ****
  If buffer exists but shell process is not running, make new shell.
  If buffer exists and shell process is running, 
!  just switch to buffer *shell*.
! Program used comes from variable explicit-shell-file-name,
   or (if that is nil) from the ESHELL environment variable,
   or else from SHELL if there is no ESHELL.
! If a file ~/.emacs_SHELLNAME exists, it is given as initial input
   (Note that this may lose due to a timing error if the shell
    discards input when it starts up.)
! The buffer is put in shell-mode, giving commands for sending input
! and controlling the subjobs of the shell.  See shell-mode.
! See also variable shell-prompt-pattern.
  
  The shell file name (sans directories) is used to make a symbol name
! such as `explicit-csh-arguments'.  If that symbol is a variable,
  its value is used as a list of arguments when invoking the shell.
  Otherwise, one argument `-i' is passed to the shell.
--- 248,264 ----
  If buffer exists but shell process is not running, make new shell.
  If buffer exists and shell process is running, 
!  just switch to buffer `*shell*'.
! Program used comes from variable `explicit-shell-file-name',
   or (if that is nil) from the ESHELL environment variable,
   or else from SHELL if there is no ESHELL.
! If a file `~/.emacs_SHELLNAME' exists, it is given as initial input
   (Note that this may lose due to a timing error if the shell
    discards input when it starts up.)
! The buffer is put in Shell mode, giving commands for sending input
! and controlling the subjobs of the shell.  See `shell-mode'.
! See also the variable `shell-prompt-pattern'.
  
  The shell file name (sans directories) is used to make a symbol name
! such as `explicit-csh-args'.  If that symbol is a variable,
  its value is used as a list of arguments when invoking the shell.
  Otherwise, one argument `-i' is passed to the shell.
***************
*** 243,247 ****
  		(name (file-name-nondirectory prog))
  		(startfile (concat "~/.emacs_" name))
! 		(xargs-name (intern-soft (concat "explicit-" name "-arguments"))))
  	   (set-buffer (apply 'make-comint "shell" prog
  			      (if (file-exists-p startfile) startfile)
--- 273,277 ----
  		(name (file-name-nondirectory prog))
  		(startfile (concat "~/.emacs_" name))
! 		(xargs-name (intern-soft (concat "explicit-" name "-args"))))
  	   (set-buffer (apply 'make-comint "shell" prog
  			      (if (file-exists-p startfile) startfile)
***************
*** 261,265 ****
  ;;;
  ;;; This is basically a fragile hack, although it's more accurate than
! ;;; the released version in shell.el. It has the following failings:
  ;;; 1. It doesn't know about the cdpath shell variable.
  ;;; 2. It only spots the first command in a command sequence. E.g., it will
--- 291,295 ----
  ;;;
  ;;; This is basically a fragile hack, although it's more accurate than
! ;;; the version in Emacs 18's shell.el. It has the following failings:
  ;;; 1. It doesn't know about the cdpath shell variable.
  ;;; 2. It only spots the first command in a command sequence. E.g., it will
***************
*** 274,278 ****
  ;;; separate working directories, and some have commands for manipulating
  ;;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have
! ;;; commands that do *not* effect the current w.d. at all, but look like they
  ;;; do (e.g., the cd command in ftp).  In shells that allow you job
  ;;; control, you can switch between jobs, all having different w.d.'s. So
--- 304,308 ----
  ;;; separate working directories, and some have commands for manipulating
  ;;; their w.d.'s (e.g., the lcd command in ftp). Some of these programs have
! ;;; commands that do *not* affect the current w.d. at all, but look like they
  ;;; do (e.g., the cd command in ftp).  In shells that allow you job
  ;;; control, you can switch between jobs, all having different w.d.'s. So
***************
*** 305,312 ****
  default directory to track these commands.
  
! You may toggle this tracking on and off with M-x shell-dirtrack-toggle.
! If emacs gets confused, you can resync with the shell with M-x shell-resync-dirs.
! 
! See variables shell-cd-regexp, shell-pushd-regexp, and shell-popd-regexp."
    (cond (shell-dirtrackp
  	 (string-match "^\\s *" str) ; skip whitespace
--- 335,345 ----
  default directory to track these commands.
  
! You may toggle this tracking on and off with M-x dirtrack-toggle.
! If emacs gets confused, you can resync with the shell
! with M-x shell-resync-dirs.
! 
! See variables `shell-cd-regexp', `shell-pushd-regexp' and `shell-popd-regexp'.
! Environment variables are expanded, see function `substitute-in-file-name'."
!   (condition-case err
        (cond (shell-dirtrackp
               (string-match "^\\s *" str) ; skip whitespace
***************
*** 313,327 ****
  	 (let ((bos (match-end 0))
  	       (x nil))
! 	   (cond ((setq x (shell-match-cmd-w/optional-arg shell-popd-regexp
! 							     str bos))
! 		  (shell-process-popd x))
! 		 ((setq x (shell-match-cmd-w/optional-arg shell-pushd-regexp
! 							     str bos))
! 		  (shell-process-pushd x))
! 		 ((setq x (shell-match-cmd-w/optional-arg shell-cd-regexp
! 							     str bos))
! 		  (shell-process-cd x)))))))
  
- 
  ;;; Try to match regexp CMD to string, anchored at position START.
  ;;; CMD may be followed by a single argument. If a match, then return
--- 346,362 ----
               (let ((bos (match-end 0))
                     (x nil))
!                (cond ((setq x (shell-match-cmd-w/optional-arg
!                                shell-popd-regexp str bos))
!                       (shell-process-popd (substitute-in-file-name x)))
!                      ((setq x (shell-match-cmd-w/optional-arg
!                                shell-pushd-regexp str bos))
!                       (shell-process-pushd (substitute-in-file-name x)))
!                      ((setq x (shell-match-cmd-w/optional-arg 
!                                shell-cd-regexp str bos))
!                       (shell-process-cd (substitute-in-file-name x)))))))
!     (error
!      (message nil)
!      (display-error err t))))
  
  ;;; Try to match regexp CMD to string, anchored at position START.
  ;;; CMD may be followed by a single argument. If a match, then return
***************
*** 350,354 ****
    ;; emacs understand that at least some of the time.
    (condition-case nil
!       (let ((prev-command (ring-ref (get-input-ring) 1)))
  	(if (string-match "[ \t]+\\([^ \t\n;]+\\)[ \t]*\\'" prev-command)
  	    (substring prev-command (match-beginning 1) (match-end 1))))
--- 385,389 ----
    ;; emacs understand that at least some of the time.
    (condition-case nil
!       (let ((prev-command (ring-ref comint-input-ring 1)))
  	(if (string-match "[ \t]+\\([^ \t\n;]+\\)[ \t]*\\'" prev-command)
  	    (substring prev-command (match-beginning 1) (match-end 1))))
***************
*** 361,365 ****
      (if (and num (< num (length shell-dirstack)))
  	(if (= num 0) ; condition-case because the CD could lose.
! 	    (condition-case nil (progn (comint-cd (car shell-dirstack))
  				       (setq shell-dirstack
  					     (cdr shell-dirstack))
--- 396,400 ----
      (if (and num (< num (length shell-dirstack)))
  	(if (= num 0) ; condition-case because the CD could lose.
! 	    (condition-case nil (progn (cd (car shell-dirstack))
  				       (setq shell-dirstack
  					     (cdr shell-dirstack))
***************
*** 377,382 ****
  (defun shell-process-cd (arg)
    (if (equal arg "!$") (setq arg (shell-snarf-bang-dollar)))
!   (condition-case nil (progn (comint-cd (if (zerop (length arg)) (getenv "HOME")
! 				     arg))
  			     (shell-dirstack-message))
  	   (error (message "Couldn't cd."))))
--- 412,422 ----
  (defun shell-process-cd (arg)
    (if (equal arg "!$") (setq arg (shell-snarf-bang-dollar)))
!   (condition-case nil
!       (let ((new-dir (cond
!                       ((zerop (length arg)) (getenv "HOME"))
!                       ((string-equal "-" arg) shell-last-dir)
!                       (t arg))))
!        (setq shell-last-dir default-directory)
!        (cd new-dir)
         (shell-dirstack-message))
      (error (message "Couldn't cd."))))
***************
*** 390,394 ****
        (condition-case nil (if shell-dirstack
  			      (let ((old default-directory))
! 				(comint-cd (car shell-dirstack))
  				(setq shell-dirstack
  				      (cons old (cdr shell-dirstack)))
--- 430,434 ----
        (condition-case nil (if shell-dirstack
  			      (let ((old default-directory))
! 				(cd (car shell-dirstack))
  				(setq shell-dirstack
  				      (cons old (cdr shell-dirstack)))
***************
*** 407,411 ****
  		       (new-ds (append front back)))
  		  (condition-case nil
! 		      (progn (comint-cd (car new-ds))
  			     (setq shell-dirstack (cdr new-ds))
  			     (shell-dirstack-message))
--- 447,451 ----
  		       (new-ds (append front back)))
  		  (condition-case nil
! 		      (progn (cd (car new-ds))
  			     (setq shell-dirstack (cdr new-ds))
  			     (shell-dirstack-message))
***************
*** 415,419 ****
  	    (let ((old-wd default-directory))
  	      (condition-case nil
! 		  (progn (comint-cd arg)
  			 (setq shell-dirstack
  			       (cons old-wd shell-dirstack))
--- 455,459 ----
  	    (let ((old-wd default-directory))
  	      (condition-case nil
! 		  (progn (cd arg)
  			 (setq shell-dirstack
  			       (cons old-wd shell-dirstack))
***************
*** 434,441 ****
  	   (if shell-dirtrackp "ON" "OFF")))
  
  (defun shell-resync-dirs ()
    "Resync the buffer's idea of the current directory stack.
  This command queries the shell with the command bound to 
! shell-dirstack-query (default \"dirs\"), reads the next
  line output and parses it to form the new directory stack.
  DON'T issue this command unless the buffer is at a shell prompt.
--- 474,484 ----
  	   (if shell-dirtrackp "ON" "OFF")))
  
+ ;;; For your typing convenience:
+ (define-function 'dirtrack-toggle 'shell-dirtrack-toggle)
+ 
  (defun shell-resync-dirs ()
    "Resync the buffer's idea of the current directory stack.
  This command queries the shell with the command bound to 
! `shell-dirstack-query' (default \"dirs\"), reads the next
  line output and parses it to form the new directory stack.
  DON'T issue this command unless the buffer is at a shell prompt.
***************
*** 473,477 ****
        (let ((ds (reverse ds)))
  	(condition-case nil
! 	    (progn (comint-cd (car ds))
  		   (setq shell-dirstack (cdr ds))
  		   (shell-dirstack-message))
--- 516,520 ----
        (let ((ds (reverse ds)))
  	(condition-case nil
! 	    (progn (cd (car ds))
  		   (setq shell-dirstack (cdr ds))
  		   (shell-dirstack-message))
***************
*** 478,484 ****
  	  (error (message "Couldn't cd.")))))))
  
! (defun comint-cd (d)
!   "Substitute environment variables before calling cd."
!   (cd (substitute-in-file-name d)))
  
  (defvar shell-dirstack-message-hook nil
--- 521,526 ----
  	  (error (message "Couldn't cd.")))))))
  
! ;;; For your typing convenience:
! ;(define-function 'dirs 'shell-resync-dirs)
  
  (defvar shell-dirstack-message-hook nil
***************
*** 506,509 ****
--- 548,553 ----
  
  ;;; Interfacing to client packages (and converting them)
+ ;;; Notes from when this was called cmushell, and was not the standard emacs
+ ;;; shell package.  Many of the conversions discussed here have been done.
  ;;;============================================================================
  ;;; Several gnu packages (tex-mode, background, dbx, gdb, kermit, prolog, 
***************
*** 514,522 ****
  ;;; functions depend on. So they (kill-all-local-variables), then create
  ;;; the few local variables that shell.el functions depend on. Alas,
! ;;; shell.el functions depend on a different set of vars (for example,
! ;;; the input history ring is a local variable in shell.el's shell mode,
  ;;; whereas there is no input history ring in shell.el's shell mode).
! ;;; So we have a situation where the greater functionality of shell.el
! ;;; is biting us -- you can't just replace shell will shell.
  ;;;
  ;;; Altering these packages to use comint mode directly should *greatly*
--- 558,566 ----
  ;;; functions depend on. So they (kill-all-local-variables), then create
  ;;; the few local variables that shell.el functions depend on. Alas,
! ;;; cmushell.el functions depend on a different set of vars (for example,
! ;;; the input history ring is a local variable in cmushell.el's shell mode,
  ;;; whereas there is no input history ring in shell.el's shell mode).
! ;;; So we have a situation where the greater functionality of cmushell.el
! ;;; is biting us -- you can't just replace shell will cmushell.
  ;;;
  ;;; Altering these packages to use comint mode directly should *greatly*
***************
*** 535,584 ****
  (run-hooks 'shell-load-hook)
  
! ;;; Change Log
! ;;; ===========================================================================
! ;;; Olin 8/88
! ;;; Created.
! ;;;
! ;;; Olin 5/26/90
! ;;; - Split cmulisp and cmushell modes into separate files. 
! ;;;   Not only is this a good idea, it's apparently the way it'll be rel 19.
! ;;; - Souped up the directory tracking; it now can handle pushd, pushd +n, 
! ;;;   and popd +n.
! ;;; - Added cmushell-dirtrack-toggle command to toggle the directory
! ;;;   tracking that cmushell tries to do. This is useful, for example,
! ;;;   when you are running ftp -- it prevents the ftp "cd" command from
! ;;;   spoofing the tracking machinery.
! ;;; - Added cmushell-resync-dirs command. This queries the shell
! ;;;   for the current directory stack, and resets the buffer's stack
! ;;;   accordingly.
! ;;; - Bits of the new directory tracking code were adapted from source
! ;;;   contributed by Vince Broman, Jeff Peck, and Barry Warsaw.
! ;;; - See also the improvements made to comint.el at the same time.
! ;;; - Renamed several variables. Mostly this comprised changing "shell"
! ;;;   to "cmushell" in the names. The only variables that are not prefixed
! ;;;   with "cmushell-" are the ones that are common with shell.el:
! ;;;       explicit-shell-file-name shell-prompt-pattern explicit-csh-args 
! ;;;       and shell-cd/popd/pushd-regexp
! ;;;   The variables and functions that were changed to have "cmushell-" 
! ;;;   prefixes are:
! ;;;       shell-directory-stack (v), shell-directory-tracker (f)
! ;;;   This should not affect users, only elisp hackers. Hopefully
! ;;;   one day shell.el will just go away, and we can drop all this
! ;;;   "cmushell" bullshit.
! ;;; - Upgraded process sends to use comint-send-string instead of
! ;;;   process-send-string.
! ;;;
! ;;; Olin 6/14/90
! ;;; - If your shell is named <shellname>, and a variable named
! ;;;   explicit-<shellname>-arguments exists, cmushell is supposed
! ;;;   to use its value as the arglist to the shell invocation.
! ;;;   E.g., if you define explicit-csh-arguments to be 
! ;;;   ("-ifx"), then when cmushell cranks up a csh, it execs it
! ;;;   as "csh -ifx". This is what is documented. What has actually
! ;;;   been the case is that the variable checked is
! ;;;   explicit-<shellname>-args, not explicit-<shellname>-arguments.
! ;;;   The code has been changed to conform to the documentation.
! ;;;   This bug reported by Stephen Anderson.
! ;;;
  ;;; Eric Benson 7/10/91
  ;;;   Adapted for Emacs 19 by renaming cmushell to shell everywhere.
--- 579,584 ----
  (run-hooks 'shell-load-hook)
  
! (provide 'shell)
! 
  ;;; Eric Benson 7/10/91
  ;;;   Adapted for Emacs 19 by renaming cmushell to shell everywhere.
***************
*** 587,588 ****
--- 587,590 ----
  ;;;   Instead of calling cd directly, use comint-cd which does
  ;;;    substitute-in-file-name.
+ 
+ ;;; shell.el ends here
*** ../lemacs-beta6/lisp/comint/telnet.el	Thu Apr 15 12:59:43 1993
--- lisp/comint/telnet.el	Sat Jul 24 21:54:53 1993
***************
*** 1,4 ****
! ;; Copyright (C) 1985, 1988, 1992 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,9 ----
! ;;; telnet.el --- run a telnet session from within an Emacs buffer
  
+ ;;; Copyright (C) 1985, 1988, 1992 Free Software Foundation, Inc.
+ 
+ ;; Author: William F. Schelter
+ ;; Maintainer: FSF
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 17,26 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
! ;; Author William F. Schelter
! ;; Hacked for lemacs and comint by Jamie Zawinski
  
! ;;to do fix software types for lispm:
! ;;to eval current expression.  Also to try to send escape keys correctly.
! ;;essentially we'll want the rubout-handler off.
  
  ;; filter is simplistic but should be okay for typical shell usage.
--- 22,46 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
! ;;; Commentary:
  
! ;; This mode is intended to be used for telnet or rsh to a remode host;
! ;; `telnet' and `rsh' are the two entry points.  Multiple telnet or rsh
! ;; sessions are supported.
! ;;
! ;; Normally, input is sent to the remote telnet/rsh line-by-line, as you
! ;; type RET or LFD.  C-c C-c sends a C-c to the remote immediately; 
! ;; C-c C-z sends C-z immediately.  C-c C-q followed by any character
! ;; sends that character immediately.
! ;;
! ;; All RET characters are filtered out of the output coming back from the
! ;; remote system.  The mode tries to do other useful translations based
! ;; on what it sees coming back from the other system before the password
! ;; query.  It knows about UNIX, ITS, TOPS-20 and Explorer systems.
! 
! ;;; Code:
! 
! ;; to do fix software types for lispm:
! ;; to eval current expression.  Also to try to send escape keys correctly.
! ;; essentially we'll want the rubout-handler off.
  
  ;; filter is simplistic but should be okay for typical shell usage.
***************
*** 31,67 ****
  
  (defvar telnet-mode-map nil)
! 
! (if telnet-mode-map
!     nil
!   (if (fboundp 'set-keymap-parent)
!       (progn
! 	(setq telnet-mode-map (make-sparse-keymap))
! 	(set-keymap-name telnet-mode-map 'telnet-mode-map)
! 	(set-keymap-parent telnet-mode-map comint-mode-map))
!     (setq telnet-mode-map (copy-keymap comint-mode-map)))
!   (define-key telnet-mode-map "\C-m" 'telnet-send-input)
! ;  (define-key telnet-mode-map "\C-j" 'telnet-send-input)
!   (define-key telnet-mode-map "\C-c\C-q" 'telnet-send-process-next-char)
!   (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob) 
!   (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z))
! 
! (defvar telnet-new-line "\r")				; buffer-local
! (defvar telnet-replace-c-g nil)				; buffer-local
! (defvar telnet-prompt-pattern "^[^#$%>]*[#$%>] *")	; buffer-local
! (defvar telnet-remote-echoes t				; buffer-local
     "True if the telnet process will echo input.")
! (defvar telnet-interrupt-string "\C-c"			; buffer-local
    "String sent by C-c.")
  
! (defvar telnet-count 0					; buffer-local
    "Number of output strings read from the telnet process
  while looking for the initial password.")
  
  (defvar telnet-initial-count -50
!   "Initial value of telnet-count.  Should be set to the negative of the
  number of terminal writes telnet will make setting up the host connection.")
  
  (defvar telnet-maximum-count 4
!   "Maximum value telnet-count can have.
  After this many passes, we stop looking for initial setup data.
  Should be set to the number of terminal writes telnet will make
--- 51,77 ----
  
  (defvar telnet-mode-map nil)
! (defvar telnet-new-line "\r")
! (make-variable-buffer-local 'telnet-new-line)
! (defvar telnet-prompt-pattern "^[^#$%>]*[#$%>] *")
! (defvar telnet-replace-c-g nil)
! (make-variable-buffer-local 'telnet-replace-c-g)
! (defvar telnet-remote-echoes t
     "True if the telnet process will echo input.")
! (make-variable-buffer-local 'telnet-remote-echoes)
! (defvar telnet-interrupt-string "\C-c"
    "String sent by C-c.")
+ (make-variable-buffer-local 'telnet-interrupt-string)
  
! (defvar telnet-count 0
    "Number of output strings read from the telnet process
  while looking for the initial password.")
+ (make-variable-buffer-local 'telnet-count)
  
  (defvar telnet-initial-count -50
!   "Initial value of `telnet-count'.  Should be set to the negative of the
  number of terminal writes telnet will make setting up the host connection.")
  
  (defvar telnet-maximum-count 4
!   "Maximum value `telnet-count' can have.
  After this many passes, we stop looking for initial setup data.
  Should be set to the number of terminal writes telnet will make
***************
*** 71,83 ****
    (interactive)
    "Interrupt the program running through telnet on the remote host."
!   (send-string nil telnet-interrupt-string))
  
  (defun telnet-c-z ()
    (interactive)
!   (send-string nil "\C-z"))
  
  (defun telnet-send-process-next-char ()
    (interactive)
!   (send-string nil
  	       (char-to-string
  		(let ((inhibit-quit t))
--- 81,93 ----
    (interactive)
    "Interrupt the program running through telnet on the remote host."
!   (process-send-string nil telnet-interrupt-string))
  
  (defun telnet-c-z ()
    (interactive)
!   (process-send-string nil "\C-z"))
  
  (defun telnet-send-process-next-char ()
    (interactive)
!   (process-send-string nil
  	       (char-to-string
  		(let ((inhibit-quit t))
***************
*** 85,88 ****
--- 95,111 ----
  		    (setq quit-flag nil))))))
  
+ ; initialization on first load.
+ (if telnet-mode-map
+     nil
+   (progn
+     (setq telnet-mode-map (make-sparse-keymap))
+     (set-keymap-name telnet-mode-map 'telnet-mode-map)
+     (set-keymap-parent telnet-mode-map comint-mode-map)
+     (define-key telnet-mode-map "\C-m" 'telnet-send-input)
+     ;;(define-key telnet-mode-map "\C-j" 'telnet-send-input)
+     (define-key telnet-mode-map "\C-c\C-q" 'telnet-send-process-next-char)
+     (define-key telnet-mode-map "\C-c\C-c" 'telnet-interrupt-subjob) 
+     (define-key telnet-mode-map "\C-c\C-z" 'telnet-c-z)))
+ 
  ;;maybe should have a flag for when have found type
  (defun telnet-check-software-type-initialize (string)
***************
*** 90,104 ****
    (let ((case-fold-search t))
      (cond ((string-match "unix" string)
! 	   ;;(setq telnet-prompt-pattern comint-prompt-regexp)
! 	   (setq telnet-prompt-pattern shell-prompt-pattern)
  	   (setq telnet-new-line "\n"))
! 	  ((string-match "tops-20" string);;maybe add telnet-replace-c-g
  	   (setq telnet-prompt-pattern  "[@>]*"))
  	  ((string-match "its" string)
  	   (setq telnet-prompt-pattern  "^[^*>]*[*>] *"))
! 	  ((string-match "explorer" string);;explorer telnet needs work
  	   (setq telnet-replace-c-g ?\n))))
!   (set (make-local-variable 'comint-prompt-regexp)
!        telnet-prompt-pattern))
  
  (defun telnet-initial-filter (proc string)
--- 113,125 ----
    (let ((case-fold-search t))
      (cond ((string-match "unix" string)
! 	   (setq telnet-prompt-pattern comint-prompt-regexp)
  	   (setq telnet-new-line "\n"))
! 	  ((string-match "tops-20" string) ;;maybe add telnet-replace-c-g
  	   (setq telnet-prompt-pattern  "[@>]*"))
  	  ((string-match "its" string)
  	   (setq telnet-prompt-pattern  "^[^*>]*[*>] *"))
! 	  ((string-match "explorer" string) ;;explorer telnet needs work
  	   (setq telnet-replace-c-g ?\n))))
!   (setq comint-prompt-regexp telnet-prompt-pattern))
  
  (defun telnet-initial-filter (proc string)
***************
*** 109,116 ****
  	((string-match "passw" string)
  	 (telnet-filter proc string)
! 	 (let* ((echo-keystrokes 0)
! 		(password (telnet-read-password)))
  	   (setq telnet-count 0)
! 	   (send-string proc (concat password telnet-new-line))))
  	(t (telnet-check-software-type-initialize string)
  	   (telnet-filter proc string)
--- 130,136 ----
  	((string-match "passw" string)
  	 (telnet-filter proc string)
! 	 (let ((password (comint-read-noecho "Password: ")))
  	   (setq telnet-count 0)
! 	   (process-send-string proc (concat password telnet-new-line))))
  	(t (telnet-check-software-type-initialize string)
  	   (telnet-filter proc string)
***************
*** 119,122 ****
--- 139,148 ----
  		 (t (setq telnet-count (1+ telnet-count)))))))
  
+ ;; Identical to comint-simple-send, except that it sends telnet-new-line
+ ;; instead of "\n".
+ (defun telnet-simple-send (proc string)
+   (comint-send-string proc string)
+   (comint-send-string proc telnet-new-line))
+ 
  (defun telnet-filter (proc string)
    (save-excursion
***************
*** 130,133 ****
--- 156,160 ----
  	    (ws (and w (window-start w))))
         (goto-char last-insertion)
+ 	;; Insert STRING, omitting all C-m characters.
         (insert-before-markers string)
         (set-marker (process-mark proc) (point))
***************
*** 149,161 ****
         ))))
  
- (defun telnet-read-password ()
-   (let ((answ "") tem)
-     (message "Reading password...")
-     (while (not (or (= (setq tem (read-char)) ?\^m)
- 		    (= tem ?\n)))
-       (setq answ (concat answ (char-to-string tem))))
-     (message "")
-     answ))
- 
  (defun telnet-send-input ()
    (interactive)
--- 176,179 ----
***************
*** 177,184 ****
  	  (delete-region p1 (1+ p2))))))
  
! (defun telnet-input-sender (proc string)
!   (comint-send-string proc string)
!   (comint-send-string proc telnet-new-line))
! 
  (defun telnet (hostname)
    "Open a network login connection to host named HOST (a string).
--- 195,199 ----
  	  (delete-region p1 (1+ p2))))))
  
! ;;;###autoload
  (defun telnet (hostname)
    "Open a network login connection to host named HOST (a string).
***************
*** 190,198 ****
      (switch-to-buffer (make-comint name "telnet"))
      (set-process-filter (get-process name) 'telnet-initial-filter)
      (erase-buffer)
!     (send-string  name (concat "open " hostname "\n"))
      (telnet-mode)
      (setq telnet-count telnet-initial-count)))
  
  (defun rsh (hostname)
    "Open a network login connection to host named HOST (a string).
--- 205,235 ----
      (switch-to-buffer (make-comint name "telnet"))
      (set-process-filter (get-process name) 'telnet-initial-filter)
+     ;; Don't send the `open' cmd till telnet is ready for it.
+     (accept-process-output (get-process name))
      (erase-buffer)
!     (process-send-string name (concat "open " hostname "\n"))
      (telnet-mode)
+     (setq comint-input-sender 'telnet-simple-send)
      (setq telnet-count telnet-initial-count)))
  
+ (defun telnet-mode ()
+   "This mode is for using telnet (or rsh) from a buffer to another host.
+ It has most of the same commands as comint-mode.
+ There is a variable ``telnet-interrupt-string'' which is the character
+ sent to try to stop execution of a job on the remote host.
+ Data is sent to the remote host when RET is typed.
+ 
+ \\{telnet-mode-map}
+ "
+   (interactive)
+   (comint-mode)
+   (setq major-mode 'telnet-mode
+         mode-name "Telnet"
+         comint-prompt-regexp telnet-prompt-pattern)
+   (use-local-map telnet-mode-map)
+   (run-hooks 'telnet-mode-hook))
+ 
+ ;; Berkeley spawn of hell
+ ;;;###autoload
  (defun rsh (hostname)
    "Open a network login connection to host named HOST (a string).
***************
*** 201,204 ****
--- 238,242 ----
  See also `\\[telnet]'."
    (interactive "sOpen rsh connection to host: ")
+   (require 'shell)
    (let ((name (concat hostname "-rsh")))
      (switch-to-buffer (make-comint name "rsh" nil hostname))
***************
*** 211,239 ****
      (telnet-check-software-type-initialize "unix")
      (setq telnet-count telnet-initial-count)))
- 
- (defun telnet-mode ()
-   "This mode is for use during telnet or rsh from a buffer to another
- host. It has most of the same commands as comint-mode.
- There is a variable ``telnet-interrupt-string'' which is the character
- sent to try to stop execution of a job on the remote host.
- Data is sent to the remote host when RET is typed.
- \\{telnet-mode-map}
- 
- Bugs:
- --Replaces \C-m by a space, really should remove."
-   (interactive)
-   (comint-mode)					    ; runs comint-mode-hook
-   (setq major-mode 'telnet-mode)
-   (setq mode-name "Telnet")
-   (setq comint-prompt-regexp telnet-prompt-pattern) ; local via comint-mode
-   (setq comint-input-sender 'telnet-input-sender)   ; local via comint-mode
-   (make-local-variable 'telnet-prompt-pattern)
-   (make-local-variable 'telnet-new-line)
-   (make-local-variable 'telnet-replace-c-g)
-   (make-local-variable 'telnet-remote-echoes)
-   (make-local-variable 'telnet-interrupt-string)
-   (make-local-variable 'telnet-count)
-   (use-local-map telnet-mode-map)
-   (run-hooks 'telnet-mode-hook))
  
  (provide 'telnet)
--- 249,252 ----
*** ../lemacs-beta6/lisp/modes/c-mode.el	Thu Jun 10 19:06:38 1993
--- lisp/modes/c-mode.el	Sun Jul 25 15:50:54 1993
***************
*** 1,5 ****
! ;; C code editing commands for Emacs
  ;; Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,8 ----
! ;;; c-mode.el --- C code editing commands for Emacs
  ;; Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
  
+ ;; Maintainer: FSF
+ ;; Keywords: c
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,24 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
  (defvar c-mode-abbrev-table nil
!   "Abbrev table in use in C-mode buffers.")
  (define-abbrev-table 'c-mode-abbrev-table ())
  
--- 21,35 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; A smart editing mode for C code.  It knows a lot about C syntax and tries
+ ;; to position the curser according to C layout conventions.  You can
+ ;; change the details of the layout style with option variables.  Load it
+ ;; and do M-x describe-mode for details.
+ 
+ ;;; Code:
  
  (defvar c-mode-abbrev-table nil
!   "Abbrev table in use in C mode.")
  (define-abbrev-table 'c-mode-abbrev-table ())
  
***************
*** 26,45 ****
    "Keymap used in C mode.")
  (if (null c-mode-map)
!     (setq c-mode-map (make-sparse-keymap)))
! 
! (define-key c-mode-map "{" 'electric-c-brace)
! (define-key c-mode-map "}" 'electric-c-brace)
! (define-key c-mode-map ";" 'electric-c-semi)
! (define-key c-mode-map "#" 'electric-c-sharp-sign)
! (define-key c-mode-map ":" 'electric-c-terminator)
! (define-key c-mode-map "\e{" 'c-insert-braces)
! ;;; Commented out eletric square brackets because nobody likes them.
! ;;;(define-key c-mode-map "[" 'c-insert-brackets)
! (define-key c-mode-map "\e\C-h" 'mark-c-function)
! (define-key c-mode-map "\e\C-q" 'indent-c-exp)
! (define-key c-mode-map "\eq" 'c-fill-paragraph)
! (define-key c-mode-map "\177" 'backward-delete-char-untabify)
! (define-key c-mode-map "\t" 'c-indent-command)
  
  (autoload 'c-macro-expand "cmacexp"
    "Display the result of expanding all C macros occurring in the region.
--- 37,64 ----
    "Keymap used in C mode.")
  (if (null c-mode-map)
!     (progn
!       (setq c-mode-map (make-sparse-keymap))
!       (set-keymap-name c-mode-map 'c-mode-map)
!       (define-key c-mode-map "{" 'electric-c-brace)
!       (define-key c-mode-map "}" 'electric-c-brace)
!       (define-key c-mode-map ";" 'electric-c-semi)
!       (define-key c-mode-map "#" 'electric-c-sharp-sign)
!       (define-key c-mode-map ":" 'electric-c-terminator)
!       (define-key c-mode-map "\e{" 'c-insert-braces)
!       ;; Commented out electric square brackets because nobody likes them.
!       ;;(define-key c-mode-map "[" 'c-insert-brackets)
!       (define-key c-mode-map "\e\C-h" 'mark-c-function)
!       (define-key c-mode-map "\e\C-q" 'indent-c-exp)
!       (define-key c-mode-map "\ea" 'c-beginning-of-statement)
!       (define-key c-mode-map "\ee" 'c-end-of-statement)
!       (define-key c-mode-map "\eq" 'c-fill-paragraph)
!       (define-key c-mode-map "\C-c\C-n" 'c-forward-conditional)
!       (define-key c-mode-map "\C-c\C-p" 'c-backward-conditional)
!       (define-key c-mode-map "\C-c\C-u" 'c-up-conditional)
!       (define-key c-mode-map "\177" 'backward-delete-char-untabify)
!       (define-key c-mode-map "\t" 'c-indent-command)))
  
+ ;; cmacexp is lame because it uses no preprocessor symbols.
+ ;; It isn't very extensible either -- hardcodes /lib/cpp.
  (autoload 'c-macro-expand "cmacexp"
    "Display the result of expanding all C macros occurring in the region.
***************
*** 66,86 ****
    (modify-syntax-entry ?\' "\"" c-mode-syntax-table))
  
! (defconst c-indent-level 2
    "*Indentation of C statements with respect to containing block.")
! (defconst c-brace-imaginary-offset 0
    "*Imagined indentation of a C open brace that actually follows a statement.")
! (defconst c-brace-offset 0
    "*Extra indentation for braces, compared with other text in same context.")
! (defconst c-argdecl-indent 5
    "*Indentation level of declarations of C function arguments.")
! (defconst c-label-offset -2
    "*Offset of C label lines and case statements relative to usual indentation.")
! (defconst c-continued-statement-offset 2
    "*Extra indent for lines not starting new statements.")
! (defconst c-continued-brace-offset 0
    "*Extra indent for substatements that start with open-braces.
  This is in addition to c-continued-statement-offset.")
  
! (defconst c-auto-newline nil
    "*Non-nil means automatically newline before and after braces,
  and after colons and semicolons, inserted in C code.
--- 85,105 ----
    (modify-syntax-entry ?\' "\"" c-mode-syntax-table))
  
! (defvar c-indent-level 2
    "*Indentation of C statements with respect to containing block.")
! (defvar c-brace-imaginary-offset 0
    "*Imagined indentation of a C open brace that actually follows a statement.")
! (defvar c-brace-offset 0
    "*Extra indentation for braces, compared with other text in same context.")
! (defvar c-argdecl-indent 5
    "*Indentation level of declarations of C function arguments.")
! (defvar c-label-offset -2
    "*Offset of C label lines and case statements relative to usual indentation.")
! (defvar c-continued-statement-offset 2
    "*Extra indent for lines not starting new statements.")
! (defvar c-continued-brace-offset 0
    "*Extra indent for substatements that start with open-braces.
  This is in addition to c-continued-statement-offset.")
  
! (defvar c-auto-newline nil
    "*Non-nil means automatically newline before and after braces,
  and after colons and semicolons, inserted in C code.
***************
*** 88,94 ****
    (define-key c-mode-map \"{\" 'electric-c-semi)")
  
! (defconst c-tab-always-indent t
    "*Non-nil means TAB in C mode should always reindent the current line,
  regardless of where in the line point is when the TAB command is used.")
  
  (defun c-mode ()
--- 107,119 ----
    (define-key c-mode-map \"{\" 'electric-c-semi)")
  
! (defvar c-tab-always-indent t
    "*Non-nil means TAB in C mode should always reindent the current line,
  regardless of where in the line point is when the TAB command is used.")
+ 
+ ;;; Regular expression used internally to recognize labels in switch
+ ;;; statements.
+ (defvar c-switch-label-regexp
+   (purecopy "case[ \t'/(]\\|default\\(\\S_\\|'\\)"))
+ 
  
  (defun c-mode ()
***************
*** 163,168 ****
    (make-local-variable 'comment-start-skip)
    (setq comment-start-skip "/\\*+ *")
!   (make-local-variable 'comment-indent-hook)
!   (setq comment-indent-hook 'c-comment-indent)
    (make-local-variable 'parse-sexp-ignore-comments)
    (setq parse-sexp-ignore-comments t)
--- 188,193 ----
    (make-local-variable 'comment-start-skip)
    (setq comment-start-skip "/\\*+ *")
!   (make-local-variable 'comment-indent-function)
!   (setq comment-indent-function 'c-comment-indent)
    (make-local-variable 'parse-sexp-ignore-comments)
    (setq parse-sexp-ignore-comments t)
***************
*** 199,212 ****
  (defun c-fill-paragraph (&optional arg)
    "Like \\[fill-paragraph] but handle C comments.
! If point is inside a comment, the current paragraph of the comment
! is filled, preserving the comment indentation or line-starting decorations."
    (interactive "P")
!   (let ((first-line
! 	 (save-excursion
  	   (beginning-of-line)
! 	   (skip-chars-forward " \t")
! 	   (looking-at comment-start-skip))))
      (if (or first-line
! 	    (eq (calculate-c-indent) t))
  	;; Inside a comment: fill one comment paragraph.
  	(let ((fill-prefix
--- 224,251 ----
  (defun c-fill-paragraph (&optional arg)
    "Like \\[fill-paragraph] but handle C comments.
! If any of the current line is a comment or within a comment,
! fill the comment or the paragraph of it that point is in,
! preserving the comment indentation or line-starting decorations."
    (interactive "P")
!   (let* ((first-line (save-excursion
!                        ;; Check for obvious entry to comment.
                         (beginning-of-line)
!                        (skip-chars-forward " \t\n")
!                        (and (looking-at comment-start-skip)
!                             (point))))
!          (comment-start-place first-line))
      (if (or first-line
!             ;; t if we enter a comment between start of function and this line.
! 	    (eq (calculate-c-indent) t)
! 	    ;; t if this line contains a comment starter.
! 	    (setq first-line
! 		  (save-excursion
! 		    (beginning-of-line)
! 		    (prog1
! 			(re-search-forward comment-start-skip
! 					   (save-excursion (end-of-line)
! 							   (point))
! 					   t)
! 		      (setq comment-start-place (point))))))
  	;; Inside a comment: fill one comment paragraph.
  	(let ((fill-prefix
***************
*** 220,228 ****
  			    (make-string (current-column) ?\ ))
  		   (if first-line (forward-line 1))
! 		   (buffer-substring (point)
! 				     (progn (move-to-column
  					     (calculate-c-indent-within-comment t)
  					     t)
! 					    (point))))))
  	      (paragraph-start
  	       ;; Lines containing just a comment start or just an end
--- 259,304 ----
  			    (make-string (current-column) ?\ ))
  		   (if first-line (forward-line 1))
! 
! 		   (let ((line-width (progn (end-of-line) (current-column))))
! 		     (beginning-of-line)
! 		     (prog1
! 			 (buffer-substring
! 			  (point)
! 
! 			  ;; How shall we decide where the end of the
! 			  ;; fill-prefix is?
! 			  ;; calculate-c-indent-within-comment bases its value
! 			  ;; on the indentation of previous lines; if they're
! 			  ;; indented specially, it could return a column
! 			  ;; that's well into the current line's text.  So
! 			  ;; we'll take at most that many space, tab, or *
! 			  ;; characters, and use that as our fill prefix.
! 			  (let ((max-prefix-end
! 				 (progn
! 				   (move-to-column
  				    (calculate-c-indent-within-comment t)
  				    t)
! 				   (point))))
! 			    (beginning-of-line)
! 			    (skip-chars-forward " \t*" max-prefix-end)
! 			    (point)))
! 
! 		       ;; If the comment is only one line followed by a blank
! 		       ;; line, calling move-to-column above may have added
! 		       ;; some spaces and tabs to the end of the line; the
! 		       ;; fill-paragraph function will then delete it and the
! 		       ;; newline following it, so we'll lose a blank line
! 		       ;; when we shouldn't.  So delete anything
! 		       ;; move-to-column added to the end of the line.  We
! 		       ;; record the line width instead of the position of the
! 		       ;; old line end because move-to-column might break a
! 		       ;; tab into spaces, and the new characters introduced
! 		       ;; there shouldn't be deleted.
! 
! 		       ;; If you can see a better way to do this, please make
! 		       ;; the change.  This seems very messy to me.
! 		       (delete-region (progn (move-to-column line-width)
! 					     (point))
! 				      (progn (end-of-line) (point))))))))
  	      (paragraph-start
  	       ;; Lines containing just a comment start or just an end
***************
*** 229,240 ****
  	       ;; should not be filled into paragraphs they are next to.
  	       (concat paragraph-start
! 		       "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]"))
  	      (paragraph-separate
  	       (concat paragraph-separate
! 		       "\\|^[ \t]*/\\*[ \t]*$\\|^[ \t]*\\*/[ \t]*$\\|^[^ \t/*]")))
  	  (save-restriction
  	    ;; Don't fill the comment together with the code following it.
! 	    (narrow-to-region (point-min)
! 			      (save-excursion (search-forward "*/" nil 'move)
  					      (forward-line 1)
  					      (point)))
--- 305,344 ----
  	       ;; should not be filled into paragraphs they are next to.
  	       (concat paragraph-start
!                        ;; This:
! 		       ;;   "\\|^[ \t]*/\\*[ \t]*$"
!                        ;;   "\\|^[ \t]*\\*/[ \t]*$"
!                        ;;   "\\|^[ \t/*]*$"
!                        ;; is just this:
!                        "\\|^[ \t/*]*$"))
  	      (paragraph-separate
  	       (concat paragraph-separate
! 		       ;; This:
!                        ;;   "\\|^[ \t]*/\\*[ \t]*$"
!                        ;;   "\\|^[ \t]*\\*/[ \t]*$"
!                        ;;   "\\|^[ \t/*]*$"
!                        ;; is just this:
!                        "\\|^[ \t/*]*$"))
!               (chars-to-delete 0))
  	  (save-restriction
  	    ;; Don't fill the comment together with the code following it.
! 	    ;; So temporarily exclude everything before the comment start,
! 	    ;; and everything after the line where the comment ends.
! 	    ;; If comment-start-place is non-nil, the comment starter is there.
! 	    ;; Otherwise, point is inside the comment.
! 	    (narrow-to-region (save-excursion
! 				(if comment-start-place
! 				    (goto-char comment-start-place)
!                                     (search-backward "/*"))
! 				;; Protect text before the comment start 
! 				;; by excluding it.  Add spaces to bring back 
! 				;; proper indentation of that point.
! 				(let ((column (current-column)))
! 				  (prog1 (point)
! 				    (setq chars-to-delete column)
! 				    (insert-char ?\  column))))
! 			      (save-excursion
! 				(if comment-start-place
! 				    (goto-char (+ comment-start-place 2)))
!                                 (search-forward "*/" nil 'move)
                                  (forward-line 1)
                                  (point)))
***************
*** 241,245 ****
  	    (fill-paragraph arg)
  	    (save-excursion
! 	      (search-forward "*/")
  	      (beginning-of-line)
  	      (if (looking-at "[ \t]*\\*/")
--- 345,358 ----
  	    (fill-paragraph arg)
  	    (save-excursion
! 	      ;; Delete the chars we inserted to avoid clobbering
! 	      ;; the stuff before the comment start.
! 	      (goto-char (point-min))
! 	      (if (> chars-to-delete 0)
! 		  (delete-region (point) (+ (point) chars-to-delete)))
! 	      ;; Find the comment ender (should be on last line of buffer,
! 	      ;; given the narrowing) and don't leave it on its own line.
! 	      (goto-char (point-max))
! 	      (forward-line -1)
! 	      (search-forward "*/" nil 'move)
  	      (beginning-of-line)
  	      (if (looking-at "[ \t]*\\*/")
***************
*** 324,328 ****
  			;; and do no indentation for them.
  			(and (eq last-command-char ?:)
! 			     (not (looking-at "case[ \t'/(]"))
  			     (save-excursion
  			       (skip-chars-forward "a-zA-Z0-9_$")
--- 437,441 ----
  			;; and do no indentation for them.
  			(and (eq last-command-char ?:)
! 			     (not (looking-at c-switch-label-regexp))
  			     (save-excursion
  			       (skip-chars-forward "a-zA-Z0-9_$")
***************
*** 364,368 ****
  (defun c-indent-command (&optional whole-exp)
    "Indent current line as C code, or in some cases insert a tab character.
! If c-tab-always-indent is non-nil (the default), always indent current line.
  Otherwise, indent the current line only if point is at the left margin
  or in the line's indentation; otherwise insert a tab.
--- 477,481 ----
  (defun c-indent-command (&optional whole-exp)
    "Indent current line as C code, or in some cases insert a tab character.
! If `c-tab-always-indent' is non-nil (the default), always indent current line.
  Otherwise, indent the current line only if point is at the left margin
  or in the line's indentation; otherwise insert a tab.
***************
*** 416,420 ****
  	   (skip-chars-forward " \t")
  	   (if (listp indent) (setq indent (car indent)))
! 	   (cond ((or (looking-at "case[ \t'/(]")
  		      (and (looking-at "[A-Za-z]")
  			   (save-excursion
--- 529,533 ----
  	   (skip-chars-forward " \t")
  	   (if (listp indent) (setq indent (car indent)))
! 	   (cond ((or (looking-at c-switch-label-regexp)
  		      (and (looking-at "[A-Za-z]")
  			   (save-excursion
***************
*** 427,430 ****
--- 540,549 ----
  				 (c-backward-to-start-of-if)
  				 (current-indentation))))
+ 		 ((looking-at "}[ \t]*else")
+ 		  (setq indent (save-excursion
+ 				 (forward-char)
+ 				 (backward-sexp)
+ 				 (c-backward-to-start-of-if)
+ 				 (current-indentation))))
  		 ((and (looking-at "while\\b")
  		       (save-excursion
***************
*** 468,474 ****
--- 587,598 ----
  	(setq state (parse-partial-sexp (point) indent-point 0))
  	(setq containing-sexp (car (cdr state))))
+       (goto-char indent-point)
        (cond ((or (nth 3 state) (nth 4 state))
  	     ;; return nil or t if should not change this line
  	     (nth 4 state))
+ 	    ((and (null containing-sexp)
+                   (looking-at "[ \t]*{"))
+              ;; It starts a function body
+              0)
              ((null containing-sexp)
  	     ;; Line is at top level.  May be data or function definition,
***************
*** 477,484 ****
  	     ;; unless that ends in a closeparen without semicolon,
  	     ;; in which case this line is the first argument decl.
- 	     (goto-char indent-point)
- 	     (skip-chars-forward " \t")
- 	     (if (= (following-char) ?{)
- 		 0   ; Unless it starts a function body
  	       (c-backward-to-noncomment (or parse-start (point-min)))
  	       ;; Look at previous line that's at column 0
--- 601,604 ----
***************
*** 485,512 ****
  	       ;; to determine whether we are in top-level decls
  	       ;; or function's arg decls.  Set basic-indent accordingly.
! 	       (let ((basic-indent
! 		      (save-excursion
  			(re-search-backward "^[^ \^L\t\n#]" nil 'move)
! 			(if (and (looking-at "\\sw\\|\\s_")
! 				 (looking-at "[^\"\n=]*(")
! 				 (progn
! 				   (goto-char (1- (match-end 0)))
  				   (forward-sexp 1)
  				   (and (< (point) indent-point)
  					(not (memq (following-char)
! 						   '(?\, ?\;))))))
! 			    c-argdecl-indent 0))))
! 		 basic-indent)))
! 
! ;; 		 ;; Now add a little if this is a continuation line.
! ;; 		 (+ basic-indent (if (or (bobp)
! ;; 					 (memq (preceding-char) '(?\) ?\; ?\}))
! ;; 					 ;; Line with zero indentation
! ;; 					 ;; is probably the return-type
! ;; 					 ;; of a function definition,
! ;; 					 ;; so following line is function name.
! ;; 					 (= (current-indentation) 0))
! ;;				     0 c-continued-statement-offset))
! 
  	    ((/= (char-after containing-sexp) ?{)
  	     ;; line is expression, not statement:
--- 605,660 ----
               ;; to determine whether we are in top-level decls
               ;; or function's arg decls.  Set basic-indent accordingly.
!              (+ (save-excursion
                    (re-search-backward "^[^ \^L\t\n#]" nil 'move)
!                   (cond ((save-excursion
!                            ;; Recognize the DEFUN macro in Emacs...
!                            ;; Move down to the (putative) argnames line.
!                            (while (and (not (eobp))
!                                        (not (looking-at " *[({}#/]")))
!                              (forward-line 1))
!                            ;; Go back to the DEFUN, if it is one.
!                            (condition-case nil
!                                (backward-sexp 1)
!                              (error))
!                            (beginning-of-line)
!                            (looking-at "DEFUN\\b"))
!                          c-argdecl-indent)
!                         ((and (looking-at "\\sw\\|\\s_")
!                               ;; This is careful to stop at the first
!                               ;; paren if we have
!                               ;; int foo Proto ((int, int));
!                               (looking-at "[^\"\n=(]*(")
!                               (let ((lim (1- (match-end 0))))
!                                 (goto-char lim)
!                                 (condition-case nil
                                      (forward-sexp 1)
+                                   (error))
+                                 (skip-chars-forward " \t\f")
                                  (and (< (point) indent-point)
                                       (not (memq (following-char)
!                                                 '(?\, ?\;))))
!                                 ;; Make sure the "function decl" we found
!                                 ;; is not inside a comment.
!                                 (let ((comment nil))
!                                   (beginning-of-line)
!                                   (while (and (not comment)
!                                               (search-forward "/*" lim t))
!                                     (setq comment
!                                           (not (search-forward "*/" lim t))))
!                                   (not comment))))
!                          c-argdecl-indent)
!                         (t
!                          0)))
!                 ;; Now add a little if this is a continuation line.
!                 ;; (if (or (bobp)
!                 ;;        (memq (preceding-char) '(?\) ?\; ?\}))
!                 ;;        ;; Line with zero indentation
!                 ;;        ;; is probably the return-type
!                 ;;        ;; of a function definition,
!                 ;;        ;; so following line is function name.
!                 ;;        (= (current-indentation) 0))
!                 ;;    0
!                 ;;    c-continued-statement-offset)
!                 ))
  	    ((/= (char-after containing-sexp) ?{)
  	     ;; line is expression, not statement:
***************
*** 517,521 ****
  	     ;; Statement level.  Is it a continuation or a new statement?
  	     ;; Find previous non-comment character.
- 	     (goto-char indent-point)
  	     (c-backward-to-noncomment containing-sexp)
  	     ;; Back up over label lines, since they don't
--- 665,668 ----
***************
*** 531,534 ****
--- 678,697 ----
  	       (beginning-of-line)
  	       (c-backward-to-noncomment containing-sexp))
+ 	     ;; Check for a preprocessor statement or its continuation lines.
+ 	     ;; Move back to end of previous non-preprocessor line.
+ 	     (let ((found (point)) stop)
+ 	       (while (not stop)
+ 		 (cond ((save-excursion (end-of-line 0)
+ 					(= (preceding-char) ?\\))
+ 			(end-of-line 0))
+ 		       ;; This line is not preceded by a backslash.
+ 		       ;; So either it starts a preprocessor command
+ 		       ;; or any following continuation lines
+ 		       ;; should not be skipped.
+ 		       ((progn (beginning-of-line) (= (following-char) ?#))
+ 			(end-of-line 0)
+ 			(setq found (point)))
+ 		       (t (setq stop t))))
+ 	       (goto-char found))
  	     ;; Now we get the answer.
  	     (if (and (not (memq (preceding-char) '(nil ?\, ?\; ?\} ?\{)))
***************
*** 575,581 ****
  		     ;; if it is before the line we want to indent.
  		     (and (< (point) indent-point)
! 			  (if (> colon-line-end (point))
  			      (- (current-indentation) c-label-offset)
! 			    (current-column)))))
  		 ;; If no previous statement,
  		 ;; indent it relative to line brace is on.
--- 738,751 ----
  		     ;; if it is before the line we want to indent.
  		     (and (< (point) indent-point)
! 			  (- (if (> colon-line-end (point))
                                   (- (current-indentation) c-label-offset)
!                                  (current-column))
!                              ;; If prev stmt starts with open-brace, that
!                              ;; open brace was offset by c-brace-offset.
!                              ;; Compensate to get the column where
!                              ;; an ordinary statement would start.
!                              (if (= (following-char) ?\{)
!                                  c-brace-offset 
!                                  0)))))
  		 ;; If no previous statement,
  		 ;; indent it relative to line brace is on.
***************
*** 604,608 ****
  (defun calculate-c-indent-within-comment (&optional after-star)
    "Return the indentation amount for line inside a block comment.
! Non-nil arg AFTER-STAR means, if lines in the comment have a leading star,
  return the indentation of the text that would follow this star."
    (let (end star-start)
--- 774,778 ----
  (defun calculate-c-indent-within-comment (&optional after-star)
    "Return the indentation amount for line inside a block comment.
! Optional arg AFTER-STAR means, if lines in the comment have a leading star,
  return the indentation of the text that would follow this star."
    (let (end star-start)
***************
*** 657,661 ****
  
  (defun c-backward-to-start-of-if (&optional limit)
!   "Move to the start of the last ``unbalanced'' if."
    (or limit (setq limit (save-excursion (beginning-of-defun) (point))))
    (let ((if-level 1)
--- 827,831 ----
  
  (defun c-backward-to-start-of-if (&optional limit)
!   "Move to the start of the last \"unbalanced\" `if'."
    (or limit (setq limit (save-excursion (beginning-of-defun) (point))))
    (let ((if-level 1)
***************
*** 672,677 ****
  
  (defun c-backward-to-start-of-do (&optional limit)
!   "If point follows a `do' statement, move to beginning of it and return `t'.
! Otherwise return `nil' and don't move point."
    (or limit (setq limit (save-excursion (beginning-of-defun) (point))))
    (let ((first t)
--- 842,847 ----
  
  (defun c-backward-to-start-of-do (&optional limit)
!   "If point follows a `do' statement, move to beginning of it and return t.
! Otherwise return nil and don't move point."
    (or limit (setq limit (save-excursion (beginning-of-defun) (point))))
    (let ((first t)
***************
*** 711,714 ****
--- 881,949 ----
        nil)))
  
+ (defun c-beginning-of-statement (count)
+   "Go to the beginning of the innermost C statement.
+ With prefix arg, go back N - 1 statements.  If already at the beginning of a
+ statement then go to the beginning of the preceding one.
+ If within a string or comment, or next to a comment (only whitespace between),
+ move by sentences instead of statements."
+   (interactive "p")
+   (let ((here (point)) state)
+     (save-excursion
+       (beginning-of-defun)
+       (setq state (parse-partial-sexp (point) here nil nil)))
+     (if (or (nth 3 state) (nth 4 state)
+ 	    (looking-at (concat "[ \t]*" comment-start-skip))
+ 	    (save-excursion (skip-chars-backward " \t")
+ 			    (goto-char (- (point) 2))
+ 			    (looking-at "\\*/")))
+ 	(forward-sentence (- count))
+       (while (> count 0)
+ 	(c-beginning-of-statement-1)
+ 	(setq count (1- count)))
+       (while (< count 0)
+ 	(c-end-of-statement-1)
+ 	(setq count (1+ count))))))
+ 
+ (defun c-end-of-statement (count)
+   "Go to the end of the innermost C statement.
+ With prefix arg, go forward N - 1 statements.
+ Move forward to end of the next statement if already at end.
+ If within a string or comment, move by sentences instead of statements."
+   (interactive "p")
+   (c-beginning-of-statement (- count)))
+ 
+ (defun c-beginning-of-statement-1 ()
+   (let ((last-begin (point))
+ 	(first t))
+     (condition-case ()
+ 	(progn
+ 	  (while (and (not (bobp))
+ 		      (progn
+ 			(backward-sexp 1)
+ 			(or first
+ 			    (not (re-search-forward "[;{}]" last-begin t)))))
+ 	    (setq last-begin (point) first nil))
+ 	  (goto-char last-begin))
+       (error (if first (backward-up-list 1) (goto-char last-begin))))))
+ 
+ (defun c-end-of-statement-1 ()
+   (condition-case ()
+       (progn
+ 	(while (and (not (eobp))
+ 		    (let ((beg (point)))
+ 		      (forward-sexp 1)
+ 		      (let ((end (point)))
+ 			(save-excursion
+ 			  (goto-char beg)
+ 			  (not (re-search-forward "[;{}]" end t)))))))
+ 	(re-search-backward "[;}]")
+ 	(forward-char 1))
+     (error 
+      (let ((beg (point)))
+        (backward-up-list -1)
+        (let ((end (point)))
+ 	 (goto-char beg)
+ 	 (search-forward ";" end 'move))))))
+ 
  (defun mark-c-function ()
    "Put mark at end of C function, point at beginning."
***************
*** 716,723 ****
    (push-mark (point))
    (end-of-defun)
!   (push-mark (point))
    (beginning-of-defun)
!   (backward-paragraph)
!   (zmacs-activate-region))
  
  (defun indent-c-exp (&optional endpos)
--- 951,957 ----
    (push-mark (point))
    (end-of-defun)
!   (push-mark (point) nil t)
    (beginning-of-defun)
!   (backward-paragraph))
  
  (defun indent-c-exp (&optional endpos)
***************
*** 739,756 ****
  		      (save-restriction
  			(narrow-to-region funbeg (point))
- ;			(condition-case nil
- ;			    (save-excursion
- ;			      (backward-up-list 1) (point))
- ;			  ;; We gave up: must be between fcns.
- ;			  ;; Set opoint to beg of prev fcn
- ;			  ;; since otherwise calculate-c-indent
- ;			  ;; will get wrong answers.
- ;			  (error (setq opoint funbeg)
- ;				 (point)))
  			(condition-case nil
  			    (save-excursion
  			      (backward-up-list 1) (point))
! 			  (error (point)))
! 			))
  		  (point))))
  	 (case-fold-search nil)
--- 973,987 ----
  		      (save-restriction
  			(narrow-to-region funbeg (point))
  			(condition-case nil
  			    (save-excursion
  			      (backward-up-list 1) (point))
! 			  ;; We gave up: must be between fcns.
! 			  ;; Set opoint to beg of prev fcn
! 			  ;; since otherwise calculate-c-indent
! 			  ;; will get wrong answers.
! 			  (error
! ;;;>>> Commented-out in lemacs, present in FSFmacs
! ;                          (setq opoint funbeg)
!                            (point)))))
  		  (point))))
  	 (case-fold-search nil)
***************
*** 779,783 ****
        (setq outer-loop-done nil)
        (while (and (not (eobp))
! 		  (if endpos (< (point) endpos)
  		    (not outer-loop-done)))
  	(setq last-depth next-depth)
--- 1010,1015 ----
        (setq outer-loop-done nil)
        (while (and (not (eobp))
! 		  (if endpos
!                       (< (point) endpos)
                        (not outer-loop-done)))
  	(setq last-depth next-depth)
***************
*** 830,839 ****
  							(point)))))
  	  (forward-line 1)
- 	  ;; if (point) is out of endpos, quit right here
- 	  (if (and endpos (> (point) endpos))
-   	      nil
  	    (skip-chars-forward " \t")
! 	    (if (eolp)
  		nil
  	      (if (and (car indent-stack)
  		       (>= (car indent-stack) 0))
--- 1062,1071 ----
  							(point)))))
  	  (forward-line 1)
  	  (skip-chars-forward " \t")
! 	  (if (or (eolp)
!                   ;; if (point) is out of endpos, quit right here
!                   (and endpos (> (point) endpos)))
    	      nil
+             (progn
                (if (and (car indent-stack)
                         (>= (car indent-stack) 0))
***************
*** 850,854 ****
  		      (setq at-while (looking-at "while\\b"))
  		      (c-backward-to-noncomment opoint)
! 		      (if (not (memq (preceding-char) '(nil ?\, ?\; ?} ?: ?{)))
  			  ;; Preceding line did not end in comma or semi;
  			  ;; indent this line  c-continued-statement-offset
--- 1082,1087 ----
                          (setq at-while (looking-at "while\\b"))
                          (c-backward-to-noncomment opoint)
!                         (if (not (memq (preceding-char) 
!                                        '(nil ?\, ?\; ?} ?: ?{)))
                              ;; Preceding line did not end in comma or semi;
                              ;; indent this line  c-continued-statement-offset
***************
*** 855,870 ****
  			  ;; more than previous.
  			  (progn
! 			    (c-backward-to-start-of-continued-exp (car contain-stack))
  			    (setq this-indent
! 				  (+ c-continued-statement-offset (current-column)
! 				     (if at-brace c-continued-brace-offset 0))))
  			;; Preceding line ended in comma or semi;
  			;; use the standard indent for this level.
! 			(cond (at-else (progn (c-backward-to-start-of-if opoint)
  					      (setq this-indent
  						    (current-indentation))))
! 			      ((and at-while (c-backward-to-start-of-do opoint))
  			       (setq this-indent (current-indentation)))
! 			      (t (setq this-indent (car indent-stack)))))))
  		;; Just started a new nesting level.
  		;; Compute the standard indent for this level.
--- 1088,1110 ----
                              ;; more than previous.
                              (progn
!                               (c-backward-to-start-of-continued-exp
!                                (car contain-stack))
                                (setq this-indent
!                                     (+ c-continued-statement-offset
!                                        (current-column)
!                                        (if at-brace
!                                            c-continued-brace-offset 
!                                            0))))
                              ;; Preceding line ended in comma or semi;
                              ;; use the standard indent for this level.
!                             (cond (at-else 
!                                    (progn (c-backward-to-start-of-if opoint)
                                            (setq this-indent
                                                  (current-indentation))))
!                                   ((and at-while 
!                                         (c-backward-to-start-of-do opoint))
                                     (setq this-indent (current-indentation)))
!                                   (t 
!                                    (setq this-indent (car indent-stack)))))))
                    ;; Just started a new nesting level.
                    ;; Compute the standard indent for this level.
***************
*** 872,880 ****
  			    (if (car indent-stack)
  				(- (car indent-stack))
! 			      nil))))
  		  (setcar indent-stack
  			  (setq this-indent val))))
  	      ;; Adjust line indentation according to its contents
! 	      (if (or (looking-at "case[ \t'/(]")
  		      (and (looking-at "[A-Za-z]")
  			   (save-excursion
--- 1112,1120 ----
                                (if (car indent-stack)
                                    (- (car indent-stack))
!                                   opoint))))
                      (setcar indent-stack
                              (setq this-indent val))))
  	      ;; Adjust line indentation according to its contents
! 	      (if (or (looking-at c-switch-label-regexp)
  		      (and (looking-at "[A-Za-z]")
  			   (save-excursion
***************
*** 892,896 ****
  		  (= (following-char) ?\#)
  		  (progn
! 		    (delete-region (point) (progn (beginning-of-line) (point)))
  		    (indent-to this-indent)))
  	      ;; Indent any comment following the text.
--- 1132,1137 ----
  		  (= (following-char) ?\#)
  		  (progn
! 		    (delete-region (point)
!                                    (progn (beginning-of-line) (point)))
  		    (indent-to this-indent)))
  	      ;; Indent any comment following the text.
***************
*** 905,910 ****
  				(parse-partial-sexp beg (point)
  						    nil nil state)))
! 			   (and (not (nth 3 new-state)) (not (nth 5 new-state))))
! 			 (progn (indent-for-comment) (beginning-of-line))))))))))))
  
  ;; Indent every line whose first char is between START and END inclusive.
--- 1146,1171 ----
  				(parse-partial-sexp beg (point)
  						    nil nil state)))
! 			   (and (not (nth 3 new-state))
!                                 (not (nth 5 new-state))))
! 			 (progn (indent-for-comment)
!                                 (beginning-of-line))))))))))))
! 
! ;; Look at all comment-start strings in the current line after point.
! ;; Return t if one of them starts a real comment.
! ;; This is not used yet, because indent-for-comment
! ;; isn't smart enough to handle the cases this can find.
! ;(defun indent-c-find-real-comment (state)
! ;  (let ((win nil))
! ;    (while (and (not win)
! ;		(re-search-forward comment-start-skip
! ;				   (save-excursion (end-of-line) (point))
! ;				   t))
! ;      ;; Make sure the comment start is not quoted.
! ;      (let ((state-1
! ;	     (parse-partial-sexp
! ;	      (save-excursion (beginning-of-line) (point))
! ;	      (point) nil nil state)))
! ;	(setq win (and (null (nth 3 state-1)) (null (nth 5 state-1))))))
! ;    win))
  
  ;; Indent every line whose first char is between START and END inclusive.
*** ../lemacs-beta6/lisp/modes/lisp-mode.el	Fri Jan 15 18:25:56 1993
--- lisp/modes/lisp-mode.el	Sat Jul 24 22:46:13 1993
***************
*** 1,5 ****
! ;; Lisp mode, and its idiosyncratic commands.
! ;; Copyright (C) 1985-1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,9 ----
! ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands.
  
+ ;; Copyright (C) 1985, 1993 Free Software Foundation, Inc.
+ 
+ ;; Maintainer: FSF
+ ;; Keywords: lisp, languages
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,21 ****
--- 22,33 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Code:
+ 
+ ;;; Commentary:
+ 
+ ;; The base major mode for editing Lisp code (used also for Emacs Lisp).
+ ;; This mode is documented in the Emacs manual
+ 
+ ;;; Code:
  
  (defvar lisp-mode-syntax-table nil "")
***************
*** 59,72 ****
        (modify-syntax-entry ?\] ")[  " emacs-lisp-mode-syntax-table)))
  
! (if lisp-mode-syntax-table
!     nil
!   (setq lisp-mode-syntax-table
  	(copy-syntax-table emacs-lisp-mode-syntax-table))
    (modify-syntax-entry ?\[ "_   " lisp-mode-syntax-table)
    (modify-syntax-entry ?\] "_   " lisp-mode-syntax-table)
- 
-   ;;
-   ;; If emacs was compiled with NEW_SYNTAX, then do CL's #| |# block comments.
    ;;
    (if (= 8 (length (parse-partial-sexp (point) (point))))
        (progn
--- 71,82 ----
        (modify-syntax-entry ?\] ")[  " emacs-lisp-mode-syntax-table)))
  
! (if (not lisp-mode-syntax-table)
!     (progn (setq lisp-mode-syntax-table
  		 (copy-syntax-table emacs-lisp-mode-syntax-table))
  	   (modify-syntax-entry ?\[ "_   " lisp-mode-syntax-table)
  	   (modify-syntax-entry ?\] "_   " lisp-mode-syntax-table)
             ;;
+            ;; If emacs was compiled with NEW_SYNTAX, then do
+            ;;  CL's #| |# block comments.
             (if (= 8 (length (parse-partial-sexp (point) (point))))
                 (progn
***************
*** 74,78 ****
  	(modify-syntax-entry ?|  ". 67" lisp-mode-syntax-table))
      ;; else, old style
!     (modify-syntax-entry ?\| "\"   " lisp-mode-syntax-table)))
  
  (define-abbrev-table 'lisp-mode-abbrev-table ())
--- 84,88 ----
                   (modify-syntax-entry ?|  ". 67" lisp-mode-syntax-table))
                 ;; else, old style
!                (modify-syntax-entry ?\| "\"   " lisp-mode-syntax-table))))
  
  (define-abbrev-table 'lisp-mode-abbrev-table ())
***************
*** 100,105 ****
    (make-local-variable 'comment-column)
    (setq comment-column 40)
!   (make-local-variable 'comment-indent-hook)
!   (setq comment-indent-hook 'lisp-comment-indent))
  
  (defvar shared-lisp-mode-map ()
--- 110,115 ----
    (make-local-variable 'comment-column)
    (setq comment-column 40)
!   (make-local-variable 'comment-indent-function)
!   (setq comment-indent-function 'lisp-comment-indent))
  
  (defvar shared-lisp-mode-map ()
***************
*** 109,113 ****
--- 119,125 ----
      ()
     (setq shared-lisp-mode-map (make-sparse-keymap))
+    (set-keymap-name shared-lisp-mode-map 'shared-lisp-mode-map)
     (define-key shared-lisp-mode-map "\e\C-q" 'indent-sexp)
+    (define-key shared-lisp-mode-map "\M-q" 'lisp-fill-paragraph)
     (define-key shared-lisp-mode-map "\177" 'backward-delete-char-untabify)
     (define-key shared-lisp-mode-map "\t" 'lisp-indent-line))
***************
*** 120,124 ****
--- 132,138 ----
      ()
    (setq emacs-lisp-mode-map (make-sparse-keymap))
+   (set-keymap-name emacs-lisp-mode-map 'emacs-lisp-mode-map)
    (set-keymap-parent emacs-lisp-mode-map shared-lisp-mode-map)
+   (define-key emacs-lisp-mode-map "\e\t" 'lisp-complete-symbol)
    (define-key emacs-lisp-mode-map "\e\C-x" 'eval-defun))
  
***************
*** 129,133 ****
  Blank lines separate paragraphs.  Semicolons start comments.
  \\{emacs-lisp-mode-map}
! Entry to this mode calls the value of emacs-lisp-mode-hook
  if that value is non-nil."
    (interactive)
--- 143,147 ----
  Blank lines separate paragraphs.  Semicolons start comments.
  \\{emacs-lisp-mode-map}
! Entry to this mode calls the value of `emacs-lisp-mode-hook'
  if that value is non-nil."
    (interactive)
***************
*** 142,146 ****
  (defvar lisp-mode-map ()
    "Keymap for ordinary Lisp mode.
! All commands in shared-lisp-mode-map are inherited by this map.")
  
  (if lisp-mode-map
--- 156,160 ----
  (defvar lisp-mode-map ()
    "Keymap for ordinary Lisp mode.
! All commands in `shared-lisp-mode-map' are inherited by this map.")
  
  (if lisp-mode-map
***************
*** 147,150 ****
--- 161,165 ----
      ()
    (setq lisp-mode-map (make-sparse-keymap))
+   (set-keymap-name lisp-mode-map 'lisp-mode-map)
    (set-keymap-parent lisp-mode-map shared-lisp-mode-map)
    (define-key lisp-mode-map "\e\C-x" 'lisp-send-defun)
***************
*** 160,164 ****
  or to switch back to an existing one.
  
! Entry to this mode calls the value of lisp-mode-hook
  if that value is non-nil."
    (interactive)
--- 175,179 ----
  or to switch back to an existing one.
  
! Entry to this mode calls the value of `lisp-mode-hook'
  if that value is non-nil."
    (interactive)
***************
*** 173,177 ****
  ;; This will do unless shell.el is loaded.
  (defun lisp-send-defun nil
!   "Send the current defun to the Lisp process made by M-x run-lisp."
    (interactive)
    (error "Process lisp does not exist"))
--- 188,192 ----
  ;; This will do unless shell.el is loaded.
  (defun lisp-send-defun nil
!   "Send the current defun to the Lisp process made by \\[run-lisp]."
    (interactive)
    (error "Process lisp does not exist"))
***************
*** 179,183 ****
  (defvar lisp-interaction-mode-map ()
    "Keymap for Lisp Interaction moe.
! All commands in shared-lisp-mode-map are inherited by this map.")
  
  (if lisp-interaction-mode-map
--- 194,198 ----
  (defvar lisp-interaction-mode-map ()
    "Keymap for Lisp Interaction moe.
! All commands in `shared-lisp-mode-map' are inherited by this map.")
  
  (if lisp-interaction-mode-map
***************
*** 184,191 ****
      ()
    (setq lisp-interaction-mode-map (make-sparse-keymap))
    (set-keymap-parent lisp-interaction-mode-map shared-lisp-mode-map)
    (define-key lisp-interaction-mode-map "\e\C-x" 'eval-defun)
!   (define-key lisp-interaction-mode-map "\n" 'eval-print-last-sexp)
!   )
  
  (defun lisp-interaction-mode ()
--- 199,207 ----
      ()
    (setq lisp-interaction-mode-map (make-sparse-keymap))
+   (set-keymap-name lisp-interaction-mode-map 'lisp-interaction-mode-map)
    (set-keymap-parent lisp-interaction-mode-map shared-lisp-mode-map)
    (define-key lisp-interaction-mode-map "\e\C-x" 'eval-defun)
!   (define-key lisp-interaction-mode-map "\e\t" 'lisp-complete-symbol)
!   (define-key lisp-interaction-mode-map "\n" 'eval-print-last-sexp))
  
  (defun lisp-interaction-mode ()
***************
*** 198,202 ****
  Paragraphs are separated only by blank lines.  Semicolons start comments.
  \\{lisp-interaction-mode-map}
! Entry to this mode calls the value of lisp-interaction-mode-hook
  if that value is non-nil."
    (interactive)
--- 214,218 ----
  Paragraphs are separated only by blank lines.  Semicolons start comments.
  \\{lisp-interaction-mode-map}
! Entry to this mode calls the value of `lisp-interaction-mode-hook'
  if that value is non-nil."
    (interactive)
***************
*** 209,242 ****
    (run-hooks 'lisp-interaction-mode-hook))
  
! (defun eval-print-last-sexp (arg)
    "Evaluate sexp before point; print value into current buffer."
!   (interactive "P")
!   (eval-region
!     (let ((stab (syntax-table)))
!       (unwind-protect
! 	  (save-excursion
! 	    (set-syntax-table emacs-lisp-mode-syntax-table)
! 	    (forward-sexp -1)
! 	    (point))
! 	(set-syntax-table stab)))
!     (point)
!     (current-buffer)))
  
! (defun eval-last-sexp (arg)
    "Evaluate sexp before point; print value in minibuffer.
  With argument, print output into current buffer."
    (interactive "P")
!   (eval-region
!     (let ((stab (syntax-table)))
!       (unwind-protect
  	  (save-excursion
  	    (set-syntax-table emacs-lisp-mode-syntax-table)
  	    (forward-sexp -1)
! 	    (point))
! 	(set-syntax-table stab)))
!     (point)
!     (if arg (current-buffer) t)))
  
! (defun eval-defun (arg)
    "Evaluate defun that point is in or before.
  Print value in minibuffer.
--- 225,253 ----
    (run-hooks 'lisp-interaction-mode-hook))
  
! (defun eval-print-last-sexp ()
    "Evaluate sexp before point; print value into current buffer."
!   (interactive)
!   (let ((standard-output (current-buffer)))
!     (terpri)
!     (eval-last-sexp t)
!     (terpri)))
  
! (defun eval-last-sexp (eval-last-sexp-arg-internal) ;dynamic scoping wonderment
    "Evaluate sexp before point; print value in minibuffer.
  With argument, print output into current buffer."
    (interactive "P")
!   (let ((standard-output (if eval-last-sexp-arg-internal (current-buffer) t))
! 	(opoint (point)))
!     (prin1 (let ((stab (syntax-table)))
! 	     (eval (unwind-protect
  		       (save-excursion
  			 (set-syntax-table emacs-lisp-mode-syntax-table)
  			 (forward-sexp -1)
! 			 (save-restriction
! 			   (narrow-to-region (point-min) opoint)
! 			   (read (current-buffer))))
! 		     (set-syntax-table stab)))))))
  
! (defun eval-defun (eval-defun-arg-internal) ;dynamic scoping wonderment
    "Evaluate defun that point is in or before.
  Print value in minibuffer.
***************
*** 243,252 ****
  With argument, insert value in current buffer after the defun."
    (interactive "P")
!   (save-excursion
      (end-of-defun)
-     (let ((end (point)))
        (beginning-of-defun)
!       (eval-region (point) end
! 		   (if arg (current-buffer) t)))))
  
  (defun lisp-comment-indent ()
--- 254,262 ----
  With argument, insert value in current buffer after the defun."
    (interactive "P")
!   (let ((standard-output (if eval-defun-arg-internal (current-buffer) t)))
!     (prin1 (eval (save-excursion
  		   (end-of-defun)
  		   (beginning-of-defun)
! 		   (read (current-buffer)))))))
  
  (defun lisp-comment-indent ()
***************
*** 260,265 ****
  	   comment-column))))
  
! (defconst lisp-indent-offset nil "")
! (defconst lisp-indent-function 'lisp-indent-function "")
  
  (defun lisp-indent-line (&optional whole-exp)
--- 270,275 ----
  	   comment-column))))
  
! (defvar lisp-indent-offset nil "")
! (defvar lisp-indent-function 'lisp-indent-function "")
  
  (defun lisp-indent-line (&optional whole-exp)
***************
*** 275,279 ****
      (if (looking-at "\\s<\\s<\\s<")
  	;; Don't alter indentation of a ;;; comment line.
! 	nil
        (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<")))
  	  ;; Single-semicolon comment lines should be indented
--- 285,289 ----
      (if (looking-at "\\s<\\s<\\s<")
  	;; Don't alter indentation of a ;;; comment line.
! 	(goto-char (- (point-max) pos))
        (if (and (looking-at "\\s<") (not (looking-at "\\s<\\s<")))
  	  ;; Single-semicolon comment lines should be indented
***************
*** 317,321 ****
            (desired-indent nil)
            (retry t)
!           last-sexp containing-sexp)
        (if parse-start
            (goto-char parse-start)
--- 327,332 ----
            (desired-indent nil)
            (retry t)
!           last-sexp
!           containing-sexp)
        (if parse-start
            (goto-char parse-start)
***************
*** 397,400 ****
--- 408,412 ----
    (let ((normal-indent (current-column)))
      (goto-char (1+ (elt state 1)))
+     ;; Urk!  last-sexp, used free, is bound in calculate-lisp-indent
      (parse-partial-sexp (point) last-sexp 0 t)
      (if (and (elt state 2)
***************
*** 428,432 ****
  		(funcall method state indent-point)))))))
  
! (defconst lisp-body-indent 2 "")
  
  (defun lisp-indent-specform (count state indent-point normal-indent)
--- 440,445 ----
  		(funcall method state indent-point)))))))
  
! (defvar lisp-body-indent 2
!   "Number of columns to indent the second line of a `(def...)' form.")
  
  (defun lisp-indent-specform (count state indent-point normal-indent)
***************
*** 489,492 ****
--- 502,506 ----
  
  (put 'lambda 'lisp-indent-function 'defun)
+ (put 'autoload 'lisp-indent-function 'defun)
  (put 'progn 'lisp-indent-function 0)
  (put 'prog1 'lisp-indent-function 1)
***************
*** 495,498 ****
--- 509,513 ----
  (put 'save-window-excursion 'lisp-indent-function 0)
  (put 'save-restriction 'lisp-indent-function 0)
+ (put 'save-match-data 'lisp-indent-function 0)
  (put 'let 'lisp-indent-function 1)
  (put 'let* 'lisp-indent-function 1)
***************
*** 509,515 ****
  ENDPOS is encountered."
    (interactive)
!   (let ((indent-stack (list nil)) (next-depth 0) last-depth bol
! 	outer-loop-done inner-loop-done state this-indent
! 	(last-point (point)))
      ;; Get error now if we don't have a complete sexp after point.
      (save-excursion (forward-sexp 1))
--- 524,537 ----
  ENDPOS is encountered."
    (interactive)
!   (let ((indent-stack (list nil))
!         (next-depth 0) 
!         (starting-point (point))
!         (last-point (point))
!         last-depth 
!         bol
! 	(outer-loop-done nil)
!         inner-loop-done
!         state
!         this-indent)
      ;; Get error now if we don't have a complete sexp after point.
      (save-excursion (forward-sexp 1))
***************
*** 548,556 ****
  	    (setq inner-loop-done t)))
  	(and endpos
! 	     (while (<= next-depth 0)
! 	       (setq indent-stack (append indent-stack (list nil)))
! 	       (setq next-depth (1+ next-depth))
! 	       (setq last-depth (1+ last-depth))))
! 	(setq outer-loop-done (<= next-depth 0))
  	(if outer-loop-done
  	    nil
--- 570,581 ----
  	    (setq inner-loop-done t)))
  	(and endpos
! 	     (<= next-depth 0)
! 	     (progn
! 	       (setq indent-stack (append indent-stack
! 					  (make-list (- next-depth) nil))
! 		     last-depth (- last-depth next-depth)
! 		     next-depth 0)))
! 	(or outer-loop-done
!             (setq outer-loop-done (<= next-depth 0)))
  	(if outer-loop-done
  	    nil
***************
*** 574,578 ****
  		(setq this-indent (car indent-stack))
  	      (let ((val (calculate-lisp-indent
! 			  (if (car indent-stack) (- (car indent-stack))))))
  		(if (integerp val)
  		    (setcar indent-stack
--- 599,605 ----
  		(setq this-indent (car indent-stack))
  	      (let ((val (calculate-lisp-indent
! 			  (if (car indent-stack) 
!                               (- (car indent-stack))
!                               starting-point))))
  		(if (integerp val)
  		    (setcar indent-stack
***************
*** 596,599 ****
--- 623,696 ----
        (indent-sexp endmark)
        (set-marker endmark nil))))
+ 
+ 
+ ;;;; Lisp paragraph filling commands.
+ 
+ (defun lisp-fill-paragraph (&optional justify)
+   "Like \\[fill-paragraph], but handle Emacs Lisp comments.
+ If any of the current line is a comment, fill the comment or the
+ paragraph of it that point is in, preserving the comment's indentation
+ and initial semicolons."
+   (interactive "P")
+   (let (
+ 	;; Non-nil if the current line contains a comment.
+ 	has-comment
+ 
+ 	;; If has-comment, the appropriate fill-prefix for the comment.
+ 	comment-fill-prefix
+ 	)
+ 
+     ;; Figure out what kind of comment we are looking at.
+     (save-excursion
+       (beginning-of-line)
+       (cond
+ 
+        ;; A line with nothing but a comment on it?
+        ((looking-at "[ \t]*;[; \t]*")
+ 	(setq has-comment t
+ 	      comment-fill-prefix (buffer-substring (match-beginning 0)
+ 						    (match-end 0))))
+ 
+        ;; A line with some code, followed by a comment?  Remember that the
+        ;; semi which starts the comment shouldn't be part of a string or
+        ;; character.
+        ((progn
+ 	  (while (not (looking-at ";\\|$"))
+ 	    (skip-chars-forward "^;\n\"\\\\?")
+ 	    (cond
+ 	     ((eq (char-after (point)) ?\\) (forward-char 2))
+ 	     ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1))))
+ 	  (looking-at ";+[\t ]*"))
+ 	(setq has-comment t)
+ 	(setq comment-fill-prefix
+ 	      (concat (make-string (current-column) ? )
+ 		      (buffer-substring (match-beginning 0) (match-end 0)))))))
+ 
+     (if (not has-comment)
+ 	(fill-paragraph justify)
+ 
+       ;; Narrow to include only the comment, and then fill the region.
+       (save-restriction
+ 	(narrow-to-region
+ 	 ;; Find the first line we should include in the region to fill.
+ 	 (save-excursion
+ 	   (while (and (zerop (forward-line -1))
+ 		       (looking-at "^[ \t]*;")))
+ 	   ;; We may have gone to far.  Go forward again.
+ 	   (or (looking-at "^[ \t]*;")
+ 	       (forward-line 1))
+ 	   (point))
+ 	 ;; Find the beginning of the first line past the region to fill.
+ 	 (save-excursion
+ 	   (while (progn (forward-line 1)
+ 			 (looking-at "^[ \t]*;")))
+ 	   (point)))
+ 
+ 	;; Lines with only semicolons on them can be paragraph boundaries.
+ 	(let ((paragraph-start (concat paragraph-start "\\|^[ \t;]*$"))
+ 	      (paragraph-separate (concat paragraph-start "\\|^[ \t;]*$"))
+ 	      (fill-prefix comment-fill-prefix))
+ 	  (fill-paragraph justify))))))
+ 
  
  (defun indent-code-rigidly (start end arg &optional nochange-regexp)
***************
*** 628,629 ****
--- 725,730 ----
  					  (forward-line 1) (point))
  					nil nil state))))))
+ 
+ (provide 'lisp-mode)
+ 
+ ;;; lisp-mode.el ends here
*** ../lemacs-beta6/lisp/prim/fill.el	Sat Jul 10 19:50:32 1993
--- lisp/prim/fill.el	Sat Jul 24 17:37:07 1993
***************
*** 1,5 ****
! ;; Fill commands for Emacs
! ;; Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,8 ----
! ;;; fill.el --- fill commands for Emacs
  
+ ;; Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
+ 
+ ;; Keywords: wp
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,21 ****
--- 21,30 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; All the commands for filling text.  These are documented in the Emacs
+ ;; manual.
+ 
+ ;;; Code:
  
  (defvar fill-individual-varying-indent nil
***************
*** 40,44 ****
      (message "fill-prefix cancelled")))
  
! (defvar adaptive-fill-mode nil
    "*Non-nil means determine a paragraph's fill prefix from its text.")
  
--- 49,53 ----
      (message "fill-prefix cancelled")))
  
! (defvar adaptive-fill-mode t
    "*Non-nil means determine a paragraph's fill prefix from its text.")
  
***************
*** 265,277 ****
  	    (insert " ")
  	    (skip-chars-backward " ")
! 	    (setq ncols (1- ncols))))))))
  
! (defun fill-individual-paragraphs (min max &optional justifyp mailp)
!   "Fill each paragraph in region according to its individual fill prefix.
  
! If `fill-individual-varying-indent' is non-nil,
! then a mere change in indentation does not end a paragraph.  In this mode,
! the indentation for a paragraph is the minimum indentation of any line in it.
  
  When calling from a program, pass range to fill as first two arguments.
  
--- 274,302 ----
  	    (insert " ")
  	    (skip-chars-backward " ")
! 	    (setq ncols (1- ncols)))))))
!   nil)
  
! (defun fill-nonuniform-paragraphs (min max &optional justifyp mailp)
!   "Fill paragraphs within the region, allowing varying indentation within each.
! This command divides the region into \"paragraphs\",
! only at paragraph-separator lines, then fills each paragraph
! using as the fill prefix the smallest indentation of any line
! in the paragraph.
! 
! When calling from a program, pass range to fill as first two arguments.
  
! Optional third and fourth arguments JUSTIFY-FLAG and MAIL-FLAG:
! JUSTIFY-FLAG to justify paragraphs (prefix arg),
! MAIL-FLAG for a mail message, i. e. don't fill header lines."
!   (interactive "r\nP")
!   (let ((fill-individual-varying-indent t))
!     (fill-individual-paragraphs min max justifyp mailp)))
  
+ (defun fill-individual-paragraphs (min max &optional justifyp mailp)
+   "Fill paragraphs of uniform indentation within the region.
+ This command divides the region into \"paragraphs\",
+ treating every change in indentation level as a paragraph boundary,
+ then fills each paragraph using its indentation level as the fill prefix.
+ 
  When calling from a program, pass range to fill as first two arguments.
  
***************
*** 286,290 ****
        (if mailp 
  	  (while (or (looking-at "[ \t]*[^ \t\n]*:") (looking-at "[ \t]*$"))
! 	    (forward-line 1)))
        (narrow-to-region (point) max)
        ;; Loop over paragraphs.
--- 311,315 ----
        (if mailp 
  	  (while (or (looking-at "[ \t]*[^ \t\n]*:") (looking-at "[ \t]*$"))
! 	    (search-forward "\n\n" nil 'move)))
        (narrow-to-region (point) max)
        ;; Loop over paragraphs.
***************
*** 333,334 ****
--- 358,361 ----
  	    (fill-region-as-paragraph start (point) justifyp)
  	    (or had-newline (delete-char -1))))))))
+ 
+ ;;; fill.el ends here
*** ../lemacs-beta6/lisp/prim/keydefs.el	Sat Jul 10 19:50:33 1993
--- lisp/prim/keydefs.el	Sun Jul 25 00:40:50 1993
***************
*** 249,252 ****
--- 249,253 ----
  (define-key global-map "\C-x=" 'what-cursor-position)
  (define-key global-map "\M-\e" 'eval-expression)
+ (put 'eval-expression 'disabled t)
  (define-key global-map "\C-x\e" 'repeat-complex-command)
  (define-key global-map "\C-xu" 'advertised-undo)
***************
*** 271,274 ****
--- 272,278 ----
  (define-key global-map "\C-p" 'previous-line)
  (define-key global-map "\C-x\C-n" 'set-goal-column)
+ ;;; Many people have said they rarely use this feature, and often type
+ ;;; it by accident.  Maybe it shouldn't even be on a key.
+ (put 'set-goal-column 'disabled t)
  
  (define-key global-map "\C-t" 'transpose-chars)
*** ../lemacs-beta6/lisp/prim/minibuf.el	Fri Jul 16 21:52:31 1993
--- lisp/prim/minibuf.el	Sat Jul 24 20:41:20 1993
***************
*** 103,112 ****
  (define-key minibuffer-local-must-match-map "\n" 'minibuffer-complete-and-exit)
  
- (define-key minibuffer-local-map "\M-n" 'next-history-element)
- (define-key minibuffer-local-map "\M-p" 'previous-history-element)
  (define-key minibuffer-local-map [next] 'next-history-element)
  (define-key minibuffer-local-map [prior] 'previous-history-element)
  (define-key minibuffer-local-map "\M-r" 'previous-matching-history-element)
  (define-key minibuffer-local-map "\M-s" 'next-matching-history-element)
  
  (defvar read-expression-map (let ((map (make-sparse-keymap)))
--- 103,116 ----
  (define-key minibuffer-local-must-match-map "\n" 'minibuffer-complete-and-exit)
  
  (define-key minibuffer-local-map [next] 'next-history-element)
  (define-key minibuffer-local-map [prior] 'previous-history-element)
+ (define-key minibuffer-local-map "\M-n" '[next])
+ (define-key minibuffer-local-map "\M-p" '[prior])
  (define-key minibuffer-local-map "\M-r" 'previous-matching-history-element)
  (define-key minibuffer-local-map "\M-s" 'next-matching-history-element)
+ (define-key minibuffer-local-must-match-map [next] 
+   'next-complete-history-element)
+ (define-key minibuffer-local-must-match-map [prior]
+   'previous-complete-history-element)
  
  (defvar read-expression-map (let ((map (make-sparse-keymap)))
***************
*** 113,121 ****
                                (set-keymap-parent map minibuffer-local-map)
  			      (set-keymap-name map 'read-expression-map)
                                map)
    "Minibuffer keymap used for reading Lisp expressions.")
  
- (define-key read-expression-map "\M-\t" 'lisp-complete-symbol)
- 
  (defvar read-shell-command-map
    (let ((map (make-sparse-keymap)))
--- 117,124 ----
                                (set-keymap-parent map minibuffer-local-map)
  			      (set-keymap-name map 'read-expression-map)
+                               (define-key map "\M-\t" 'lisp-complete-symbol)
                                map)
    "Minibuffer keymap used for reading Lisp expressions.")
  
  (defvar read-shell-command-map
    (let ((map (make-sparse-keymap)))
***************
*** 876,879 ****
--- 879,898 ----
    (next-history-element (- n)))
  
+ (defun next-complete-history-element (n)
+   "\
+ Get previous element of history which is a completion of minibuffer contents."
+   (interactive "p")
+   (let ((point-at-start (point)))
+     (next-matching-history-element
+      (concat "^" (regexp-quote (buffer-substring (point-min) (point)))) n)
+     ;; next-matching-history-element always puts us at (point-min).
+     ;; Move to the position we were at before changing the buffer contents.
+     ;; This is still sensical, because the text before point has not changed.
+     (goto-char point-at-start)))
+ 
+ (defun previous-complete-history-element (n)
+   "Get next element of history which is a completion of minibuffer contents."
+   (interactive "p")
+   (next-complete-history-element (- n)))
  
  ;;;; reading various things from a minibuffer
*** ../lemacs-beta6/lisp/prim/lisp.el	Sat Jul 10 19:50:33 1993
--- lisp/prim/lisp.el	Sat Jul 24 23:19:42 1993
***************
*** 1,5 ****
! ;; Lisp editing commands for Emacs
! ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,9 ----
! ;;; lisp.el --- Lisp editing commands for Emacs
  
+ ;; Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
+ 
+ ;; Maintainer: FSF
+ ;; Keywords: lisp, languages
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 6,10 ****
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 1, or (at your option)
  ;; any later version.
  
--- 10,14 ----
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 2, or (at your option)
  ;; any later version.
  
***************
*** 18,25 ****
--- 22,37 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; Lisp editing commands to go with Lisp major mode.
  
+ ;;; Code:
+ 
  (defvar defun-prompt-regexp nil
    "Non-nil => regexp to ignore, before the `(' that starts a defun.")
  
+ (defvar parens-require-spaces t
+   "Non-nil => `insert-parentheses' should insert whitespace as needed.")
+ 
  (defun forward-sexp (&optional arg)
    "Move forward across one balanced expression (sexp).
***************
*** 26,33 ****
  With argument, do it that many times.
  Negative arg -N means move backward across N balanced expressions."
!   (interactive "p")
    (or arg (setq arg 1))
    (goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
-   (setq zmacs-region-stays t)
    (if (< arg 0) (backward-prefix-chars)))
  
--- 38,44 ----
  With argument, do it that many times.
  Negative arg -N means move backward across N balanced expressions."
!   (interactive "_p")
    (or arg (setq arg 1))
    (goto-char (or (scan-sexps (point) arg) (buffer-end arg)))
    (if (< arg 0) (backward-prefix-chars)))
  
***************
*** 36,42 ****
  With argument, do it that many times.
  Negative arg -N means move forward across N balanced expressions."
!   (interactive "p")
    (or arg (setq arg 1))
-   (setq zmacs-region-stays t)
    (forward-sexp (- arg)))
  
--- 47,52 ----
  With argument, do it that many times.
  Negative arg -N means move forward across N balanced expressions."
!   (interactive "_p")
    (or arg (setq arg 1))
    (forward-sexp (- arg)))
  
***************
*** 49,54 ****
      (save-excursion
        (forward-sexp arg)
!       (point)))
!   (zmacs-activate-region))
  
  (defun forward-list (&optional arg)
--- 59,65 ----
      (save-excursion
        (forward-sexp arg)
!       (point))
!     nil
!     t))
  
  (defun forward-list (&optional arg)
***************
*** 56,62 ****
  With argument, do it that many times.
  Negative arg -N means move backward across N groups of parentheses."
!   (interactive "p")
    (or arg (setq arg 1))
-   (setq zmacs-region-stays t)
    (goto-char (or (scan-lists (point) arg 0) (buffer-end arg))))
  
--- 67,72 ----
  With argument, do it that many times.
  Negative arg -N means move backward across N groups of parentheses."
!   (interactive "_p")
    (or arg (setq arg 1))
    (goto-char (or (scan-lists (point) arg 0) (buffer-end arg))))
  
***************
*** 65,71 ****
  With argument, do it that many times.
  Negative arg -N means move forward across N groups of parentheses."
!   (interactive "p")
    (or arg (setq arg 1))
-   (setq zmacs-region-stays t)
    (forward-list (- arg)))
  
--- 75,80 ----
  With argument, do it that many times.
  Negative arg -N means move forward across N groups of parentheses."
!   (interactive "_p")
    (or arg (setq arg 1))
    (forward-list (- arg)))
  
***************
*** 75,80 ****
  A negative argument means move backward but still go down a level.
  In Lisp programs, an argument is required."
!   (interactive "p")
!   (setq zmacs-region-stays t)
    (let ((inc (if (> arg 0) 1 -1)))
      (while (/= arg 0)
--- 84,88 ----
  A negative argument means move backward but still go down a level.
  In Lisp programs, an argument is required."
!   (interactive "_p")
    (let ((inc (if (> arg 0) 1 -1)))
      (while (/= arg 0)
***************
*** 95,100 ****
  A negative argument means move backward but still to a less deep spot.
  In Lisp programs, an argument is required."
!   (interactive "p")
!   (setq zmacs-region-stays t)
    (let ((inc (if (> arg 0) 1 -1)))
      (while (/= arg 0)
--- 103,107 ----
  A negative argument means move backward but still to a less deep spot.
  In Lisp programs, an argument is required."
!   (interactive "_p")
    (let ((inc (if (> arg 0) 1 -1)))
      (while (/= arg 0)
***************
*** 128,133 ****
  non-nil, then a string which matches that regexp may precede the
  open-parenthesis."
!   (interactive "p")
!   (setq zmacs-region-stays t)
    (and arg (< arg 0) (forward-char 1))
    (and (re-search-backward (if defun-prompt-regexp
--- 135,139 ----
  non-nil, then a string which matches that regexp may precede the
  open-parenthesis."
!   (interactive "_p")
    (and arg (< arg 0) (forward-char 1))
    (and (re-search-backward (if defun-prompt-regexp
***************
*** 147,152 ****
  An end of a defun occurs right after the close-parenthesis that matches
  the open-parenthesis that starts a defun; see `beginning-of-defun'."
!   (interactive "p")
!   (setq zmacs-region-stays t)
    (if (or (null arg) (= arg 0)) (setq arg 1))
    (let ((first t))
--- 153,157 ----
  An end of a defun occurs right after the close-parenthesis that matches
  the open-parenthesis that starts a defun; see `beginning-of-defun'."
!   (interactive "_p")
    (if (or (null arg) (= arg 0)) (setq arg 1))
    (let ((first t))
***************
*** 189,216 ****
    (push-mark (point))
    (end-of-defun)
!   (push-mark (point))
    (beginning-of-defun)
!   (re-search-backward "^\n" (- (point) 1) t)
!   (zmacs-activate-region))
  
  (defun insert-parentheses (arg)
    "Put parentheses around next ARG sexps.  Leave point after open-paren.
! No argument is equivalent to zero: just insert () and leave point between."
    (interactive "P")
!   (if arg (skip-chars-forward " \t"))
!   (and (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
         (insert " "))
- ;    (or (memq (char-syntax (preceding-char)) '(?\  ?> ?\( ))
- ;	(insert " ")))
    (insert ?\()
    (save-excursion
!     (if arg
! 	(forward-sexp (prefix-numeric-value arg)))
      (insert ?\))
! ;    (or (memq (char-syntax (following-char)) '(?\  ?> ?\( ))
! ;	(insert " "))
!   (and (memq (char-syntax (following-char)) '(?w ?_ ?\( ))
!        (insert " "))
!   ))
  
  (defun move-past-close-and-reindent ()
--- 194,219 ----
    (push-mark (point))
    (end-of-defun)
!   (push-mark (point) nil t)
    (beginning-of-defun)
!   (re-search-backward "^\n" (- (point) 1) t))
  
  (defun insert-parentheses (arg)
    "Put parentheses around next ARG sexps.  Leave point after open-paren.
! No argument is equivalent to zero: just insert `()' and leave point between.
! This command also sometimes inserts a space before and after,
! depending on the surrounding characters."
    (interactive "P")
!   (setq arg (if arg (prefix-numeric-value arg) 0))
!   (or (eq arg 0) (skip-chars-forward " \t"))
!   (and parens-require-spaces
!        (memq (char-syntax (preceding-char)) '(?w ?_ ?\) ))
         (insert " "))
    (insert ?\()
    (save-excursion
!     (or (eq arg 0) (forward-sexp arg))
      (insert ?\))
!   (and parens-require-spaces
!        (memq (char-syntax (following-char)) '(?w ?_ ?\( ))
!        (insert " "))))
  
  (defun move-past-close-and-reindent ()
***************
*** 241,246 ****
  	 (beg (unwind-protect
  		  (save-excursion
! 		    (if lisp-mode-syntax-table
! 			(set-syntax-table lisp-mode-syntax-table))
  		    (backward-sexp 1)
  		    (while (= (char-syntax (following-char)) ?\')
--- 244,249 ----
  	 (beg (unwind-protect
  		  (save-excursion
! 		    (if emacs-lisp-mode-syntax-table
! 			(set-syntax-table emacs-lisp-mode-syntax-table))
  		    (backward-sexp 1)
  		    (while (= (char-syntax (following-char)) ?\')
***************
*** 278,279 ****
--- 281,284 ----
  	       (display-completion-list list)))
  	   (message "Making completion list...%s" "done")))))
+ 
+ ;;; lisp.el ends here
*** ../lemacs-beta6/lisp/prim/replace.el	Fri Jul 16 21:52:33 1993
--- lisp/prim/replace.el	Sun Jul 25 15:58:46 1993
***************
*** 1,5 ****
! ;; Replace commands for Emacs.
! ;; Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,6 ----
! ;;; replace.el --- replace commands for Emacs.
  
+ ;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,32 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
! (defvar minibuffer-regexp-history nil)
  
! (fset 'delete-non-matching-lines 'keep-lines)
! (defun keep-lines (regexp)
    "Delete all lines except those containing matches for REGEXP.
  A match split across lines preserves all the lines it lies in.
  Applies to all lines after point."
! ;;  (interactive "sKeep lines (containing match for regexp): ")
!   (interactive (list (read-string "Keep lines (containing match for regexp): "
! 				  nil 'minibuffer-regexp-history)))
    (save-excursion
      (or (bolp) (forward-line 1))
--- 19,160 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; This package supplies the string and regular-expression replace functions
+ ;; documented in the Emacs user's manual.
+ 
+ ;;; Code:
+ 
+ ;; in loaddefs
+ ;(defvar case-replace t "\
+ ;*Non-nil means query-replace should preserve case in replacements.")
+ 
+ (defvar query-replace-history nil)
+ 
+ (defun query-replace-read-args (string)
+   (let (from to)
+     (setq from (read-from-minibuffer (format "%s: " string)
+ 				     nil nil nil
+ 				     'query-replace-history))
+     (setq to (read-from-minibuffer (format "%s %s with: " string from)
+ 				   nil nil nil
+ 				   'query-replace-history))
+     (list from to current-prefix-arg)))
+ 
+ (defun query-replace (from-string to-string &optional arg)
+   "Replace some occurrences of FROM-STRING with TO-STRING.
+ As each match is found, the user must type a character saying
+ what to do with it.  For directions, type \\[help-command] at that time.
+ 
+ Preserves case in each replacement if  case-replace  and  case-fold-search
+ are non-nil and FROM-STRING has no uppercase letters.
+ Third arg DELIMITED (prefix arg if interactive) non-nil means replace
+ only matches surrounded by word boundaries.
+ 
+ To customize possible responses, change the \"bindings\" in `query-replace-map'."
+   (interactive (query-replace-read-args "Query replace"))
+   (perform-replace from-string to-string t nil arg)
+   (or unread-command-event (message "Done")))
+ 
+ (defun query-replace-regexp (regexp to-string &optional arg)
+   "Replace some things after point matching REGEXP with TO-STRING.
+ As each match is found, the user must type a character saying
+ what to do with it.  For directions, type \\[help-command] at that time.
+ 
+ Preserves case in each replacement if  case-replace  and  case-fold-search
+ are non-nil and REGEXP has no uppercase letters.
+ Third arg DELIMITED (prefix arg if interactive) non-nil means replace
+ only matches surrounded by word boundaries.
+ In TO-STRING, \\& means insert what matched REGEXP,
+ and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP."
+   (interactive (query-replace-read-args "Query replace regexp"))
+   (perform-replace regexp to-string t t arg)
+   (or unread-command-event (message "Done")))
+ 
+ ;;>>> Not patently useful
+ (defun map-query-replace-regexp (regexp to-strings &optional arg)
+   "Replace some matches for REGEXP with various strings, in rotation.
+ The second argument TO-STRINGS contains the replacement strings, separated
+ by spaces.  This command works like `query-replace-regexp' except
+ that each successive replacement uses the next successive replacement string,
+ wrapping around from the last such string to the first.
+ 
+ Non-interactively, TO-STRINGS may be a list of replacement strings.
+ 
+ A prefix argument N says to use each replacement string N times
+ before rotating to the next."
+   (interactive
+    (let (from to)
+      (setq from (read-from-minibuffer "Map query replace (regexp): "
+ 				      nil nil nil
+ 				      'query-replace-history))
+      (setq to (read-from-minibuffer
+ 	       (format "Query replace %s with (space-separated strings): "
+ 		       from)
+ 	       nil nil nil
+ 	       'query-replace-history))
+      (list from to current-prefix-arg)))
+   (let (replacements)
+     (if (listp to-strings)
+ 	(setq replacements to-strings)
+       (while (/= (length to-strings) 0)
+ 	(if (string-match " " to-strings)
+ 	    (setq replacements
+ 		  (append replacements
+ 			  (list (substring to-strings 0
+ 					   (string-match " " to-strings))))
+ 		  to-strings (substring to-strings
+ 				       (1+ (string-match " " to-strings))))
+ 	  (setq replacements (append replacements (list to-strings))
+ 		to-strings ""))))
+    (perform-replace regexp replacements t t nil arg))
+   (or unread-command-event (message "Done")))
+ 
+ (defun replace-string (from-string to-string &optional delimited)
+   "Replace occurrences of FROM-STRING with TO-STRING.
+ Preserve case in each match if `case-replace' and `case-fold-search'
+ are non-nil and FROM-STRING has no uppercase letters.
+ Third arg DELIMITED (prefix arg if interactive) non-nil means replace
+ only matches surrounded by word boundaries.
+ 
+ This function is usually the wrong thing to use in a Lisp program.
+ What you probably want is a loop like this:
+   (while (search-forward OLD-STRING nil t)
+     (replace-match REPLACEMENT nil t))
+ which will run faster and will not set the mark or print anything."
+   (interactive (query-replace-read-args "Replace string"))
+   (perform-replace from-string to-string nil nil delimited)
+   (or unread-command-event (message "Done")))
+ 
+ (defun replace-regexp (regexp to-string &optional delimited)
+   "Replace things after point matching REGEXP with TO-STRING.
+ Preserve case in each match if case-replace and case-fold-search
+ are non-nil and REGEXP has no uppercase letters.
+ Third arg DELIMITED (prefix arg if interactive) non-nil means replace
+ only matches surrounded by word boundaries.
+ In TO-STRING, \\& means insert what matched REGEXP,
+ and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP.
+ 
+ This function is usually the wrong thing to use in a Lisp program.
+ What you probably want is a loop like this:
+   (while (re-search-forward REGEXP nil t)
+     (replace-match REPLACEMENT nil nil))
+ which will run faster and will not set the mark or print anything."
+   (interactive (query-replace-read-args "Replace regexp"))
+   (perform-replace regexp to-string nil t delimited)
+   (or unread-command-event (message "Done")))
  
! 
! (defvar regexp-history nil
!   "History list for some commands that read regular expressions.")
  
! (define-function 'keep-lines 'delete-non-matching-lines)
! (defun delete-non-matching-lines (regexp)
    "Delete all lines except those containing matches for REGEXP.
  A match split across lines preserves all the lines it lies in.
  Applies to all lines after point."
!   (interactive (list (read-from-minibuffer
! 		      "Keep lines (containing match for regexp): "
! 		      nil nil nil 'regexp-history)))
    (save-excursion
      (or (bolp) (forward-line 1))
***************
*** 48,59 ****
  	     (forward-char 1))))))
  
! (fset 'delete-matching-lines 'flush-lines)
! (defun flush-lines (regexp)
    "Delete lines containing matches for REGEXP.
  If a match is split across lines, all the lines it lies in are deleted.
  Applies to lines after point."
! ;;  (interactive "sFlush lines (containing match for regexp): ")
!   (interactive (list (read-string "Flush lines (containing match for regexp): "
! 				  nil 'minibuffer-regexp-history)))
    (save-excursion
      (while (and (not (eobp))
--- 176,187 ----
  	     (forward-char 1))))))
  
! (define-function 'flush-lines 'delete-matching-lines)
! (defun delete-matching-lines (regexp)
    "Delete lines containing matches for REGEXP.
  If a match is split across lines, all the lines it lies in are deleted.
  Applies to lines after point."
!   (interactive (list (read-from-minibuffer
! 		      "Flush lines (containing match for regexp): "
! 		      nil nil nil 'regexp-history)))
    (save-excursion
      (while (and (not (eobp))
***************
*** 64,73 ****
  		     (progn (forward-line 1) (point))))))
  
! (fset 'count-matches 'how-many)
! (defun how-many (regexp)
    "Print number of matches for REGEXP following point."
! ;;  (interactive "sHow many matches for (regexp): ")
!   (interactive (list (read-string "How many matches for (regexp): "
! 			    nil 'minibuffer-regexp-history)))
    (let ((count 0) opoint)
      (save-excursion
--- 192,201 ----
  		     (progn (forward-line 1) (point))))))
  
! (define-function 'how-many 'count-matches)
! (defun count-matches (regexp)
    "Print number of matches for REGEXP following point."
!   (interactive (list (read-from-minibuffer
! 		      "How many matches for (regexp): "
! 		      nil nil nil 'regexp-history)))
    (let ((count 0) opoint)
      (save-excursion
***************
*** 80,83 ****
--- 208,212 ----
       (message "%d occurrences" count))))
  
+ 
  (defvar occur-mode-map ())
  (if occur-mode-map
***************
*** 84,87 ****
--- 213,217 ----
      ()
    (setq occur-mode-map (make-sparse-keymap))
+   (set-keymap-name occur-mode-map 'occur-mode-map)
    (define-key occur-mode-map "\C-c\C-c" 'occur-mode-goto-occurrence)
    (define-key occur-mode-map 'button2 'occur-mouse-goto))
***************
*** 90,94 ****
  (defvar occur-nlines nil)
  (defvar occur-pos-list nil)
- (defvar occur-last-string "")
  
  (defun occur-mode ()
--- 220,223 ----
***************
*** 137,145 ****
      (goto-char (marker-position pos))))
  
  (defvar list-matching-lines-default-context-lines 0
!   "*Default number of context lines to include around a list-matching-lines
  match.  A negative number means to include that many lines before the match.
  A positive number means to include that many lines both before and after.")
  
  (defvar occur-whole-buffer nil
    "If t, occur operates on whole buffer, otherwise occur starts from point.
--- 266,276 ----
      (goto-char (marker-position pos))))
  
+ 
  (defvar list-matching-lines-default-context-lines 0
!   "*Default number of context lines to include around a `list-matching-lines'
  match.  A negative number means to include that many lines before the match.
  A positive number means to include that many lines both before and after.")
  
+ ;;>>> Should be named list-matching-lines-whole-buffer
  (defvar occur-whole-buffer nil
    "If t, occur operates on whole buffer, otherwise occur starts from point.
***************
*** 146,169 ****
  default is nil.")
  
! (fset 'list-matching-lines 'occur)
  
! (defun occur (regexp &optional nlines)
!   "Show lines containing a match for REGEXP.  If the global variable
! occur-whole-buffer is non-nil, the entire buffer is searched, otherwise
! search begins at point.  Interactively, REGEXP defaults to the last REGEXP
! used interactively.
  
  Each line is displayed with NLINES lines before and after,
  or -NLINES before if NLINES is negative.
! NLINES defaults to list-matching-lines-default-context-lines.
  Interactively it is the prefix arg.
  
! The lines are shown in a buffer named *Occur*.
  It serves as a menu to find any of the occurrences in this buffer.
  \\[describe-mode] in that buffer will explain how."
!   (interactive (list (setq occur-last-string
! 			   (read-string "List lines matching regexp: "
! 					occur-last-string
! 					'minibuffer-regexp-history))
  		     current-prefix-arg))
    (setq nlines (if nlines (prefix-numeric-value nlines)
--- 277,306 ----
  default is nil.")
  
! (define-function 'occur 'list-matching-lines)
! (defun list-matching-lines (regexp &optional nlines)
!   "Show all lines in the current buffer containing a match for REGEXP.
  
! If a match spreads across multiple lines, all those lines are shown.
  
+ If variable `occur-whole-buffer' is non-nil, the entire buffer is
+ searched, otherwise search begins at point.
+ 
  Each line is displayed with NLINES lines before and after,
  or -NLINES before if NLINES is negative.
! NLINES defaults to `list-matching-lines-default-context-lines'.
  Interactively it is the prefix arg.
  
! The lines are shown in a buffer named `*Occur*'.
  It serves as a menu to find any of the occurrences in this buffer.
  \\[describe-mode] in that buffer will explain how."
!   (interactive (list (let* ((default (car regexp-history))
! 			    (input 
! 			     (read-from-minibuffer
! 			      (format "List lines matching regexp (default `%s'): " default)
! 			      nil nil nil
! 			      'regexp-history)))
! 		       (if (> (length input) 0) 
!                            input
!                            (setcar regexp-history default)))
  		     current-prefix-arg))
    (setq nlines (if nlines (prefix-numeric-value nlines)
***************
*** 172,176 ****
  	(buffer (current-buffer))
  	(linenum 1)
! 	(prevpos (point-min)))
      (if (not occur-whole-buffer)
  	(save-excursion
--- 309,314 ----
  	(buffer (current-buffer))
  	(linenum 1)
! 	(prevpos (point-min))
!         (final-context-start (make-marker)))
      (if (not occur-whole-buffer)
  	(save-excursion
***************
*** 196,206 ****
  	(while (and (not (= prevpos (point-max)))
  		    (re-search-forward regexp nil t))
  	  (beginning-of-line)
! 	  (setq linenum (+ linenum (count-lines prevpos (point))))
  	  (setq prevpos (point))
  	  (let* ((start (save-excursion
  			  (forward-line (if (< nlines 0) nlines (- nlines)))
  			  (point)))
  		 (end (save-excursion
  			(if (> nlines 0)
  			    (forward-line (1+ nlines))
--- 334,349 ----
  	(while (and (not (= prevpos (point-max)))
  		    (re-search-forward regexp nil t))
+ 	  (goto-char (match-beginning 0))
  	  (beginning-of-line)
! 	  (save-match-data
!             (setq linenum (+ linenum (count-lines prevpos (point)))))
  	  (setq prevpos (point))
+ 	  (goto-char (match-end 0))
  	  (let* ((start (save-excursion
+ 			  (goto-char (match-beginning 0))
                            (forward-line (if (< nlines 0) nlines (- nlines)))
  			  (point)))
  		 (end (save-excursion
+ 			(goto-char (match-end 0))
  			(if (> nlines 0)
  			    (forward-line (1+ nlines))
***************
*** 225,230 ****
--- 368,381 ----
  		(forward-line 1)
  		(setq tem (1- tem)))
+ 	      (let ((this-linenum linenum))
+ 		(set-marker final-context-start
+ 			    (+ (point) (- (match-end 0) (match-beginning 0))))
+ 		(while (< (point) final-context-start)
+ 		  (if (null tag)
+ 		      (setq tag (format "%3d" this-linenum)))
  		  (insert tag ?:)
+ 		  (setq tag nil)
  		  (forward-line 1)
+ 		  (setq this-linenum (1+ this-linenum))))
  	      (while (< tem nlines)
  		(insert empty ?:)
***************
*** 238,242 ****
  	    (message "%d matching lines." (length occur-pos-list)))))))
  
! (defconst query-replace-help
    "Type Space or `y' to replace one match, Delete or `n' to skip to next,
  ESC or `q' to exit, Period to replace one match and exit,
--- 389,395 ----
  	    (message "%d matching lines." (length occur-pos-list)))))))
  
! ;; It would be nice to use \\[...], but there is no reasonable way
! ;; to make that display both SPC and Y.
! (defvar query-replace-help (purecopy
    "Type Space or `y' to replace one match, Delete or `n' to skip to next,
  ESC or `q' to exit, Period to replace one match and exit,
***************
*** 246,252 ****
  C-l to clear the screen, redisplay, and offer same replacement again,
  ! to replace all remaining matches with no more questions,
! ^ to move point back to previous match."
    "Help message while in query-replace")
  
  (autoload 'isearch-highlight "isearch")
  
--- 399,440 ----
  C-l to clear the screen, redisplay, and offer same replacement again,
  ! to replace all remaining matches with no more questions,
! ^ to move point back to previous match.")
    "Help message while in query-replace")
  
+ (defvar	query-replace-map nil
+   "Keymap that defines the responses to questions in `query-replace'.
+ The \"bindings\" in this map are not commands; they are answers.
+ The valid answers include `act', `skip', `act-and-show',
+ `exit', `act-and-exit', `edit', `delete-and-edit', `recenter',
+ `automatic', `backup', and `help'.")
+ 
+ (if query-replace-map
+     nil
+     (let ((map (make-sparse-keymap)))
+       (set-keymap-name map 'query-replace-map)
+       (define-key map " " 'act)
+       (define-key map "\d" 'skip)
+       (define-key map [delete] 'skip)
+       (define-key map [backspace] 'skip)
+       (define-key map "y" 'act)
+       (define-key map "n" 'skip)
+       (define-key map "," 'act-and-show)
+       (define-key map [escape] 'exit)
+       (define-key map "q" 'exit)
+       (define-key map [return] 'exit)
+       (define-key map "." 'act-and-exit)
+       (define-key map "\C-r" 'edit)
+       (define-key map "\C-w" 'delete-and-edit)
+       (define-key map "\C-l" 'recenter)
+       (define-key map "!" 'automatic)
+       (define-key map "^" 'backup)
+       (define-key map "\C-h" 'help)
+       (define-key map "?" 'help)
+       (define-key map "\C-g" 'quit)
+       (define-key map "\C-]" 'quit)
+       
+       (setq query-replace-map map)))
+ 
+ 
  (autoload 'isearch-highlight "isearch")
  
***************
*** 264,268 ****
  (defun perform-replace (from-string replacements
  		        query-flag regexp-flag delimited-flag
! 			&optional repeat-count)
    "Subroutine of `query-replace'.  Its complexity handles interactive queries.
  Don't use this in your own program unless you want to query and set the mark
--- 452,456 ----
  (defun perform-replace (from-string replacements
  		        query-flag regexp-flag delimited-flag
! 			&optional repeat-count map)
    "Subroutine of `query-replace'.  Its complexity handles interactive queries.
  Don't use this in your own program unless you want to query and set the mark
***************
*** 271,276 ****
      (replace-match \"foobar\" nil nil))
  which will run faster and do exactly what you probably want."
!   (let ((char nil)
! 	(event (allocate-event))
  	(nocasify (not (and case-fold-search case-replace
  			    (string-equal from-string
--- 459,464 ----
      (replace-match \"foobar\" nil nil))
  which will run faster and do exactly what you probably want."
!   (or map (setq map query-replace-map))
!   (let ((event (allocate-event))
  	(nocasify (not (and case-fold-search case-replace
  			    (string-equal from-string
***************
*** 279,282 ****
--- 467,471 ----
  	(search-function (if regexp-flag 're-search-forward 'search-forward))
  	(search-string from-string)
+ 	(real-match-data nil)		; the match data for the current match
  	(next-replacement nil)
  	(replacement-index 0)
***************
*** 285,289 ****
  	(next-rotate-count 0)
  	(replace-count 0)
! 	(lastrepl nil))			;Position after last match considered.
      (if (stringp replacements)
  	(setq next-replacement replacements)
--- 474,479 ----
  	(next-rotate-count 0)
  	(replace-count 0)
! 	(lastrepl nil)			;Position after last match considered.
! 	(match-again t))
      (if (stringp replacements)
  	(setq next-replacement replacements)
***************
*** 297,305 ****
      (push-mark)
      (undo-boundary)
      (while (and keep-going
  		(not (eobp))
  		(funcall search-function search-string nil t)
! 		(if (eq lastrepl (point))
! 		    (progn 
  		      ;; Don't replace the null string 
  		      ;; right after end of previous replacement.
--- 487,504 ----
      (push-mark)
      (undo-boundary)
+     ;; Loop finding occurrences that perhaps should be replaced.
      (while (and keep-going
  		(not (eobp))
  		(funcall search-function search-string nil t)
! 		;; If the search string matches immediately after
! 		;; the previous match, but it did not match there
! 		;; before the replacement was done, ignore the match.
! 		(if (or (eq lastrepl (point))
! 			(and regexp-flag
! 			     (eq lastrepl (match-beginning 0))
! 			     (not match-again)))
! 
! 		    (if (eobp)
! 			nil
  		      ;; Don't replace the null string 
  		      ;; right after end of previous replacement.
***************
*** 307,310 ****
--- 506,517 ----
  		      (funcall search-function search-string nil t))
  		  t))
+       ;; Save the data associated with the real match.
+       (setq real-match-data (match-data))
+ 
+       ;; Before we make the replacement, decide whether the search string
+       ;; can match again just after this match.
+       (if regexp-flag
+ 	  (setq match-again (looking-at search-string)))
+ 
        ;; If time for a change, advance to next replacement string.
        (if (and (listp replacements)
***************
*** 317,349 ****
        (if (not query-flag)
  	  (progn
  	    (replace-match next-replacement nocasify literal)
  	    (setq replace-count (1+ replace-count)))
  	(undo-boundary)
! 	(let (done replaced)
! 	  (while (not done)
! 	    ;; Preserve the match data.  Process filters and sentinels
! 	    ;; could run inside read-char..
! 	    (let ((data (match-data))
! 		  (help-form
! 		   '(concat "Query replacing "
  			    (if regexp-flag "regexp " "")
  			    from-string " with " next-replacement ".\n\n"
! 			    (substitute-command-keys query-replace-help))))
! 	      (setq char help-char)
! 	      (while (or (not (numberp char)) (= char help-char))
! 		(message "Query replacing %s with %s: " from-string next-replacement)
! 		(perform-replace-next-event event)
! 		
! 		(setq char (or (event-to-character event) event))
! 		(if (and (numberp char) (= char ??))
! 		    (setq unread-command-event
! 			   (character-to-event help-char (allocate-event))
! 			  char help-char)))
! 	      (store-match-data data))
! 	    (cond ((or (= char ?\e)
! 		       (= char ?q))
  		   (setq keep-going nil)
  		   (setq done t))
! 		  ((= char ?^)
  		   (let ((elt (car stack)))
  		     (goto-char (car elt))
--- 524,560 ----
        (if (not query-flag)
  	  (progn
+ 	    (store-match-data real-match-data)
  	    (replace-match next-replacement nocasify literal)
  	    (setq replace-count (1+ replace-count)))
  	(undo-boundary)
! 	(let ((help-form '(concat "Query replacing "
                             (if regexp-flag "regexp " "")
                             from-string " with " next-replacement ".\n\n"
!                            (substitute-command-keys query-replace-help)))
!               (done nil)
!               (replaced nil)
!               def)
!           ;; Loop reading commands until one of them sets done,
! 	  ;; which means it has finished handling this occurrence.
! 	  (while (not done)
!             (message "Query replacing %s with %s: "
!                      from-string next-replacement)
!             (perform-replace-next-event event))
!             (setq def (lookup-key (vector event) map))
! 	    ;; Restore the match data while we process the command.
!             (store-match-data real-match-data)
! 	    (cond ((eq def 'help)
! 		   (with-output-to-temp-buffer "*Help*"
! 		     (princ
! 		      (concat "Query replacing "
! 			      (if regexp-flag "regexp " "")
! 			      from-string " with "
! 			      next-replacement ".\n\n"
! 			      (substitute-command-keys
! 			       query-replace-help)))))
! 		  ((eq def 'exit)
  		   (setq keep-going nil)
  		   (setq done t))
! 		  ((eq def 'backup)
  		   (let ((elt (car stack)))
  		     (goto-char (car elt))
***************
*** 352,361 ****
  			 (store-match-data (cdr elt)))
  		     (setq stack (cdr stack))))		     
! 		  ((or (= char ?\ )
! 		       (= char ?y))
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
  		   (setq done t replaced t))
! 		  ((= char ?\.)
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
--- 563,571 ----
  			 (store-match-data (cdr elt)))
  		     (setq stack (cdr stack))))		     
! 		  ((eq def 'act)
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
  		   (setq done t replaced t))
! 		  ((eq def 'act-and-exit)
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
***************
*** 362,366 ****
  		   (setq keep-going nil)
  		   (setq done t replaced t))
! 		  ((= char ?\,)
  		   (if (not replaced)
  		       (progn
--- 572,576 ----
  		   (setq keep-going nil)
  		   (setq done t replaced t))
! 		  ((eq def 'act-and-show)
  		   (if (not replaced)
  		       (progn
***************
*** 367,387 ****
  			 (replace-match next-replacement nocasify literal)
  			 (setq replaced t))))
! 		  ((= char ?!)
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
  		   (setq done t query-flag nil replaced t))
! 		  ((or (= char ?\177)
! 		       (= char ?n))
  		   (setq done t))
! 		  ((= char ?\C-l)
  		   (recenter nil))
! 		  ((= char ?\C-r)
  		   (store-match-data
  		    (prog1 (match-data)
! 		      (save-excursion (recursive-edit)))))
! 		  ((= char ?\C-w)
  		   (delete-region (match-beginning 0) (match-end 0))
! 		   (store-match-data
! 		    (prog1 (match-data)
  		      (save-excursion (recursive-edit))))
  		   (setq replaced t))
--- 577,600 ----
  			 (replace-match next-replacement nocasify literal)
  			 (setq replaced t))))
! 		  ((eq def 'automatic)
  		   (or replaced
  		       (replace-match next-replacement nocasify literal))
  		   (setq done t query-flag nil replaced t))
! 		  ((eq def 'skip)
  		   (setq done t))
! 		  ((eq def 'recenter)
  		   (recenter nil))
! 		  ((eq def 'edit)
  		   (store-match-data
  		    (prog1 (match-data)
! 		      (save-excursion (recursive-edit))))
! 		   ;; Before we make the replacement,
! 		   ;; decide whether the search string
! 		   ;; can match again just after this match.
! 		   (if regexp-flag
! 		       (setq match-again (looking-at search-string))))
! 		  ((eq def 'delete-and-edit)
  		   (delete-region (match-beginning 0) (match-end 0))
! 		   (store-match-data (prog1 (match-data)
                                         (save-excursion (recursive-edit))))
  		   (setq replaced t))
***************
*** 389,393 ****
  		   (setq keep-going nil)
  		   (setq unread-command-event event)
! 		   (setq done t))))
  	  ;; Record previous position for ^ when we move on.
  	  ;; Change markers to numbers in the match data
--- 602,606 ----
  		   (setq keep-going nil)
  		   (setq unread-command-event event)
! 		   (setq done t)))
              ;; Record previous position for ^ when we move on.
              ;; Change markers to numbers in the match data
***************
*** 407,497 ****
      (and keep-going stack)))
  
! (defun query-replace (from-string to-string &optional arg)
!   "Replace some occurrences of FROM-STRING with TO-STRING.
! As each match is found, the user must type a character saying
! what to do with it.  For directions, type \\[help-command] at that time.
! 
! Preserves case in each replacement if  case-replace  and  case-fold-search
! are non-nil and FROM-STRING has no uppercase letters.
! Third arg DELIMITED (prefix arg if interactive) non-nil means replace
! only matches surrounded by word boundaries."
!   (interactive "sQuery replace: \nsQuery replace %s with: \nP")
!   (perform-replace from-string to-string t nil arg)
!   (message "Done"))
! 
! (defun query-replace-regexp (regexp to-string &optional arg)
!   "Replace some things after point matching REGEXP with TO-STRING.
! As each match is found, the user must type a character saying
! what to do with it.  For directions, type \\[help-command] at that time.
! 
! Preserves case in each replacement if  case-replace  and  case-fold-search
! are non-nil and REGEXP has no uppercase letters.
! Third arg DELIMITED (prefix arg if interactive) non-nil means replace
! only matches surrounded by word boundaries.
! In TO-STRING, \\& means insert what matched REGEXP,
! and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP."
!   (interactive "sQuery replace regexp: \nsQuery replace regexp %s with: \nP")
!   (perform-replace regexp to-string t t arg)
!   (message "Done"))
! 
! (defun replace-string (from-string to-string &optional delimited)
!   "Replace occurrences of FROM-STRING with TO-STRING.
! Preserve case in each match if `case-replace' and `case-fold-search'
! are non-nil and FROM-STRING has no uppercase letters.
! Third arg DELIMITED (prefix arg if interactive) non-nil means replace
! only matches surrounded by word boundaries.
! 
! This function is usually the wrong thing to use in a Lisp program.
! What you probably want is a loop like this:
!   (while (search-forward OLD-STRING nil t)
!     (replace-match REPLACEMENT nil t))
! which will run faster and will not set the mark or print anything."
!   (interactive "sReplace string: \nsReplace string %s with: \nP")
!   (perform-replace from-string to-string nil nil delimited)
!   (message "Done"))
! 
! (defun replace-regexp (regexp to-string &optional delimited)
!   "Replace things after point matching REGEXP with TO-STRING.
! Preserve case in each match if case-replace and case-fold-search
! are non-nil and REGEXP has no uppercase letters.
! Third arg DELIMITED (prefix arg if interactive) non-nil means replace
! only matches surrounded by word boundaries.
! In TO-STRING, \\& means insert what matched REGEXP,
! and \\=\\<n> means insert what matched <n>th \\(...\\) in REGEXP.
! 
! This function is usually the wrong thing to use in a Lisp program.
! What you probably want is a loop like this:
!   (while (re-search-forward REGEXP nil t)
!     (replace-match REPLACEMENT nil nil))
! which will run faster and will not set the mark or print anything."
!   (interactive "sReplace regexp: \nsReplace regexp %s with: \nP")
!   (perform-replace regexp to-string nil t delimited)
!   (message "Done"))
! 
! (defun map-query-replace-regexp (regexp to-strings &optional arg)
!   "Replace some matches for REGEXP with various strings, in rotation.
! The second argument TO-STRINGS contains the replacement strings, separated
! by spaces.  This command works like `query-replace-regexp' except
! that each successive replacement uses the next successive replacement string,
! wrapping around from the last such string to the first.
! 
! Non-interactively, TO-STRINGS may be a list of replacement strings.
! 
! A prefix argument N says to use each replacement string N times
! before rotating to the next."
!   (interactive "sMap query replace (regexp): \nsQuery replace %s with (space-separated strings): \nP")
!   (let (replacements)
!     (if (listp to-strings)
! 	(setq replacements to-strings)
!       (while (/= (length to-strings) 0)
! 	(if (string-match " " to-strings)
! 	    (setq replacements
! 		  (append replacements
! 			  (list (substring to-strings 0
! 					   (string-match " " to-strings))))
! 		  to-strings (substring to-strings
! 				       (1+ (string-match " " to-strings))))
! 	  (setq replacements (append replacements (list to-strings))
! 		to-strings ""))))
!     (perform-replace regexp replacements t t nil arg))
!   (message "Done"))
--- 620,622 ----
      (and keep-going stack)))
  
! ;;; replace.el ends here
*** ../lemacs-beta6/lisp/prim/page.el	Sat Jul 10 19:50:34 1993
--- lisp/prim/page.el	Sun Jul 25 00:41:36 1993
***************
*** 1,5 ****
! ;; Page motion commands for emacs.
  ;; Copyright (C) 1985 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,8 ----
! ;;; page.el --- page motion commands for emacs.
! 
  ;; Copyright (C) 1985 Free Software Foundation, Inc.
  
+ ;; Maintainer: FSF
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 6,10 ****
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 1, or (at your option)
  ;; any later version.
  
--- 9,13 ----
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 2, or (at your option)
  ;; any later version.
  
***************
*** 18,28 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
  (defun forward-page (&optional count)
    "Move forward to page boundary.  With arg, repeat, or go back if negative.
! A page boundary is any line whose beginning matches the regexp  page-delimiter."
!   (interactive "p")
    (or count (setq count 1))
    (while (and (> count 0) (not (eobp)))
      (if (re-search-forward page-delimiter nil t)
  	nil
--- 21,41 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; This code provides the page-oriented movement and selection commands
+ ;; documented in the Emacs manual.
+ 
+ ;;; Code:
  
  (defun forward-page (&optional count)
    "Move forward to page boundary.  With arg, repeat, or go back if negative.
! A page boundary is any line whose beginning matches the regexp
! `page-delimiter'."
!   (interactive "_p")
    (or count (setq count 1))
    (while (and (> count 0) (not (eobp)))
+     ;; In case the page-delimiter matches the null string,
+     ;; don't find a match without moving.
+     (if (bolp) (forward-char 1))
      (if (re-search-forward page-delimiter nil t)
  	nil
***************
*** 34,43 ****
  	(goto-char (match-end 0))
        (goto-char (point-min)))
!     (setq count (1+ count)))
!   (setq zmacs-region-stays t))
  
  (defun backward-page (&optional count)
    "Move backward to page boundary.  With arg, repeat, or go fwd if negative.
! A page boundary is any line whose beginning matches the regexp  page-delimiter."
    (interactive "p")
    (or count (setq count 1))
--- 47,56 ----
  	(goto-char (match-end 0))
        (goto-char (point-min)))
!     (setq count (1+ count))))
  
  (defun backward-page (&optional count)
    "Move backward to page boundary.  With arg, repeat, or go fwd if negative.
! A page boundary is any line whose beginning matches the regexp
! `page-delimiter'."
    (interactive "p")
    (or count (setq count 1))
***************
*** 55,61 ****
          (forward-page (1- arg))))
    (forward-page)
!   (push-mark nil t)
!   (forward-page -1)
!   (zmacs-activate-region))
  
  (defun narrow-to-page (&optional arg)
--- 68,73 ----
          (forward-page (1- arg))))
    (forward-page)
!   (push-mark nil t t)
!   (forward-page -1))
  
  (defun narrow-to-page (&optional arg)
***************
*** 93,97 ****
  (defun count-lines-page ()
    "Report number of lines on current page, and how many are before or after point."
!   (interactive)
    (save-excursion
      (let ((opoint (point)) beg end
--- 105,109 ----
  (defun count-lines-page ()
    "Report number of lines on current page, and how many are before or after point."
!   (interactive "_")
    (save-excursion
      (let ((opoint (point)) beg end
***************
*** 107,116 ****
  	    before (count-lines beg opoint)
  	    after (count-lines opoint end))
!       (message "Page has %d lines (%d + %d)" total before after)))
!   (setq zmacs-region-stays t))
  
  (defun what-page ()
    "Print page and line number of point."
!   (interactive)
    (save-restriction
      (widen)
--- 119,127 ----
  	    before (count-lines beg opoint)
  	    after (count-lines opoint end))
!       (message "Page has %d lines (%d + %d)" total before after))))
  
  (defun what-page ()
    "Print page and line number of point."
!   (interactive "_")
    (save-restriction
      (widen)
***************
*** 124,127 ****
  	(message "Page %d, line %d"
  		 count
! 		 (1+ (count-lines (point) opoint))))))
!   (setq zmacs-region-stays t))
--- 135,139 ----
  	(message "Page %d, line %d"
  		 count
! 		 (1+ (count-lines (point) opoint)))))))
! 
! ;;; page.el ends here
*** ../lemacs-beta6/lisp/prim/simple.el	Sat Jul 10 19:50:34 1993
--- lisp/prim/simple.el	Sun Jul 25 00:40:36 1993
***************
*** 1,5 ****
! ;; Basic editing commands for Emacs
! ;; Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,6 ----
! ;;; simple.el --- basic editing commands for Emacs
  
+ ;; Copyright (C) 1985, 1986, 1987, 1993 Free Software Foundation, Inc.
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,21 ****
--- 19,26 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; A grab-bag of basic Emacs commands not specifically related to some
+ ;; major mode or to file-handling.
  
  ;;; Changes for zmacs-style active-regions:
***************
*** 44,47 ****
--- 49,54 ----
  ;;; to use (mark t) for the same reason.
  
+ ;;; Code:
+ 
  (defun open-line (arg)
    "Insert a newline and leave point before it.
***************
*** 53,57 ****
    (interactive "*p")
    (let* (;;(do-fill-prefix (and fill-prefix (bolp)))
! 	 (do-fill-prefix nil)  ;; screw this
  	 (flag (and (null do-fill-prefix) (bolp) (not (bobp)))))
      ;; If this is a simple case, and we are at the beginning of a line,
--- 60,64 ----
    (interactive "*p")
    (let* (;;(do-fill-prefix (and fill-prefix (bolp)))
! 	 (do-fill-prefix nil)  ;; screw this -- says JWZ
  	 (flag (and (null do-fill-prefix) (bolp) (not (bobp)))))
      ;; If this is a simple case, and we are at the beginning of a line,
***************
*** 86,95 ****
    "Read next input character and insert it.
  This is useful for inserting control characters.
! You may also type up to 3 octal digits, to insert a character with that code"
    (interactive "*p")
!   (let ((char (read-quoted-char)))
!     (while (> arg 0)
!       (insert char)
!       (setq arg (1- arg)))))
  
  (defun delete-indentation (&optional arg)
--- 93,114 ----
    "Read next input character and insert it.
  This is useful for inserting control characters.
! You may also type up to 3 octal digits, to insert a character with that code.
! 
! In overwrite mode, this function inserts the character anyway, and
! does not handle octal digits specially.  This means that if you use
! overwrite as your normal editing mode, you can use this function to
! insert characters when necessary.
! 
! In binary overwrite mode, this function does overwrite, and octal
! digits are interpreted as a character code.  This is supposed to make
! this function useful in editing binary files."
    (interactive "*p")
!   (let ((char (if (or (not overwrite-mode)
! 		      (eq overwrite-mode 'overwrite-mode-binary))
! 		  (read-quoted-char)
! 		  (read-char))))
!     (if (eq overwrite-mode 'overwrite-mode-binary)
! 	(delete-char arg))
!     (insert-char char arg)))
  
  (defun delete-indentation (&optional arg)
***************
*** 306,311 ****
  			(/ (buffer-size) 10))
  		   (/ (+ 10 (* (buffer-size) (prefix-numeric-value arg))) 10))
! 	       (point-min)))
!   (zmacs-activate-region))
  (fset 'mark-bob 'mark-beginning-of-buffer)
  
--- 325,331 ----
  			(/ (buffer-size) 10))
  		   (/ (+ 10 (* (buffer-size) (prefix-numeric-value arg))) 10))
! 	       (point-min))
!              nil
!              t))
  (fset 'mark-bob 'mark-beginning-of-buffer)
  
***************
*** 321,326 ****
  			   (/ (buffer-size) 10))
  		      (/ (* (buffer-size) (prefix-numeric-value arg)) 10)))
! 	       (point-max)))
!   (zmacs-activate-region))
  (fset 'mark-eob 'mark-end-of-buffer)
  
--- 341,347 ----
  			   (/ (buffer-size) 10))
  		      (/ (* (buffer-size) (prefix-numeric-value arg)) 10)))
!                  (point-max))
!              nil
!              t))
  (fset 'mark-eob 'mark-end-of-buffer)
  
***************
*** 332,338 ****
    (interactive)
    (push-mark (point))
!   (push-mark (point-max))
!   (goto-char (point-min))
!   (zmacs-activate-region))
  
  (defun eval-current-buffer (&optional printflag)
--- 353,358 ----
    (interactive)
    (push-mark (point))
!   (push-mark (point-max) nil t)
!   (goto-char (point-min)))
  
  (defun eval-current-buffer (&optional printflag)
***************
*** 351,372 ****
  	       (count-words-region (point-min) (point-max))))))
  
! (defun count-words-region (debut fin)
    (interactive "r")
    (save-excursion
!     (let ((cnt 0))
!       (goto-char debut)
!       (while (< (point) fin)
  	(if (forward-word 1)
! 	    (setq cnt (1+ cnt))))
!       (message "Region has %d words" cnt)
!       cnt)))
  
  (defun count-lines-region (start end)
!   "Print number of lines and charcters in the region."
    (interactive "_r")
!   (let ((cnt (count-lines start end)))
      (message "Region has %d lines, %d characters"
! 	     cnt (- end start))
!     cnt))
  
  (defun count-lines-buffer (b)
--- 371,392 ----
  	       (count-words-region (point-min) (point-max))))))
  
! (defun count-words-region (start end)
    (interactive "r")
    (save-excursion
!     (let ((n 0))
!       (goto-char start)
!       (while (< (point) end)
  	(if (forward-word 1)
! 	    (setq n (1+ n))))
!       (message "Region has %d words" n)
!       n)))
  
  (defun count-lines-region (start end)
!   "Print number of lines and characters in the region."
    (interactive "_r")
!   (let ((n (count-lines start end)))
      (message "Region has %d lines, %d characters"
! 	     n (- end start))
!     n))
  
  (defun count-lines-buffer (b)
***************
*** 396,399 ****
--- 416,420 ----
  but can be one more if START is not equal to END
  and the greater of them is not at the start of a line."
+   (save-match-data
      (save-excursion
        (save-restriction
***************
*** 407,411 ****
  	      (setq done (+ 1 done)))
  	    done)
! 	(- (buffer-size) (forward-line (buffer-size)))))))
  
  (defun what-cursor-position ()
--- 428,432 ----
                  (setq done (+ 1 done)))
                done)
!           (- (buffer-size) (forward-line (buffer-size))))))))
  
  (defun what-cursor-position ()
***************
*** 444,448 ****
  
  
! (put 'eval-expression 'disabled t)
  
  ;; We define this, rather than making  eval  interactive,
--- 465,472 ----
  
  
! ;; in minibuf.el
! ;(defvar read-expression-map (copy-keymap minibuffer-local-map)
! ;  "Minibuffer keymap used for reading Lisp expressions.")
! ;(define-key read-expression-map "\M-\t" 'lisp-complete-symbol)
  
  ;; We define this, rather than making  eval  interactive,
***************
*** 515,519 ****
  
  ;Put this on C-x u, so we can force that rather than C-_ into startup msg
! (fset 'advertised-undo 'undo)
  
  (defun undo (&optional arg)
--- 539,543 ----
  
  ;Put this on C-x u, so we can force that rather than C-_ into startup msg
! (define-function 'advertised-undo 'undo)
  
  (defun undo (&optional arg)
***************
*** 534,537 ****
--- 558,564 ----
  	 (delete-auto-save-file-if-necessary recent-save))))
  
+ (defvar pending-undo-list nil
+   "Within a run of consecutive undo commands, list remaining to be undone.")
+ 
  (defun undo-start ()
    "Set `pending-undo-list' to the front of the undo list.
***************
*** 706,719 ****
   multiplies the argument by 4 each time."
    (interactive)
!   (let* ((c-u 4)
  	 (start-char last-command-event)
! 	 event)
      (while (progn
! 	     (setq event (next-command-event event))
! 	     (equal event start-char))
!       (setq c-u (* 4 c-u)))
!     (prefix-arg-internal event c-u nil)))
  
! (defun prefix-arg-internal (event c-u value)
    (setq zmacs-region-stays t)
    (let ((sign 1)
--- 733,751 ----
   multiplies the argument by 4 each time."
    (interactive)
!   (let ((factor 4)
          (start-char last-command-event)
!         (key nil))
! ;;;>>>>> Fix read-key-sequence so we can use that instead
! ;   (setq key (read-key-sequence nil t))
! ;   (while (equal (key-binding key) 'universal-argument)
! ;     (setq factor (* 4 factor))
! ;     (setq key (read-key-sequence nil t)))
      (while (progn
! 	     (setq key (next-command-event key))
! 	     (equal key start-char))
!       (setq factor (* 4 factor)))
!     (prefix-arg-internal key factor nil)))
  
! (defun prefix-arg-internal (event factor value)
    (setq zmacs-region-stays t)
    (let ((sign 1)
***************
*** 725,737 ****
  	(setq sign -1 value nil))
      (while (eq ?- char)
!       (setq sign (- sign) c-u nil)
        (next-command-event event)
        (if (key-press-event-p event) (setq char (event-key event))))
      (while (and (numberp char) (>= char ?0) (<= char ?9))
!       (setq value (+ (* (if (numberp value) value 0) 10) (- char ?0)) c-u nil)
        (next-command-event event)
        (if (key-press-event-p event) (setq char (event-key event))))
      (setq prefix-arg
! 	  (cond (c-u (list c-u))
  		((numberp value) (* value sign))
  		((= sign -1) '-)))
--- 757,771 ----
  	(setq sign -1 value nil))
      (while (eq ?- char)
!       (setq sign (- sign) factor nil)
!       ;;>>(setq key (read-key-sequence nil t)))
        (next-command-event event)
        (if (key-press-event-p event) (setq char (event-key event))))
      (while (and (numberp char) (>= char ?0) (<= char ?9))
!       (setq value (+ (* (if (numberp value) value 0) 10) (- char ?0))
!             factor nil)
        (next-command-event event)
        (if (key-press-event-p event) (setq char (event-key event))))
      (setq prefix-arg
! 	  (cond (factor (list factor))
  		((numberp value) (* value sign))
  		((= sign -1) '-)))
***************
*** 775,778 ****
--- 809,815 ----
    (skip-chars-forward " \t"))
  
+ (defvar kill-whole-line nil
+   "*If non-nil, `kill-line' with no arg at beg of line kills the whole line.")
+ 
  (defun kill-line (&optional arg)
    "Kill the rest of the current line; if no nonblanks there, kill thru newline.
***************
*** 781,788 ****
  
  When calling from a program, nil means \"no arg\",
! a number counts as a prefix arg."
    (interactive "*P")
    (kill-region (point)
! 	       (progn
  		 (if arg
  		     (forward-line (prefix-numeric-value arg))
--- 818,830 ----
  
  When calling from a program, nil means \"no arg\",
! a number counts as a prefix arg.
! 
! If `kill-whole-line' is non-nil, then kill the whole line
! when given no argument at the beginning of a line."
    (interactive "*P")
    (kill-region (point)
! 	       ;; Don't shift point before doing the delete; that way,
! 	       ;; undo will record the right position of point.
! 	       (save-excursion
  		 (if arg
  		     (forward-line (prefix-numeric-value arg))
***************
*** 789,793 ****
  		   (if (eobp)
  		       (signal 'end-of-buffer nil))
! 		   (if (looking-at "[ \t]*$")
  		       (forward-line 1)
  		     (end-of-line)))
--- 831,835 ----
  		   (if (eobp)
  		       (signal 'end-of-buffer nil))
! 		   (if (or (looking-at "[ \t]*$") (and kill-whole-line (bolp)))
  		       (forward-line 1)
                         (end-of-line)))
***************
*** 794,798 ****
  		 (point))))
  
! ;;;; Window system cut and paste hooks
  ;;;
  ;;; I think that kill-hooks is a better name and more general mechanism
--- 836,840 ----
  		 (point))))
  
! ;;;; Window system cut and paste hooks.
  ;;;
  ;;; I think that kill-hooks is a better name and more general mechanism
***************
*** 864,873 ****
        (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))
    (setq kill-ring-yank-pointer kill-ring)
!   (let ((rest kill-hooks))
!     (if (or (not (listp rest)) (eq (car-safe rest) 'lambda))
! 	(and rest (funcall rest string))
!       (while rest
! 	(funcall (car rest) string)
! 	(setq rest (cdr rest))))))
  
  (defun kill-append (string before-p)
--- 906,910 ----
        (setcdr (nthcdr (1- kill-ring-max) kill-ring) nil))
    (setq kill-ring-yank-pointer kill-ring)
!   (run-hooks 'kill-hooks))
  
  (defun kill-append (string before-p)
***************
*** 879,888 ****
  	      (concat string (car kill-ring))
  	      (concat (car kill-ring) string)))
!   (let ((rest kill-hooks))
!     (if (or (not (listp rest)) (eq (car-safe rest) 'lambda))
! 	(and rest (funcall rest string))
!       (while rest
! 	(funcall (car rest) string)
! 	(setq rest (cdr rest))))))
  
  (defun current-kill (n &optional do-not-move)
--- 916,920 ----
  	      (concat string (car kill-ring))
  	      (concat (car kill-ring) string)))
!   (run-hooks 'kill-hooks))
  
  (defun current-kill (n &optional do-not-move)
***************
*** 906,910 ****
  The text is deleted but saved in the kill ring.
  The command \\[yank] can retrieve it from there.
! \(If you want to kill and then yank immediately, use \\[kill-ring-save].)
  
  This is the primitive for programs to kill text (as opposed to deleting it).
--- 938,942 ----
  The text is deleted but saved in the kill ring.
  The command \\[yank] can retrieve it from there.
! \(If you want to kill and then yank immediately, use \\[copy-region-as-kill].)
  
  This is the primitive for programs to kill text (as opposed to deleting it).
***************
*** 937,946 ****
                    (eq last-command 'kill-region)
                    (eq beg end)))
           ;; Don't let the undo list be truncated before we can even access it.
!          (let ((undo-high-threshold (+ (- (max beg end) (min beg end)) 100)))
             (delete-region beg end)
             ;; Take the same string recorded for undo
             ;; and put it in the kill-ring.
!            (kill-new (car (car buffer-undo-list)))
             (setq this-command 'kill-region)))
          (t
--- 969,988 ----
                    (eq last-command 'kill-region)
                    (eq beg end)))
+          ;; In certain cases, we can arrange for the undo list and the kill
+          ;; ring to share the same string object.  This code does that.
+ 
           ;; Don't let the undo list be truncated before we can even access it.
!          (let ((undo-high-threshold (+ (- (max beg end) (min beg end)) 100))
!                (old-list buffer-undo-list)
!                tail)
             (delete-region beg end)
+            ;; Search back in buffer-undo-list for this string,
+            ;; in case a change hook made property changes.
+            (setq tail buffer-undo-list)
+            (while (not (stringp (car (car tail))))
+              (setq tail (cdr tail)))
             ;; Take the same string recorded for undo
             ;; and put it in the kill-ring.
!            (kill-new (car (car tail)))
             (setq this-command 'kill-region)))
          (t
***************
*** 950,956 ****
           (delete-region beg end))))
  
! (fset 'copy-region-as-kill 'kill-ring-save)
! 
! (defun kill-ring-save (beg end)
    "Save the region as if killed, but don't kill it.
  Runs `kill-hooks'."
--- 992,996 ----
           (delete-region beg end))))
  
! (defun copy-region-as-kill (beg end)
    "Save the region as if killed, but don't kill it.
  Runs `kill-hooks'."
***************
*** 960,971 ****
      (kill-new (buffer-substring beg end)))
    (setq this-command 'kill-region)
    ;; copy before delay, for xclipboard's benefit
    (if (interactive-p)
!       (save-excursion
! 	(let ((other-end (if (= (point) beg) end beg)))
  	  (if (pos-visible-in-window-p other-end (selected-window))
  	      (progn
  		(goto-char other-end)
! 		(sit-for 0))
  ;; too noisy. -- jwz
  ;	    (let* ((killed-text (current-kill 0))
--- 1000,1027 ----
      (kill-new (buffer-substring beg end)))
    (setq this-command 'kill-region)
+   nil)
+ 
+ (defun kill-ring-save (beg end)
+   "Save the region as if killed, but don't kill it.
+ This command is similar to `copy-region-as-kill', except that it gives
+ visual feedback indicating the extent of the region being copied."
+   (interactive "r")
+   (copy-region-as-kill beg end)
    ;; copy before delay, for xclipboard's benefit
    (if (interactive-p)
!       (let ((other-end (if (= (point) beg) end beg))
! 	    (opoint (point))
! 	    ;; Inhibit quitting so we can make a quit here
! 	    ;; look like a C-g typed as a command.
! 	    (inhibit-quit t))
          (if (pos-visible-in-window-p other-end (selected-window))
              (progn
                (goto-char other-end)
!               (sit-for 0)
!               (goto-char opoint)
!               ;; If user quit, deactivate the mark
! 	      ;; as C-g would as a command.
! 	      (and quit-flag (mark)
!                    (zmacs-deactivate-region)))
  ;; too noisy. -- jwz
  ;	    (let* ((killed-text (current-kill 0))
***************
*** 978,982 ****
  ;                           (substring killed-text 0 message-len))))
  	    ))))
!   nil)
  
  (defun append-next-kill ()
--- 1034,1038 ----
  ;                           (substring killed-text 0 message-len))))
              ))))
! 
  
  (defun append-next-kill ()
***************
*** 1017,1021 ****
  killed OR yanked.  Put point at end, and set mark at beginning.
  With just C-u as argument, same but put point at beginning (and mark at end).
! With argument N, reinsert the Nth most recently killed stretch of text.
  See also the command \\[yank-pop]."
    (interactive "*P")
--- 1073,1077 ----
  killed OR yanked.  Put point at end, and set mark at beginning.
  With just C-u as argument, same but put point at beginning (and mark at end).
! With argument N, reinsert the Nth most recently killed stretch of killed text.
  See also the command \\[yank-pop]."
    (interactive "*P")
***************
*** 1058,1062 ****
  START and END specify the portion of the current buffer to be copied."
    (interactive (list (read-buffer "Append to buffer: "
!                                   (other-buffer nil t) t)))
    (let ((oldbuf (current-buffer)))
      (save-excursion
--- 1114,1119 ----
  START and END specify the portion of the current buffer to be copied."
    (interactive (list (read-buffer "Append to buffer: "
!                                   (other-buffer nil t) t)
!                      (region-beginning) (region-end)))
    (let ((oldbuf (current-buffer)))
      (save-excursion
***************
*** 1093,1096 ****
--- 1150,1164 ----
  	(insert-buffer-substring oldbuf start end)))))
  
+ ;;;>>> RMSmacs
+ ;(defvar mark-even-if-inactive nil
+ ;  "*Non-nil means you can use the mark even when inactive.
+ ;This option makes a difference in Transient Mark mode.
+ ;When the option is non-nil, deactivation of the mark
+ ;turns off region highlighting, but commands that use the mark
+ ;behave as if the mark were still active.")
+ ;
+ ;(put 'mark-inactive 'error-conditions '(mark-inactive error))
+ ;(put 'mark-inactive 'error-message "The mark is not active now")
+ 
  (defun mark (&optional inactive-p)
    "Return this buffer's mark value as integer, or nil if no mark.
***************
*** 1097,1101 ****
  
  If `zmacs-regions' is true, then this returns nil unless the region is
! currently in the active (hilighted) state.  With an argument of t, this
  returns the mark (if there is one) regardless of the active-region state.
  You should *generally* not use the mark unless the region is active, if
--- 1165,1169 ----
  
  If `zmacs-regions' is true, then this returns nil unless the region is
! currently in the active (highlighted) state.  With an argument of t, this
  returns the mark (if there is one) regardless of the active-region state.
  You should *generally* not use the mark unless the region is active, if
***************
*** 1116,1120 ****
  This is why most applications should use push-mark, not set-mark.
  
! Novice emacs-lisp programmers often try to use the mark for the wrong
  purposes.  The mark saves a location for the user's convenience.
  Most editing commands should not alter the mark.
--- 1184,1188 ----
  This is why most applications should use push-mark, not set-mark.
  
! Novice Emacs Lisp programmers often try to use the mark for the wrong
  purposes.  The mark saves a location for the user's convenience.
  Most editing commands should not alter the mark.
***************
*** 1136,1141 ****
  (defun set-mark-command (arg)
    "Set mark at where point is, or jump to mark.
! With no prefix argument, set mark, and push previous mark on mark ring.
! With argument, jump to mark, and pop into mark off the mark ring.
  
  Novice Emacs Lisp programmers often try to use the mark for the wrong
--- 1204,1209 ----
  (defun set-mark-command (arg)
    "Set mark at where point is, or jump to mark.
! With no prefix argument, set mark, and push old mark position on mark ring.
! With argument, jump to mark, and pop a new position for mark off the ring.
  
  Novice Emacs Lisp programmers often try to use the mark for the wrong
***************
*** 1143,1149 ****
    (interactive "P")
    (if (null arg)
!       (progn
! 	(push-mark)
! 	(zmacs-activate-region))
      (if (null (mark t))
  	(error "No mark set in this buffer")
--- 1211,1215 ----
    (interactive "P")
    (if (null arg)
!       (push-mark nil nil t)
      (if (null (mark t))
  	(error "No mark set in this buffer")
***************
*** 1151,1157 ****
        (pop-mark))))
  
! (defun push-mark (&optional location nomsg)
    "Set mark at LOCATION (point, by default) and push old mark on mark ring.
! Displays \"Mark set\" unless the optional second arg NOMSG is non-nil.
  
  Novice Emacs Lisp programmers often try to use the mark for the wrong
--- 1217,1224 ----
        (pop-mark))))
  
! (defun push-mark (&optional location nomsg activate-region)
    "Set mark at LOCATION (point, by default) and push old mark on mark ring.
! Display \"Mark set\" unless the optional second arg NOMSG is non-nil.
! Activate mark if optional third arg ACTIVATE-REGION non-nil.
  
  Novice Emacs Lisp programmers often try to use the mark for the wrong
***************
*** 1167,1170 ****
--- 1234,1238 ----
    (or nomsg executing-macro (> (minibuffer-depth) 0)
        (message "Mark set"))
+   (if activate-region (zmacs-activate-region))
    nil)
  
***************
*** 1180,1184 ****
  	(setq mark-ring (cdr mark-ring)))))
  
! (fset 'exchange-dot-and-mark 'exchange-point-and-mark)
  (defun exchange-point-and-mark (&optional dont-activate-region)
    "Put the mark where point is now, and point where the mark is now."
--- 1248,1252 ----
  	(setq mark-ring (cdr mark-ring)))))
  
! (define-function 'exchange-dot-and-mark 'exchange-point-and-mark)
  (defun exchange-point-and-mark (&optional dont-activate-region)
    "Put the mark where point is now, and point where the mark is now."
***************
*** 1191,1196 ****
      (or dont-activate-region (zmacs-activate-region))
      nil))
  
! (defvar next-line-extends-end-of-buffer t
    "*If non-nil, when \\[next-line] is invoked on the last line of a buffer,
  a newline character is inserted to create a new line.
--- 1259,1276 ----
      (or dont-activate-region (zmacs-activate-region))
      nil))
+ 
+ ;(defun transient-mark-mode (arg)
+ ;  "Toggle Transient Mark mode.
+ ;With arg, turn Transient Mark mode on if arg is positive, off otherwise.
+ ;
+ ;In Transient Mark mode, changing the buffer \"deactivates\" the mark.
+ ;While the mark is active, the region is highlighted."
+ ;  (interactive "P")
+ ;  (setq transient-mark-mode
+ ;	(if (null arg)
+ ;	    (not transient-mark-mode)
+ ;	  (> (prefix-numeric-value arg) 0))))
  
! (defvar next-line-add-newlines t
    "*If non-nil, when \\[next-line] is invoked on the last line of a buffer,
  a newline character is inserted to create a new line.
***************
*** 1203,1209 ****
  column, or at the end of the line if it is not long enough.
  
! If the variable `next-line-extends-end-of-buffer' is true and there is no line
! in the buffer after this one, a newline character is inserted to create
! a line and the cursor moves to that line.
  
  The command \\[set-goal-column] can be used to create
--- 1283,1291 ----
  column, or at the end of the line if it is not long enough.
  
! If there is no line in the buffer after this one, behavior depends on the
! value of next-line-add-newlines.  If non-nil, a newline character is inserted
! to create a line and the cursor moves to that line, otherwise the cursor is
! moved to the end of the buffer (if already at the end of the buffer, an error
! is signaled).
  
  The command \\[set-goal-column] can be used to create
***************
*** 1216,1231 ****
  and more reliable (no dependence on goal column, etc.)."
    (interactive "_p")
-   (if (= arg 1)
        (let ((opoint (point)))
  	(forward-line 1)
  	(if (or (= opoint (point))
  		(not (eq (preceding-char) ?\n)))
! 	    (progn
! 	      (if (not next-line-extends-end-of-buffer)
! 		  (signal 'end-of-buffer nil))
! 	      (insert ?\n))
  	  (goto-char opoint)
  	  (line-move arg)))
!     (line-move arg))
    nil)
  
--- 1298,1316 ----
  and more reliable (no dependence on goal column, etc.)."
    (interactive "_p")
    (let ((opoint (point)))
+     (if next-line-add-newlines
+ 	(if (/= arg 1)
+ 	    (line-move arg)
            (forward-line 1)
            (if (or (= opoint (point))
                    (not (eq (preceding-char) ?\n)))
!               (insert ?\n)
              (goto-char opoint)
              (line-move arg)))
!       (if (eobp)
! 	  (signal 'end-of-buffer nil))
!       (line-move arg)
!       (if (= opoint (point))
! 	  (end-of-line))))
    nil)
  
***************
*** 1241,1245 ****
  
  If you are thinking of using this in a Lisp program, consider using
! `forward-line' with negative argument instead..  It is usually easier
  to use and more reliable (no dependence on goal column, etc.)."
    (interactive "_p")
--- 1326,1330 ----
  
  If you are thinking of using this in a Lisp program, consider using
! `forward-line' with a negative argument instead.  It is usually easier
  to use and more reliable (no dependence on goal column, etc.)."
    (interactive "_p")
***************
*** 1252,1258 ****
  The beginning of a blank line does not count as the end of a line.")
  
! (make-variable-buffer-local
!  (defvar goal-column nil
!    "*Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil."))
  
  (defvar temporary-goal-column 0
--- 1337,1343 ----
  The beginning of a blank line does not count as the end of a line.")
  
! (defvar goal-column nil
!   "*Semipermanent goal column for vertical motion, as set by \\[set-goal-column], or nil.")
! (make-variable-buffer-local 'goal-column)
  
  (defvar temporary-goal-column 0
***************
*** 1292,1296 ****
  rather than trying to keep the same horizontal position.
  With a non-nil argument, clears out the goal column
! so that \\[next-line] and \\[previous-line] resume vertical motion."
    (interactive "_P")
    (if arg
--- 1377,1382 ----
  rather than trying to keep the same horizontal position.
  With a non-nil argument, clears out the goal column
! so that \\[next-line] and \\[previous-line] resume vertical motion.
! The goal column is stored in the variable `goal-column'."
    (interactive "_P")
    (if arg
***************
*** 1304,1307 ****
--- 1390,1454 ----
    nil)
  
+ ;;;>>>> RMSmacs terminal randomness
+ ;;; Partial support for horizontal autoscrolling.  Someday, this feature
+ ;;; will be built into the C level and all the (hscroll-point-visible) calls
+ ;;; will go away.
+ 
+ ;(defvar hscroll-step 0
+ ;   "*The number of columns to try scrolling a window by when point moves out.
+ ;If that fails to bring point back on frame, point is centered instead.
+ ;If this is zero, point is always centered after it moves off frame.")
+ ;
+ ;(defun hscroll-point-visible ()
+ ;  "Scrolls the window horizontally to make point visible."
+ ;  (let* ((here (current-column))
+ ;	 (left (window-hscroll))
+ ;	 (right (- (+ left (window-width)) 3)))
+ ;    (cond
+ ;     ;; Should we recenter?
+ ;     ((or (< here (- left  hscroll-step))
+ ;	  (> here (+ right hscroll-step)))
+ ;      (set-window-hscroll
+ ;       (selected-window)
+ ;       ;; Recenter, but don't show too much white space off the end of
+ ;       ;; the line.
+ ;       (max 0
+ ;	    (min (- (save-excursion (end-of-line) (current-column))
+ ;		    (window-width)
+ ;		    -5)
+ ;		 (- here (/ (window-width) 2))))))
+ ;     ;; Should we scroll left?
+ ;     ((> here right)
+ ;      (scroll-left hscroll-step))
+ ;     ;; Or right?
+ ;     ((< here left)
+ ;      (scroll-right hscroll-step)))))
+ ;
+ ;; rms: (1) The definitions of arrow keys should not simply restate
+ ;; what keys they are.  The arrow keys should run the ordinary commands.
+ ;; (2) The arrow keys are just one of many common ways of moving point
+ ;; within a line.  Real horizontal autoscrolling would be a good feature,
+ ;; but supporting it only for arrow keys is too incomplete to be desirable.
+ 
+ ;;;;; Make arrow keys do the right thing for improved terminal support
+ ;;;;; When we implement true horizontal autoscrolling, right-arrow and
+ ;;;;; left-arrow can lose the (if truncate-lines ...) clause and become
+ ;;;;; aliases.  These functions are bound to the corresponding keyboard
+ ;;;;; events in loaddefs.el.
+ 
+ ;;(defun right-arrow (arg)
+ ;;  "Move right one character on the screen (with prefix ARG, that many chars).
+ ;;Scroll right if needed to keep point horizontally onscreen."
+ ;;  (interactive "P")
+ ;;  (forward-char arg)
+ ;;  (hscroll-point-visible))
+ 
+ ;;(defun left-arrow (arg)
+ ;;  "Move left one character on the screen (with prefix ARG, that many chars).
+ ;;Scroll left if needed to keep point horizontally onscreen."
+ ;;  (interactive "P")
+ ;;  (backward-char arg)
+ ;;  (hscroll-point-visible))
+ 
  (defun transpose-chars (arg)
    "Interchange characters around point, moving forward one character.
***************
*** 1401,1405 ****
  (defvar comment-column 32
    "*Column to indent right-margin comments to.
! Setting this variable automatically makes it local to the current buffer.")
  (make-variable-buffer-local 'comment-column)
  
--- 1548,1554 ----
  (defvar comment-column 32
    "*Column to indent right-margin comments to.
! Setting this variable automatically makes it local to the current buffer.
! Each mode establishes a different default value for this variable; you
! can the value for a particular mode using that mode's hook.")
  (make-variable-buffer-local 'comment-column)
  
***************
*** 1416,1420 ****
  Should be an empty string if comments are terminated by end-of-line.")
  
! (defvar comment-indent-hook
    '(lambda () comment-column)
    "Function to compute desired indentation for a comment.
--- 1565,1575 ----
  Should be an empty string if comments are terminated by end-of-line.")
  
! (defconst comment-indent-hook nil
!   "Obsolete variable for function to compute desired indentation for a comment.
! Use `comment-indent-function' instead.
! This function is called with no args with point at the beginning of
! the comment's starting delimiter.")
! 
! (defvar comment-indent-function
    '(lambda () comment-column)
    "Function to compute desired indentation for a comment.
***************
*** 1437,1450 ****
  		 (if (match-end 1)
  		     (goto-char (match-end 1))
! 		   ;; If comment-start-skip matched a string with internal
! 		   ;; whitespace (not final whitespace) then the delimiter
! 		   ;; start at the end of that whitespace.
! 		   ;; Otherwise, it starts at the beginning of what was matched.
! 		   (skip-chars-backward " \t" (match-beginning 0))
! 		   (skip-chars-backward "^ \t" (match-beginning 0)))))
        (setq begpos (point))
        ;; Compute desired indent.
        (if (= (current-column)
! 	     (setq indent (funcall comment-indent-hook)))
  	  (goto-char begpos)
  	;; If that's different from current, change it.
--- 1592,1609 ----
  		 (if (match-end 1)
  		     (goto-char (match-end 1))
! 		   ;; If comment-start-skip matched a string with
! 		   ;; internal whitespace (not final whitespace) then
! 		   ;; the delimiter start at the end of that
! 		   ;; whitespace.  Otherwise, it starts at the
! 		   ;; beginning of what was matched.
! 		   (skip-syntax-backward " " (match-beginning 0))
! 		   (skip-syntax-backward "^ " (match-beginning 0)))))
        (setq begpos (point))
        ;; Compute desired indent.
        (if (= (current-column)
! 	     (setq indent (if comment-indent-hook
!                               ;; old name
!                               (funcall comment-indent-hook)
!                               (funcall comment-indent-function))))
  	  (goto-char begpos)
  	;; If that's different from current, change it.
***************
*** 1553,1557 ****
                      (backward-char (length ce))
                      (if (looking-at (regexp-quote ce))
!                         (delete-char (length ce))))))
              (if (looking-at "[ \t]*$") ()
                (insert cs)
--- 1712,1717 ----
                      (backward-char (length ce))
                      (if (looking-at (regexp-quote ce))
!                         (delete-char (length ce)))))
!                 (forward-line 1))
              (if (looking-at "[ \t]*$") ()
                (insert cs)
***************
*** 1574,1579 ****
      (save-excursion
        (forward-word arg)
!       (point)))
!   (zmacs-activate-region))
  
  (defun kill-word (arg)
--- 1734,1739 ----
      (save-excursion
        (forward-word arg)
!       (point))
!     nil t))
  
  (defun kill-word (arg)
***************
*** 1588,1591 ****
--- 1748,1779 ----
    (interactive "*p")
    (kill-word (- arg)))
+ 
+ (defun current-word ()
+   "Return the word point is on as a string, if it's between two
+ word-constituent characters. If not, but it immediately follows one,
+ move back first.  Otherwise, if point precedes a word constituent,
+ move forward first.  Otherwise, move backwards until a word constituent
+ is found and get that word; if you reach a newline first, move forward
+ instead."
+   (interactive)
+   (save-excursion
+     (let ((oldpoint (point)) (start (point)) (end (point)))
+       (skip-syntax-backward "w_") (setq start (point))
+       (goto-char oldpoint)
+       (skip-syntax-forward "w_") (setq end (point))
+       (if (and (eq start oldpoint) (eq end oldpoint))
+ 	  (progn
+ 	    (skip-syntax-backward "^w_"
+ 				  (save-excursion (beginning-of-line) (point)))
+ 	    (if (eq (preceding-char) ?\n)
+ 		(progn
+ 		  (skip-syntax-forward "^w_")
+ 		  (setq start (point))
+ 		  (skip-syntax-forward "w_")
+ 		  (setq end (point)))
+ 	      (setq end (point))
+ 	      (skip-syntax-backward "w_")
+ 	      (setq start (point)))))
+       (buffer-substring start end))))
  
  (defvar fill-prefix nil
***************
*** 1728,1735 ****
  When the value of `selective-display' is a number > 0,
  lines whose indentation is >= that value are not displayed.
! The variable `selective-display' has a separate value for each buffer.
! 
! WARNING: selective-display does not currently work with Lucid Emacs.
! This is a known bug that will be fixed eventually."
    (interactive "P")
    (if (eq selective-display t)
--- 1916,1920 ----
  When the value of `selective-display' is a number > 0,
  lines whose indentation is >= that value are not displayed.
! The variable `selective-display' has a separate value for each buffer."
    (interactive "P")
    (if (eq selective-display t)
***************
*** 1748,1751 ****
--- 1933,1941 ----
    (princ "." t))
  
+ (defvar overwrite-mode-textual (purecopy " Ovwrt")
+   "The string displayed in the mode line when in overwrite mode.")
+ (defvar overwrite-mode-binary (purecopy " Bin Ovwrt")
+   "The string displayed in the mode line when in binary overwrite mode.")
+ 
  (defun overwrite-mode (arg)
    "Toggle overwrite mode.
***************
*** 1752,1761 ****
  With arg, turn overwrite mode on iff arg is positive.
  In overwrite mode, printing characters typed in replace existing text
! on a one-for-one basis, rather than pushing it to the right."
    (interactive "P")
    (setq overwrite-mode
! 	(if (null arg) (not overwrite-mode)
! 	  (> (prefix-numeric-value arg) 0)))
!   (set-buffer-modified-p (buffer-modified-p))) ;No-op, but updates mode line.
  
  (defvar blink-matching-paren t
--- 1942,1994 ----
  With arg, turn overwrite mode on iff arg is positive.
  In overwrite mode, printing characters typed in replace existing text
! on a one-for-one basis, rather than pushing it to the right.  At the
! end of a line, such characters extend the line.  Before a tab,
! such characters insert until the tab is filled in.
! \\[quoted-insert] still inserts characters in overwrite mode; this
! is supposed to make it easier to insert characters when necessary."
!   (interactive "P")
!   (setq overwrite-mode
! 	(if (if (null arg) (not overwrite-mode)
! 	      (> (prefix-numeric-value arg) 0))
! 	    'overwrite-mode-textual))
!   (force-mode-line-update))
! 
! (defun binary-overwrite-mode (arg)
!   "Toggle binary overwrite mode.
! With arg, turn binary overwrite mode on iff arg is positive.
! In binary overwrite mode, printing characters typed in replace
! existing text.  Newlines are not treated specially, so typing at the
! end of a line joins the line to the next, with the typed character
! between them.  Typing before a tab character simply replaces the tab
! with the character typed.
! \\[quoted-insert] replaces the text at the cursor, just as ordinary
! typing characters do.
! 
! Note that binary overwrite mode is not its own minor mode; it is a
! specialization of overwrite-mode, entered by setting the
! `overwrite-mode' variable to `overwrite-mode-binary'."
    (interactive "P")
    (setq overwrite-mode
! 	(if (if (null arg)
! 		(not (eq overwrite-mode 'overwrite-mode-binary))
! 	      (> (prefix-numeric-value arg) 0))
! 	    'overwrite-mode-binary))
!   (force-mode-line-update))
! 
! ;;;>>> NYI
! ;(defvar line-number-mode nil
! ;  "*Non-nil means display line number in mode line.")
! ;
! ;(defun line-number-mode (arg)
! ;  "Toggle Line Number mode.
! ;With arg, turn Line Number mode on iff arg is positive.
! ;When Line Number mode is enabled, the line number appears
! ;in the mode line."
! ;  (interactive "P")
! ;  (setq line-number-mode
! ;	(if (null arg) (not line-number-mode)
! ;	  (> (prefix-numeric-value arg) 0)))
! ;  (force-mode-line-update))
! 
  
  (defvar blink-matching-paren t
***************
*** 1762,1766 ****
    "*Non-nil means show matching open-paren when close-paren is inserted.")
  
! (defvar blink-matching-paren-distance 4000
    "*If non-nil, is maximum distance to search for matching open-paren
  when close-paren is inserted.")
--- 1995,1999 ----
    "*Non-nil means show matching open-paren when close-paren is inserted.")
  
! (defvar blink-matching-paren-distance 12000
    "*If non-nil, is maximum distance to search for matching open-paren
  when close-paren is inserted.")
*** ../lemacs-beta6/lisp/prim/macros.el	Sat Jul 10 19:50:33 1993
--- lisp/prim/macros.el	Sun Jul 25 00:08:22 1993
***************
*** 1,5 ****
! ;; Non-primitive commands for keyboard macros.
! ;; Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,9 ----
! ;;; macros.el --- non-primitive commands for keyboard macros.
  
+ ;; Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
+ 
+ ;; Maintainer: FSF
+ ;; Keywords: abbrev
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 6,10 ****
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 1, or (at your option)
  ;; any later version.
  
--- 10,14 ----
  ;; GNU Emacs is free software; you can redistribute it and/or modify
  ;; it under the terms of the GNU General Public License as published by
! ;; the Free Software Foundation; either version 2, or (at your option)
  ;; any later version.
  
***************
*** 18,22 ****
--- 22,35 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Commentary:
+ 
+ ;; Extension commands for keyboard macros.  These permit you to assign
+ ;; a name to the last-defined keyboard macro, expand and insert the
+ ;; lisp corresponding to a macro, query the user from within a macro,
+ ;; or apply a macro to each line in the reason.
  
+ ;;; Code:
+ 
+ ;;;###autoload
  (defun name-last-kbd-macro (symbol)
    "Assign a name to the last keyboard macro defined.
***************
*** 63,70 ****
  	     (forward-char 1))))))
  
  (defun insert-kbd-macro (macroname &optional keys)
    "Insert in buffer the definition of kbd macro NAME, as Lisp code.
! Second argument KEYS non-nil means also record the keys it is on.
!  (This is the prefix argument, when calling interactively.)
  
  This Lisp code will, when executed, define the kbd macro with the
--- 76,84 ----
  	     (forward-char 1))))))
  
+ ;;;###autoload
  (defun insert-kbd-macro (macroname &optional keys)
    "Insert in buffer the definition of kbd macro NAME, as Lisp code.
! Optional second argument KEYS means also record the keys it is on
! \(this is the prefix argument, when calling interactively.)
  
  This Lisp code will, when executed, define the kbd macro with the
***************
*** 74,85 ****
  always makes global bindings.
  
! To save a kbd macro, visit a file of Lisp code such as your ~/.emacs,
  use this command, and then save the file."
    (interactive "CInsert kbd macro (name): \nP")
!   (if (/= (preceding-char) ?\n) (insert "\n"))
!   (insert "(fset '")
    (prin1 macroname (current-buffer))
    (insert "\n   ")
!   (let ((string (events-to-keys (symbol-function macroname) t)))
      (if (stringp string)
  	(insert-kbd-macro-pretty-string string)
--- 88,106 ----
  always makes global bindings.
  
! To save a kbd macro, visit a file of Lisp code such as your `~/.emacs',
  use this command, and then save the file."
    (interactive "CInsert kbd macro (name): \nP")
!   (let (definition)
!     (if (string= (symbol-name macroname) "")
! 	(progn
! 	  (setq macroname 'last-kbd-macro 
!                 definition last-kbd-macro)
! 	  (insert "(setq "))
!         (progn
!           (setq definition (symbol-function macroname))
!           (insert "(fset '")))
      (prin1 macroname (current-buffer))
      (insert "\n   ")
!     (let ((string (events-to-keys definition t)))
        (if (stringp string)
            (insert-kbd-macro-pretty-string string)
***************
*** 94,99 ****
  	  (prin1 macroname (current-buffer))
  	  (insert ")\n")
! 	  (setq keys (cdr keys))))))
  
  (defun kbd-macro-query (flag)
    "Query user during kbd macro execution.
--- 115,121 ----
              (prin1 macroname (current-buffer))
              (insert ")\n")
!             (setq keys (cdr keys)))))))
    
+ ;;;###autoload
  (defun kbd-macro-query (flag)
    "Query user during kbd macro execution.
***************
*** 101,110 ****
   reading keyboard commands even within a kbd macro.
   You can give different commands each time the macro executes.
! Without prefix argument, reads a character.  Your options are:
!  Space -- execute the rest of the macro.
!  DEL -- skip the rest of the macro; start next repetition.
!  C-d -- skip rest of the macro and don't repeat it any more.
!  C-r -- enter a recursive edit, then on exit ask again for a character
!  C-l -- redisplay screen and ask again."
    (interactive "P")
    (or executing-macro
--- 123,133 ----
   reading keyboard commands even within a kbd macro.
   You can give different commands each time the macro executes.
! Without prefix argument, asks whether to continue running the macro.
! Your options are: \\<query-replace-map>
! \\[act]	Finish this iteration normally and continue with the next.
! \\[skip]	Skip the rest of this iteration, and start the next.
! \\[exit]	Stop the macro entirely right now.
! \\[recenter]	Redisplay the screen, then ask again.
! \\[edit]	Enter recursive edit; ask again when you exit from that."
    (interactive "P")
    (or executing-macro
***************
*** 116,136 ****
      (if (not executing-macro)
  	nil
!       (let ((loop t))
  	(while loop
! 	  (let ((char (let ((executing-macro nil)
  			    (defining-kbd-macro nil))
! 			(message "Proceed with macro? (Space, DEL, C-d, C-r or C-l) ")
! 			(read-char))))
! 	    (cond ((= char ? )
  		   (setq loop nil))
! 		  ((= char ?\177)
  		   (setq loop nil)
  		   (setq executing-macro ""))
! 		  ((= char ?\C-d)
  		   (setq loop nil)
  		   (setq executing-macro t))
! 		  ((= char ?\C-l)
  		   (recenter nil))
! 		  ((= char ?\C-r)
  		   (let (executing-macro defining-kbd-macro)
! 		     (recursive-edit))))))))))
--- 139,250 ----
      (if (not executing-macro)
  	nil
!       (let ((loop t)
! 	    (msg (substitute-command-keys
!                   "Proceed with macro?\\<query-replace-map>\
!  (\\[act], \\[skip], \\[exit], \\[recenter], \\[edit]) ")))
  	(while loop
! 	  (let ((key (let ((executing-macro nil)
  			    (defining-kbd-macro nil))
!                        (message msg)
!                        (read-char)))
!                 def)
! 	    (setq key (vector key))
! 	    (setq def (lookup-key query-replace-map key))
! 	    (cond ((eq def 'act)
  		   (setq loop nil))
! 		  ((eq def 'skip)
  		   (setq loop nil)
  		   (setq executing-macro ""))
! 		  ((eq def 'exit)
  		   (setq loop nil)
  		   (setq executing-macro t))
! 		  ((eq def 'recenter)
  		   (recenter nil))
! 		  ((eq def 'edit)
  		   (let (executing-macro defining-kbd-macro)
! 		     (recursive-edit)))
! 		  ((eq def 'quit)
! 		   (setq quit-flag t))
! 		  (t
! 		   (or (eq def 'help)
! 		       (ding))
! 		   (with-output-to-temp-buffer "*Help*"
! 		     (princ
! 		      (substitute-command-keys
! 		       "Specify how to procede with keyboard macro execution.
! Possibilities: \\<query-replace-map>
! \\[act]	Finish this iteration normally and continue with the next.
! \\[skip]	Skip the rest of this iteration, and start the next.
! \\[exit]	Stop the macro entirely right now.
! \\[recenter]	Redisplay the screen, then ask again.
! \\[edit]	Enter recursive edit; ask again when you exit from that."))))
! 		  )))))))
! 
! ;;;###autoload
! (defun apply-macro-to-region-lines (top bottom &optional macro)
!   "For each complete line between point and mark, move to the beginning
! of the line, and run the last keyboard macro.
! 
! When called from lisp, this function takes two arguments TOP and
! BOTTOM, describing the current region.  TOP must be before BOTTOM.
! The optional third argument MACRO specifies a keyboard macro to
! execute.
! 
! This is useful for quoting or unquoting included text, adding and
! removing comments, or producing tables where the entries are regular.
! 
! For example, in Usenet articles, sections of text quoted from another
! author are indented, or have each line start with `>'.  To quote a
! section of text, define a keyboard macro which inserts `>', put point
! and mark at opposite ends of the quoted section, and use
! `\\[apply-macro-to-region-lines]' to mark the entire section.
! 
! Suppose you wanted to build a keyword table in C where each entry
! looked like this:
! 
!     { \"foo\", foo_data, foo_function }, 
!     { \"bar\", bar_data, bar_function },
!     { \"baz\", baz_data, baz_function },
! 
! You could enter the names in this format:
! 
!     foo
!     bar
!     baz
! 
! and write a macro to massage a word into a table entry:
! 
!     \\C-x (
!        \\M-d { \"\\C-y\", \\C-y_data, \\C-y_function },
!     \\C-x )
! 
! and then select the region of un-tablified names and use
! `\\[apply-macro-to-region-lines]' to build the table from the names.
! "
!   (interactive "r")
!   (or macro
!       (progn
! 	(if (null last-kbd-macro)
! 	    (error "No keyboard macro has been defined."))
! 	(setq macro last-kbd-macro)))
!   (save-excursion
!     (let ((end-marker (progn
! 			(goto-char bottom)
! 			(beginning-of-line)
! 			(point-marker)))
! 	  next-line-marker)
!       (goto-char top)
!       (if (not (bolp))
! 	  (forward-line 1))
!       (setq next-line-marker (point-marker))
!       (while (< next-line-marker end-marker)
! 	(goto-char next-line-marker)
! 	(save-excursion
! 	  (forward-line 1)
! 	  (set-marker next-line-marker (point)))
! 	(save-excursion
! 	  (execute-kbd-macro (or macro last-kbd-macro))))
!       (set-marker end-marker nil)
!       (set-marker next-line-marker nil))))
! 
! ;;; macros.el ends here
*** ../lemacs-beta6/lisp/prim/indent.el	Sat Jul 10 19:50:32 1993
--- lisp/prim/indent.el	Sun Jul 25 00:14:03 1993
***************
*** 1,5 ****
! ;; Indentation commands for Emacs
  ;; Copyright (C) 1985, 1992, 1993 Free Software Foundation, Inc.
  
  ;; This file is part of GNU Emacs.
  
--- 1,8 ----
! ;;; indent.el --- indentation commands for Emacs
! 
  ;; Copyright (C) 1985, 1992, 1993 Free Software Foundation, Inc.
  
+ ;; Maintainer: FSF
+ 
  ;; This file is part of GNU Emacs.
  
***************
*** 18,26 ****
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
  ;Now in loaddefs.el
! ;(defvar indent-line-function
! ;  'indent-to-left-margin
! ;  "Function to indent current line.")
  
  (defun indent-according-to-mode ()
--- 21,29 ----
  ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
+ ;;; Code:
  
  ;Now in loaddefs.el
! ;(defvar indent-line-function 'indent-to-left-margin "\
! ;Function to indent current line.")
  
  (defun indent-according-to-mode ()
***************
*** 174,181 ****
  
  (defun edit-tab-stops ()
!   "Edit the tab stops used by tab-to-tab-stop.
  Creates a buffer *Tab Stops* containing text describing the tab stops.
  A colon indicates a column where there is a tab stop.
! You can add or remove colons and then do C-c C-c to make changes take effect."
    (interactive)
    (setq edit-tab-stops-buffer (current-buffer))
--- 177,184 ----
  
  (defun edit-tab-stops ()
!   "Edit the tab stops used by `tab-to-tab-stop'.
  Creates a buffer *Tab Stops* containing text describing the tab stops.
  A colon indicates a column where there is a tab stop.
! You can add or remove colons and then do \\<edit-tab-stops-map>\\[edit-tab-stops-note-changes] to make changes take effect."
    (interactive)
    (setq edit-tab-stops-buffer (current-buffer))
***************
*** 242,243 ****
--- 245,248 ----
      (if tabs
  	(move-to-column (car tabs) t))))
+ 
+ ;;; indent.el ends here
*** ../lemacs-beta6/src/lwlib/xrdb-cpp.c	Fri Jul 16 20:09:55 1993
--- src/lwlib/xrdb-cpp.c	Sun Jul 25 19:59:20 1993
***************
*** 81,85 ****
  
    Push (" -DCLIENTHOST=");
!   XmuGetHostname (s, cpp_string - s);
    s = index (s, 0);
    Push (" -DSERVERHOST=");
--- 81,85 ----
  
    Push (" -DCLIENTHOST=");
!   XmuGetHostname (s, s - cpp_string);
    s = index (s, 0);
    Push (" -DSERVERHOST=");
*** ../lemacs-beta6/src/keyboard.c	Sat Jul 24 10:24:04 1993
--- src/keyboard.c	Sun Jul 25 16:41:47 1993
***************
*** 75,78 ****
--- 75,82 ----
  Lisp_Object Qpre_command_hook, Qpost_command_hook;
  
+ Lisp_Object Qsuspend_hook;
+ Lisp_Object Qsuspend_resume_hook;
+ 
+ 
  /* Current depth in recursive edits.  */
  int command_loop_level;
***************
*** 548,554 ****
       Lisp_Object cmd, record;
  {
-   register Lisp_Object final;
-   register Lisp_Object tem;
    Lisp_Object prefixarg;
    struct backtrace backtrace;
  
--- 552,557 ----
       Lisp_Object cmd, record;
  {
    Lisp_Object prefixarg;
+   Lisp_Object final = cmd;
    struct backtrace backtrace;
  
***************
*** 557,578 ****
    Vcurrent_prefix_arg = prefixarg;
  
!   if (SYMBOLP (cmd))
      {
-       tem = Fget (cmd, Qdisabled, Qnil);
-       if (!NILP (tem))
  	return call1 (Vrun_hooks, Vdisabled_command_hook);
      }
  
!   while (1)
!     {
!       final = cmd;
!       while (SYMBOLP (final))
  	{
! 	  if (EQ (Qunbound, XSYMBOL (final)->function))
! 	    Fsymbol_function (final);    /* Get an error! */
! 	  final = XSYMBOL (final)->function;
! 	}
! 
!       if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
  	do_autoload (final, cmd);
        else
--- 560,572 ----
    Vcurrent_prefix_arg = prefixarg;
  
!   if (SYMBOLP (cmd) && !NILP (Fget (cmd, Qdisabled, Qnil)))
      {
        return call1 (Vrun_hooks, Vdisabled_command_hook);
      }
  
!   for (;;)
      {
!       final = indirect_function (cmd, 1);
!       if (CONSP (final) && EQ (Fcar (final), Qautoload))
  	do_autoload (final, cmd);
        else
***************
*** 594,601 ****
        backtrace.debug_on_exit = 0;
  
!       tem = Fcall_interactively (cmd, record);
  
        backtrace_list = backtrace.next;
!       return tem;
      }
    else if (STRINGP (final) || VECTORP (final))
--- 588,595 ----
        backtrace.debug_on_exit = 0;
  
!       final = Fcall_interactively (cmd, record);
  
        backtrace_list = backtrace.next;
!       return (final);
      }
    else if (STRINGP (final) || VECTORP (final))
***************
*** 760,764 ****
      {
        file = Fexpand_file_name (file, Qnil);
!       dribble = fopen ((char *)XSTRING (file)->data, "w");
      }
    return Qnil;
--- 754,758 ----
      {
        file = Fexpand_file_name (file, Qnil);
!       dribble = fopen ((char *) XSTRING (file)->data, "w");
      }
    return Qnil;
***************
*** 800,804 ****
    if (!NILP (Vrun_hooks))
      {
!       tem = call1 (Vrun_hooks, intern ("suspend-hook"));
        if (!EQ (tem, Qnil)) return Qnil;
      }
--- 794,798 ----
    if (!NILP (Vrun_hooks))
      {
!       tem = call1 (Vrun_hooks, Qsuspend_hook);
        if (!EQ (tem, Qnil)) return Qnil;
      }
***************
*** 815,819 ****
       if it is bound and value is non-nil.  */
    if (!NILP (Vrun_hooks))
!     call1 (Vrun_hooks, intern ("suspend-resume-hook"));
    
    UNGCPRO;
--- 809,813 ----
       if it is bound and value is non-nil.  */
    if (!NILP (Vrun_hooks))
!     call1 (Vrun_hooks, Qsuspend_resume_hook);
    
    UNGCPRO;
***************
*** 1071,1074 ****
--- 1065,1070 ----
    defsymbol (&Qcommand_error, "command-error");
    defsymbol (&Qtop_level, "top-level");
+   defsymbol (&Qsuspend_hook, "suspend-hook");
+   defsymbol (&Qsuspend_resume_hook, "suspend-resume-hook");
  
  #ifndef LISP_COMMAND_LOOP
*** ../lemacs-beta6/src/xdisp.c	Sat Jul 24 10:24:23 1993
--- src/xdisp.c	Tue Jul 27 14:42:57 1993
***************
*** 892,895 ****
--- 892,896 ----
  	{
  	  if (echo_area_glyphs || previous_echo_glyphs) goto finish;
+  	  unhold_window_change ();
  	  return;
  	}
***************
*** 1226,1337 ****
  
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
! void
! layout_window(window,just_this_one)
!      Lisp_Object window;
!      int just_this_one;
  {
!   register struct window *w = XWINDOW(window);
!   struct screen *s = XSCREEN(w->screen);
!   struct buffer *b = XBUFFER(w->buffer);
!   int height,opoint;
!   struct buffer *old = current_buffer;
    struct position pos;
-   register int startp;
-   register int hscroll = XINT (w->hscroll);
-   int tem,force = 0;
-   int first=0;
- 
-   if (s->height == 0) abort();
- 
-   /* If this is a combination window, do its children; that's all.  */
- 
-   if (!NILP (w->vchild))
-     {
-       layout_windows (w->vchild);
-       return;
-     }
-   if (!NILP (w->hchild))
-     {
-       layout_windows (w->hchild);
-       return;
-     }
-   /*
-    * If minibuffer is in a distinct screen, this is the minibuffer window,
-    * and this isn't the minibuffer screen, then return (silently fail).
-    */
-   if (SCREENP(Vglobal_minibuffer_screen) && EQ(window,minibuf_window) &&
-       s != XSCREEN(Vglobal_minibuffer_screen))
-     return;
-   /*
-    * If this is one of (potentially) many minibuffers, then synchronize
-    * prior to doing layout.
-    */
-   if (!SCREENP(Vglobal_minibuffer_screen) && EQ(window,s->minibuffer_window))
-     {
-       if (!EQ(window,minibuf_window))
- 	{
- 	  if (!NILP(Vsynchronize_minibuffers))
- 	    {
- 	      /* We've got a duplicate minibuffer window & need to
- 	       * synchronize it
- 	       */
- 	      sync_minibuffer(window);
- 	    }
- 	  else
- 	    {
- 	      /* We've got a duplicate minibuffer and need to blow off
- 	       * doing any redisplay of its contents
- 	       */
- 	      struct line_header *l = w->lines;
- 	      XFontStruct *xfont = SCREEN_DEFAULT_FONT (s);
- 	      if (l->body != l->end)
- 		{
- 		  free_char_blocks (l->body, l->end->prev);
- 		}
- 	      l->ascent = FONT_ASCENT (xfont);
- 	      l->descent = FONT_DESCENT (xfont);
- 	      l->ypos = w->pixtop + l->ascent;
- 	      l->body = l->end;
- 	      l->body->next = l->body->prev = 0;
- 	      l->end->xpos = w->pixleft + LEFT_MARGIN (b, s);
- 	      l->chars = 0;
- 	      l->changed = 1;
- 	      list_ptr = 0;
- 	      BLOCK_TYPE(list_ptr) = BODY_LINE;
- 	      BLOCK_LINE(list_ptr) = l;
- 	      BLOCK_LINE_START(list_ptr) = l->body;
- 	      BLOCK_LINE_END(list_ptr) = 0;
- 	      BLOCK_LINE_CLEAR(list_ptr) = 1;
- 	      goto do_update;
- 	    }
- 	}
-     }
-   
-   if (NILP (w->buffer))
-     abort ();			/* No buffer...we're screwed */
- 
-   if (redraw_mode_line)
-     w->redo_mode_line = 1;
- 
-   /* Stack is empty initially */
-   list_ptr = -1;
-   /* Set up data on this window; select its buffer and point */
-   height = window_char_height(w);
-   if (!EQ(window,s->minibuffer_window)) height--;
-   if (w == XWINDOW(s->minibuffer_window) && echo_area_glyphs)
-     return;
- 
-   current_buffer = XBUFFER(w->buffer);
- 
-   if (MARGINCHANGE)
-     w->size_change = 1;
  
!   if (!just_this_one
!       && current_buffer == XBUFFER(XWINDOW(selected_window)->buffer))
!     buffer_shared++;
! 
    opoint = point;
  
! /*  if (!just_this_one && !NILP(current_buffer->force_redisplay)) */
    if (!just_this_one)
      {
--- 1227,1249 ----
  
  /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
! static void
! layout_window_1 (Lisp_Object window, int just_this_one, int height)
  {
!   struct buffer *old_current_buffer = current_buffer;
!   struct window *w = XWINDOW (window);
!   struct screen *s = XSCREEN (w->screen);
!   struct buffer *b = XBUFFER (w->buffer);
!   int hscroll = XINT (w->hscroll);
!   int opoint;
!   int startp;
!   int force = 0;
!   int first = 0;
!   int tem;
    struct position pos;
  
!   current_buffer = b;
    opoint = point;
  
! /*  if (!just_this_one && !NILP (current_buffer->force_redisplay)) */
    if (!just_this_one)
      {
***************
*** 1339,1355 ****
      }
    
!   if (!EQ (window,selected_window))
      {
!       SET_PT(marker_position(w->pointm));
        if (point < BEGV)
! 	SET_PT(BEGV);
        else if (point > ZV)
! 	SET_PT(ZV);
      }
  
!   if (XMARKER(w->start)->buffer != current_buffer)
      goto recenter;
  
!   startp = marker_position(w->start);
  
    if (w->force_start)
--- 1251,1267 ----
      }
  
!   if (!EQ (window, selected_window))
      {
!       SET_PT (marker_position (w->pointm));
        if (point < BEGV)
!         SET_PT (BEGV);
        else if (point > ZV)
!         SET_PT (ZV);
      }
  
!   if (XMARKER (w->start)->buffer != b)
      goto recenter;
  
!   startp = marker_position (w->start);
  
    if (w->force_start)
***************
*** 1358,1362 ****
        w->force_start = 0;
        w->last_modified = Qzero;
!       try_layout(window,startp);
        first++;
        if (point_vpos < 0)
--- 1270,1274 ----
        w->force_start = 0;
        w->last_modified = Qzero;
!       try_layout (window,startp);
        first++;
        if (point_vpos < 0)
***************
*** 1365,1375 ****
  	  /* New interface */
  	  pos = *compute_motion (w, startp, 0,
! 				 ((EQ (window, s->minibuffer_window)
  				   && startp == 1)
  				  ? minibuf_prompt_width : 0)
! 				 + (hscroll ? 1 - hscroll : 0),
! 				 ZV, height / 2,
  				 - (1 << (SHORTBITS - 1)),
! 				 hscroll, pos_tab_offset (w, startp));
  	  SET_PT (pos.bufpos);
  	  if (w != XWINDOW (selected_window))
--- 1277,1289 ----
            /* New interface */
            pos = *compute_motion (w, startp, 0,
!                                  (((EQ (window, s->minibuffer_window)
                                     && startp == 1)
                                    ? minibuf_prompt_width : 0)
!                                   + (hscroll ? 1 - hscroll : 0)),
!                                  ZV, 
!                                  height / 2,
                                   - (1 << (SHORTBITS - 1)),
!                                  hscroll, 
!                                  pos_tab_offset (w, startp));
            SET_PT (pos.bufpos);
            if (w != XWINDOW (selected_window))
***************
*** 1529,1533 ****
  	    }
  	}
!       scroll_fail: ;
      }
    
--- 1443,1448 ----
              }
          }
!     scroll_fail: 
!       ;
      }
  
***************
*** 1561,1566 ****
     * Do the window's mode line if appropriate.  
     */
!   if (!EQ(window,s->minibuffer_window) && (w->redo_mode_line
!                                            || w->size_change))
      {
        layout_mode_line(w);
--- 1476,1481 ----
     * Do the window's mode line if appropriate.  
     */
!   if (!EQ (window,s->minibuffer_window) 
!       && (w->redo_mode_line || w->size_change))
      {
        layout_mode_line(w);
***************
*** 1569,1575 ****
  /*  if (old != XBUFFER(w->buffer))
      old->force_redisplay = Qnil; */
-   SET_PT(opoint);
-   current_buffer = old;
  
    /*
     * Window's display structure is accurate.  Stack contains requests
--- 1484,1592 ----
  /*  if (old != XBUFFER(w->buffer))
      old->force_redisplay = Qnil; */
  
+   SET_PT (opoint);
+   current_buffer = old_current_buffer;
+ }
+ 
+ void
+ layout_window(window,just_this_one)
+      Lisp_Object window;
+      int just_this_one;
+ {
+   struct window *w = XWINDOW(window);
+   struct screen *s = XSCREEN(w->screen);
+   struct buffer *b = XBUFFER(w->buffer);
+   int height;
+ 
+   if (s->height == 0) abort();
+ 
+   /* If this is a combination window, do its children; that's all.  */
+ 
+   if (!NILP (w->vchild))
+     {
+       layout_windows (w->vchild);
+       return;
+     }
+   if (!NILP (w->hchild))
+     {
+       layout_windows (w->hchild);
+       return;
+     }
+   /*
+    * If minibuffer is in a distinct screen, this is the minibuffer window,
+    * and this isn't the minibuffer screen, then return (silently fail).
+    */
+   if (SCREENP(Vglobal_minibuffer_screen) && EQ(window,minibuf_window) &&
+       s != XSCREEN(Vglobal_minibuffer_screen))
+     return;
+   /*
+    * If this is one of (potentially) many minibuffers, then synchronize
+    * prior to doing layout.
+    */
+   if (!SCREENP(Vglobal_minibuffer_screen) && EQ(window,s->minibuffer_window))
+     {
+       if (!EQ(window,minibuf_window))
+ 	{
+ 	  if (!NILP(Vsynchronize_minibuffers))
+ 	    {
+ 	      /* We've got a duplicate minibuffer window & need to
+ 	       * synchronize it
+ 	       */
+ 	      sync_minibuffer(window);
+ 	    }
+ 	  else
+ 	    {
+ 	      /* We've got a duplicate minibuffer and need to blow off
+ 	       * doing any redisplay of its contents
+ 	       */
+ 	      struct line_header *l = w->lines;
+ 	      XFontStruct *xfont = SCREEN_DEFAULT_FONT (s);
+ 	      if (l->body != l->end)
+ 		{
+ 		  free_char_blocks (l->body, l->end->prev);
+ 		}
+ 	      l->ascent = FONT_ASCENT (xfont);
+ 	      l->descent = FONT_DESCENT (xfont);
+ 	      l->ypos = w->pixtop + l->ascent;
+ 	      l->body = l->end;
+ 	      l->body->next = l->body->prev = 0;
+ 	      l->end->xpos = w->pixleft + LEFT_MARGIN (b, s);
+ 	      l->chars = 0;
+ 	      l->changed = 1;
+ 	      list_ptr = 0;
+ 	      BLOCK_TYPE(list_ptr) = BODY_LINE;
+ 	      BLOCK_LINE(list_ptr) = l;
+ 	      BLOCK_LINE_START(list_ptr) = l->body;
+ 	      BLOCK_LINE_END(list_ptr) = 0;
+ 	      BLOCK_LINE_CLEAR(list_ptr) = 1;
+ 	      goto do_update;
+ 	    }
+ 	}
+     }
+   
+   if (NILP (w->buffer))
+     abort ();			/* No buffer...we're screwed */
+ 
+   if (redraw_mode_line)
+     w->redo_mode_line = 1;
+ 
+   /* Stack is empty initially */
+   list_ptr = -1;
+   /* Set up data on this window; select its buffer and point */
+   height = window_char_height(w);
+   if (!EQ(window,s->minibuffer_window))
+     height--;
+   if (w == XWINDOW(s->minibuffer_window) && echo_area_glyphs)
+     return;
+ 
+   if (!just_this_one
+       && b == XBUFFER (XWINDOW (selected_window)->buffer))
+     buffer_shared++;
+ 
+   if (BUF_MARGINCHANGE (b))
+     w->size_change = 1;
+ 
+   layout_window_1 (window, just_this_one, height);
+ 
    /*
     * Window's display structure is accurate.  Stack contains requests
***************
*** 2720,2726 ****
        && STRINGP (Voverlay_arrow_string))
      {
! 
!       unsigned char *p = XSTRING(Voverlay_arrow_string)->data;
!       int len = XSTRING(Voverlay_arrow_string)->size;
        /* Overwrite first 'len' displayed characters with the overlay
         * arrow string.
--- 2737,2742 ----
        && STRINGP (Voverlay_arrow_string))
      {
!       unsigned char *p = XSTRING (Voverlay_arrow_string)->data;
!       int len = string_length (XSTRING (Voverlay_arrow_string));
        /* Overwrite first 'len' displayed characters with the overlay
         * arrow string.
***************
*** 3472,3476 ****
    int pixright = w->pixleft + w->pixwidth;
    struct char_block *cb,*prev,*t,*Changed,*endc;
!   unsigned char c; 
    unsigned char c1;
    int lwidth = 0;
--- 3488,3492 ----
    int pixright = w->pixleft + w->pixwidth;
    struct char_block *cb,*prev,*t,*Changed,*endc;
!   unsigned char c = 0; 
    unsigned char c1;
    int lwidth = 0;
*** ../lemacs-beta6/src/commands.h	Sat Jul 24 10:23:44 1993
--- src/commands.h	Sat Jul 24 22:02:36 1993
***************
*** 33,38 ****
  extern int recent_keys_ring_index;
    
! /* Nonzero if input is coming from the keyboard */
  
  #define INTERACTIVE (NILP (Vexecuting_macro) && !noninteractive)
  
--- 33,42 ----
  extern int recent_keys_ring_index;
  
! extern Lisp_Object Qpre_command_hook, Qpost_command_hook;
! 
! extern Lisp_Object recent_keys_ring;
! extern int recent_keys_ring_index;
    
+ /* Nonzero if input is coming from the keyboard */
  #define INTERACTIVE (NILP (Vexecuting_macro) && !noninteractive)
  
***************
*** 70,84 ****
  extern int zmacs_region_stays;
  extern void zmacs_update_region (void);
- 
- #ifdef LOADHIST /* this is just a stupid idea */
- #define LOADHIST_ATTACH(x) \
-  do { if (initialized) \
-         Vcurrent_load_list = Fcons (x, Vcurrent_load_list); } \
-  while (0)
- extern Lisp_Object Vcurrent_load_list;
- extern Lisp_Object Vload_history;
- #else /*! LOADHIST */
- # define LOADHIST_ATTACH(x)
- #endif /*! LOADHIST */
  
  #endif /* _EMACS_COMMANDS_H_ */
--- 74,77 ----
*** ../lemacs-beta6/src/emacsfns.h	Sat Jul 24 10:23:51 1993
--- src/emacsfns.h	Wed Jul 28 11:16:00 1993
***************
*** 123,126 ****
--- 123,128 ----
  extern Lisp_Object long_to_cons (unsigned long);
  extern unsigned long cons_to_long (Lisp_Object);
+ extern Lisp_Object word_to_lisp (unsigned int);
+ extern unsigned int lisp_to_word (Lisp_Object);
  
  extern Lisp_Object Fquo (int nargs, Lisp_Object *args);
***************
*** 202,208 ****
  extern Lisp_Object Fcopy_alist (Lisp_Object alist);
  
- extern Lisp_Object word_to_lisp (unsigned int);
- extern unsigned int lisp_to_word (Lisp_Object);
- 
  extern Lisp_Object Fplay_sound (Lisp_Object sound, Lisp_Object volume);
  extern void bitch_at_user (Lisp_Object sound);
--- 204,207 ----
***************
*** 254,259 ****
  extern Lisp_Object Fpurecopy (Lisp_Object);
  extern void report_pure_usage (int report_impurities);
! extern Lisp_Object make_pure_string (const char *, int len);
! extern Lisp_Object make_pure_pname (const char *, int len);
  extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
  extern Lisp_Object make_pure_vector (int len, Lisp_Object init);
--- 253,258 ----
  extern Lisp_Object Fpurecopy (Lisp_Object);
  extern void report_pure_usage (int report_impurities);
! extern Lisp_Object make_pure_string (const char *, int len, int nocopy);
! extern Lisp_Object make_pure_pname (const char *, int len, int nocopy);
  extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
  extern Lisp_Object make_pure_vector (int len, Lisp_Object init);
***************
*** 324,327 ****
--- 323,337 ----
  extern int isfloat_string (const char *);
  
+ #ifdef LOADHIST /* this is just a stupid idea */
+ #define LOADHIST_ATTACH(x) \
+  do { if (initialized) Vcurrent_load_list = Fcons (x, Vcurrent_load_list); } \
+  while (0)
+ extern Lisp_Object Vcurrent_load_list;
+ extern Lisp_Object Vload_history;
+ #else /*! LOADHIST */
+ # define LOADHIST_ATTACH(x)
+ #endif /*! LOADHIST */
+ 
+ 
  /* Defined in editfns.c */
  extern int clip_to_bounds (int lower, int num, int upper);
***************
*** 437,440 ****
--- 447,451 ----
  extern Lisp_Object Ffile_directory_p (Lisp_Object fn);
  extern Lisp_Object Ffile_readable_p (Lisp_Object fn);
+ extern Lisp_Object Ffile_name_absolute_p (Lisp_Object fn);
  extern Lisp_Object Ffile_exists_p (Lisp_Object fn);
  extern Lisp_Object Ffile_executable_p (Lisp_Object filename);
***************
*** 883,886 ****
--- 894,900 ----
  extern int popup_menu_up_p;
  extern int dbox_up_p;
+ 
+ 
+ 
  
  /* Defined in eval.c */
*** ../lemacs-beta6/src/alloc.c	Sat Jul 24 10:23:41 1993
--- src/alloc.c	Sun Jul 25 23:05:37 1993
***************
*** 49,52 ****
--- 49,55 ----
    ((unsigned) (((char *) (&(((type *)0)->slot_name))) - ((char *)0)))
  
+ #define ALIGN_SIZE(len,unit) \
+   ((((len) + (unit) - 1) / (unit)) * (unit))
+ 
  /* Macro to verify that storage intended for Lisp objects is not
     out of range to fit in the space for a pointer.
***************
*** 345,348 ****
--- 348,360 ----
    return (val);
  }
+ 
+ #ifdef NEED_STRDUP
+ char *
+ strdup (const char *s)
+ {
+   return xstrdup (s);
+ }
+ #endif /* NEED_STRDUP */
+ 
  
  #if 1 /* lemacs doesn't malloc inside signal handlers */
***************
*** 785,789 ****
  
  
! static struct Lisp_Vector *all_vectors;
  
  static struct Lisp_Vector *
--- 797,801 ----
  
  
! static Lisp_Object all_vectors;
  
  static struct Lisp_Vector *
***************
*** 790,796 ****
  make_vector_internal (int sizei)
  {
!   register int sizem = (sizeof (struct Lisp_Vector)
!                         + (sizei - 1) * sizeof (Lisp_Object));
!   register struct Lisp_Vector *p = (struct Lisp_Vector *) xmalloc (sizem);
  
    VALIDATE_LISP_STORAGE (p, sizem);
--- 802,811 ----
  make_vector_internal (int sizei)
  {
!   int sizem = (sizeof (struct Lisp_Vector)
!                /* -1 because struct Lisp_Vector includes 1 slot,
!                 * +1 to account for vector_next */
!                + (sizei - 1 + 1) * sizeof (Lisp_Object)
!                );
!   struct Lisp_Vector *p = (struct Lisp_Vector *) xmalloc (sizem);
  
    VALIDATE_LISP_STORAGE (p, sizem);
***************
*** 799,804 ****
  
    p->size = sizei;
!   p->next = all_vectors;
!   all_vectors = p;
    return (p);
  }
--- 814,819 ----
  
    p->size = sizei;
!   vector_next (p) = all_vectors;
!   XSET (all_vectors, Lisp_Vector, p);
    return (p);
  }
***************
*** 809,815 ****
  make_vector (int length, Lisp_Object init)
  {
!   register int index;
    Lisp_Object vector;
!   register struct Lisp_Vector *p;
  
    if (length < 0)
--- 824,830 ----
  make_vector (int length, Lisp_Object init)
  {
!   int index;
    Lisp_Object vector;
!   struct Lisp_Vector *p;
  
    if (length < 0)
***************
*** 881,885 ****
   *  return some statistics.
   */
! static struct Lisp_Vector *all_bytecodes;
  
  static Lisp_Object
--- 896,900 ----
   *  return some statistics.
   */
! static Lisp_Object all_bytecodes;
  
  static Lisp_Object
***************
*** 888,892 ****
    struct Lisp_Vector *b;
    Lisp_Object new;
!   int size = (sizeof (struct Lisp_Vector) + (len - 1) * sizeof (Lisp_Object));
  
    if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_INTERACTIVE + 1)
--- 903,908 ----
    struct Lisp_Vector *b;
    Lisp_Object new;
!   int size = (sizeof (struct Lisp_Vector) 
!               + ((len - 1 + 1) * sizeof (Lisp_Object)));
  
    if (len < COMPILED_STACK_DEPTH + 1 || len > COMPILED_INTERACTIVE + 1)
***************
*** 895,898 ****
--- 911,917 ----
    if (make_pure)
      {
+       /* Don't need slot for next if pure */
+       size -= sizeof (Lisp_Object);
+ 
        if (pureptr + size > PURESIZE)
          pure_storage_exhausted ();
***************
*** 901,904 ****
--- 920,924 ----
        pureptr += size;
        bump_purestat (&purestat_bytecode, size);
+       b->size = len;
      }
    else
***************
*** 909,916 ****
        INCREMENT_CONS_COUNTER (size);
  
-       b->next = all_bytecodes;
-       all_bytecodes = b;
-     }
    b->size = len;
    for (size = 0; size < len; size++)
      b->contents[size] = Qnil;
--- 929,936 ----
        INCREMENT_CONS_COUNTER (size);
  
        b->size = len;
+       vector_next (b) = all_bytecodes;
+       XSET (all_bytecodes, Lisp_Vector, b);
+     }
    for (size = 0; size < len; size++)
      b->contents[size] = Qnil;
***************
*** 922,926 ****
  init_bytecode_alloc ()
  {
!   all_bytecodes = 0;
  }
  
--- 942,946 ----
  init_bytecode_alloc ()
  {
!   XSET (all_bytecodes, Lisp_Int, 0);
  }
  
***************
*** 1425,1431 ****
  struct string_chars_block
  {
    struct string_chars_block *next;
    struct string_chars_block *prev;
-   int pos;
    /* Contents of string_chars_block->string_chars are interleaved
       string_chars structures (see below) and the actual string data */
--- 1445,1451 ----
  struct string_chars_block
  {
+   int pos;
    struct string_chars_block *next;
    struct string_chars_block *prev;
    /* Contents of string_chars_block->string_chars are interleaved
       string_chars structures (see below) and the actual string data */
***************
*** 1436,1443 ****
  struct string_chars_block *current_string_chars_block;
  
! #define BIG_STRING_SIZE(size) ((size) >= 1020)
  
- #define ROUND_UP_STRING_SIZE(s) (((s) + (sizeof (struct Lisp_String *))) \
- 				  & ~((sizeof (struct Lisp_String *)) - 1))
  /* If SIZE is the length of a string, this returns how many bytes
   *  the string occupies in string_chars_block->string_chars
--- 1456,1461 ----
  struct string_chars_block *current_string_chars_block;
  
! #define BIG_STRING_SIZE(size) ((size) >= STRING_CHARS_BLOCK_SIZE)
  
  /* If SIZE is the length of a string, this returns how many bytes
   *  the string occupies in string_chars_block->string_chars
***************
*** 1444,1449 ****
   *  (including alignment padding).
   */
! #define STRING_FULLSIZE(size) ROUND_UP_STRING_SIZE ((size) \
! 					     + sizeof (struct Lisp_String *))
  #define CHARS_TO_STRING_CHAR(x) \
    ((struct string_chars *) \
--- 1462,1469 ----
   *  (including alignment padding).
   */
! #define STRING_FULLSIZE(s) \
!    ALIGN_SIZE (((s) + 1 + sizeof (struct Lisp_String *)),\
!                ALIGNOF (struct Lisp_String *))
! 
  #define CHARS_TO_STRING_CHAR(x) \
    ((struct string_chars *) \
***************
*** 1576,1586 ****
  
  Lisp_Object
! make_pure_string (const char *data, int length)
  {
    Lisp_Object new;
    struct Lisp_String *s;
!   int size = sizeof (struct Lisp_String) + ROUND_UP_STRING_SIZE (length);
!   int puresize = ((size + sizeof (Lisp_Object) - 1)
!                   / sizeof (Lisp_Object)) * sizeof (Lisp_Object);
  
    if (symbols_initialised)
--- 1596,1609 ----
  
  Lisp_Object
! make_pure_string (const char *data, int length,
!                   int no_need_to_copy_data)
  {
    Lisp_Object new;
    struct Lisp_String *s;
!   int size = (sizeof (struct Lisp_String) + ((no_need_to_copy_data) 
!                                              ? 0 
!                                              /* + 1 for terminating 0 */
!                                              : (length + 1)));
!   int puresize = ALIGN_SIZE (size, ALIGNOF (Lisp_Object));
  
    if (symbols_initialised)
***************
*** 1602,1608 ****
    s = (struct Lisp_String *) (PUREBEG + pureptr);
    s->size = length;
!   s->data = (unsigned char *) (PUREBEG + pureptr + sizeof (struct Lisp_String));
    memcpy (s->data, data, length);
    s->data[length] = 0;
    s->dup_list = Qnil;
    pureptr += puresize;
--- 1625,1639 ----
    s = (struct Lisp_String *) (PUREBEG + pureptr);
    s->size = length;
!   if (no_need_to_copy_data)
!   {
!     s->data = (unsigned char *) data;
!   }
!   else
!   {
!     s->data = (unsigned char *) s + sizeof (struct Lisp_String);
      memcpy (s->data, data, length);
      s->data[length] = 0;
+   }
+   /* A waste: always Qnil in pure strings. */
    s->dup_list = Qnil;
    pureptr += puresize;
***************
*** 1620,1626 ****
  
  Lisp_Object
! make_pure_pname (const char *data, int length)
  {
!   Lisp_Object name = make_pure_string (data, length);
    bump_purestat (&purestat_string_pname, pure_sizeof (name));
  
--- 1651,1657 ----
  
  Lisp_Object
! make_pure_pname (const char *data, int length, int no_need_to_copy_data)
  {
!   Lisp_Object name = make_pure_string (data, length, no_need_to_copy_data);
    bump_purestat (&purestat_string_pname, pure_sizeof (name));
  
***************
*** 1749,1753 ****
      case Lisp_String:
        return make_pure_string ((char *) XSTRING (obj)->data,
! 			       string_length (XSTRING (obj)));
  
      case Lisp_Vector:
--- 1780,1785 ----
      case Lisp_String:
        return make_pure_string ((char *) XSTRING (obj)->data,
! 			       string_length (XSTRING (obj)), 
!                                0);
  
      case Lisp_Vector:
***************
*** 2147,2153 ****
  	struct Lisp_String *ptr = XSTRING (obj);
          int size = string_length (ptr);
!         size = sizeof (struct Lisp_String) + ROUND_UP_STRING_SIZE (size);
!         size = ((size + sizeof (Lisp_Object) - 1)
!                 / sizeof (Lisp_Object)) * sizeof (Lisp_Object);
          total += size;
        }
--- 2179,2194 ----
  	struct Lisp_String *ptr = XSTRING (obj);
          int size = string_length (ptr);
! 
!         if (ptr->data != (unsigned char *) ptr + sizeof (struct Lisp_String))
!         {
!           /* string-data not allocated contiguously.  
!              Probably (better be!!) a pointer constant "C" data. */
!           size = sizeof (struct Lisp_String);
!         }
!         else
!         {
!           size = sizeof (struct Lisp_String) + size + 1;
!           size = ALIGN_SIZE (size, sizeof (Lisp_Object));
!         }
          total += size;
        }
***************
*** 2214,2218 ****
  
          total += (sizeof (struct Lisp_Vector)
!                   + (len - 1) * sizeof (Lisp_Object));
  #if 0 /* unused */
          if (!recurse)
--- 2255,2259 ----
  
          total += (sizeof (struct Lisp_Vector)
!                   + (len - 1 + 1) * sizeof (Lisp_Object));
  #if 0 /* unused */
          if (!recurse)
***************
*** 2337,2344 ****
  
  static void
! sweep_vectors_1 (struct Lisp_Vector **prev, 
                   int *used, int *total, int *storage)
  {
!   struct Lisp_Vector *vector;
    int num_used = 0;
    int total_size = 0;
--- 2378,2385 ----
  
  static void
! sweep_vectors_1 (Lisp_Object *prev, 
                   int *used, int *total, int *storage)
  {
!   Lisp_Object vector;
    int num_used = 0;
    int total_size = 0;
***************
*** 2345,2361 ****
    int total_storage = 0;
  
!   for (vector = *prev; vector; )
      {
!       int len = vector->size;
        if (len < 0)     /* marked */
  	{
            len = - (len + 1);
! 	  vector->size = len;
  	  total_size += len;
!           total_storage += (sizeof (struct Lisp_Vector)
!                             + MALLOC_OVERHEAD
!                             + (len - 1) * sizeof (Lisp_Object));
  	  num_used++;
! 	  prev = &(vector->next);
  	  vector = *prev;
  	}
--- 2386,2403 ----
    int total_storage = 0;
  
!   for (vector = *prev; VECTORP (vector); )
      {
!       struct Lisp_Vector *v = XVECTOR (vector);
!       int len = v->size;
        if (len < 0)     /* marked */
  	{
            len = - (len + 1);
! 	  v->size = len;
  	  total_size += len;
!           total_storage += (MALLOC_OVERHEAD
!                             + sizeof (struct Lisp_Vector)
!                             + (len - 1 + 1) * sizeof (Lisp_Object));
  	  num_used++;
! 	  prev = &(vector_next (v));
  	  vector = *prev;
  	}
***************
*** 2362,2368 ****
        else
  	{
!           struct Lisp_Vector *next = vector->next;
            *prev = next;
! 	  xfree (vector);
  	  vector = next;
  	}
--- 2404,2410 ----
        else
  	{
!           Lisp_Object next = vector_next (v);
            *prev = next;
! 	  xfree (v);
  	  vector = next;
  	}
***************
*** 3217,3221 ****
    pureptr = 0;
    breathing_space = 0;
!   all_vectors = 0;
    all_lcrecords = 0;
    ignore_warnings = 1;
--- 3259,3263 ----
    pureptr = 0;
    breathing_space = 0;
!   XSET (all_vectors, Lisp_Int, 0); /* Qzero may not be set yet. */
    all_lcrecords = 0;
    ignore_warnings = 1;
*** ../lemacs-beta6/src/puresize.h	Sat Jul 24 10:24:11 1993
--- src/puresize.h	Sun Jul 25 00:34:22 1993
***************
*** 30,34 ****
  #  define PURESIZE 570000
  # else
! #  define PURESIZE 282000
  # endif
  #endif
--- 30,34 ----
  #  define PURESIZE 570000
  # else
! #  define PURESIZE 290000
  # endif
  #endif
*** ../lemacs-beta6/src/lisp.h	Tue Jul 13 01:04:02 1993
--- src/lisp.h	Sun Jul 25 17:28:03 1993
***************
*** 194,199 ****
  #define XSYMBOL(a) ((struct Lisp_Symbol *) XPNTR(a))
  #define XMARKER(a) ((struct Lisp_Marker *) XPNTR(a))
- #define XEXTENT(a) ((EXTENT) XPNTR(a))
- #define XEXTENT_REPLICA(a) ((EXTENT_REPLICA) XPNTR(a))
  #ifdef LISP_FLOAT_TYPE
  # define XFLOAT(a) ((struct Lisp_Float *) XPNTR(a))
--- 194,197 ----
***************
*** 225,232 ****
    {
      int size;
!     struct Lisp_Vector *next;
      Lisp_Object contents[1];
    };
  #define vector_length(v) ((v)->size)
  
  /* In a symbol, the markbit of the plist is used as the gc mark bit */
--- 223,233 ----
    {
      int size;
!     /* Now uses vector->contents[size], terminated by Qzero.
!      * This means that pure vectors don't need a "next" */
!     /* struct Lisp_Vector *next; */
      Lisp_Object contents[1];
    };
  #define vector_length(v) ((v)->size)
+ #define vector_next(v) ((v)->contents[(v)->size])
  
  /* In a symbol, the markbit of the plist is used as the gc mark bit */
***************
*** 384,392 ****
           ; \
         else if (MARKERP ((x))) \
!          x = make_number (marker_position (x)); \
!        else x = wrong_type_argument (Qinteger_or_marker_p, (x)); } while (0)
  
  #define CHECK_SUBR(x, i) \
!   do { if (!SUBRP ((x))) x = wrong_type_argument (Qsubrp, (x)); } while (0)
  
  #ifdef LISP_FLOAT_TYPE
--- 385,394 ----
           ; \
         else if (MARKERP ((x))) \
!          (x) = make_number (marker_position ((x))); \
!        else \
!          (x) = wrong_type_argument (Qinteger_or_marker_p, ((x))); } while (0)
  
  #define CHECK_SUBR(x, i) \
!   do { if (!SUBRP ((x))) (x) = wrong_type_argument (Qsubrp, ((x))); } while (0)
  
  #ifdef LISP_FLOAT_TYPE
***************
*** 399,415 ****
  
  #define CHECK_FLOAT(x, i) \
!   do { if (!FLOATP (x)) xm = wrong_type_argument (Qfloatp, (x)); } while (0)
  
  #define CHECK_NUMBER(x, i)  \
!   do { if ( !FIXNUMP (x) && !FLOATP (x)) \
!        x = wrong_type_argument (Qnumberp, (x)); } while (0)
  
  #define CHECK_NUMBER_COERCE_MARKER(x, i) \
!   do { if (FIXNUMP (x) || FLOATP (x)) \
           ; \
         else if (MARKERP ((x))) \
!          x = make_number (marker_position (x)); \
         else  \
!          x = wrong_type_argument (Qnumber_or_marker_p, (x)); } while (0)
  
  #else  /* not LISP_FLOAT_TYPE */
--- 401,417 ----
  
  #define CHECK_FLOAT(x, i) \
!   do { if (!FLOATP (x)) (x) = wrong_type_argument (Qfloatp, ((x))); } while (0)
  
  #define CHECK_NUMBER(x, i)  \
!   do { if ( !FIXNUMP ((x)) && !FLOATP ((x))) \
!         (x) = wrong_type_argument (Qnumberp, ((x))); } while (0)
  
  #define CHECK_NUMBER_COERCE_MARKER(x, i) \
!   do { if (FIXNUMP ((x)) || FLOATP ((x))) \
           ; \
         else if (MARKERP ((x))) \
!          (x) = make_number (marker_position ((x))); \
         else  \
!          (x) = wrong_type_argument (Qnumber_or_marker_p, ((x))); } while (0)
  
  #else  /* not LISP_FLOAT_TYPE */
***************
*** 427,467 ****
  
  
- #if 1 /* Check_impure is not time-critical -- just use general version
-          (and incur one whole extra comparison!) */
  #define CHECK_IMPURE(obj) \
    do { if (purified (obj)) pure_write_error (); } while (0)
  
- #else /* unexec-specific versions of CHECK_IMPURE */
- 
- #ifdef VIRT_ADDR_VARIES
- 
- /* For machines like APOLLO where text and data can go anywhere
-    in virtual memory.  */
- #define CHECK_IMPURE(obj) \
-   { extern int pure[]; \
-     if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) ((char *) pure + PURESIZE) \
- 	&& (PNTR_COMPARISON_TYPE) XPNTR (obj) >= (PNTR_COMPARISON_TYPE) pure) \
-       pure_write_error (); }
- 
- #else /* not VIRT_ADDR_VARIES */
- #ifdef PNTR_COMPARISON_TYPE
- 
- /* when PNTR_COMPARISON_TYPE is not the default (unsigned int) */
- #define CHECK_IMPURE(obj) \
-   { extern char my_edata; \
-     if ((PNTR_COMPARISON_TYPE) XPNTR (obj) < (PNTR_COMPARISON_TYPE) &my_edata) \
-       pure_write_error (); }
- 
- #else /* not VIRT_ADDRESS_VARIES, not PNTR_COMPARISON_TYPE */
- 
- #define CHECK_IMPURE(obj) \
-   { extern char my_edata; \
-     if (XPNTR (obj) < (unsigned int) &my_edata) \
-       pure_write_error (); }
- 
- #endif /* PNTR_COMPARISON_TYPE */
- #endif /* VIRT_ADDRESS_VARIES */
- #endif /* if 0'd specific purity tests */
- 
  /* Cast pointers to this type to compare them.  Some machines want int.  */
  #ifndef PNTR_COMPARISON_TYPE
--- 429,435 ----
***************
*** 578,581 ****
--- 546,551 ----
  extern int check_sigio (void);
  
+ extern void signal_quit (void);
+ 
  /* Nonzero if ought to quit now.  */
  #define QUITP ((sigio_happened ? check_sigio() : 0), \
***************
*** 584,588 ****
  /* Check quit-flag and quit if it is non-nil. */
  #define QUIT \
!   do { if (QUITP) { Vquit_flag = Qnil; Fsignal (Qquit, Qnil); } } while (0)
  
  
--- 554,558 ----
  /* Check quit-flag and quit if it is non-nil. */
  #define QUIT \
!   do { if (QUITP) signal_quit (); } while (0)
  
  
***************
*** 712,716 ****
  
  /* Call staticpro (&var) to protect static variable `var'. */
- 
  extern void staticpro (Lisp_Object *);
  
--- 682,685 ----
***************
*** 719,723 ****
  extern int initialized;
  
! extern int immediate_quit;	   /* Nonzero means ^G can quit instantly */
  
  #ifdef __GNUC__
--- 688,693 ----
  extern int initialized;
  
! /* Nonzero means ^G can quit instantly */
! extern int immediate_quit;
  
  #ifdef __GNUC__
*** ../lemacs-beta6/src/xobjs.c	Sat Jul 24 10:24:25 1993
--- src/xobjs.c	Wed Jul 28 12:08:26 1993
***************
*** 40,44 ****
  
  #ifdef HAVE_XPM
! #include <X11/xpm.h>
  #endif
  
--- 40,44 ----
  
  #ifdef HAVE_XPM
! #include <xpm.h> /* >>> Was X11/xpm.h  headers misinstalled at this site */
  #endif
  
***************
*** 48,55 ****
    XtScreen ((get_x_screen ((l)))->display.x->widget)
  
! #define finalose(type,ptr) do { Lisp_Object obj; XSETR (obj, (type), ptr); \
!  signal_error (Qerror, list2 (build_string ( \
!     "Can't dump an emacs containing window system objects"), \
! 			      (obj))); } while (0)
  
  Lisp_Object Qpixelp;
--- 48,62 ----
    XtScreen ((get_x_screen ((l)))->display.x->widget)
  
! void
! finalose (void *ptr)
! {
!   Lisp_Object obj; 
!   XSET (obj, Lisp_Record, ptr);
! 
!   signal_error (Qerror, 
!                 list2 (build_string ("Can't dump an emacs "
!                                      "containing window system objects"),
!                        obj));
! }
  
  Lisp_Object Qpixelp;
***************
*** 75,83 ****
    struct Lisp_Pixel *p = XPIXEL (obj);
    if (print_readably)
!     error ("printing unreadable object #<pixel 0x%x>", (int) XPIXEL (obj));
    write_string_1 ("#<pixel ", -1, printcharfun);
    print_internal (p->color_name, printcharfun, 0);
!   sprintf (buf, " %d=(%X,%X,%X)>", p->color.pixel,
! 	   p->color.red, p->color.green, p->color.blue);
    write_string_1 (buf, -1, printcharfun);
  }
--- 82,93 ----
    struct Lisp_Pixel *p = XPIXEL (obj);
    if (print_readably)
!     error ("printing unreadable object #<pixel 0x%x>",
!            p->header.uid);
    write_string_1 ("#<pixel ", -1, printcharfun);
    print_internal (p->color_name, printcharfun, 0);
!   sprintf (buf, " %d=(%d,%d,%d) 0x%x>", 
!            p->color.pixel,
! 	   p->color.red, p->color.green, p->color.blue,
!            p->header.uid);
    write_string_1 (buf, -1, printcharfun);
  }
***************
*** 87,91 ****
  {
    struct Lisp_Pixel *p = (struct Lisp_Pixel *) header;
!   if (for_disksave) finalose (Lisp_Pixel, p);
    BLOCK_INPUT;
    XFreeColors (DisplayOfScreen (p->screen),
--- 97,101 ----
  {
    struct Lisp_Pixel *p = (struct Lisp_Pixel *) header;
!   if (for_disksave) finalose (p);
    BLOCK_INPUT;
    XFreeColors (DisplayOfScreen (p->screen),
***************
*** 184,190 ****
  print_cursor (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
  {
    struct Lisp_Cursor *c = XCURSOR (obj);
    if (print_readably)
!     error ("printing unreadable object #<cursor 0x%x>", (int) XCURSOR (obj));
  
    write_string_1 ("#<cursor ", -1, printcharfun);
--- 194,201 ----
  print_cursor (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
  {
+   char buf[20];
    struct Lisp_Cursor *c = XCURSOR (obj);
    if (print_readably)
!     error ("printing unreadable object #<cursor 0x%x>", c->header.uid);
  
    write_string_1 ("#<cursor ", -1, printcharfun);
***************
*** 192,203 ****
    if (!NILP (c->fg))
      {
!       char buf[100];
!       sprintf (buf, " (%s/%s)>",
! 	       XSTRING (XPIXEL (c->fg)->color_name)->data,
! 	       XSTRING (XPIXEL (c->bg)->color_name)->data);
!       write_string_1 (buf, -1, printcharfun);
      }
!   else
!     write_string_1 (">", -1, printcharfun);
  }
  
--- 203,213 ----
    if (!NILP (c->fg))
      {
!       write_string_1 (" (", -1, printcharfun);
!       print_internal (XPIXEL (c->fg)->color_name, printcharfun, 0);
!       write_string_1 ("/", -1, printcharfun);
!       print_internal (XPIXEL (c->bg)->color_name, printcharfun, 0);
      }
!   sprintf (buf, "%s 0x%x>", (NILP (c->fg) ? "" : ")"), c->header.uid);
!   write_string_1 (buf, -1, printcharfun);
  }
  
***************
*** 206,210 ****
  {
    struct Lisp_Cursor *c = (struct Lisp_Cursor *) header;
!   if (for_disksave) finalose (Lisp_Cursor, c);
    BLOCK_INPUT;
    XFreeCursor (DisplayOfScreen (c->screen), c->cursor);
--- 216,220 ----
  {
    struct Lisp_Cursor *c = (struct Lisp_Cursor *) header;
!   if (for_disksave) finalose (c);
    BLOCK_INPUT;
    XFreeCursor (DisplayOfScreen (c->screen), c->cursor);
***************
*** 384,391 ****
  print_font (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
  {
!   char buf[100];
    struct Lisp_Font *f = XFONT (obj);
    if (print_readably)
!     error ("printing unreadable object #<font 0x%x>", (int) XFONT (obj));
    write_string_1 ("#<font ", -1, printcharfun);
    print_internal (f->name, printcharfun, 0);
--- 394,401 ----
  print_font (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
  {
!   char buf[20];
    struct Lisp_Font *f = XFONT (obj);
    if (print_readably)
!     error ("printing unreadable object #<font 0x%x>", f->font->fid);
    write_string_1 ("#<font ", -1, printcharfun);
    print_internal (f->name, printcharfun, 0);
***************
*** 400,404 ****
    if (! f->font) /* font is 0 on tty screens */
      return;
!   if (for_disksave) finalose (Lisp_Font, f);
    BLOCK_INPUT;
    XFreeFont (DisplayOfScreen (f->screen), f->font);
--- 410,414 ----
    if (! f->font) /* font is 0 on tty screens */
      return;
!   if (for_disksave) finalose (f);
    BLOCK_INPUT;
    XFreeFont (DisplayOfScreen (f->screen), f->font);
***************
*** 503,510 ****
    char *s;
    if (print_readably)
!     error ("printing unreadable object #<pixmap 0x%x>", (int) XPIXMAP (obj));
    write_string_1 ((p->depth ? "#<pixmap " : "#<bitmap "), -1, printcharfun);
    if (STRINGP (p->file_name) &&
        (s = strrchr ((char *) XSTRING (p->file_name)->data, '/')))
      write_string_1 (s+1, -1, printcharfun);
    else
--- 513,522 ----
    char *s;
    if (print_readably)
!     error ("printing unreadable object #<pixmap 0x%x>", p->header.uid);
! 
    write_string_1 ((p->depth ? "#<pixmap " : "#<bitmap "), -1, printcharfun);
    if (STRINGP (p->file_name) &&
        (s = strrchr ((char *) XSTRING (p->file_name)->data, '/')))
+     /* >>> Not GC safe.  printcharfun may relocate p->file_name->data */
      write_string_1 (s+1, -1, printcharfun);
    else
***************
*** 527,531 ****
        write_string_1 (buf, -1, printcharfun);
      }
!   write_string_1 (")>", -1, printcharfun);
  }
  
--- 539,544 ----
        write_string_1 (buf, -1, printcharfun);
      }
!   sprintf (buf, ") 0x%x>", p->header.uid);
!   write_string_1 (buf, -1, printcharfun);
  }
  
***************
*** 534,538 ****
  {
    struct Lisp_Pixmap *p = (struct Lisp_Pixmap *) header;
!   if (for_disksave) finalose (Lisp_Pixmap, p);
    BLOCK_INPUT;
    XFreePixmap (DisplayOfScreen (p->screen), p->pixmap);
--- 547,551 ----
  {
    struct Lisp_Pixmap *p = (struct Lisp_Pixmap *) header;
!   if (for_disksave) finalose (p);
    BLOCK_INPUT;
    XFreePixmap (DisplayOfScreen (p->screen), p->pixmap);
***************
*** 539,543 ****
    if (p->mask && p->mask != p->pixmap)
      XFreePixmap (DisplayOfScreen (p->screen), p->mask);
!   if (p->npixels)
      XFreeColors (DisplayOfScreen (p->screen),
  		 DefaultColormapOfScreen (p->screen),
--- 552,556 ----
    if (p->mask && p->mask != p->pixmap)
      XFreePixmap (DisplayOfScreen (p->screen), p->mask);
!   if (p->npixels != 0)
      XFreeColors (DisplayOfScreen (p->screen),
  		 DefaultColormapOfScreen (p->screen),
***************
*** 613,616 ****
--- 626,630 ----
  #define USE_XBMLANGPATH
  
+ /*>>> Jamie:  why aren't you using locate_file??? */
  static int
  locate_pixmap_file (char *in, char *out)
***************
*** 663,666 ****
--- 677,687 ----
  
  #ifdef HAVE_XPM
+  /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()...
+     There's no version number in xpm.h, but this should do.
+   */
+ # ifdef XpmExactColors
+ #  define XPM_DOES_BUFFERS
+ # endif
+ 
  Lisp_Object Vxpm_color_symbols;
  
***************
*** 668,674 ****
  extract_xpm_color_names (XpmAttributes *xpmattrs, Lisp_Object screen)
  {
!   Screen *xs;
!   Display *dpy;
!   Colormap cmap;
    XColor color;
    Lisp_Object rest;
--- 689,695 ----
  extract_xpm_color_names (XpmAttributes *xpmattrs, Lisp_Object screen)
  {
!   Screen *xs = LISP_SCREEN_TO_X_SCREEN (screen);
!   Display *dpy = DisplayOfScreen (xs);
!   Colormap cmap = DefaultColormapOfScreen (xs);
    XColor color;
    Lisp_Object rest;
***************
*** 676,680 ****
    int i;
    XpmColorSymbol *symbols;
!   struct gcpro gcpro1;
  
    if (NILP (Vxpm_color_symbols))
--- 697,701 ----
    int i;
    XpmColorSymbol *symbols;
!   struct gcpro gcpro1, gcpro2;
  
    if (NILP (Vxpm_color_symbols))
***************
*** 681,689 ****
      return 0;
    CHECK_CONS (Vxpm_color_symbols, 0);
-   xs = LISP_SCREEN_TO_X_SCREEN (screen);
-   dpy = DisplayOfScreen (xs);
-   cmap = DefaultColormapOfScreen (xs);
  
!   GCPRO1 (results);
  
    /* We built up results to be (("name" . #<pixel>) ...) so that if an
--- 702,707 ----
      return 0;
    CHECK_CONS (Vxpm_color_symbols, 0);
  
!   GCPRO2 (results, screen);
  
    /* We built up results to be (("name" . #<pixel>) ...) so that if an
***************
*** 737,801 ****
  }
  
- #endif
- 
- #ifdef HAVE_XPM
-  /* xpm 3.2g and better has XpmCreatePixmapFromBuffer()...
-     There's no version number in xpm.h, but this should do.
-   */
- # define XPM_DOES_BUFFERS defined(XpmExactColors)
- #endif
- 
  static Lisp_Object
! make_pixmap_from_file (Lisp_Object name, Lisp_Object screen)
  {
-   Screen *xs;
-   char file [1024];
-   int xhot, yhot;
-   unsigned int w, h, d;
-   unsigned char *data = 0;
    int result;
    Pixmap pixmap;
    Pixmap mask = 0;
- #ifdef HAVE_XPM
    XpmAttributes xpmattrs;
    XpmColorSymbol *color_symbols;
-   Pixel *pixels;
-   int npixels;
-   int retry_in_mono = 0;
- # ifdef XPM_DOES_BUFFERS
-   int raw_data_p = 0;
- # endif
- #endif /* HAVE_XPM */
  
!   CHECK_STRING (name, 0);
!   xs = LISP_SCREEN_TO_X_SCREEN (screen);
  
!   if (XSTRING (name)->size > 9 &&
!       !strncmp ("/* XPM */", (char *) XSTRING (name)->data, 9))
! #ifdef HAVE_XPM
! # ifdef XPM_DOES_BUFFERS
!     raw_data_p = 1;
! # else /* !XPM_DOES_BUFFERS */
!     signal_error (Qerror, list2 (build_string
! 				 ("XPM library is too old: no raw data"),
! 				 name));
! # endif /* !XPM_DOES_BUFFERS */
! #else /* !XPM */
!     signal_error (Qerror, list2 (build_string ("no support for XPM data"),
! 				 name));
! #endif /* !XPM */
!   else if (! locate_pixmap_file ((char *) XSTRING (name)->data, file))
!     signal_error (Qfile_error,
! 		  list3 (build_string ("Opening pixmap file"),
! 			 build_string ("no such file or directory"),
! 			 name));
!   else
!     name = build_string (file);
  
- #ifdef HAVE_XPM
-  RETRY:
    BLOCK_INPUT;
!   xpmattrs.valuemask = XpmReturnPixels;
    color_symbols = extract_xpm_color_names (&xpmattrs, screen);
  # ifdef XPM_DOES_BUFFERS
    if (raw_data_p)
--- 755,788 ----
  }
  
  static Lisp_Object
! try_reading_xpm_bitmap (Lisp_Object screen, Lisp_Object name,
!                         char *file, int raw_data_p)
  {
    int result;
+   int retry_in_mono = 0;
+   Screen *xs = LISP_SCREEN_TO_X_SCREEN (screen);
+ 
    Pixmap pixmap;
    Pixmap mask = 0;
    XpmAttributes xpmattrs;
+ 
+   {
      XpmColorSymbol *color_symbols;
  
!   retry:
  
!     memset (&xpmattrs, 0, sizeof (xpmattrs)); /* want xpmInitAttributes */
!     xpmattrs.valuemask = XpmReturnPixels;
!     if (retry_in_mono)
!     {
!       xpmattrs.depth = 1;
!       xpmattrs.valuemask |= XpmDepth;
!     }
  
      BLOCK_INPUT;
!     /* >>> Seems kind of dicey having a BLOCK_INPUT around a function
!        which calls eval!!! */
      color_symbols = extract_xpm_color_names (&xpmattrs, screen);
+ 
  # ifdef XPM_DOES_BUFFERS
      if (raw_data_p)
***************
*** 809,824 ****
  				  RootWindowOfScreen (xs), file,
  				  &pixmap, &mask, &xpmattrs);
-   w = xpmattrs.width;
-   h = xpmattrs.height;
-   xhot = (xpmattrs.valuemask & XpmHotspot) ? xpmattrs.x_hotspot : -1;
-   yhot = (xpmattrs.valuemask & XpmHotspot) ? xpmattrs.y_hotspot : -1;
-   npixels = xpmattrs.npixels;
-   if (npixels)
-     {
-       pixels = xmalloc (npixels * sizeof (Pixel));
-       memcpy (pixels, xpmattrs.pixels, npixels * sizeof (Pixel));
-     }
-   else
-     pixels = 0;
  
    if (color_symbols)
--- 796,799 ----
***************
*** 828,833 ****
--- 803,812 ----
        xpmattrs.numsymbols = 0;
      }
+ 
+     /* >>>Can lose if XpmXXX returned an error without first initialising 
+        this structure!!! */ 
      XpmFreeAttributes (&xpmattrs);
      UNBLOCK_INPUT;
+   }
  
    switch (result)
***************
*** 834,872 ****
      {
      case XpmSuccess:
!       /* XpmReadFileToPixmap() doesn't return the depth (bogus!) so we need to
!  	 get it ourself.  (No, xpmattrs.depth is not it; that's an input slot,
! 	 not output.)  We could just assume that it has the same depth as the
! 	 root window, but some screens allow more than one depth, so that
! 	 isn't necessarily correct (I guess?)
!        */
!       {
! 	Window root;
!  	int x, y;
!  	unsigned int w2, h2, bw;
!  	BLOCK_INPUT;
!  	if (!XGetGeometry (DisplayOfScreen (xs), pixmap, &root, &x, &y,
! 			   &w2, &h2, &bw, &d))
!  	  abort ();
!  	if (w != w2 || h != h2) abort ();
! 	UNBLOCK_INPUT;
!  	if (raw_data_p) name = Qnil;
! 	return make_pixmap_1 (name, xs, xhot, yhot, w, h, d, pixmap, mask,
! 			      pixels, npixels);
!       }
  
      case XpmFileInvalid:
        if (raw_data_p)
  	signal_error (Qerror, list2 (build_string ("invalid XPM data"),
  				     name));
!       /* Ok, we'll try to read the file as an XBM, and error if that fails. */
!       break;
  	  
      case XpmColorFailed:
!       /* If we couldn't allocate any colors for this image, then silently
! 	 retry in monochrome.  If that fails too, then signal an error.
! 	 */
!       if (npixels)
! 	xfree (pixels);
!       if (retry_in_mono)	/* second time; blow out. */
  	signal_error (Qfile_error,
  		      list3 (build_string ("Reading pixmap file"),
--- 813,830 ----
    {
    case XpmSuccess:
!     break;
  
    case XpmFileInvalid:
+     {
        if (raw_data_p)
          signal_error (Qerror, list2 (build_string ("invalid XPM data"),
                                       name));
!       return (Qnil);
!     }
  
    case XpmColorFailed:
!     {
!       if (retry_in_mono)
!         /* second time; blow out. */
          signal_error (Qfile_error,
                        list3 (build_string ("Reading pixmap file"),
***************
*** 873,883 ****
  			     build_string ("color allocation failed"),
  			     name));
!       /* else... */
!       retry_in_mono = 1;
!       xpmattrs.depth = 1;
!       xpmattrs.valuemask |= XpmDepth;
!       goto RETRY;
  
      case XpmColorError:
        /* Maybe we should just read it in monochrome instead of allowing the
  	 colors to be substituted?
--- 831,839 ----
                               build_string ("color allocation failed"),
                               name));
!       goto retry;
!     }
  
      case XpmColorError:
+     {
        /* Maybe we should just read it in monochrome instead of allowing the
           colors to be substituted?
***************
*** 886,897 ****
  	message ("color substitution performed for XPM data");
        else
! 	{
! 	  char buf [2000];
! 	  sprintf (buf, "color substitution performed for file \"%s\"",
! 		   (char *) XSTRING (name)->data);
! 	  message (buf);
! 	}
        break;
      case XpmNoMemory:
        signal_error (Qfile_error,
  		    list3 (build_string (raw_data_p
--- 842,852 ----
          message ("color substitution performed for XPM data");
        else
!         message ("color substitution performed for file \"%s\"", 
!                  XSTRING (name)->data);
        break;
+     }
+ 
    case XpmNoMemory:
+     {
        signal_error (Qfile_error,
                      list3 (build_string (raw_data_p
***************
*** 900,904 ****
--- 855,862 ----
                             build_string ("out of memory"),
                             name));
+     }
+ 
    case XpmOpenFailed:
+     {
        signal_error (Qfile_error,
                      list3 (build_string ("Opening pixmap file"),
***************
*** 905,909 ****
--- 863,870 ----
                             build_string ("no such file or directory"),
                             name));
+     }
+ 
    default:
+     {
        signal_error (Qfile_error,
                      list4 (build_string (raw_data_p
***************
*** 913,921 ****
  			   make_number (result), name));
      }
  
!   if (raw_data_p) abort ();
  
  #endif /* HAVE_XPM */
        
    BLOCK_INPUT;
    result = XmuReadBitmapDataFromFile (file, &w, &h, &data, &xhot, &yhot);
--- 874,931 ----
                             make_number (result), name));
      }
+   }
+ 
+   {
+     /* XpmReadFileToPixmap() doesn't return the depth (bogus!) so 
+        we need to get it ourself.  (No, xpmattrs.depth is not it; 
+        that's an input slot, not output.)  
+        We could just assume that it has the same depth as the
+        root window, but some screens allow more than one depth, 
+        so that isn't necessarily correct (I guess?) */
+     Window root;
+     int x, y;
+     unsigned int w2, h2, bw;
+ 
+     unsigned int w = xpmattrs.width;
+     unsigned int h = xpmattrs.height;
+     int d;
+     int xhot = ((xpmattrs.valuemask & XpmHotspot) ? xpmattrs.x_hotspot : -1);
+     int yhot = ((xpmattrs.valuemask & XpmHotspot) ? xpmattrs.y_hotspot : -1);
+     int npixels = xpmattrs.npixels;
+     Pixel *pixels = 0;
+ 
+     if (npixels != 0)
+     {
+       pixels = xmalloc (npixels * sizeof (Pixel));
+       memcpy (pixels, xpmattrs.pixels, npixels * sizeof (Pixel));
+     }
+     else
+       pixels = 0;
  
!     BLOCK_INPUT;
!     if (!XGetGeometry (DisplayOfScreen (xs), pixmap, &root, &x, &y,
!                        &w2, &h2, &bw, &d))
!       abort ();
!     if (w != w2 || h != h2)
!       abort ();
!     UNBLOCK_INPUT;
  
+     return make_pixmap_1 (((raw_data_p) ? Qnil : name), xs,
+                           xhot, yhot, w, h, d, 
+                           pixmap, mask,
+                           pixels, npixels);
+   }
+ }
  #endif /* HAVE_XPM */
  
+ static Lisp_Object
+ try_reading_Xmu_bitmap (Screen *xs, Lisp_Object name, const char *file)
+ {
+   Pixmap pixmap;
+   unsigned int w, h;
+   int xhot, yhot;
+   unsigned char *data;
+   int result;
+ 
    BLOCK_INPUT;
    result = XmuReadBitmapDataFromFile (file, &w, &h, &data, &xhot, &yhot);
***************
*** 925,928 ****
--- 935,939 ----
      {
      case BitmapSuccess:
+       {
          BLOCK_INPUT;
          pixmap = XCreatePixmapFromBitmapData (DisplayOfScreen (xs),
***************
*** 929,938 ****
  					    RootWindowOfScreen (xs),
  					    (char *) data, w, h, 1, 0, 1);
-       d = 0;
        XFree ((char *)data);
        UNBLOCK_INPUT;
!       return make_pixmap_1 (name, xs, xhot, yhot, w, h, d, pixmap, 0, 0, 0);
!       break;
      case BitmapOpenFailed:
        signal_error (Qfile_error,
  		    list3 (build_string ("Opening bitmap file"),
--- 940,949 ----
                                                RootWindowOfScreen (xs),
                                                (char *) data, w, h, 1, 0, 1);
          XFree ((char *)data);
          UNBLOCK_INPUT;
!         return make_pixmap_1 (name, xs, xhot, yhot, w, h, 0, pixmap, 0, 0, 0);
!       }
      case BitmapOpenFailed:
+       {
          signal_error (Qfile_error,
                        list3 (build_string ("Opening bitmap file"),
***************
*** 939,955 ****
  			   build_string ("no such file or directory"),
  			   name));
      case BitmapFileInvalid:
!       signal_error (Qfile_error,
! #ifdef HAVE_XPM
! 		    list3 (build_string ("Reading pixmap file"),
! 			   build_string ("invalid pixmap or bitmap data"),
! 			   name)
! #else
! 		    list3 (build_string ("Reading bitmap file"),
! 			   build_string ("invalid bitmap data"),
! 			   name)
! #endif
! 		    );
      case BitmapNoMemory:
        signal_error (Qfile_error,
  		    list3 (build_string ("Reading bitmap file"),
--- 950,960 ----
                               build_string ("no such file or directory"),
                               name));
+       }
      case BitmapFileInvalid:
!       {
!         return (Qnil);
!       }
      case BitmapNoMemory:
+       {
          signal_error (Qfile_error,
                        list3 (build_string ("Reading bitmap file"),
***************
*** 956,960 ****
--- 961,967 ----
                               build_string ("out of memory"),
                               name));
+       }
      default:
+       {
          signal_error (Qfile_error,
                        list4 (build_string ("Reading bitmap file"),
***************
*** 962,967 ****
--- 969,1034 ----
                               make_number (result), name));
        }
+     }
+ }
+ 
+ 
+ static Lisp_Object
+ make_pixmap_from_file (Lisp_Object name, Lisp_Object screen)
+ {
+   Screen *xs = LISP_SCREEN_TO_X_SCREEN (screen);
+   char file [MAXPATHLEN];
+   int raw_data_p = 0;
+   Lisp_Object result;
+ 
+   CHECK_STRING (name, 0);
+ 
+   if (XSTRING (name)->size > 9 &&
+       !strncmp ("/* XPM */", (char *) XSTRING (name)->data, 9))
+   {
+ #ifdef XPM_DOES_BUFFERS
+     raw_data_p = 1;
+ #else
+ #ifdef HAVE_XPM
+     signal_error (Qerror, list2 (build_string
+ 				 ("XPM library is too old: no raw data"),
+ 				 name));
+ #else /* !XPM */
+     signal_error (Qerror, list2 (build_string ("no support for XPM data"),
+ 				 name));
+ #endif /* !XPM */
+ #endif /* !XPM_DOES_BUFFERS */
+   }
+   else if (! locate_pixmap_file ((char *) XSTRING (name)->data, file))
+   {
+     signal_error (Qfile_error,
+ 		  list3 (build_string ("Opening pixmap file"),
+ 			 build_string ("no such file or directory"),
+ 			 name));
+   }
+   else
+     name = build_string (file);
+ 
+ #ifdef HAVE_XPM
+ 
+   result = try_reading_xpm_bitmap (screen, name, file, raw_data_p);
+   if (!NILP (result))
+     return (result);
+ #endif /* HAVE_XPM */
+ 
+   result = try_reading_Xmu_bitmap (xs, name, file);
+   if (!NILP (result))
+     return (result);
+ 
+   signal_error (Qfile_error,
+                 list3 (build_string ("Reading pixmap file"),
+ #ifdef HAVE_XPM
+                        build_string ("invalid pixmap or bitmap data"),
+ #else
+                        build_string ("invalid bitmap data"),
+ #endif
+                        name));
  }
  
+ 
  Lisp_Object
  make_pixmap_from_data (Screen *screen, char *bits, int width, int height)
***************
*** 977,981 ****
  make_pixmap_from_lisp_data (Lisp_Object data, Lisp_Object screen)
  {
!   Screen *xs;
    Dimension w, h;
    char *bits;
--- 1044,1048 ----
  make_pixmap_from_lisp_data (Lisp_Object data, Lisp_Object screen)
  {
!   Screen *xs = LISP_SCREEN_TO_X_SCREEN (screen);
    Dimension w, h;
    char *bits;
***************
*** 982,986 ****
  
    CHECK_CONS (data, 0);
-   xs = LISP_SCREEN_TO_X_SCREEN (screen);
    
    if (!CONSP (Fcdr (data)) ||
--- 1049,1052 ----
*** ../lemacs-beta6/src/eval.c	Sat Jul 24 10:23:53 1993
--- src/eval.c	Sun Jul 25 17:33:51 1993
***************
*** 587,591 ****
  	       || EQ (*btp->function, Qbytecode));
         btp = btp->next)
!     {}
    /* btp now points at the frame of the innermost function
       that DOES eval its args.
--- 587,591 ----
  	       || EQ (*btp->function, Qbytecode));
         btp = btp->next)
!     ;
    /* btp now points at the frame of the innermost function
       that DOES eval its args.
***************
*** 592,596 ****
       If it is a built-in function (such as load or eval-region)
       return nil.  */
!   fun = Findirect_function (*btp->function);
    /* Beats me why this is necessary, but it is */
    if (btp && EQ (*btp->function, Qcall_interactively))
--- 592,596 ----
       If it is a built-in function (such as load or eval-region)
       return nil.  */
!   fun = indirect_function (*btp->function, 0);
    /* Beats me why this is necessary, but it is */
    if (btp && EQ (*btp->function, Qcall_interactively))
***************
*** 1297,1301 ****
--- 1297,1309 ----
  }
  
+ /* This is what the QUIT macro calls to signal a quit */
+ void
+ signal_quit ()
+ {
+   Vquit_flag = Qnil; 
+   Fsignal (Qquit, Qnil); 
+ }
  
+ 
  
  #ifndef standalone
***************
*** 1758,1761 ****
--- 1766,1770 ----
  #endif
  
+   if (SYMBOLP (fun))
      fun = indirect_function (fun, 1);
  
***************
*** 1797,1810 ****
    else if (COMPILEDP (fun))
      val = funcall_lambda (fun, nargs, args + 1);
    else
      {
!       Lisp_Object funcar;
!       if (!CONSP (fun))
!         goto invalid_function;
  
-       funcar = Fcar (fun);
        if (!SYMBOLP (funcar))
          goto invalid_function;
!       if (EQ (funcar, Qlambda))
  	val = funcall_lambda (fun, nargs, args + 1);
  #ifdef MOCKLISP_SUPPORT
--- 1806,1821 ----
    else if (COMPILEDP (fun))
      val = funcall_lambda (fun, nargs, args + 1);
+   else if (!CONSP (fun))
+     {
+     invalid_function:
+       return Fsignal (Qinvalid_function, list1 (fun));
+     }
    else
      {
!       Lisp_Object funcar = Fcar (fun);
  
        if (!SYMBOLP (funcar))
          goto invalid_function;
!       else if (EQ (funcar, Qlambda))
  	val = funcall_lambda (fun, nargs, args + 1);
  #ifdef MOCKLISP_SUPPORT
***************
*** 1818,1825 ****
  	}
        else
! 	{
! 	invalid_function:
! 	  return Fsignal (Qinvalid_function, list1 (fun));
! 	}
      }
    lisp_eval_depth--;
--- 1829,1833 ----
  	}
        else
!         goto invalid_function;
      }
    lisp_eval_depth--;
***************
*** 1861,1865 ****
--- 1869,1875 ----
    funcall_nargs = 1 + numargs;
  
+   if (SYMBOLP (fun))
      fun = indirect_function (fun, 0);
+ 
    if (EQ (fun, Qunbound))
      {
***************
*** 1906,1910 ****
      for (; i < funcall_nargs; i++)
        funcall_args[i] = Qnil;
- 
  
      RETURN_UNGCPRO (Ffuncall (funcall_nargs, funcall_args));
--- 1916,1919 ----
*** ../lemacs-beta6/src/process.c	Sat Jul 24 10:24:11 1993
--- src/process.c	Sat Jul 24 22:16:45 1993
***************
*** 717,721 ****
    Lisp_Object status;
  
!   proc = get_process (proc);
    if (NILP (proc))
      return (Qnil);
--- 717,721 ----
    Lisp_Object status;
  
!   proc = Fget_process (proc);
    if (NILP (proc))
      return (Qnil);
*** ../lemacs-beta6/src/lread.c	Sat Jul 24 10:24:07 1993
--- src/lread.c	Wed Jul 28 11:10:05 1993
***************
*** 416,434 ****
  
  
- static int
- complete_filename_p (pathname)
-      Lisp_Object pathname;
- {
-   register unsigned char *s = XSTRING (pathname)->data;
-   return (*s == '/'
- #ifdef ALTOS
- 	  || *s == '@'
- #endif
- #ifdef VMS
- 	  || index (s, ':')
- #endif /* VMS */
- 	  );
- }
- 
  DEFUN ("locate-file", Flocate_file, Slocate_file, 2, 4, 0,
    "Search for FILENAME through PATH-LIST, expanded by one of the optional\n\
--- 416,419 ----
***************
*** 478,482 ****
    char buf[100];
    register char *fn = buf;
!   int absolute = 0;
    int want_size;
    struct stat st;
--- 463,467 ----
    char buf[100];
    register char *fn = buf;
!   int absolute;
    int want_size;
    struct stat st;
***************
*** 489,494 ****
      *storeptr = Qnil;
  
!   if (complete_filename_p (str))
!     absolute = 1;
  
    for (; !NILP (path); path = Fcdr (path))
--- 474,478 ----
      *storeptr = Qnil;
  
!   absolute = !NILP (Ffile_name_absolute_p (str));
  
    for (; !NILP (path); path = Fcdr (path))
***************
*** 497,501 ****
  
        filename = Fexpand_file_name (str, Fcar (path));
!       if (!complete_filename_p (filename))
  	/* If there are non-absolute elts in PATH (eg ".") */
  	/* Of course, this could conceivably lose if luser sets
--- 481,485 ----
  
        filename = Fexpand_file_name (str, Fcar (path));
!       if (NILP (Ffile_name_absolute_p (filename)))
  	/* If there are non-absolute elts in PATH (eg ".") */
  	/* Of course, this could conceivably lose if luser sets
***************
*** 503,507 ****
  	{
  	  filename = Fexpand_file_name (filename, current_buffer->directory);
! 	  if (!complete_filename_p (filename))
  	    /* Give up on this path element! */
  	    continue;
--- 487,491 ----
  	{
  	  filename = Fexpand_file_name (filename, current_buffer->directory);
! 	  if (NILP (Ffile_name_absolute_p (filename)))
  	    /* Give up on this path element! */
  	    continue;
***************
*** 664,673 ****
        if (c == ';')
  	{
  	  while ((c = readchar (readcharfun)) != '\n' && c != -1)
!             ;
  	  continue;
  	}
!       if (c < 0) break;
!       if (c == ' ' || c == '\t' || c == '\n' || c == '\f') continue;
  
  #if 0 /* defun hack */
--- 648,660 ----
        if (c == ';')
  	{
+           /* Skip comment */
  	  while ((c = readchar (readcharfun)) != '\n' && c != -1)
!             QUIT;
  	  continue;
  	}
!       if (c < 0)
!         break;
!       if (c == ' ' || c == '\t' || c == '\n' || c == '\f')
!         continue;
  
  #if 0 /* defun hack */
***************
*** 1084,1102 ****
  
    {
!     Lisp_Object tem;
!     Lisp_Object (*maker) (const char *, int) 
!       = ((purify_flag) ? make_pure_pname : make_string);
  
      if (uninterned_symbol)
!       return (Fmake_symbol ((maker) (read_buffer, p - read_buffer)));
! 
!     /* We go through this hair so as not to unnecessarily cons
!        symbol-names which intern then just has to purecopy */
!     tem = oblookup (Vobarray, (unsigned char *) read_buffer,
! 		    p - read_buffer);
!     if (SYMBOLP (tem))
!       return (tem);
!     tem = ((maker) (read_buffer, p - read_buffer));
!     return (Fintern (tem, Qnil));
    }
  }
--- 1071,1083 ----
  
    {
!     int len = p - read_buffer;
  
      if (uninterned_symbol)
!       return (Fmake_symbol ((purify_flag) 
!                             ? make_pure_pname (read_buffer, len, 0)
!                             : make_string (read_buffer, len)));
!     else
!       /* intern will purecopy pname if necessary */
!       return (Fintern (make_string (read_buffer, len), Qnil));
    }
  }
***************
*** 1131,1135 ****
          /* Comment */
          while ((c = readchar (readcharfun)) >= 0 && c != '\n')
!           ;
          goto retry;
        }
--- 1112,1116 ----
          /* Comment */
          while ((c = readchar (readcharfun)) >= 0 && c != '\n')
!           QUIT;
          goto retry;
        }
*** ../lemacs-beta6/src/broken-sun.h	Sat Jul 10 19:13:28 1993
--- src/broken-sun.h	Tue Jul 27 12:54:56 1993
***************
*** 1,11 ****
- /* /tool/acc/SC1.0/ansi_include */
- 
  #include <stdlib.h>
  #include <stddef.h>
  
! extern void *	memchr(const void *, int, int);
! extern int 	memcmp(const void *, const void *, int);
! extern void *	memcpy(void *, const void *, int);
  /* extern void * memmove(void *, const void *, size_t);*/
  extern void *	memset(void *, int, int);
  extern char *	strcat(char *, const char *);
--- 1,10 ----
  #include <stdlib.h>
  #include <stddef.h>
  
! extern void *	memchr(const void *, int, size_t);
! extern int 	memcmp(const void *, const void *, size_t);
! extern void *	memcpy(void *, const void *, size_t);
  /* extern void * memmove(void *, const void *, size_t);*/
+ #define memmove(s,d,n) bcopy((d),(s),(n))
  extern void *	memset(void *, int, int);
  extern char *	strcat(char *, const char *);
*** ../lemacs-beta6/src/gmalloc.c	Sat Jul 24 10:24:02 1993
--- src/gmalloc.c	Sun Jul 25 19:14:38 1993
***************
*** 1,6 ****
  /* Get the configuration files if we're being compiled for Emacs.  */
  #ifdef emacs
! #include "config.h"
! #include "getpagesize.h"
  #endif
  
--- 1,9 ----
  /* Get the configuration files if we're being compiled for Emacs.  */
  #ifdef emacs
! # include "config.h"
! # include "getpagesize.h"
! # ifndef HAVE_CONFIG_H
! # define HAVE_CONFIG_H
! # endif
  #endif
  
***************
*** 17,21 ****
  #endif
  
- /* WTF!! */
  #define __const const
  
--- 20,23 ----
***************
*** 23,35 ****
  /* DO NOT EDIT THIS FILE -- it is automagically generated.  -*- C -*- */
  
- #if	defined(__GNU_LIBRARY__) || defined(STDC_HEADERS) || defined(USG)
- #include <string.h>
- 
- #else /* !STDC */
- #define	memset(s, zero, n)	bzero ((s), (n))
- #define	memcpy(d, s, n)		bcopy ((s), (d), (n))
- #define memmove(d, s, n)	bcopy ((s), (d), (n))
- #endif  /* !STDC */
- 
  #define _MALLOC_INTERNAL
  
--- 25,28 ----
***************
*** 62,65 ****
--- 55,84 ----
  #define _MALLOC_H	1
  
+ #ifdef _MALLOC_INTERNAL
+ 
+ #ifdef	HAVE_CONFIG_H
+ #include "config.h"
+ #endif
+ 
+ #if	defined(_LIBC) || defined(STDC_HEADERS) || defined(USG)
+ #include <string.h>
+ #else
+ #ifndef memset
+ #define	memset(s, zero, n)	bzero ((s), (n))
+ #endif
+ #ifndef memcpy
+ #define	memcpy(d, s, n)		bcopy ((s), (d), (n))
+ #endif
+ #endif
+ 
+ #if	defined(__GNU_LIBRARY__) || defined(__STDC__)
+ #include <limits.h>
+ #else
+ #define	CHAR_BIT	8
+ #endif
+ 
+ #endif	/* _MALLOC_INTERNAL.  */
+ 
+ 
  #ifdef	__cplusplus
  extern "C"
***************
*** 81,88 ****
  #endif /* C++ or ANSI C.  */
  
- #ifndef	NULL
- #define	NULL	0
- #endif
- 
  #ifdef	__STDC__
  #include <stddef.h>
--- 100,103 ----
***************
*** 94,97 ****
--- 109,116 ----
  #endif
  
+ #ifndef	NULL
+ #define	NULL	0
+ #endif
+ 
  
  /* Allocate SIZE bytes of memory.  */
***************
*** 114,137 ****
  #ifdef _MALLOC_INTERNAL
  
- #include <stdio.h>		/* Harmless, gets __GNU_LIBRARY__ defined.  */
- 
- #if	defined(__GNU_LIBRARY__) || defined(STDC_HEADERS) || defined(USG)
- #include <string.h>
- #else
- #ifndef memset
- #define	memset(s, zero, n)	memset ((s), 0, (n))
- #endif
- #ifndef memcpy
- #define	memcpy(d, s, n)		memcpy ((d), (s), (n))
- #endif
- #endif
- 
- 
- #if	defined(__GNU_LIBRARY__) || defined(__STDC__)
- #include <limits.h>
- #else
- #define	CHAR_BIT	8
- #endif
- 
  /* The allocator divides the heap into blocks of fixed size; large
     requests receive one or more whole blocks, and small requests
--- 133,136 ----
***************
*** 152,161 ****
  #define FINAL_FREE_BLOCKS	8
  
- /* Where to start searching the free list when looking for new memory.
-    The two possible values are 0 and _heapindex.  Starting at 0 seems
-    to reduce total memory usage, while starting at _heapindex seems to
-    run faster.  */
- #define MALLOC_SEARCH_START	_heapindex
- 
  /* Data structure giving per-block information.  */
  typedef union
--- 151,154 ----
***************
*** 254,258 ****
  
  /* Activate a standard collection of debugging hooks.  */
! extern void mcheck __P ((void (*__func) __P ((void))));
  
  /* Activate a standard collection of tracing hooks.  */
--- 247,251 ----
  
  /* Activate a standard collection of debugging hooks.  */
! extern int mcheck __P ((void (*__func) __P ((void))));
  
  /* Activate a standard collection of tracing hooks.  */
***************
*** 295,299 ****
  #endif /* malloc.h  */
  /* Memory allocator `malloc'.
!    Copyright 1990, 1991, 1992 Free Software Foundation
  		  Written May 1989 by Mike Haertel.
  
--- 288,292 ----
  #endif /* malloc.h  */
  /* Memory allocator `malloc'.
!    Copyright 1990, 1991, 1992, 1993 Free Software Foundation
  		  Written May 1989 by Mike Haertel.
  
***************
*** 451,454 ****
--- 444,454 ----
    struct list *next;
  
+   /* ANSI C allows `malloc (0)' to either return NULL, or to return a
+      valid address you can realloc and free (though not dereference).
+ 
+      It turns out that some extant code (sunrpc, at least Ultrix's version)
+      expects `malloc (0)' to return non-NULL and breaks otherwise.
+      Be compatible.  */
+ 
  #ifdef HAVE_X_WINDOWS
    /* there is at least one Xt bug where calloc(n,x) is blindly called
***************
*** 548,552 ****
  	 space we will have to get more memory from the system.  */
        blocks = BLOCKIFY (size);
!       start = block = MALLOC_SEARCH_START;
        while (_heapinfo[block].free.size < blocks)
  	{
--- 548,552 ----
  	 space we will have to get more memory from the system.  */
        blocks = BLOCKIFY (size);
!       start = block = _heapindex;
        while (_heapinfo[block].free.size < blocks)
  	{
***************
*** 616,619 ****
--- 616,648 ----
    return result;
  }
+ 
+ #ifndef _LIBC
+ 
+ /* On some ANSI C systems, some libc functions call _malloc, _free
+    and _realloc.  Make them use the GNU functions.  */
+ 
+ __ptr_t
+ _malloc (size)
+      size_t size;
+ {
+   return malloc (size);
+ }
+ 
+ void
+ _free (ptr)
+      __ptr_t ptr;
+ {
+   free (ptr);
+ }
+ 
+ __ptr_t
+ _realloc (ptr, size)
+      __ptr_t ptr;
+      size_t size;
+ {
+   return realloc (ptr, size);
+ }
+ 
+ #endif
  /* Free a block of memory allocated by `malloc'.
     Copyright 1990, 1991, 1992 Free Software Foundation
***************
*** 826,831 ****
      _free_internal (ptr);
  }
  /* Change the size of a block allocated by `malloc'.
!    Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
  		     Written May 1989 by Mike Haertel.
  
--- 855,903 ----
      _free_internal (ptr);
  }
+ /* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ 
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+ 
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Library General Public License for more details.
+ 
+ You should have received a copy of the GNU Library General Public
+ License along with the GNU C Library; see the file COPYING.LIB.  If
+ not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+ Cambridge, MA 02139, USA.  */
+ 
+ #ifndef	_MALLOC_INTERNAL
+ #define _MALLOC_INTERNAL
+ #include <malloc.h>
+ #endif
+ 
+ #undef	cfree
+ 
+ #ifdef _LIBC
+ 
+ #include <ansidecl.h>
+ #include <gnu-stabs.h>
+ 
+ function_alias(cfree, free, void, (ptr),
+ 	       DEFUN(cfree, (ptr), PTR ptr))
+ 
+ #else
+ 
+ void
+ cfree (ptr)
+      __ptr_t ptr;
+ {
+   free (ptr);
+ }
+ 
+ #endif
  /* Change the size of a block allocated by `malloc'.
!    Copyright 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
  		     Written May 1989 by Mike Haertel.
  
***************
*** 853,856 ****
--- 925,993 ----
  #endif
  
+ #if	!defined(_LIBC) && !defined(STDC_HEADERS) && !defined(USG)
+ 
+ /* Snarfed directly from Emacs src/dispnew.c:
+    XXX Should use system bcopy if it handles overlap.  */
+ 
+ /* Like bcopy except never gets confused by overlap.  */
+ 
+ static void
+ safe_bcopy (from, to, size)
+      char *from, *to;
+      int size;
+ {
+   if (size <= 0 || from == to)
+     return;
+ 
+   /* If the source and destination don't overlap, then bcopy can
+      handle it.  If they do overlap, but the destination is lower in
+      memory than the source, we'll assume bcopy can handle that.  */
+   if (to < from || from + size <= to)
+     bcopy (from, to, size);
+ 
+   /* Otherwise, we'll copy from the end.  */
+   else
+     {
+       register char *endf = from + size;
+       register char *endt = to + size;
+ 
+       /* If TO - FROM is large, then we should break the copy into
+ 	 nonoverlapping chunks of TO - FROM bytes each.  However, if
+ 	 TO - FROM is small, then the bcopy function call overhead
+ 	 makes this not worth it.  The crossover point could be about
+ 	 anywhere.  Since I don't think the obvious copy loop is too
+ 	 bad, I'm trying to err in its favor.  */
+       if (to - from < 64)
+ 	{
+ 	  do
+ 	    *--endt = *--endf;
+ 	  while (endf != from);
+ 	}
+       else
+ 	{
+ 	  for (;;)
+ 	    {
+ 	      endt -= (to - from);
+ 	      endf -= (to - from);
+ 
+ 	      if (endt < to)
+ 		break;
+ 
+ 	      bcopy (endf, endt, to - from);
+ 	    }
+ 
+ 	  /* If SIZE wasn't a multiple of TO - FROM, there will be a
+ 	     little left over.  The amount left over is
+ 	     (endt + (to - from)) - to, which is endt - from.  */
+ 	  bcopy (from, to, endt - from);
+ 	}
+     }
+ }     
+ 
+ #define memmove(to, from, size) safe_bcopy ((from), (to), (size))
+ 
+ #endif
+ 
+ 
  #define min(A, B) ((A) < (B) ? (A) : (B))
  
***************
*** 933,937 ****
--- 1070,1084 ----
  	  if (result == NULL)
  	    {
+ 	      /* Now we're really in trouble.  We have to unfree
+ 		 the thing we just freed.  Unfortunately it might
+ 		 have been coalesced with its neighbors.  */
+ 	      if (_heapindex == block)
+ 	        (void) malloc (blocks * BLOCKSIZE);
+ 	      else
+ 		{
+ 		  __ptr_t previous = malloc ((block - _heapindex) * BLOCKSIZE);
  		  (void) malloc (blocks * BLOCKSIZE);
+ 		  free (previous);
+ 		}
  	      return NULL;
  	    }
***************
*** 1045,1120 ****
    return result;
  }
- /* Allocate memory on a page boundary.
-    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
- 
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
- 
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- Library General Public License for more details.
- 
- You should have received a copy of the GNU Library General Public
- License along with this library; see the file COPYING.LIB.  If
- not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- Cambridge, MA 02139, USA.
- 
-    The author may be reached (Email) at the address mike@ai.mit.edu,
-    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
- 
- #ifndef	_MALLOC_INTERNAL
- #define	_MALLOC_INTERNAL
- #include <malloc.h>
- #endif
- 
- #ifdef	 emacs
- #include "config.h"
- #endif
- 
- #ifdef HAVE_UNISTD_H
- #include <unistd.h>
- #endif
- 
- #ifdef	__GNU_LIBRARY__
- extern size_t __getpagesize __P ((void));
- #else
- #ifdef _SC_PAGESIZE
- #define __getpagesize() sysconf(_SC_PAGESIZE)
- #else
- #ifndef	USG
- /*extern size_t getpagesize __P ((void));*/
- #define	__getpagesize()	getpagesize()
- #else
- #include <sys/param.h>
- #ifdef	EXEC_PAGESIZE
- #define	__getpagesize()	EXEC_PAGESIZE
- #else /* No EXEC_PAGESIZE.  */
- #ifdef	NBPG
- #ifndef	CLSIZE
- #define	CLSIZE	1
- #endif /* No CLSIZE.  */
- #define	__getpagesize()	(NBPG * CLSIZE)
- #else /* No NBPG.  */
- #define	__getpagesize()	NBPC
- #endif /* NBPG.  */
- #endif /* EXEC_PAGESIZE.  */
- #endif /* USG.  */
- #endif /* not _SC_PAGESIZE */
- #endif
- 
- static size_t pagesize;
- 
- __ptr_t
- valloc (size)
-      size_t size;
- {
-   if (pagesize == 0)
-     pagesize = __getpagesize ();
- 
-   return memalign (pagesize, size);
- }
  /* Copyright (C) 1991, 1992 Free Software Foundation, Inc.
  
--- 1192,1195 ----
***************
*** 1178,1317 ****
    return result;
  }
! /* Standard debugging hooks for `malloc'.
!    Copyright 1990, 1991, 1992 Free Software Foundation
!    Written May 1989 by Mike Haertel.
! 
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Library General Public License as
! published by the Free Software Foundation; either version 2 of the
! License, or (at your option) any later version.
! 
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
! Library General Public License for more details.
! 
! You should have received a copy of the GNU Library General Public
! License along with this library; see the file COPYING.LIB.  If
! not, write to the Free Software Foundation, Inc., 675 Mass Ave,
! Cambridge, MA 02139, USA.
! 
!    The author may be reached (Email) at the address mike@ai.mit.edu,
!    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
! 
! #ifndef	_MALLOC_INTERNAL
! #define	_MALLOC_INTERNAL
! #include <malloc.h>
! #endif
! 
! /* Old hook values.  */
! static void (*old_free_hook) __P ((__ptr_t ptr));
! static __ptr_t (*old_malloc_hook) __P ((size_t size));
! static __ptr_t (*old_realloc_hook) __P ((__ptr_t ptr, size_t size));
! 
! /* Function to call when something awful happens.  */
! extern void abort __P ((void));
! static void (*abortfunc) __P ((void)) = (void (*) __P ((void))) abort;
! 
! /* Arbitrary magical numbers.  */
! #define MAGICWORD	0xfedabeeb
! #define MAGICBYTE	((char) 0xd7)
! 
! struct hdr
!   {
!     size_t size;		/* Exact size requested by user.  */
!     unsigned long int magic;	/* Magic number to check header integrity.  */
!   };
! 
! static void checkhdr __P ((__const struct hdr *));
! static void
! checkhdr (hdr)
!      __const struct hdr *hdr;
! {
!   if (hdr->magic != MAGICWORD || ((char *) &hdr[1])[hdr->size] != MAGICBYTE)
!     (*abortfunc) ();
! }
! 
! static void freehook __P ((__ptr_t));
! static void
! freehook (ptr)
!      __ptr_t ptr;
! {
!   struct hdr *hdr = ((struct hdr *) ptr) - 1;
!   checkhdr (hdr);
!   hdr->magic = 0;
!   __free_hook = old_free_hook;
!   free (hdr);
!   __free_hook = freehook;
! }
! 
! static __ptr_t mallochook __P ((size_t));
! static __ptr_t
! mallochook (size)
!      size_t size;
! {
!   struct hdr *hdr;
! 
!   __malloc_hook = old_malloc_hook;
!   hdr = (struct hdr *) malloc (sizeof (struct hdr) + size + 1);
!   __malloc_hook = mallochook;
!   if (hdr == NULL)
!     return NULL;
! 
!   hdr->size = size;
!   hdr->magic = MAGICWORD;
!   ((char *) &hdr[1])[size] = MAGICBYTE;
!   return (__ptr_t) (hdr + 1);
! }
! 
! static __ptr_t reallochook __P ((__ptr_t, size_t));
! static __ptr_t
! reallochook (ptr, size)
!      __ptr_t ptr;
!      size_t size;
! {
!   struct hdr *hdr = ((struct hdr *) ptr) - 1;
! 
!   checkhdr (hdr);
!   __free_hook = old_free_hook;
!   __malloc_hook = old_malloc_hook;
!   __realloc_hook = old_realloc_hook;
!   hdr = (struct hdr *) realloc ((__ptr_t) hdr, sizeof (struct hdr) + size + 1);
!   __free_hook = freehook;
!   __malloc_hook = mallochook;
!   __realloc_hook = reallochook;
!   if (hdr == NULL)
!     return NULL;
! 
!   hdr->size = size;
!   ((char *) &hdr[1])[size] = MAGICBYTE;
!   return (__ptr_t) (hdr + 1);
! }
! 
! void
! mcheck (func)
!      void (*func) __P ((void));
! {
!   static int mcheck_used = 0;
! 
!   if (func != NULL)
!     abortfunc = func;
! 
!   /* These hooks may not be safely inserted if malloc is already in use.  */
!   if (!__malloc_initialized && !mcheck_used)
!     {
!       old_free_hook = __free_hook;
!       __free_hook = freehook;
!       old_malloc_hook = __malloc_hook;
!       __malloc_hook = mallochook;
!       old_realloc_hook = __realloc_hook;
!       __realloc_hook = reallochook;
!       mcheck_used = 1;
!     }
! }
! /* More debugging hooks for `malloc'.
!    Copyright (C) 1991, 1992 Free Software Foundation, Inc.
! 		 Written April 2, 1991 by John Gilmore of Cygnus Support.
! 		 Based on mcheck.c by Mike Haertel.
  
  This library is free software; you can redistribute it and/or
--- 1253,1258 ----
    return result;
  }
! /* Allocate memory on a page boundary.
!    Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
  
  This library is free software; you can redistribute it and/or
***************
*** 1338,1500 ****
  #endif
  
! #include <stdio.h>
! 
! #ifndef	__GNU_LIBRARY__
! extern char *getenv ();
  #else
! #include <stdlib.h>
  #endif
  
! static FILE *mallstream;
! static char mallenv[]= "MALLOC_TRACE";
! static char mallbuf[BUFSIZ];	/* Buffer for the output.  */
! 
! /* Address to breakpoint on accesses to... */
! __ptr_t mallwatch;
! 
! /* Old hook values.  */
! static void (*tr_old_free_hook) __P ((__ptr_t ptr));
! static __ptr_t (*tr_old_malloc_hook) __P ((size_t size));
! static __ptr_t (*tr_old_realloc_hook) __P ((__ptr_t ptr, size_t size));
! 
! /* This function is called when the block being alloc'd, realloc'd, or
!    freed has an address matching the variable "mallwatch".  In a debugger,
!    set "mallwatch" to the address of interest, then put a breakpoint on
!    tr_break.  */
! 
! void tr_break __P ((void));
! void
! tr_break ()
! {
! }
! 
! static void tr_freehook __P ((__ptr_t));
! static void
! tr_freehook (ptr)
!      __ptr_t ptr;
! {
!   fprintf (mallstream, "- %p\n", ptr);	/* Be sure to print it first.  */
!   if (ptr == mallwatch)
!     tr_break ();
!   __free_hook = tr_old_free_hook;
!   free (ptr);
!   __free_hook = tr_freehook;
! }
! 
! static __ptr_t tr_mallochook __P ((size_t));
! static __ptr_t
! tr_mallochook (size)
!      size_t size;
! {
!   __ptr_t hdr;
! 
!   __malloc_hook = tr_old_malloc_hook;
!   hdr = (__ptr_t) malloc (size);
!   __malloc_hook = tr_mallochook;
! 
!   /* We could be printing a NULL here; that's OK.  */
!   fprintf (mallstream, "+ %p %x\n", hdr, size);
! 
!   if (hdr == mallwatch)
!     tr_break ();
! 
!   return hdr;
! }
  
! static __ptr_t tr_reallochook __P ((__ptr_t, size_t));
! static __ptr_t
! tr_reallochook (ptr, size)
!      __ptr_t ptr;
       size_t size;
  {
!   __ptr_t hdr;
! 
!   if (ptr == mallwatch)
!     tr_break ();
! 
!   __free_hook = tr_old_free_hook;
!   __malloc_hook = tr_old_malloc_hook;
!   __realloc_hook = tr_old_realloc_hook;
!   hdr = (__ptr_t) realloc (ptr, size);
!   __free_hook = tr_freehook;
!   __malloc_hook = tr_mallochook;
!   __realloc_hook = tr_reallochook;
!   if (hdr == NULL)
!     /* Failed realloc.  */
!     fprintf (mallstream, "! %p %x\n", ptr, size);
!   else
!     fprintf (mallstream, "< %p\n> %p %x\n", ptr, hdr, size);
! 
!   if (hdr == mallwatch)
!     tr_break ();
! 
!   return hdr;
! }
! 
! /* We enable tracing if either the environment variable MALLOC_TRACE
!    is set, or if the variable mallwatch has been patched to an address
!    that the debugging user wants us to stop on.  When patching mallwatch,
!    don't forget to set a breakpoint on tr_break!  */
! 
! void
! mtrace ()
! {
!   char *mallfile;
! 
!   mallfile = getenv (mallenv);
!   if (mallfile != NULL || mallwatch != NULL)
!     {
!       mallstream = fopen (mallfile != NULL ? mallfile : "/dev/null", "w");
!       if (mallstream != NULL)
! 	{
! 	  /* Be sure it doesn't malloc its buffer!  */
! 	  setbuf (mallstream, mallbuf);
! 	  fprintf (mallstream, "= Start\n");
! 	  tr_old_free_hook = __free_hook;
! 	  __free_hook = tr_freehook;
! 	  tr_old_malloc_hook = __malloc_hook;
! 	  __malloc_hook = tr_mallochook;
! 	  tr_old_realloc_hook = __realloc_hook;
! 	  __realloc_hook = tr_reallochook;
! 	}
!     }
! }
! /* Access the statistics maintained by `malloc'.
!    Copyright 1990, 1991, 1992 Free Software Foundation
! 		  Written May 1989 by Mike Haertel.
! 
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Library General Public License as
! published by the Free Software Foundation; either version 2 of the
! License, or (at your option) any later version.
! 
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
! Library General Public License for more details.
! 
! You should have received a copy of the GNU Library General Public
! License along with this library; see the file COPYING.LIB.  If
! not, write to the Free Software Foundation, Inc., 675 Mass Ave,
! Cambridge, MA 02139, USA.
! 
!    The author may be reached (Email) at the address mike@ai.mit.edu,
!    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
! 
! #ifndef	_MALLOC_INTERNAL
! #define _MALLOC_INTERNAL
! #include <malloc.h>
! #endif
! 
! struct mstats
! mstats ()
! {
!   struct mstats result;
  
!   result.bytes_total = (char *) (*__morecore) (0) - _heapbase;
!   result.chunks_used = _chunks_used;
!   result.bytes_used = _bytes_used;
!   result.chunks_free = _chunks_free;
!   result.bytes_free = _bytes_free;
!   return result;
  }
--- 1279,1298 ----
  #endif
  
! #ifdef	__GNU_LIBRARY__
! extern size_t __getpagesize __P ((void));
  #else
! #include "getpagesize.h"
! #define	 __getpagesize()	getpagesize()
  #endif
  
! static size_t pagesize;
  
! __ptr_t
! valloc (size)
       size_t size;
  {
!   if (pagesize == 0)
!     pagesize = __getpagesize ();
  
!   return memalign (pagesize, size);
  }
*** ../lemacs-beta6/src/emacs.c	Sat Jul 24 10:23:50 1993
--- src/emacs.c	Wed Jul 28 11:19:35 1993
***************
*** 264,504 ****
  
  
- /* DOT_FOUND_IN_SEARCH becomes non-zero when find_user_command ()
-    encounters a `.' as the directory pathname while scanning the
-    list of possible pathnames; i.e., if `.' comes before the directory
-    containing the file of interest. */
- static int dot_found_in_search;
- 
- #define u_mode_bits(x) (((x) & 0000700) >> 6)
- #define g_mode_bits(x) (((x) & 0000070) >> 3)
- #define o_mode_bits(x) (((x) & 0000007) >> 0)
- #define X_BIT(x) (x & 1)
- 
- /* Non-zero if the last call to executable_file () found
-    the file, but stated that it wasn't executable. */
- static int file_exists_p;
- 
- static int
- group_member (gid)
-      int gid;
- {
-   return ((gid == getgid ()) || (gid == getegid ()));
- }
- 
- /* Return non-zero if FILE is an executable file, otherwise 0.
-    Note that this function is the definition of what an
-    executable file is; do not change this unless YOU know
-    what an executable file is. */
- static int
- executable_file (file)
-      char *file;
- {
-   struct stat finfo;
-   int user_id;
- 
-   /* If the file doesn't exist, or is a directory, then we are
-      not interested. */
-   file_exists_p = !stat (file, &finfo);
- 
- #ifndef S_ISDIR
- #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
- #endif
- 
-   if (!file_exists_p || S_ISDIR (finfo.st_mode))
-     return (0);
- 
-   /* By definition, the only other criteria is that the file has
-      an execute bit set that we can use. */
-   user_id = geteuid ();
- 
-   /* Root only requires execute permission for any of owner, group or
-      others to be able to exec a file. */
-   if (user_id == 0)
-     {
-       int bits;
- 
-       bits = (u_mode_bits (finfo.st_mode) |
- 	      g_mode_bits (finfo.st_mode) |
- 	      o_mode_bits (finfo.st_mode));
- 
-       return (X_BIT (bits));
-     }
- 
-   /* If we are the owner of the file, the owner execute bit applies. */
-   if (user_id == finfo.st_uid)
-     return (X_BIT (u_mode_bits (finfo.st_mode)));
- 
-   /* If we are in the owning group, the group permissions apply. */
-   if (group_member (finfo.st_gid))
-     return (X_BIT (g_mode_bits (finfo.st_mode)));
- 
-   /* If `others' have execute permission to the file, then so do we,
-      since we are also `others'. */
-   return (X_BIT (o_mode_bits (finfo.st_mode)));
- }
- 
- /* Return 1 if PATH1 and PATH2 are the same file.  This is kind of
-    expensive.   If non-NULL STP1 and STP2 point to stat structures
-    corresponding to PATH1 and PATH2, respectively. */
- static int
- same_file (path1, path2, stp1, stp2)
-      char *path1, *path2;
-      struct stat *stp1, *stp2;
- {
-   struct stat st1, st2;
- 
-   if (stp1 == 0)
-     {
-       if (stat (path1, &st1) != 0)
- 	return (0);
-       stp1 = &st1;
-     }
- 
-   if (stp2 == 0)
-     {
-       if (stat (path2, &st2) != 0)
- 	return (0);
-       stp2 = &st2;
-     }
- 
-   return ((stp1->st_dev == stp2->st_dev) && (stp1->st_ino == stp2->st_ino));
- }
- 
- /* Return 1 if STRING is an absolute program name; it is absolute if it
-    contains any slashes.  This is used to decide whether or not to look
-    up through $PATH. */
- static int
- absolute_program (const char *string)
- {
-   return (strchr (string, '/') != 0);
- }
- 
- /* Given a string containing units of information separated by colons,
-    return the next one pointed to by INDEX, or NULL if there are no more.
-    Advance INDEX to the character after the colon. */
- static char *
- extract_colon_unit (string, index)
-      const char *string;
-      int *index;
- {
-   int i, start;
- 
-   i = *index;
- 
-   if (!string || (i >= strlen (string)))
-     return 0;
- 
-   /*
-    * Each call to this routine leaves the index pointing at a colon if there
-    * is more to the path.  If i is > 0, then increment past the `:'.  (If i
-    * is 0, then the path has a leading colon.  If this is not done, the
-    * second call to this routine will always return NULL, which will be
-    * translated to  `.', even if `.' is not in the path.  Trailing colons
-    * are handled OK by the `else' part of the if statement; it returns a null
-    * string for the last component of a path with a trailing colon, and the
-    * routines that call this will translate that to `.'.
-    */
- 
-   if (i && string[i] == ':')
-     i++;
- 
-   start = i;
- 
-   while (string[i] && string[i] != ':') i++;
- 
-   *index = i;
- 
-   if (i == start)
-     {
-       if (!string[i])
- 	return 0;
- 
-       (*index)++;
- 
-       return (xstrdup (""));
-     }
-   else
-     {
-       char *value;
- 
-       value = (char *)xmalloc (1 + (i - start));
-       strncpy (value, &string[start], (i - start));
-       value [i - start] = '\0';
- 
-       return (value);
-     }
- }
- 
- static char *
- find_executable_name ()
- {
-   extern char *getenv ();
-   struct Lisp_String *lname = XSTRING (Fcar (Vcommand_line_args));
-   int name_len = string_length (lname);
-   char *path_list = egetenv ("PATH");
-   int must_be_executable = 1;
-   extern int file_exists_p;
-   char *full_path;
-   char *path;
-   int path_index = 0;
-   struct stat dot_stat_buf;
-   char *name = (char *) alloca (name_len + 1);
-   memcpy (name, lname->data, name_len);
-   name[name_len] = 0;
- 
-   /* We haven't started looking, so we certainly haven't seen
-      a `.' as the directory path yet. */
-   dot_found_in_search = 0;
- 
-   if (absolute_program (name))
-     {
-       full_path = (char *)xmalloc (1 + name_len);
-       strcpy (full_path, name);
- 
-       if (executable_file (full_path) || file_exists_p)
- 	{
- 	  return (full_path);
- 	}
-       else
- 	{
- 	  xfree (full_path);
- 	  return 0;
- 	}
-     }
- 
-   stat (".", &dot_stat_buf);   /* should set in get_working_directory */
- 
-   while (path_list && path_list[path_index])
-     {
-       path = extract_colon_unit (path_list, &path_index);
-       if (!path || !*path)
- 	{
- 	  if (path)
- 	    xfree (path);
- 	  path = xstrdup ("."); /* by definition. */
- 	}
- 
-       /* Remember the location of "." in the path, in all its forms (as long as
- 	 they begin with a `.', e.g. `./.') */
-       if ((*path == '.') && same_file (".", path, &dot_stat_buf, (struct stat *) 0))
- 	dot_found_in_search = 1;
- 
-       full_path = (char *)xmalloc (2 + strlen (path) + name_len);
-       sprintf (full_path, "%s/%s", path, name);
-       xfree (path);
- 
-       if (executable_file (full_path) ||
- 	  (!must_be_executable && file_exists_p))
- 	{
- 	  return (full_path);
- 	}
-       else
- 	xfree (full_path);
-     }
- 
-   return 0;
- }
- 
- 
  #ifdef BSD
  extern pid_t setpgrp ();
--- 264,267 ----
***************
*** 890,909 ****
      }
  
!   /* try really hard to get the actually pathname of the exec file we
!      are running */
!   {
!     Lisp_Object full_program_name;
!     char *progname = find_executable_name ();
  
!     Vexecution_path = Qnil;     /* In case of GC */
!     Vinvocation_name = Qnil;
!     full_program_name = (progname
! 			 ? Fexpand_file_name (build_string (progname), Qnil)
! 			 : Fcar (Vcommand_line_args));
!     xfree (progname);
  
!     Vexecution_path = full_program_name;
!     Vinvocation_name = Ffile_name_nondirectory (full_program_name);
!   }
  
  #ifdef sun
--- 653,667 ----
      }
  
!   /* try to get the actually pathname of the exec file we are running */
!   Vinvocation_name = Fcar (Vcommand_line_args);
!   Vexecution_path = Vinvocation_name;
  
!   locate_file (decode_env_path ("PATH", 0), Vinvocation_name, EXEC_SUFFIXES,
!                &Vexecution_path, X_OK);
  
!   if (NILP (Vexecution_path))
!     Vexecution_path = Vinvocation_name;
! 
!   Vinvocation_name = Ffile_name_nondirectory (Vexecution_path);
  
  #ifdef sun
***************
*** 1250,1255 ****
  
  Lisp_Object
! decode_env_path (evarname, defalt)
!      const char *evarname, *defalt;
  {
    register const char *path;
--- 1008,1012 ----
  
  Lisp_Object
! decode_env_path (const char *evarname, const char *defalt)
  {
    register const char *path;
***************
*** 1311,1314 ****
--- 1068,1072 ----
  This is the same as `(file-name-nondirectory execution-path)'.");
  
+   /* Poor name */
    DEFVAR_LISP ("execution-path", &Vexecution_path,
      "Pathname of executable emacs program now running.");
*** ../lemacs-beta6/src/symbols.c	Fri Jul 16 19:59:30 1993
--- src/symbols.c	Sun Jul 25 18:00:24 1993
***************
*** 94,98 ****
      return tem;
    return Fintern (((purify_flag)
! 		   ? make_pure_pname (str, len)
  		   : make_string (str, len)),
  		  obarray);
--- 94,98 ----
      return tem;
    return Fintern (((purify_flag)
! 		   ? make_pure_pname (str, len, 0)
  		   : make_string (str, len)),
  		  obarray);
***************
*** 124,128 ****
  
    if (purify_flag && ! purified (str))
!     str = make_pure_pname ((char *) XSTRING (str)->data, len);
    sym = Fmake_symbol (str);
  
--- 124,128 ----
  
    if (purify_flag && ! purified (str))
!     str = make_pure_pname ((char *) XSTRING (str)->data, len, 0);
    sym = Fmake_symbol (str);
  
***************
*** 423,426 ****
--- 423,440 ----
  }
  
+ /* FSFmacs */
+ DEFUN ("define-function", Fdefine_function, Sdefine_function, 2, 2, 0,
+   "Set SYMBOL's function definition to NEWVAL, and return NEWVAL.\n\
+ Associates the function with the current load file, if any.")
+   (sym, newdef)
+      register Lisp_Object sym, newdef;
+ {
+   CHECK_SYMBOL (sym, 0);
+   Ffset (sym, newdef);
+   LOADHIST_ATTACH (sym);
+   return newdef;
+ }
+ 
+ 
  DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0,
    "Set SYMBOL's property list to NEWVAL, and return NEWVAL.")
***************
*** 1457,1461 ****
  defsymbol (Lisp_Object *location, const char *name)
  {
!   *location = intern (name);
    staticpro (location);
  }
--- 1471,1476 ----
  defsymbol (Lisp_Object *location, const char *name)
  {
!   *location = Fintern (make_pure_pname (name, strlen (name), 1),
!                        Qnil);
    staticpro (location);
  }
***************
*** 1498,1506 ****
    Lisp_Object *tem;
  
!   Qnil = Fmake_symbol (make_pure_pname ("nil", 3));
    /* Bootstrapping problem: Qnil isn't set when make_pure_pname is
       called the first time. */
    XSYMBOL (Qnil)->name->dup_list = Qnil;
!   XSYMBOL (Qnil)->value = Qnil;
    XSYMBOL (Qnil)->plist = Qnil;
  
--- 1513,1521 ----
    Lisp_Object *tem;
  
!   Qnil = Fmake_symbol (make_pure_pname ("nil", 3, 1));
    /* Bootstrapping problem: Qnil isn't set when make_pure_pname is
       called the first time. */
    XSYMBOL (Qnil)->name->dup_list = Qnil;
!   XSYMBOL (Qnil)->value = Qnil; /* Nihil ex hihil */
    XSYMBOL (Qnil)->plist = Qnil;
  
***************
*** 1514,1528 ****
    /* Intern nil in the obarray */
    /* These locals are to kludge around a pyramid compiler bug. */
!   hash = hash_string ((const unsigned char *) "nil", 3);
    /* Separate statement here to avoid VAXC bug. */
    hash %= OBARRAY_SIZE;
    tem = &XVECTOR (Vobarray)->contents[hash];
!   *tem = Qnil;                  /* Nihil ex hihil */
  
!   {
!     const void *foobar = &guts_of_unbound_marker;
!     XSETR (Qunbound, Lisp_Symbol_Value_Magic, foobar);
      if ((const void *) XPNTR (Qunbound) != (const void *) &guts_of_unbound_marker)
!       abort ();
    }
  
--- 1529,1547 ----
    /* Intern nil in the obarray */
    /* These locals are to kludge around a pyramid compiler bug. */
!   hash = hash_string (XSYMBOL (Qnil)->name->data, 3);
    /* Separate statement here to avoid VAXC bug. */
    hash %= OBARRAY_SIZE;
    tem = &XVECTOR (Vobarray)->contents[hash];
!   *tem = Qnil;
  
!   XSETR (Qunbound, Lisp_Symbol_Value_Magic, &guts_of_unbound_marker);
    if ((const void *) XPNTR (Qunbound) != (const void *) &guts_of_unbound_marker)
!   {
!     /* abort (); */
!     /* Can't represent a pointer to constant C data using a Lisp_Object.
!        So heap-allocate it. */
!     struct symbol_value_magic *urk = xmalloc (sizeof (*urk));
!     memcpy (urk, &guts_of_unbound_marker, sizeof (*urk));
!     XSETR (Qunbound, Lisp_Symbol_Value_Magic, urk);
    }
  
***************
*** 1570,1573 ****
--- 1589,1593 ----
    defsubr (&Sfboundp);
    defsubr (&Sfset);
+   defsubr (&Sdefine_function);
    defsubr (&Ssetplist);
    defsubr (&Ssymbol_value);
***************
*** 1588,1589 ****
--- 1608,1610 ----
  
  }
+ 
*** ../lemacs-beta6/src/keymap.c	Sat Jul 24 10:24:06 1993
--- src/keymap.c	Sun Jul 25 17:36:07 1993
***************
*** 3171,3175 ****
    staticpro (&Vcurrent_global_map);
  
!   Vsingle_space_string = make_pure_string (" ", 1);
    staticpro (&Vsingle_space_string);
  
--- 3171,3175 ----
    staticpro (&Vcurrent_global_map);
  
!   Vsingle_space_string = make_pure_string (" ", 1, 1);
    staticpro (&Vsingle_space_string);
  
*** ../lemacs-beta6/src/fns.c	Fri Jul 16 19:58:51 1993
--- src/fns.c	Sat Jul 24 22:29:46 1993
***************
*** 48,92 ****
  #define max(a, b) ((a) > (b) ? (a) : (b))
  
- 
- /* Convert 32 bit items <-> (<high16> . <low16>) */
- 
- Lisp_Object
- word_to_lisp (unsigned int item)
- {
-   return Fcons (make_number (item >> 16), make_number (item & 0xffff));
- }
- 
- unsigned int
- lisp_to_word (Lisp_Object obj)
- {
-   Lisp_Object high;
-   Lisp_Object low;
-   if ((NILP (obj)) || (!CONSP (obj))) return 0;
-   
-   high = XCONS (obj)->car;
-   if (!FIXNUMP (high)) return 0;
-   
-   low = XCONS (obj)->cdr; 
-   if (!FIXNUMP (low)) return 0;
-   
-   return ((((unsigned int) (((unsigned int) (XINT (high))) << 16))
-            | ((unsigned int) XINT ((low)))));
- }
- 
- #ifdef NEED_STRDUP
- char *
- strdup (s)
-      const char *s;
- {
-     char *result = (char *) xmalloc (strlen (s) + 1);
-     if (result == (char *) 0)
-       return (char *) 0;
-     strcpy (result, s);
-     return result;
- }
- #endif
- 
- 
- 
  DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
    "Return the argument unchanged.")
--- 48,51 ----
***************
*** 1045,1050 ****
  
  
- extern int gc_currently_forbidden; /* from alloc.c */
- 
  static Lisp_Object
  restore_gc_inhibit (Lisp_Object val)
--- 1004,1007 ----
***************
*** 1713,1724 ****
  /* Sound stuff, by jwz. */
  
- #ifdef USE_SOUND
  extern void play_sound_file (char *name, int volume);
  extern void play_sound_data (unsigned char *data, int length, int volume);
- 
- extern int interrupt_input;
- extern void request_sigio (void);
- extern void unrequest_sigio (void);
- #endif /* USE_SOUND */
  
  DEFUN ("play-sound-file", Fplay_sound_file, Splay_sound_file,
--- 1670,1675 ----
*** ../lemacs-beta6/src/xselect.c	Tue Jul 13 01:05:18 1993
--- src/xselect.c	Sat Jul 24 22:26:02 1993
***************
*** 203,231 ****
  }
  
- 
- Lisp_Object
- long_to_cons (i)
-      unsigned long i;
- {
-   unsigned int top = i >> 16;
-   unsigned int bot = i & 0xFFFF;
-   if (top == 0) return make_number (bot);
-   if (top == 0xFFFF) return Fcons (make_number (-1), make_number (bot));
-   return Fcons (make_number (top), make_number (bot));
- }
- 
- unsigned long
- cons_to_long (c)
-      Lisp_Object c;
- {
-   Lisp_Object top, bot;
-   if (FIXNUMP (c)) return XINT (c);
-   top = XCONS (c)->car;
-   bot = XCONS (c)->cdr;
-   if (CONSP (bot)) bot = XCONS (bot)->car;
-   return ((XINT (top) << 16) | XINT (bot));
- }
- 
- 
  
  /* Do protocol to assert ourself as a selection owner.
--- 203,206 ----
*** ../lemacs-beta6/src/ymakefile	Sat Jul 24 10:24:28 1993
--- src/ymakefile	Sun Jul 25 19:19:01 1993
***************
*** 169,173 ****
  ILD=/cadillac1/code/bin.sun4/ild
  
! PURIFY=/usr/local/purify/purify
  
  /* Figure out whether the system cpp can handle long names.
--- 169,173 ----
  ILD=/cadillac1/code/bin.sun4/ild
  
! PURIFY=purify
  
  /* Figure out whether the system cpp can handle long names.
*** ../lemacs-beta6/src/menubar.c	Fri Jul 16 19:59:12 1993
--- src/menubar.c	Tue Jul 27 16:47:38 1993
***************
*** 1,3 ****
--- 1,5 ----
  /* Implements an elisp-programmable menubar.
+    Copyright (C) 1993
+    Free Software Foundation, Inc.
  
  This file is part of GNU Emacs.
***************
*** 73,79 ****
   */
  static widget_value *
! menu_item_descriptor_to_widget_value (desc, menubar_p, deep_p)
!      Lisp_Object desc;
!      int menubar_p, deep_p;
  {
    widget_value *wv;
--- 75,80 ----
   */
  static widget_value *
! menu_item_descriptor_to_widget_value (Lisp_Object desc, 
!                                       int menubar_p, int deep_p)
  {
    widget_value *wv;
***************
*** 83,101 ****
    UNBLOCK_INPUT;
  
!   switch (XTYPE (desc))
      {
-     case Lisp_String:
        wv->name = (char *) XSTRING (desc)->data;
        wv->value = 0;
        wv->enabled = 1;
!       break;
!     case Lisp_Vector:
!       if (XVECTOR (desc)->size < 3 || XVECTOR (desc)->size > 4)
! 	signal_error (Qerror, list2 (build_string
                                       ("button descriptors must be 3 or 4 long"),
                                       desc));
        CHECK_STRING (XVECTOR (desc)->contents [0], 0);
        wv->name = (char *) XSTRING (XVECTOR (desc)->contents [0])->data;
!       if (XVECTOR (desc)->size == 4 && !NILP (XVECTOR (desc)->contents [3]))
  	{
  	  CHECK_STRING (XVECTOR (desc)->contents [3], 0);
--- 84,106 ----
    UNBLOCK_INPUT;
  
!   if (STRINGP (desc))
      {
        wv->name = (char *) XSTRING (desc)->data;
        wv->value = 0;
        wv->enabled = 1;
!     }
!   else if (VECTORP (desc))
!     {
!       if (vector_length (XVECTOR (desc)) < 3
!           || vector_length (XVECTOR (desc)) > 4)
! 	signal_error (Qerror, 
!                       list2 (build_string
                               ("button descriptors must be 3 or 4 long"),
                               desc));
        CHECK_STRING (XVECTOR (desc)->contents [0], 0);
+ 
        wv->name = (char *) XSTRING (XVECTOR (desc)->contents [0])->data;
!       if (vector_length (XVECTOR (desc)) == 4
!           && !NILP (XVECTOR (desc)->contents [3]))
  	{
  	  CHECK_STRING (XVECTOR (desc)->contents [3], 0);
***************
*** 112,125 ****
  	  where_is_to_char (tmp, Fcurrent_local_map (), Qnil, buf);
  	  if (buf [0])
! 	    {
! 	      int len = strlen (buf) + 1;
! 	      wv->key = xmalloc (len);
! 	      memcpy (wv->key, buf, len);
! 	    }
  	  else
  	    wv->key = 0;
  	}
!       break;
!     case Lisp_Cons:
        if (STRINGP (XCONS (desc)->car))
  	{
--- 117,127 ----
  	  where_is_to_char (tmp, Fcurrent_local_map (), Qnil, buf);
  	  if (buf [0])
!             wv->key = xstrdup (buf);
  	  else
  	    wv->key = 0;
  	}
!     }
!   else if (CONSP (desc))
!     {
        if (STRINGP (XCONS (desc)->car))
  	{
***************
*** 160,165 ****
  	  wv = 0;
  	}
!       break;
!     default:
        free_widget_value (wv);
        wv = 0;
--- 162,168 ----
  	  wv = 0;
  	}
!     }
!   else
!     {
        free_widget_value (wv);
        wv = 0;
***************
*** 200,211 ****
  
  
- /* screen->menubar_data holds a Lisp_Vector.
-    In this code, we treat that vector as a menubar_data structure.
-  */
  struct menubar_data
  {
!   int size;
!   struct Lisp_Vector *next;
! 
    /* This is the last buffer for which the menubar was displayed.
       If the buffer has changed, we may have to update things.
--- 203,209 ----
  
  
  struct menubar_data
  {
!   struct lcrecord_header header;
    /* This is the last buffer for which the menubar was displayed.
       If the buffer has changed, we may have to update things.
***************
*** 213,222 ****
    Lisp_Object last_menubar_buffer;
  
-   /* This flag tells us if the menubar contents are up-to-date with respect
-      to the current menubar structure.  If we want to actually pull down a
-      menu and this is false, then we need to update things.
-    */
-   Lisp_Object menubar_contents_up_to_date;
- 
    /* This is a vector of all of the callbacks of the menubar menu buttons.
       This is used only to protect them from being GCed, since the only other
--- 211,214 ----
***************
*** 225,235 ****
     */
    Lisp_Object menubar_callbacks;
  };
  
  #define SCREEN_MENUBAR_DATA(screen) \
!   ((struct menubar_data *) XVECTOR ((screen)->menubar_data))
  
- #define MENUBAR_DATA_SIZE \
-   ((sizeof (struct menubar_data) / sizeof (Lisp_Object)) - 2)
  
  /* This is like SCREEN_MENUBAR_DATA(s)->menubar_callbacks, but contains an
--- 217,255 ----
     */
    Lisp_Object menubar_callbacks;
+ 
+   /* This flag tells us if the menubar contents are up-to-date with respect
+      to the current menubar structure.  If we want to actually pull down a
+      menu and this is false, then we need to update things.
+    */
+   char menubar_contents_up_to_date;
  };
  
+ static Lisp_Object
+ mark_menubar_data (Lisp_Object obj, void (*markobj) (Lisp_Object))
+ {
+   struct menubar_data *data = XRECORD (obj);
+   ((markobj) (data->last_menubar_buffer));
+   return (data->menubar_callbacks);
+ }
+ static void
+ print_menubar_data (Lisp_Object obj, Lisp_Object stream, int escapeflag)
+ {
+   char buf[40];
+   sprintf (buf, "#<menubar-data 0x%x>", 
+            ((struct menubar_data *) XRECORD (obj))->header.uid);
+   write_string_1 (buf, -1, stream);
+ }
+ static int sizeof_menubar_data (void *h)
+ {
+   return (sizeof (struct menubar_data)); 
+ }
+ DEFINE_LRECORD_IMPLEMENTATION (lrecord_menubar_data,
+                                mark_menubar_data, print_menubar_data,
+                                0, sizeof_menubar_data);
+ 
+ 
  #define SCREEN_MENUBAR_DATA(screen) \
!   ((struct menubar_data *) XRECORD ((screen)->menubar_data))
  
  
  /* This is like SCREEN_MENUBAR_DATA(s)->menubar_callbacks, but contains an
***************
*** 246,273 ****
    if (NILP (menu))
      return index;
!   switch (XTYPE (menu))
      {
!     case Lisp_Vector:
!       if (XVECTOR (menu)->size > 2)
  	{
! 	  if (XVECTOR (*vector)->size <= index)
  	    {
  	      /* reallocate the vector by doubling its size */
! 	      Lisp_Object new_vector =
! 		Fmake_vector (make_number (index * 2), Qnil);
  	      memcpy (XVECTOR (new_vector)->contents,
! 		      XVECTOR (*vector)->contents,
! 		      XVECTOR (*vector)->size * sizeof (Lisp_Object));
  	      *vector = new_vector;
  	    }
! 	  XVECTOR (*vector)->contents [index] = XVECTOR (menu)->contents [1];
  	  index++;
  	}
!       break;
!       
!     case Lisp_String:
!       break;
! 
!     case Lisp_Cons:
        {
  	Lisp_Object current;
--- 266,291 ----
    if (NILP (menu))
      return index;
!   if (VECTORP (menu))
      {
!       if (vector_length (XVECTOR (menu)) > 2)
  	{
!           struct Lisp_Vector *v = XVECTOR (*vector);
! 	  if (vector_length (v) <= index)
  	    {
  	      /* reallocate the vector by doubling its size */
! 	      Lisp_Object new_vector = make_vector (index * 2, Qnil);
  	      memcpy (XVECTOR (new_vector)->contents,
! 		      v->contents,
! 		      vector_length (v) * sizeof (Lisp_Object));
  	      *vector = new_vector;
+               v = XVECTOR (new_vector);
  	    }
! 	  v->contents [index] = XVECTOR (menu)->contents [1];
  	  index++;
  	}
!     }
!   else if (STRINGP (menu))
!     ;
!   else if (CONSP (menu))
      {
        Lisp_Object current;
***************
*** 274,283 ****
  	for (current = menu; !NILP (current); current = Fcdr (current))
  	  index = gcpro_menu_callbacks_1 (Fcar (current), vector, index);
- 	break;
        }
!     default:
        /* syntax checking has already been done */
        abort ();
!     }
    return index;
  }
--- 292,300 ----
        for (current = menu; !NILP (current); current = Fcdr (current))
          index = gcpro_menu_callbacks_1 (Fcar (current), vector, index);
      }
!   else
      /* syntax checking has already been done */
      abort ();
! 
    return index;
  }
***************
*** 288,292 ****
    int i, end;
    if (NILP (*vector))
!     *vector = Fmake_vector (make_number (10), Qnil);
    else if (!VECTORP (*vector))
      abort ();
--- 305,309 ----
    int i, end;
    if (NILP (*vector))
!     *vector = make_vector (10, Qnil);
    else if (!VECTORP (*vector))
      abort ();
***************
*** 296,300 ****
    /* pad it with nil, so that we don't continue protecting things
       we don't need any more */
!   for (i = end; i < XVECTOR (*vector)->size; i++)
      XVECTOR (*vector)->contents [i] = Qnil;
  }
--- 313,317 ----
    /* pad it with nil, so that we don't continue protecting things
       we don't need any more */
!   for (i = end; i < vector_length (XVECTOR (*vector)); i++)
      XVECTOR (*vector)->contents [i] = Qnil;
  }
***************
*** 331,335 ****
    struct gcpro gcpro1;
    struct screen* s = x_any_window_to_screen (XtWindow (widget));
-   Lisp_Object menubar_data;
    Lisp_Object rest = Qnil;
    int any_changes = 0;
--- 348,351 ----
***************
*** 340,345 ****
      return;
  
!   menubar_data = s->menubar_data;
!   if (!VECTORP (menubar_data))
      return;
  
--- 356,360 ----
      return;
  
!   if (!RECORD_TYPEP (s->menubar_data, lrecord_menubar_data))
      return;
  
***************
*** 356,360 ****
        any_changes = 1;
    if (any_changes ||
!       NILP (SCREEN_MENUBAR_DATA (s)->menubar_contents_up_to_date))
      set_screen_menubar (s, 1);
    UNGCPRO;
--- 371,375 ----
        any_changes = 1;
    if (any_changes ||
!       !SCREEN_MENUBAR_DATA (s)->menubar_contents_up_to_date)
      set_screen_menubar (s, 1);
    UNGCPRO;
***************
*** 489,494 ****
  
    if (NILP (s->menubar_data))
!     s->menubar_data = make_vector (MENUBAR_DATA_SIZE, Qnil);
  
    {
      Widget menubar_widget = s->display.x->menubar_widget;
--- 504,517 ----
  
    if (NILP (s->menubar_data))
!   {
!     struct menubar_data *data = alloc_lcrecord (sizeof (struct menubar_data),
!                                                 lrecord_menubar_data);
      
+     data->last_menubar_buffer = Qnil;
+     data->menubar_callbacks = Qnil;
+     data->menubar_contents_up_to_date = 0;
+     XSET (s->menubar_data, Lisp_Record, data);
+   }
+ 
    {
      Widget menubar_widget = s->display.x->menubar_widget;
***************
*** 534,539 ****
      UNBLOCK_INPUT;
    }
!   if (data) free_menubar_widget_value_tree (data);
!   SCREEN_MENUBAR_DATA (s)->menubar_contents_up_to_date = deep_p ? Qt : Qnil;
    SCREEN_MENUBAR_DATA (s)->last_menubar_buffer =
      XWINDOW (s->selected_window)->buffer;
--- 557,563 ----
      UNBLOCK_INPUT;
    }
!   if (data)
!     free_menubar_widget_value_tree (data);
!   SCREEN_MENUBAR_DATA (s)->menubar_contents_up_to_date = deep_p;
    SCREEN_MENUBAR_DATA (s)->last_menubar_buffer = 
      XWINDOW (s->selected_window)->buffer;
***************
*** 729,733 ****
  #ifdef HAVE_DIALOG_BOXES
  
! static char *button_names [] = {
    "button1", "button2", "button3", "button4", "button5",
    "button6", "button7", "button8", "button9", "button10" };
--- 753,757 ----
  #ifdef HAVE_DIALOG_BOXES
  
! static const char * const button_names [] = {
    "button1", "button2", "button3", "button4", "button5",
    "button6", "button7", "button8", "button9", "button10" };
***************
*** 763,767 ****
        Lisp_Object button = XCONS (desc)->car;
        widget_value *wv;
!       if (XVECTOR (button)->size != 4)
  	error ("dialog box text field descriptors must be 4 long");
        CHECK_STRING (XVECTOR (button)->contents [2], 0);
--- 787,791 ----
        Lisp_Object button = XCONS (desc)->car;
        widget_value *wv;
!       if (vector_length (XVECTOR (button)) != 4)
  	error ("dialog box text field descriptors must be 4 long");
        CHECK_STRING (XVECTOR (button)->contents [2], 0);
***************
*** 793,801 ****
  	}
        CHECK_VECTOR (button, 0);
!       if (XVECTOR (button)->size != 3)
! 	while (1)
! 	  Fsignal (Qerror,
! 		   Fcons (build_string("button descriptors must be 3 long"),
! 			  Fcons (button, Qnil)));
        CHECK_STRING (XVECTOR (button)->contents [0], 0);
        cb = XVECTOR (button)->contents [1];
--- 817,824 ----
  	}
        CHECK_VECTOR (button, 0);
!       if (vector_length (XVECTOR (button)) != 3)
!         signal_error (Qerror, list2 (build_string
!                                      ("button descriptors must be 3 long"),
!                                      button));
        CHECK_STRING (XVECTOR (button)->contents [0], 0);
        cb = XVECTOR (button)->contents [1];
***************
*** 946,950 ****
  	 has changed we have to update the menubar. */
        if (menubar_has_changed
! 	  || !VECTORP (s->menubar_data)
  	  || (!EQ (SCREEN_MENUBAR_DATA (s)->last_menubar_buffer,
  		   XWINDOW (s->selected_window)->buffer)))
--- 969,973 ----
  	 has changed we have to update the menubar. */
        if (menubar_has_changed
! 	  || !RECORD_TYPEP (s->menubar_data, lrecord_menubar_data)
  	  || (!EQ (SCREEN_MENUBAR_DATA (s)->last_menubar_buffer,
  		   XWINDOW (s->selected_window)->buffer)))
diff: ../lemacs-beta6/src/.purify: No such file or directory
*** ../lemacs-beta6/src/editfns.c	Fri Jul 16 19:58:21 1993
--- src/editfns.c	Sat Jul 24 21:59:20 1993
***************
*** 306,310 ****
    "Return this buffer's mark, as a marker object.\n\
  If `zmacs-regions' is true, then this returns nil unless the region is\n\
! currently in the active (hilighted) state.  With an argument of t, this\n\
  returns the mark (if there is one) regardless of the zmacs-region state.\n\
  You should *generally* not use the mark unless the region is active, if\n\
--- 306,310 ----
    "Return this buffer's mark, as a marker object.\n\
  If `zmacs-regions' is true, then this returns nil unless the region is\n\
! currently in the active (highlighted) state.  With an argument of t, this\n\
  returns the mark (if there is one) regardless of the zmacs-region state.\n\
  You should *generally* not use the mark unless the region is active, if\n\
***************
*** 456,460 ****
      return (Qzero);             /* >>> Gag me! */
    else
!     return (make_number (CHAR_AT (point)));
  }
  
--- 456,460 ----
      return (Qzero);             /* >>> Gag me! */
    else
!     return (make_number (FETCH_CHAR (point)));
  }
  
***************
*** 465,471 ****
  {
    if (point <= BEGV)
!     return (Qzero);
    else
!     return (make_number (CHAR_AT (point - 1)));
  }
  
--- 465,471 ----
  {
    if (point <= BEGV)
!     return (Qzero);             /* >>> Gag me! */
    else
!     return (make_number (FETCH_CHAR (point - 1)));
  }
  
***************
*** 523,527 ****
    if (n < BEGV || n >= ZV)
      return Qnil;
!   return (make_number (CHAR_AT (n)));
  }
  
--- 523,527 ----
    if (n < BEGV || n >= ZV)
      return Qnil;
!   return (make_number (FETCH_CHAR (n)));
  }
  
***************
*** 894,899 ****
  }
  
- /* Return a string with the contents of the current region */
- 
  DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0,
    "Return the contents of part of the current buffer as a string.\n\
--- 894,897 ----
***************
*** 922,926 ****
  DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
    1, 3, 0,
!   "Insert before point a substring of the contents buffer BUFFER.\n\
  BUFFER may be a buffer or a buffer name.\n\
  Arguments START and END are character numbers specifying the substring.\n\
--- 920,924 ----
  DEFUN ("insert-buffer-substring", Finsert_buffer_substring, Sinsert_buffer_substring,
    1, 3, 0,
!   "Insert before point a substring of the contents of buffer BUFFER.\n\
  BUFFER may be a buffer or a buffer name.\n\
  Arguments START and END are character numbers specifying the substring.\n\
***************
*** 1628,1632 ****
  This means that commands which operate on the region (the area between the\n\
  point and the mark) will only work while the region is in the ``active''\n\
! state, which is indicated by hilighting.  Executing most commands causes\n\
  the region to not be in the active state, so (for example) \\[kill-region] will only\n\
  work immediately after activating the region.\n\
--- 1626,1630 ----
  This means that commands which operate on the region (the area between the\n\
  point and the mark) will only work while the region is in the ``active''\n\
! state, which is indicated by highlighting.  Executing most commands causes\n\
  the region to not be in the active state, so (for example) \\[kill-region] will only\n\
  work immediately after activating the region.\n\
***************
*** 1671,1675 ****
    DEFVAR_BOOL ("zmacs-region-stays", &zmacs_region_stays,
     "Commands which do not wish to affect whether the region is currently\n\
! hilighted should set this to t.  Normally, the region is turned off after\n\
  executing each command that did not explicitly turn it on with the function\n\
  zmacs-activate-region. Setting this to true lets a command be non-intrusive.\n\
--- 1669,1673 ----
    DEFVAR_BOOL ("zmacs-region-stays", &zmacs_region_stays,
     "Commands which do not wish to affect whether the region is currently\n\
! highlighted should set this to t.  Normally, the region is turned off after\n\
  executing each command that did not explicitly turn it on with the function\n\
  zmacs-activate-region. Setting this to true lets a command be non-intrusive.\n\
*** ../lemacs-beta6/src/buffer.c	Sat Jul 24 10:23:42 1993
--- src/buffer.c	Sun Jul 25 20:13:00 1993
***************
*** 413,416 ****
--- 413,417 ----
    BUF_MODIFF (b) = 1;
    BUF_FACECHANGE (b) = 1;
+   BUF_MARGINCHANGE (b) = 0;     /* >>>> is this right, Chuck? */
  
    b->save_length = Qzero;
***************
*** 531,535 ****
--- 532,547 ----
    reset_buffer_local_variables (b);
  }
+ 
  
+ /*>>> Somebody had better think out this margin stuff much more clearly*/
+ /* >>> Is it a property of buffers or of windows?
+  * >>>  If of buffers, then what if the buffer is displayed on multiple
+  * >>>  windows?  On different displays?
+  * >>> Even if it is a property of buffers, these functions
+  * >>>  (a) should live in some file which would normally include the
+  * >>>       header files necessary for EM-width -type calculations
+  *>>>   (b) should include the string "buffer" in their names.
+  */
+ 
  DEFUN ("set-left-outside-margin-width", Fset_left_outside_margin_width,
         Sset_left_outside_margin_width, 1, 2, 0,
***************
*** 2103,2106 ****
--- 2115,2119 ----
    defsubr (&Sget_file_buffer);
    defsubr (&Sget_buffer_create);
+ 
    defsubr (&Sset_left_outside_margin_width);
    defsubr (&Sleft_outside_margin_width);
***************
*** 2109,2112 ****
--- 2122,2126 ----
    defsubr (&Sright_outside_margin_width);
    defsubr (&Sright_outside_margin_pixwidth);
+ 
    defsubr (&Sgenerate_new_buffer_name);
    defsubr (&Sbuffer_name);
diff: ../lemacs-beta6/src/.gdbinit: No such file or directory
*** ../lemacs-beta6/src/data.c	Fri Jul 16 19:58:15 1993
--- src/data.c	Tue Jul 27 13:09:51 1993
***************
*** 453,457 ****
  indirect_function (Lisp_Object object, int error)
  {
!   Lisp_Object tortise = object; 
    Lisp_Object hare = object;
  
--- 453,457 ----
  indirect_function (Lisp_Object object, int error)
  {
!   Lisp_Object tortoise = object; 
    Lisp_Object hare = object;
  
***************
*** 465,471 ****
        hare = XSYMBOL (hare)->function;
  
!       tortise = XSYMBOL (tortise)->function;
  
!       if (EQ (hare, tortise))
  	return (Fsignal (Qcyclic_function_indirection, list1 (object)));
      }
--- 465,471 ----
        hare = XSYMBOL (hare)->function;
  
!       tortoise = XSYMBOL (tortoise)->function;
  
!       if (EQ (hare, tortoise))
  	return (Fsignal (Qcyclic_function_indirection, list1 (object)));
      }
***************
*** 573,579 ****
  
  static Lisp_Object
! arithcompare (num1, num2, comparison)
!      Lisp_Object num1, num2;
!      enum comparison comparison;
  {
    double f1, f2;
--- 573,578 ----
  
  static Lisp_Object
! arithcompare (Lisp_Object num1, Lisp_Object num2, 
!               enum comparison comparison)
  {
    double f1, f2;
***************
*** 624,627 ****
--- 623,627 ----
        return Qnil;
      }
+   abort ();
  }
  
***************
*** 691,699 ****
  #endif /* LISP_FLOAT_TYPE */
  
!   if (!XINT (num))
      return Qt;
    return Qnil;
  }
  
  DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0,
    "Convert NUM to a string by printing it in decimal.\n\
--- 691,754 ----
  #endif /* LISP_FLOAT_TYPE */
  
!   if (XINT (num) == 0)
      return Qt;
+   else
      return Qnil;
  }
  
+ /* Convert between 32-bit values and kludgy pairs of lispy 24-bit values.  */
+ 
+ /* >>> do we want this or lisp_to_word/word_to_lisp ??? */
+ Lisp_Object
+ long_to_cons (unsigned long i)
+ {
+   unsigned int top = i >> 16;
+   unsigned int bot = i & 0xFFFF;
+   if (top == 0)
+     return make_number (bot);
+   if (top == 0xFFFF)
+     return Fcons (make_number (-1), make_number (bot));
+   return Fcons (make_number (top), make_number (bot));
+ }
+ 
+ unsigned long
+ cons_to_long (Lisp_Object c)
+ {
+   Lisp_Object top, bot;
+   if (FIXNUMP (c))
+     return XINT (c);
+   top = XCONS (c)->car;
+   bot = XCONS (c)->cdr;
+   if (CONSP (bot))
+     bot = XCONS (bot)->car;
+   return ((XINT (top) << 16) | XINT (bot));
+ }
+ 
+ /* Convert 32 bit items <-> (<high16> . <low16>) */
+ 
+ Lisp_Object
+ word_to_lisp (unsigned int item)
+ {
+   return Fcons (make_number (item >> 16), make_number (item & 0xffff));
+ }
+ 
+ unsigned int
+ lisp_to_word (Lisp_Object obj)
+ {
+   Lisp_Object high;
+   Lisp_Object low;
+   if ((NILP (obj)) || (!CONSP (obj))) return 0;
+   
+   high = XCONS (obj)->car;
+   if (!FIXNUMP (high)) return 0;
+   
+   low = XCONS (obj)->cdr; 
+   if (!FIXNUMP (low)) return 0;
+   
+   return ((((unsigned int) (((unsigned int) (XINT (high))) << 16))
+            | ((unsigned int) XINT ((low)))));
+ }
+ 
+ 
  DEFUN ("number-to-string", Fnumber_to_string, Snumber_to_string, 1, 1, 0,
    "Convert NUM to a string by printing it in decimal.\n\
***************
*** 812,816 ****
  	case Adiv:
  	  if (!argnum) accum = next;
! 	  else accum /= next;
  	  break;
  	case Alogand: accum &= next; break;
--- 867,876 ----
  	case Adiv:
  	  if (!argnum) accum = next;
! 	  else
! 	    {
! 	      if (next == 0)
! 		Fsignal (Qarith_error, Qnil);
! 	      accum /= next;
! 	    }
  	  break;
  	case Alogand: accum &= next; break;
***************
*** 873,877 ****
--- 933,941 ----
  	    accum = next;
  	  else
+ 	    {
+ 	      if (next == 0)
+ 		Fsignal (Qarith_error, Qnil);
  	      accum /= next;
+ 	    }
  	  break;
  	case Alogand:
***************
*** 951,956 ****
        f1 = ((FLOATP (num1)) ? float_data (XFLOAT (num1)) : XINT (num1));
        f2 = ((FLOATP (num2)) ? float_data (XFLOAT (num2)) : XINT (num2));
        f1 = fmod (f1, f2); /* fmod is ANSI. */
!       if (f1 < 0)
  	f1 += f2;
        return (make_float (f1));
--- 1015,1024 ----
        f1 = ((FLOATP (num1)) ? float_data (XFLOAT (num1)) : XINT (num1));
        f2 = ((FLOATP (num2)) ? float_data (XFLOAT (num2)) : XINT (num2));
+       if (f2 == 0)
+ 	Fsignal (Qarith_error, Qnil);
+ 
        f1 = fmod (f1, f2); /* fmod is ANSI. */
!       /* If the "remainder" comes out with the wrong sign, fix it.  */
!       if ((f1 < 0) != (f2 < 0))
  	f1 += f2;
        return (make_float (f1));
