+(defun comint-goto-process-mark ()
+ "Move point to the process mark.
+The process mark separates output, and input already sent,
+from input that has not yet been sent."
+ (interactive)
+ (let ((proc (or (get-buffer-process (current-buffer))
+ (error "Current buffer has no process"))))
+ (goto-char (process-mark proc))
+ (message "Point is now at the process mark")))
+
+(defun comint-bol-or-process-mark ()
+ "Move point beginning of line (after prompt) or to the process mark.
+The first time you use this command, it moves to the beginning of the line
+\(but after the prompt, if any). If you repeat it again immediately,
+it moves point to the process mark.
+
+The process mark separates the process output, along with input already sent,
+from input that has not yet been sent. Ordinarily, the process mark
+is at the beginning of the current input line; but if you have
+used \\[comint-accumulate] to send multiple lines at once,
+the process mark is at the beginning of the accumulated input."
+ (interactive)
+ (if (not (eq last-command 'comint-bol-or-process-mark))
+ (comint-bol nil)
+ (comint-goto-process-mark)))
+
+(defun comint-set-process-mark ()
+ "Set the process mark at point."
+ (interactive)
+ (let ((proc (or (get-buffer-process (current-buffer))
+ (error "Current buffer has no process"))))
+ (set-marker (process-mark proc) (point))
+ (message "Process mark set")))
+
+\f
+;; 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
+;; Most of the work is renaming variables and functions. These are the common
+;; 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>
+;; Miscellaneous:
+;; shell-set-directory <unnecessary>
+;; shell-mode-map comint-mode-map
+;; Commands:
+;; shell-send-input comint-send-input
+;; shell-send-eof comint-delchar-or-maybe-eof
+;; kill-shell-input comint-kill-input
+;; interrupt-shell-subjob comint-interrupt-subjob
+;; stop-shell-subjob comint-stop-subjob
+;; quit-shell-subjob comint-quit-subjob
+;; kill-shell-subjob comint-kill-subjob
+;; kill-output-from-shell comint-kill-output
+;; show-output-from-shell comint-show-output
+;; 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-filter-functions.
+;; 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.
+;; This is not modular. Instead, call comint-mode, and let *it* create the
+;; necessary comint-specific local variables. Then create the
+;; foo-mode-specific local variables in foo-mode. Set the buffer's keymap to
+;; be foo-mode-map, and its mode to be foo-mode. Set the comint-mode hooks
+;; (comint-{prompt-regexp, input-filter, input-filter-functions,
+;; 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:
+;;
+;; (defvar shell-mode-map '())
+;; (cond ((not shell-mode-map)
+;; (setq shell-mode-map (copy-keymap comint-mode-map))
+;; (define-key shell-mode-map "\C-c\C-f" 'shell-forward-command)
+;; (define-key shell-mode-map "\C-c\C-b" 'shell-backward-command)
+;; (define-key shell-mode-map "\t" 'comint-dynamic-complete)
+;; (define-key shell-mode-map "\M-?"
+;; 'comint-dynamic-list-filename-completions)))
+;;
+;; (defun shell-mode ()
+;; (interactive)
+;; (comint-mode)
+;; (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-directory-stack)
+;; (setq shell-directory-stack nil)
+;; (add-hook 'comint-input-filter-functions 'shell-directory-tracker)
+;; (run-hooks 'shell-mode-hook))
+;;
+;;
+;; Completion for comint-mode users
+;;
+;; For modes that use comint-mode, comint-dynamic-complete-functions is the
+;; hook to add completion functions to. Functions on this list should return
+;; non-nil if completion occurs (i.e., further completion should not occur).
+;; You could use comint-dynamic-simple-complete to do the bulk of the
+;; completion job.
+\f