Commits

Anonymous committed 30eded3

Created

Comments (0)

Files changed (6)

+1998-01-11  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile: Update to newer package interface
+
+1997-01-05  SL Baur  <steve@altair.xemacs.org>
+
+	* Makefile: update to newer package interface
+
+1997-12-24  SL Baur  <steve@altair.xemacs.org>
+
+	* view-process-mode.el (ps): Add appropriate autoloads.
+
+	* Makefile: Created.
+# Makefile for View Process lisp code
+
+# This file is part of XEmacs.
+
+# XEmacs 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.
+
+# XEmacs 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 XEmacs; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+VERSION = 1.02
+PACKAGE = view-process
+PKG_TYPE = regular
+REQUIRES = xemacs-base
+CATEGORY = os
+
+ELCS = view-process-mode.elc view-process-system-specific.elc \
+	view-process-xemacs.elc
+
+include ../../XEmacs.rules
+
+all:: $(ELCS) auto-autoloads.elc
+
+srckit: srckit-std
+
+binkit: binkit-sourceonly
+(view-process
+  (version VERSION
+   description "A Unix process browsing tool."
+   filename FILENAME
+   md5sum MD5SUM
+   size SIZE
+   provides (view-process-mode)
+   requires (REQUIRES)
+   type regular
+))

view-process-mode.el

+;;; view-process-mode.el --- Display current running processes
+
+;; Copyright (C) 1994, 1995, 1996 Heiko Muenkel
+
+;; Author: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
+;; Keywords: processes
+
+;; This file is part of XEmacs.
+
+;; XEmacs 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.
+
+;; XEmacs 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 XEmacs; See the file COPYING.  if not, write to the Free
+;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+;; 02111-1307, USA.
+
+;;; Synched up with:  Emacs 20.1
+
+;;; Commentary:
+
+;; DollarId: view-process-mode.el,v 1.113 1996/08/17 15:12:01 muenkel Exp $
+;;	This file defines the the view-process-mode, a mode for displaying
+;;	the current processes with ps on UNIX systems. There are also
+;;	commands to sort and filter the output and to send signals to the
+;;	processes.
+
+;;     You can display the processes with the command `view-processes'.
+;;	If you are familar with the UNIX ps command and its switches,
+;;	then you can also use the command `View-process-status' or
+;;	it's short cut `ps', which are asking for the command
+;;	switches.  You can also run the commands on a remote system
+;;	via rsh. For that you must give a prefix arg to the
+;;	commands. This leads to a question for the remote host name.
+
+;;	You need also the files: adapt.el
+;;				 view-process-system-specific.el
+;;				 view-process-xemacs.el
+;;				 view-process-emacs-19.el
+;; 
+;; Installation: 
+;;   
+;;	Put this file and the file adapt.el 
+;;     in one of your your load-path directories and
+;;	the following line in your ~/.emacs (without leading ;;;):
+;;	(autoload 'ps "view-process-mode"
+;;	"Prints a list with processes in the buffer `View-process-buffer-name'.
+;;     COMMAND-SWITCHES is a string with the command switches (ie: -aux).
+;;     IF the optional argument REMOTE-HOST is given, then the command will
+;;     be executed on the REMOTE-HOST. If an prefix arg is given, then the 
+;;     function asks for the name of the remote host."
+;;     t)
+;;
+;;	In the FSF Emacs 19 you should (but must not) put the following
+;;	line in your ~/.emacs:
+;;;	(transient-mark-mode nil)
+
+;;; Code:
+
+(provide 'view-process-mode)
+(require 'view-process-system-specific)
+
+(defconst View-process-package-version "2.4")
+
+(defconst View-process-package-name "hm--view-process") 
+
+(defconst View-process-package-maintainer "muenkel@tnt.uni-hannover.de")
+
+(defun View-process-xemacs-p ()
+  "Returns non nil if the editor is the XEmacs or lemacs."
+  (or (string-match "Lucid" emacs-version)
+      (string-match "XEmacs" emacs-version)))
+
+(defun View-process-lemacs-p ()
+  "Returns non nil if the editor is the lemacs."
+  (string-match "Lucid" emacs-version))
+
+(if (not (View-process-xemacs-p))
+    (require 'view-process-adapt)
+  )
+
+(defvar View-process-status-command "ps"
+  "*Command which reports process status (ps).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-status-command)
+
+(defvar View-process-status-command-switches-bsd "-auxw"
+  "*Switches for the command `view-processes' on BSD systems.
+Switches which suppresses the header line are not allowed here.")
+
+(defvar View-process-status-command-switches-system-v "-edaf"
+  "*Switches for the command `view-processes' on System V systems.
+Switches which suppresses the header line are not allowed here.")
+
+(defvar View-process-status-last-command-switches nil
+  "Switches of the last `View-process-status-command'.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-status-last-command-switches)
+
+(defvar View-process-signal-command "kill"
+  "*Command which sends a signal to a process (kill).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-signal-command)
+
+(defvar View-process-renice-command "renice"
+  "*Command which alter priority of running processes.")
+
+(make-variable-buffer-local 'View-process-renice-command)
+
+(defvar View-process-default-nice-value "4"
+  "*Default nice value for altering the priority of running processes.")
+
+(defvar View-process-rsh-command "rsh"
+  "*Remote shell command (rsh).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-rsh-command)
+
+(defvar View-process-uname-command "uname"
+  "*The uname command (It returns the system name).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-uname-command)
+
+(defvar View-process-uname-switches "-sr"
+  "*Switches for uname, so that it returns the sysname and the release.")
+
+(defvar View-process-test-command "test"
+  "*The test command.")
+
+(make-variable-buffer-local 'View-process-test-command)
+
+(defvar View-process-test-switches "-x"
+  "*Switches for test, to test if an executable exists.")
+
+(defvar View-process-uptime-command "uptime"
+  "*The uptime command. 
+No idea at the moment, if this exists on all systems.
+It should return some informations over the system.")
+
+(make-variable-buffer-local 'View-process-uptime-command)
+
+(defvar View-process-buffer-name "*ps*"
+  "Name of the output buffer for the 'View-process-mode'.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-buffer-name)
+
+(defvar View-process-mode-hook nil
+  "*This hook is run after reading in the processes.")
+
+(defvar View-process-motion-help t
+  "*If non nil, then help messages are displayed during mouse motion.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-motion-help)
+
+(defvar View-process-display-with-2-windows t
+  "*Determines the display type of the `View-process-mode'.
+If it is non nil, then 2 windows are used instead of one window.
+In the second window are the header lines displayed.")
+
+(defvar View-process-hide-header t
+  "*The header lines in the view processes buffer are hide, if this is t.")
+
+(make-variable-buffer-local 'View-process-hide-header)
+
+(defvar View-process-truncate-lines t
+  "*Truncates the liens in the view process buffer if t.")
+
+(make-variable-buffer-local 'View-process-truncate-lines)
+
+(defvar View-process-display-short-key-descriptions t
+  "*Controls, whether short key descriptions are displayed or not.")
+
+(defvar View-process-display-uptime t
+  "*Controls, whether the uptime is displayed or not.")
+
+(defvar View-process-use-font-lock t
+  "*Determines, if the `font-lock-mode' should be used or not.")
+
+(defvar View-process-ps-header-window-offset 2
+  "Offset for the size of the ps header window.")
+
+(defvar View-process-ps-header-window-size 0
+  "Internal variable. The size of the window with the *ps header* buffer.")
+
+(make-variable-buffer-local 'View-process-ps-header-window-size)
+
+(defvar View-process-stop-motion-help nil
+  "Internal variable. Stops motion help temporarily.")
+
+(defvar View-process-deleted-lines nil
+  "Internal variable. A list with lines, which are deleted by a filter.")
+
+(make-variable-buffer-local 'View-process-deleted-lines)
+
+(defvar View-process-header-buffer-name "*ps header*"
+  "Name of the view process header buffer.")
+
+(make-variable-buffer-local 'View-process-header-buffer-name)
+
+(defvar View-process-header-mode-name "psheader"
+  "Name of the `view process header mode'.")
+
+(defvar View-process-header-mode-hook nil
+  "*This hook is run after building the header buffer.")
+
+(defvar View-process-header-mode-line-off t
+  "t means do not display modeline in view-process-header-mode.
+This does only work in the XEmacs 19.12 or higher.")
+
+(defvar View-process-header-line-detection-list '("PID" "COMMAND" "COMD" "CMD")
+  "*The header line is detected with the help of this list.
+At least one of these words must be in a header line. Otherwise
+an error is signaled. YOu must only change this list, if your ps
+prodices header lines with strings, that are not in this list.") 
+
+(defvar View-process-header-line-background "yellow"
+  "*Background color of the header line.")
+
+(defvar View-process-header-line-foreground "blue"
+  "*Foreground color of the header line.")
+
+(defvar View-process-header-line-font (face-font 'bold)
+  "*Font of the header line")
+
+(defvar View-process-header-line-underline-p t
+  "*T, if the header line should be underlined.")
+
+(defvar View-process-no-mark ?_
+  "*A character with specifies, that a line isn't marked.")
+
+(defvar View-process-signaled-line-background nil
+  "*Background color of the line with a signaled or reniced process.")
+
+(defvar View-process-signaled-line-foreground "grey80"
+  "*Foreground color of the line with a signaled or reniced process.")
+
+(defvar View-process-signaled-line-font (face-font 'italic)
+  "*Font of the line with a signaled or reniced process.")
+
+(defvar View-process-signaled-line-underline-p nil
+  "*T, if the \"signaled line\" should be underlined.")
+
+(defvar View-process-signaled-line-mark ?s
+  "*A character, which is used as a mark for \"signaled lines\".")
+
+(defvar View-process-signal-line-background nil
+  "*Background color of the line with the process which should be signaled.")
+
+(defvar View-process-signal-line-foreground "red"
+  "*Foreground color of the line with the process which should be signaled.")
+
+(defvar View-process-signal-line-font (face-font 'bold)
+  "*Font of the line with the process which should be signaled.")
+
+(defvar View-process-signal-line-underline-p nil
+  "*T, if the \"signal line\" should be underlined.")
+
+(defvar View-process-signal-line-mark ?K
+  "*A character, which is used as a mark for \"signal lines\".")
+
+(defvar View-process-renice-line-background nil
+  "*Background color of the line with the process which should be reniced.")
+
+(defvar View-process-renice-line-foreground "red"
+  "*Foreground color of the line with the process which should be reniced.")
+
+(defvar View-process-renice-line-font (face-font 'bold)
+  "*Font of the line with the process which should be reniced.")
+
+(defvar View-process-renice-line-underline-p nil
+  "*T, if the \"renice line\" should be underlined.")
+
+(defvar View-process-renice-line-mark ?N
+  "*A character, which is used as a mark for \"renice lines\".")
+
+(defvar View-process-child-line-background nil
+  "*Background color of a line with a child process.")
+
+(defvar View-process-child-line-foreground "darkviolet"
+  "*Foreground color of a line with a child process.")
+
+(defvar View-process-child-line-font (face-font 'italic)
+  "*Font color of a line with a child process.")
+
+(defvar View-process-child-line-underline-p nil
+  "*T, if the \"line with a child process\" should be underlined.")
+
+(defvar View-process-child-line-mark ?C
+  "*A character, which is used as a mark for child processes.")
+
+(defvar View-process-parent-line-background "LightBlue"
+  "*Background color of a line with a parent process.")
+
+(defvar View-process-parent-line-foreground "darkviolet"
+  "*Foreground color of a line with a parent process.")
+
+(defvar View-process-parent-line-font (face-font 'bold)
+  "*Font  color of a line with a parent process.")
+
+(defvar View-process-parent-line-underline-p t
+  "*T, if the \"line with a parent\" should be underlined.")
+
+(defvar View-process-parent-line-mark ?P
+  "*A character, which is used as a mark for parent processes.")
+
+(defvar View-process-single-line-background nil
+  "*Background color of a line with a single line mark.")
+
+(defvar View-process-single-line-foreground "darkblue"
+  "*Foreground color of a line with a single line mark.")
+
+(defvar View-process-single-line-font (face-font 'bold)
+  "*Font  color of a line with a single line mark.")
+
+(defvar View-process-single-line-underline-p t
+  "*T, if the \"line with a single line mark\" should be underlined.")
+
+(defvar View-process-single-line-mark ?*
+  "*A character, which is used as a single line mark.")
+
+(defvar View-process-font-lock-keywords
+  (list
+   (cons (concat "^" 
+		 (char-to-string View-process-child-line-mark) 
+		 " .*")
+	 'View-process-child-line-face)
+   (cons (concat "^" 
+		 (char-to-string View-process-parent-line-mark) 
+		 " .*")
+	 'View-process-parent-line-face)
+   (cons (concat "^\\" 
+		 (char-to-string View-process-single-line-mark) 
+		 " .*")
+	 'View-process-single-line-face)
+   (cons (concat "^" 
+		 (char-to-string View-process-signaled-line-mark) 
+		 " .*")
+	 'View-process-signaled-line-face)
+   (cons (concat "^" 
+		 (char-to-string View-process-signal-line-mark) 
+		 " .*")
+	 'View-process-signal-line-face)
+   (cons (concat "^" 
+		 (char-to-string View-process-renice-line-mark) 
+		 " .*")
+	 'View-process-renice-line-face)
+   )
+  "The font lock keywords for the `View-process-mode'."
+  )  
+
+(defvar View-process-pid-mark-alist nil
+  "Internal variable. An alist with marks and pids.")
+
+(make-variable-buffer-local 'View-process-pid-mark-alist)
+
+(defvar View-process-last-pid-mark-alist nil
+  "Internal variable. An alist withthe last marks and pids.")
+
+(make-variable-buffer-local 'View-process-last-pid-mark-alist)
+
+(defvar View-process-sorter-and-filter nil
+  "*A list, which specifies sorter and filter commands.
+These commands will be run over the ps output, every time after
+ps has create a new output.
+The list consists of sublists, whereby every sublist specifies a 
+command. The first element of each list is a keyword, which 
+determines a command.
+The following keywords are allowed:
+ sort		- Sort the output by an output field
+ filter		- Filter the output by an output field, delete non matching l.
+ exclude-filter	- Filter the output by an output field, delete matching lines
+ grep		- Filter the output by the whole line, delete non matching l.
+ exclude-grep	- Filter the output by the whole line, delete matching lines
+ reverse	- Reverse the order of the output lines.
+
+The cdr of each sublist depends on the keyword. The following shows
+the syntax of the different sublist types:
+ (sort <fieldname>)
+ (filter <fieldname> <regexp>)
+ (exclude-filter <fieldname> <regexp>)
+ (grep <regexp>)
+ (exclude-grep <regexp>)
+ (reverse)
+
+Where <fieldname> is a string with determines the name of an output field
+and <regexp> is a string with an regular expression. The output field names
+are derived from the header line of the ps output.")
+
+(defvar View-process-actual-sorter-and-filter nil
+  "Internal variable. It holds the actual sorter and filter commands.
+Don't change it!")
+
+(make-variable-buffer-local 'View-process-actual-sorter-and-filter)
+
+(defvar View-process-itimer-value 5
+  "*Value of the view process itimer.")
+
+(defvar View-process-system-type nil
+  "Internal variable. Type of the system, on which the ps command is called.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-system-type)
+
+(defvar View-process-remote-host nil
+  "Internal variable. Name of the remote host or nil.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-remote-host)
+
+(defvar View-process-header-start nil
+  "Internal variable. Start of the ps output header line.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-header-start)
+
+(defvar View-process-header-end nil
+  "Internal variable. End of the ps output header line.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-header-end)
+
+(defvar View-process-output-start nil
+  "Internal variable. Start of the ps output (after the header).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-output-start)
+
+(defvar View-process-output-end nil
+  "Internal variable. End of the ps output (after the header).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-output-end)
+
+(defvar View-process-old-window-configuration nil
+  "Internal variable. Window configuration before the first ps command.")
+
+(make-variable-buffer-local 'View-process-old-window-configuration)
+
+(defvar View-process-max-fields nil
+  "Internal variable. Number of output fields.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-max-fields)
+
+(defvar View-process-field-names nil
+  "Internal variable. An alist with the fieldnames and fieldnumbers.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-max-fields)
+
+(defvar View-process-field-blanks-already-replaced nil
+  "Internal variable. It is t, if blanks in fields are already replaced.")
+
+(make-variable-buffer-local 'View-process-field-blanks-already-replaced)
+
+(defvar View-process-kill-signals nil
+  "An alist with the possible signals for the kill command.
+Don't change it by hand!
+The variable is initialised each time after running ps.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-kill-signals)
+
+(defvar View-process-kill-signals-general
+  '(("SIGHUP" "1") ("SIGKILL" "9") ("SIGTERM" "15")
+    ("1" "1") ("2" "2") ("3" "3") ("4" "4") ("5" "5") ("6" "6") ("7" "7") 
+    ("8" "8") ("9" "9") ("10" "10") ("11" "11") ("12" "12") ("13" "13") 
+    ("14" "14") ("15" "15") ("16" "16") ("17" "17") ("18" "18") 
+    ("19" "19") ("20" "20") ("21" "21") ("22" "22") ("23" "23") 
+    ("24" "24") ("25" "25") ("26" "26") ("27" "27") ("28" "28") 
+    ("29" "29") ("30" "30") ("31" "31"))
+  "An alist with the possible signals for the kill command.
+This list is used, if no system specific list is defined.
+It may be that you've other signals on your system. Try to test
+it with \"kill -l\" in a shell.")
+
+(defvar View-process-default-kill-signal "SIGTERM"
+  "*Default signal for the function `View-process-send-signal-to-process'.
+The string must be also in the alist `View-process-kill-signals'!")
+
+(defvar View-process-pid-field-name "PID"
+  "*The name of the field with the PID's.
+The name must be the same as in the first outputline of the
+command `View-process-status-command' (ps).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-pid-field-name)
+
+(defvar View-process-ppid-field-name "PPID"
+  "*The name of the field with the PPID's.
+The name must be the same as in the first outputline of the
+command `View-process-status-command' (ps).
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-ppid-field-name)
+
+(defvar View-process-host-names-and-system-types nil
+  "A list with the names and the system types of hosts.
+Each entry of the list looks like the following:
+  (<hostname> (<system-type> <version-number> <bsd-or-system-v>
+               <field-name-descriptions> 
+               <kill-signals>))
+Here are some examples:
+  (\"daedalus\" (\"sunos\" \"4\" \"bsd\" 
+               View-process-field-name-descriptions-sunos4
+               View-process-kill-signals-sunos4))
+  (\"bach\" (\"linux\" nil \"bsd\"
+           nil
+           View-process-kill-signals-linux
+           ))
+  (\"cesar\" (nil nil \"bsd\"))
+The list will be anhanced by the program, each time you run ps on
+a new system. But you can also set this variable by hand in your 
+.emacs. If the host name is found in this list, then the system 
+type will not be checked again." 
+  )
+
+(defvar View-process-status-history nil
+  "A list with the command switch history of the status command (ps).")
+
+(defvar View-process-remote-host-history nil
+  "A list with the remote host history.")
+
+(defvar View-process-field-name-history nil
+  "A list with the field name history.")
+
+(defvar View-process-filter-history nil
+  "A list with the filter history.")
+
+(defvar View-process-signal-history nil
+  "A list with the signal history.")
+
+(defvar View-process-field-name-descriptions nil
+  "Help list with the descriptions of ps fields.
+Don't change it by hand!
+The variable is initialised each time after running ps.
+The variable is buffer local.")
+
+(make-variable-buffer-local 'View-process-field-name-descriptions)
+
+(defvar View-process-field-name-descriptions-general 
+  '(
+    ("m" "Mark column of the View Processes Mode.") ; not a real field name
+    ("ADDR" "The memory address of the process. ")
+    ("%CPU" "CPU usage in percentage.")
+    ("%MEM" "Real Memory usage in percentage.")
+    ("COMMAND" "Command Name.")
+    ("F" ("Status= "
+	  ("0" "0=not in main memory.")
+	  ("1" "1=in main memory.")
+	  ("2" "2=system process.")
+	  ("4" "4=blocked in the main memory.")
+	  ("10" "10=swapped out.")
+	  ("20" "20=controlled by another one.")))
+    ("NI" "UNIX nice value, a positive value means less CPU time.")
+    ("PAGEIN" "Number of major page faults.")
+    ("PGID" "Process group id. ")
+    ("PID" "The process id.")
+    ("PPID" "The process id of the parent process.")
+    ("PRI" "Priority, a big value is a small priority.")
+    ("RSS" "Real (resident set) size, KBytes of program in memory.")
+    ("SHARE" "Shared memory")
+    ("SID" "ID of the session to which the process belongs. ")
+    ("SIZE" "Virtual image size, size of text+data+stack (in KByte ?).")
+    ("START" "Start time.")
+    ("STAT" ("Status. "
+	     ("R" "R=runnable. ")
+	     ("S" "S=sleeping. ")
+	     ("D" "D=un-interruptible sleep (eg disk or NFS I/O). ")
+	     ("T" "T=stopped or traced. ")
+	     ("Z" "Z=zombie (terminated). ")
+	     ("W" "W=waiting on an event. ")
+	     ("I" "I=intermediate status. ")
+	     ("N" "N=started with nice. ")
+	     ))
+    ("SWAP" "Kilobytes (with -p pages) on swap device.")
+    ("TIME" "Elapsed process time.")
+    ("TPGID" "Process group id of the associated terminal. ")
+    ("TRS" "Text resident size.")
+    ("TT" ("Dialog station. " ("?" "?=No dialog station")))
+    ("TTY" ("Dialog station. " ("?" "?=No dialog station")))
+    ("UID" "User Id.")
+    ("USER" "Owner of the process.")
+    ("WCHAN" "Name of the kernel function where the process is sleeping.")
+    )
+  "Help list with the descriptions of ps fields.
+This is a general list, which should be true for many systems.
+This list will only be used, if there is no entry in a special 
+list for the system.")
+
+(defvar View-process-insert-blank-alist 
+  '(("SZ" behind-predecessor 0)
+    ("SIZE" behind-predecessor 0)
+    ("RSS" behind-predecessor 0)
+    ("START" behind 1))
+  "Determines places in the output, where a blank should be inserted.
+It is an alist and each sublist has the following structure:
+ (field-name position-descriptor offset)
+The field-name is a string with the name of the field.
+The position-descriptor determines a position. It has one of the
+following values:
+`in-front' => insert in front of the field.
+`in-front-successor' => insert in front of the successor of the field.
+`behind' => insert behind of the field.
+`behind-predecessor' => insert behind the predecessor of the field.
+The offset is an integer , which specifies an offset.")
+
+(defvar View-process-mode-syntax-table nil
+  "Syntax table for the `View-process-mode'.")
+
+(if (not View-process-mode-syntax-table)
+    (let ((i 0))
+      (setq View-process-mode-syntax-table (make-syntax-table))
+      (setq i ?!)
+      (while (<= i ?#)
+	(modify-syntax-entry i "w" View-process-mode-syntax-table)
+	(setq i (1+ i)))
+      (modify-syntax-entry ?, "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?. "w" View-process-mode-syntax-table)
+      (setq i ?:)
+      (while (<= i ?\;)
+	(modify-syntax-entry i "w" View-process-mode-syntax-table)
+	(setq i (1+ i)))
+      (setq i ??)
+      (while (<= i ?@)
+	(modify-syntax-entry i "w" View-process-mode-syntax-table)
+	(setq i (1+ i)))
+      (modify-syntax-entry ?\\ "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?^ "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?` "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?' "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?~ "w" View-process-mode-syntax-table)
+      (modify-syntax-entry ?� "w" View-process-mode-syntax-table)
+      ))
+
+(defvar View-process-digit-bindings-send-signal nil
+  "The digits 1 to 9 will be bind to send signal commands, if t.")
+
+(defvar View-process-mode-mark-map nil
+  "Local subkeymap for View-process-mode buffers.")
+
+(if View-process-mode-mark-map
+    nil
+  (setq View-process-mode-mark-map (make-keymap))
+  (define-key View-process-mode-mark-map "m" 'View-process-mark-current-line)
+  (define-key View-process-mode-mark-map "u" 'View-process-unmark-current-line)
+  (define-key View-process-mode-mark-map "U" 'View-process-unmark-all)
+  (define-key View-process-mode-mark-map "c" 
+    'View-process-mark-childs-in-current-line)
+  (define-key View-process-mode-mark-map "l" 'View-process-reset-last-marks)
+  )
+
+(defvar View-process-mode-i-map nil
+  "Local subkeymap for View-process-mode buffers.")
+
+(if View-process-mode-i-map
+    nil
+  (setq View-process-mode-i-map (make-keymap))
+  (define-key View-process-mode-i-map "s" 'View-process-start-itimer)
+  (define-key View-process-mode-i-map "d" 'View-process-delete-itimer)
+  )
+
+(defvar View-process-mode-comma-map nil
+  "Local subkeymap for View-process-mode buffers.")
+
+(if View-process-mode-comma-map
+    nil
+  (setq View-process-mode-comma-map (make-keymap))
+  (define-key View-process-mode-comma-map "k"
+    'View-process-send-signal-to-processes-with-mark)
+  (define-key View-process-mode-comma-map "a"
+    'View-process-renice-processes-with-mark))
+
+(defvar View-process-mode-period-map nil
+  "Local subkeymap for View-process-mode buffers.")
+
+(if View-process-mode-period-map
+    nil
+  (setq View-process-mode-period-map (make-keymap))
+  (define-key View-process-mode-period-map "f"
+    'View-process-filter-region-by-current-field)
+  (define-key View-process-mode-period-map "l"
+    'View-process-filter-region)
+  (define-key View-process-mode-period-map "s"
+    'View-process-sort-region-by-current-field)
+  (define-key View-process-mode-period-map "r"
+    'View-process-reverse-region)
+  (define-key View-process-mode-period-map "k"
+    'View-process-send-signal-to-processes-in-region)
+  (define-key View-process-mode-period-map "a"
+    'View-process-renice-processes-in-region)
+  (define-key View-process-mode-period-map "v"
+    'View-process-status))
+    
+
+(defvar View-process-mode-map nil 
+  "Local keymap for View-process-mode buffers.")
+
+(if View-process-mode-map
+    nil
+  (setq View-process-mode-map (make-keymap))
+  (define-key View-process-mode-map "q" 'View-process-quit)
+  (define-key View-process-mode-map "V" 'View-process-display-version)
+  (define-key View-process-mode-map " " 'scroll-up)
+  (define-key View-process-mode-map "b" 'scroll-down)
+  (define-key View-process-mode-map "t" 'View-process-toggle-truncate-lines)
+  (define-key View-process-mode-map "u" 'View-process-status-update)
+  (define-key View-process-mode-map "U" 
+    'View-process-remove-all-filter-and-sorter)
+  (define-key View-process-mode-map "g" 'revert-buffer)
+;  (define-key View-process-mode-map "v" 'View-process-status)
+  (define-key View-process-mode-map "v" 'view-processes)
+  (define-key View-process-mode-map "f"
+    'View-process-filter-by-current-field-g)
+  (define-key View-process-mode-map "F"
+    'View-process-filter-output-by-current-field)
+  (define-key View-process-mode-map "l"
+    'View-process-filter-g)
+  (define-key View-process-mode-map "L"
+    'View-process-filter-output)
+  (define-key View-process-mode-map "s"
+    'View-process-sort-by-current-field-g)
+  (define-key View-process-mode-map "S"
+    'View-process-sort-output-by-current-field)
+  (define-key View-process-mode-map "r"
+    'View-process-reverse-g)
+  (define-key View-process-mode-map "R"
+    'View-process-reverse-output)
+  (define-key View-process-mode-map "k"
+    'View-process-send-signal-to-processes-g)
+  (define-key View-process-mode-map "K"
+    'View-process-send-signal-to-process-in-line)
+  (define-key View-process-mode-map "a"
+    'View-process-renice-processes-g)
+  (define-key View-process-mode-map "A"
+    'View-process-renice-process-in-line)
+;  (define-key View-process-mode-map "k"
+;    'View-process-send-signal-to-process)
+  (define-key View-process-mode-map "?"
+    'View-process-which-field-name)
+  (define-key View-process-mode-map "h"
+    'View-process-show-field-names)
+  (define-key View-process-mode-map "e"
+    'View-process-display-emacs-pid)
+  (define-key View-process-mode-map "w" 'View-process-show-pid-and-command)
+  (define-key View-process-mode-map "n" 'View-process-next-field)
+  (define-key View-process-mode-map "p" 'View-process-previous-field)
+  (define-key View-process-mode-map "<" 'View-process-output-start)
+  (define-key View-process-mode-map ">" 'View-process-output-end)
+  (define-key View-process-mode-map [return]
+    'View-process-goto-first-field-next-line)
+  (define-key View-process-mode-map "M" 'View-process-submit-bug-report)
+  (define-key View-process-mode-map "m" View-process-mode-mark-map)
+  (define-key View-process-mode-map "." View-process-mode-period-map)
+  (define-key View-process-mode-map "," View-process-mode-comma-map)
+  (define-key View-process-mode-map "i" View-process-mode-i-map)
+  )
+
+(defvar View-process-pulldown-menu-name "Processes"
+  "Name of the pulldown menu in the `View-process-mode'.")
+
+(defvar View-process-pulldown-menu nil
+  "Pulldown menu list for the `View-process-mode'.")
+
+(defvar View-process-region-menu nil
+  "Menu list for the `View-process-mode', used if a region is active.")
+
+(defvar View-process-marked-menu nil
+  "Menu list for the `View-process-mode', used if marked lines exists.
+Not used, if a region is active.")
+
+(defvar View-process-non-region-menu nil
+  "Menu list for the `View-process-mode', used if a region is not active.")
+
+(defvar View-process-mode-name "Processes"
+  "Name of the `view process mode'.")
+
+(defun View-process-make-field-postition-alist-1 ()
+"Internal function of View-process-make-field-postition-alist."
+  (if (>= (point) View-process-header-end)
+      nil
+    (let (start end)
+      (skip-chars-forward " ")
+      (setq start (current-column))
+      (skip-chars-forward "^ ")
+      (setq end (current-column))
+      (cons (list start end) 
+	    (View-process-make-field-postition-alist-1))))
+  )
+
+(defun View-process-make-field-postition-alist ()
+  "Returns an alist with the start and end positions of each field.
+The list looks like ((start1 end1) (start2 end2) ...)."
+  (save-restriction
+    (widen)
+    (goto-char View-process-header-start)
+    (View-process-make-field-postition-alist-1)))
+
+(defun View-process-overwrite-chars-in-region (begin end char)
+  "Overwrite region between BEGIN and END with CHAR."
+  (let ((region-begin (if (< begin end) begin end))
+	(region-end (if (> end begin) end begin)))
+    (save-excursion
+      (goto-char region-begin)
+      (while (> region-end (point))
+	(delete-char 1)
+	(View-process-insert-and-inherit char)))))
+
+(defun View-process-replaces-blanks-in-the-fields-of-this-line 
+  (field-position-alist)
+  "Replaces the blanks in the fields of this line with underscores.
+FIELD-POSITION-ALIST is an alist with the name and the 
+aproximated start and end positions of each field."
+  (if (cdr field-position-alist) ; don't change the last field
+      (let ((field-start (+ (View-process-return-beginning-of-line)
+			    (car (car field-position-alist))))
+	    (field-end (+ (View-process-return-beginning-of-line)
+			  (car (cdr (car field-position-alist)))))
+	    (next-field-start (+ (View-process-return-beginning-of-line)
+				 (car (car 
+				       (cdr field-position-alist))))))
+	(goto-char field-start)
+	(skip-chars-forward " ")
+	(if (> (point) field-end)
+	    (progn (goto-char field-start) 
+		   (delete-char 1) 
+		   (View-process-insert-and-inherit "_"))
+	  (let ((search-result (search-forward-regexp "[ ]+" field-end t))
+		(match-beginning nil))
+	    (if search-result
+		(if (not (= search-result field-end))
+		    (View-process-overwrite-chars-in-region (match-beginning 0)
+							    (match-end 0)
+							    ?_)
+		  (setq match-beginning (match-beginning 0))
+		  (if (and (search-forward-regexp "[^ ]+" next-field-start t)
+			   (not (eq (point) next-field-start)))
+		      (View-process-overwrite-chars-in-region 
+		       match-beginning
+		       (match-beginning 0)
+		       ?_))))
+	    ))
+	(View-process-replaces-blanks-in-the-fields-of-this-line
+	 (cdr field-position-alist)))))
+
+(defun View-process-replaces-blanks-in-fields ()
+  "Replaces the blanks in fields with underscrores."
+  (save-excursion
+    (save-window-excursion
+      (let ((field-position-alist (View-process-make-field-postition-alist))
+	    (read-only buffer-read-only))
+	(setq buffer-read-only nil)
+	(goto-char View-process-output-start)
+	(while (< (point) View-process-output-end)
+	  (beginning-of-line)
+	  (View-process-replaces-blanks-in-the-fields-of-this-line
+	   field-position-alist)
+	  (forward-line))
+	(setq buffer-read-only read-only)))))
+
+(defun View-process-replaces-blanks-in-fields-if-necessary ()
+  "Replaces blanks in fields, if necessary.
+For that it checks `View-process-field-blanks-already-replaced'."
+  (if View-process-field-blanks-already-replaced
+      nil
+    (View-process-replaces-blanks-in-fields)
+    (setq View-process-field-blanks-already-replaced t)))
+
+(defun View-process-insert-column-in-region (char 
+					     column 
+					     begin 
+					     end
+					     &optional overwrite
+					               not-looking-at)
+  "Inserts the CHAR at the COLUMN in the region from BEGIN TO END.
+The first line must have sufficient columns. No tabs are allowed.
+If the optional argument OVERWRITE is non nil, then the CHAR 
+overwrites the char in the COLUMN.
+The optional argument NOT-LOOKING-AT is nil or a regular expression.
+In the second case the insertation will only be done, if NOT-LOOKING-AT
+isn't a string starting at the column."
+  (save-excursion
+    (let ((no-of-lines (count-lines begin end))
+	  (line 1))
+      (goto-char begin)
+      (beginning-of-line)
+      (while (<= line no-of-lines)
+      (forward-char column)
+	(if (not (= (current-column) column))
+	    (View-process-insert-and-inherit 
+	     (make-string (- column (current-column)) ? )))
+	(if overwrite 
+	    (progn
+	      (delete-char -1)
+	      (View-process-insert-and-inherit char))
+	  (if (or (not not-looking-at)
+		  (not (looking-at not-looking-at)))
+	      (progn
+		(View-process-insert-and-inherit char)
+		(forward-char -1)
+		)))
+	(forward-line 1)
+	(setq line (1+ line))))))
+
+(defun View-process-insert-blank-in-column (column 
+					    &optional overwrite
+					              not-looking-at)
+  "Inserts a blank in all lines of the ps output in column COLUMN.
+If OVERWRITE is non nil, then it overwrites the old column char.
+The optional argument NOT-LOOKING-AT is nil or a regular expression.
+In the second case the insertation will only be done, if NOT-LOOKING-AT
+isn't a string starting at the column."
+  (let ((read-only buffer-read-only))
+    (setq buffer-read-only nil)
+    (View-process-insert-column-in-region ? 
+					  column 
+					  View-process-header-start
+					  View-process-output-end
+					  overwrite
+					  not-looking-at)
+    (setq View-process-output-end (point-max))
+    (setq buffer-read-only read-only)))
+
+;(defun View-process-insert-blanks-at-line-start ()
+;  "Inserts some blanks at the beginning of each output line.
+;This space is used for the marks."
+;  (save-excursion
+;    (goto-char View-process-header-start)
+;    (insert "m ")
+;    (forward-line)
+;    (while (< (point) View-process-output-end)
+;      (insert "_ ")
+;      (forward-line))))
+
+(defun View-process-insert-blanks-at-line-start ()
+  "Inserts some blanks at the beginning of each output line.
+This space is used for the marks."
+  (save-excursion
+    (goto-char View-process-output-end)
+    (forward-line -1)
+    (while (> (point) View-process-header-start)
+      (insert "_ ")
+      (forward-line -1))
+    (insert "m ")))
+
+(defun View-process-return-position (field-name position-descriptor)
+  "Returns a position deppending on the FIELD-NAME and the POSITION-DESCRIPTOR.
+The POSITION-DESCRIPTOR must be one of the 4 values: `in-front',
+`in-front-successor', `behind' and `behind-predecessor'.
+If the FIELD-NAME isn't in the header-line, then it return nil."
+  (save-excursion
+    (goto-char View-process-header-start)
+    (beginning-of-line)
+    (if (search-forward field-name (View-process-return-end-of-line) t)
+	(cond ((eq position-descriptor 'behind-predecessor)
+	       (goto-char (match-beginning 0))
+	       (skip-chars-backward " ")
+	       (current-column))
+	      ((eq position-descriptor 'behind)
+	       (current-column))
+	      ((eq position-descriptor 'in-front)
+	       (goto-char (match-beginning 0))
+	       (current-column))
+	      ((eq position-descriptor 'in-front-successor)
+	       (skip-chars-forward " ")
+	       (current-column))))))
+
+(defun View-process-split-merged-fields (insert-blank-alist)
+  "Tries to split merged fields.
+At the moment this is done by inserting a blank between fields,
+which are often merged together. The fields are determined by the
+alist INSERT-BLANK-ALIST."
+  (cond (insert-blank-alist
+	 (let ((position (View-process-return-position 
+			  (car (car insert-blank-alist))
+			  (car (cdr (car insert-blank-alist))))))
+	   (if position
+	       (View-process-insert-blank-in-column
+		(+ position
+		   (car (cdr (cdr (car insert-blank-alist)))))
+		nil
+		"[^ ][^ ]? ")))
+	 (View-process-split-merged-fields (cdr insert-blank-alist)))
+	(t)))
+
+(defun View-process-replace-colons-with-blanks ()
+  "Replaces colons with blanks, if a colon is also in the header line.
+This fixes the output of the IRIX ps on SGI's."
+  (save-excursion
+    (goto-char View-process-header-start)
+    (while (search-forward ":" (View-process-return-end-of-line) t)
+      (View-process-insert-blank-in-column (current-column)
+					   t))))
+
+(defun View-process-mode ()
+  "Mode for displaying and killing processes.
+The mode has the following keybindings: 
+\\{View-process-mode-map}.
+
+The first column of each outputline will be used to display marked lines.
+The following mark signs are possible (one can change them by changing
+the variables in the second column of the following table):
+
+Sign	Variable			Description
+_	View-process-no-mark		Process isn't marked
+*	View-process-single-line-mark	The normal mark.
+C	View-process-child-line-mark	Marked as a child of P (see also P)
+K	View-process-signal-line-mark	Used during signaling
+N	View-process-renice-line-mark	Used during renicing
+P	View-process-parent-line-mark	Marked as the parent of P (see also C)
+s	View-process-signaled-line-mark	Process was signaled or reniced.
+
+The signal and renice commands are working also on marked processes!"
+;  (kill-all-local-variables)
+  (make-local-variable 'revert-buffer-function)
+  (setq revert-buffer-function 'View-process-revert-buffer)
+  (View-process-change-display-type View-process-display-with-2-windows)
+  (use-local-map View-process-mode-map)
+  (set-syntax-table View-process-mode-syntax-table)
+  (setq major-mode 'View-process-mode
+	mode-name View-process-mode-name)
+;  (View-process-replaces-blanks-in-fields)
+  (setq View-process-deleted-lines nil)
+  (View-process-call-sorter-and-filter View-process-actual-sorter-and-filter)
+  (setq truncate-lines View-process-truncate-lines)
+  (View-process-install-pulldown-menu)
+;  (View-process-install-mode-motion)
+  (View-process-hide-header (and View-process-display-with-2-windows
+				 View-process-hide-header))
+  (View-process-install-font-lock)
+  (View-process-install-mode-motion)
+  (run-hooks 'View-process-mode-hook)
+  )
+
+(defun View-process-build-field-name-list ()
+  "Returns an alist with the field names and the field number.
+The list looks like ((\"USER\" 1) (\"PID\" 2) (\"COMMAND\" 3))."
+  (goto-char View-process-header-start)
+  (forward-word 1)
+  (setq View-process-field-names '())
+  (let ((i 1))
+    (while (<= (point) View-process-header-end)
+      (setq View-process-field-names (cons (list (current-word) i)
+					   View-process-field-names))
+      (setq i (1+ i))
+      (forward-word 1))))
+
+(defun View-process-field-name-exists-p (field-name)
+  "Returns non nil, if the field FIELD_NAME exists."
+  (assoc field-name View-process-field-names))
+
+(defun View-process-translate-field-name-to-position (field-name)
+  "Returns the position of the field with the name FIELD-NAME."
+  (car (cdr (assoc field-name View-process-field-names)))
+  )
+
+(defun View-process-translate-field-position-to-name (position)
+  "Returns the field name of the field with the position POSITION."
+  (if (> position View-process-max-fields)
+      (car (View-process-assoc-2th View-process-max-fields 
+				   View-process-field-names))
+    (car (View-process-assoc-2th position View-process-field-names))
+    ))
+
+(defun View-process-get-system-type-from-host-list (host-name)
+  "Returns nil, or the system type of the host with the name HOST-NAME."
+  (car (cdr (assoc host-name View-process-host-names-and-system-types))))
+
+(defun View-process-put-system-type-in-host-list (host-name system-type)
+  "Puts the HOST-NAME and the SYSTEM-TYPE in a special host list.
+The list has the name `View-process-host-names-and-system-types'."
+  (if (not (member (list host-name system-type)
+		   View-process-host-names-and-system-types))
+      (setq View-process-host-names-and-system-types
+	    (cons (list host-name system-type)
+		  View-process-host-names-and-system-types))))
+
+(defun View-process-bsd-or-system-v (&optional remote-host)
+  "This function determines, if the system is a BSD or a System V.
+For that it uses the ps command.
+If REMOTE-HOST is non nil, then the system of the REMOTE-HOST will 
+be tested."
+    (if remote-host
+	(if (eq 0 (call-process View-process-rsh-command
+				nil
+				nil
+				nil
+				remote-host
+				(concat View-process-status-command 
+					" " 
+					"-dfj")))
+	    "system-v"
+	  "bsd")
+      (if (eq 0 (call-process View-process-status-command 
+			      nil 
+			      nil
+			      nil
+			      "-dfj"))
+	  "system-v"
+	"bsd")))
+
+(defun View-process-program-exists-p (program &optional remote-host)
+  "Returns t, if the PROGRAM exists.
+If REMOTE_HOST is non nil, then the program will be searched remote
+on that host."
+  (if remote-host
+      (or (= 0 (call-process View-process-rsh-command
+			     nil
+			     nil
+			     nil
+			     remote-host
+			     (concat View-process-test-command
+				     " "
+				     View-process-test-switches
+				     " "
+				     program)))
+	  (= 0 (call-process View-process-rsh-command
+			     nil
+			     nil
+			     nil
+			     remote-host
+			     (concat View-process-test-command
+				     " "
+				     View-process-test-switches
+				     " "
+				     "/bin/" 
+				     program)))
+	  (= 0 (call-process View-process-rsh-command
+			     nil
+			     nil
+			     nil
+			     remote-host
+			     (concat View-process-test-command
+				     " "
+				     View-process-test-switches
+				     " "
+				     "/usr/bin/"
+				     program))))
+    (or (= 0 (call-process View-process-test-command
+			   nil
+			   nil
+			   nil
+			   View-process-test-switches
+			   program))
+	(= 0 (call-process View-process-test-command
+			   nil
+			   nil
+			   nil
+			   View-process-test-switches
+			   (concat "/bin/" program)))
+	(= 0 (call-process View-process-test-command
+			   nil
+			   nil
+			   nil
+			   View-process-test-switches
+			   (concat "/usr/bin/" program))))))
+
+(defun View-process-search-system-type-in-system-list-1 (system-type
+							 system-list)
+  "Internal function of `View-process-search-system-type-in-system-list'."
+  (cond ((not system-list) nil)
+	((equal system-type (car (car system-list)))
+	 (cons (car system-list)
+	       (View-process-search-system-type-in-system-list-1 
+		system-type
+		(cdr system-list))))
+	(t (View-process-search-system-type-in-system-list-1 system-type
+							     (cdr system-list))
+	   )))
+
+(defun View-process-search-system-type-in-system-list (system-type system-list)
+  "Searches the SYSTEM-TYPE in SYSTEM-LIST.
+It returns the entry or nil, if the SYSTEM-TYPE isn't in the list.
+If more then one entry with the same SYSTEM-TYPE are found, then the
+version number is also checked. If the version number isn't in the 
+list, then nil is returned."
+  (let ((system-type-entries (View-process-search-system-type-in-system-list-1
+			      (car system-type)
+			      system-list)))
+    (if system-type-entries
+	(if (= 1 (length system-type-entries))
+	    (car system-type-entries)
+	  (View-process-assoc-2th (car (cdr system-type)) system-type-entries))
+      nil)))
+
+
+(defun View-process-generalize-system-type (system-type &optional remote-host)
+  "Generalize the SYSTEM-TYPE.
+Determines, if the system is in the `View-process-specific-system-list'
+and if it is a BSD or a System V system. It returns a list which looks 
+like the following: (<system-type> <version-no> <bsd-or-system-v>).
+The elements <system-type> and <version-no> are set to nil, if the 
+<system-type> isn't in the `View-process-specific-system-list'. In that 
+case the third element (<bsd-or-system-v>) is determined with the help
+of the ps output. if REMOTE-HOST is non nil, the the ps command to check
+the system type is run on the remote host REMOTE-HOST."
+  (let ((new-system-type (View-process-search-system-type-in-system-list
+			  system-type
+			  View-process-specific-system-list)))
+    (if new-system-type
+	new-system-type
+      (list nil nil (View-process-bsd-or-system-v)))))
+
+(defun View-process-get-local-system-type ()
+  "Returns the system type of the local host."
+  (let ((system-type (View-process-get-system-type-from-host-list
+		      (system-name))))
+    (if (not system-type)  ; t, if the host isn't in the list
+	(progn
+	  (if (View-process-program-exists-p View-process-uname-command)
+	      (save-excursion
+		(let ((buffer (generate-new-buffer "*system-type*")))
+		  (call-process View-process-uname-command
+				nil
+				buffer
+				nil
+				View-process-uname-switches)
+		  (set-buffer buffer)
+		  (forward-line -1)
+		  (setq system-type (downcase (current-word)))
+		  (forward-word 2)
+		  (setq system-type 
+			(list system-type (downcase (current-word))))
+		  (kill-buffer buffer)
+		  ;; determine, if the system is in the
+		  ;; View-process-specific-system-list and if it is 
+		  ;; a BSD or a System V system;
+		  ;; The system type will be set to nil, 
+		  ;; if it isn't in the list
+		  (setq system-type (View-process-generalize-system-type
+				     system-type))
+		  ))
+	    (setq system-type (list nil nil (View-process-bsd-or-system-v))))
+	  (View-process-put-system-type-in-host-list (system-name)
+						     system-type)
+	  system-type)
+      system-type)))
+
+(defun View-process-get-remote-system-type ()
+  "Returns the system type of the remote host `View-process-remote-host'."
+  (let ((system-type (View-process-get-system-type-from-host-list 
+		      View-process-remote-host)))
+    (if system-type  ; nil, if the host isn't in the list
+	system-type
+      (if (View-process-program-exists-p View-process-uname-command
+					 View-process-remote-host)
+	  (let ((buffer (generate-new-buffer "*system-type*")))
+	    (save-excursion
+	      (call-process View-process-rsh-command
+			    nil
+			    buffer
+			    nil
+			    View-process-remote-host
+			    (concat View-process-uname-command
+				    " "
+				    View-process-uname-switches))
+	      (set-buffer buffer)
+	      (forward-line -1)
+	      (setq system-type (downcase (current-word)))
+	      (forward-word 2)
+	      (setq system-type 
+		    (list system-type (downcase (current-word))))
+	      (kill-buffer buffer)
+	      ;; determine, if the system is in the
+	      ;; View-process-specific-system-list and if it is 
+	      ;; a BSD or a System V system;
+	      ;; The system type will be set to nil, 
+	      ;; if it isn't in the list
+	      (setq system-type (View-process-generalize-system-type
+				 system-type
+				 View-process-remote-host))
+	      ))
+	(setq system-type (list nil nil (View-process-bsd-or-system-v
+					 View-process-remote-host))))
+      (View-process-put-system-type-in-host-list View-process-remote-host
+						 system-type)
+      system-type)))
+
+(defun View-process-get-system-type ()
+  "Returns the type of the system on which ps was executed."
+  (if View-process-remote-host
+      (View-process-get-remote-system-type)
+    (View-process-get-local-system-type)
+    ))
+
+(defun View-process-get-kill-signal-list (system-type)
+  "Returns a kill signal list for the SYSTEM-TYPE."
+  (if (= 3 (length system-type))
+      (if (string= "bsd" (nth 2 system-type))
+	  (if View-process-kill-signals-bsd
+	      View-process-kill-signals-bsd
+	    View-process-kill-signals-general)
+	(if View-process-kill-signals-system-v
+	    View-process-kill-signals-system-v
+	  View-process-kill-signals-general))
+    (if (eval (nth 4 system-type))
+	(eval (nth 4 system-type))
+      (if (string= "bsd" (nth 2 system-type))
+	  (if View-process-kill-signals-bsd
+	      View-process-kill-signals-bsd
+	    View-process-kill-signals-general)
+	(if View-process-kill-signals-system-v
+	    View-process-kill-signals-system-v
+	  View-process-kill-signals-general)))))
+
+(defun View-process-get-field-name-description-list (system-type)
+  "Returns a field name description list for the SYSTEM-TYPE.
+It returns nil, if no system specific list exists."
+  (if (= 3 (length system-type))
+      (if (string= "bsd" (nth 2 system-type))
+	  (if View-process-field-name-descriptions-bsd
+	      View-process-field-name-descriptions-bsd)
+	(if View-process-field-name-descriptions-system-v
+	    View-process-field-name-descriptions-system-v))
+    (if (eval (nth 3 system-type))
+	(eval (nth 3 system-type))
+      (if (string= "bsd" (nth 2 system-type))
+	  (if View-process-field-name-descriptions-bsd
+	      View-process-field-name-descriptions-bsd)
+	(if View-process-field-name-descriptions-system-v
+	    View-process-field-name-descriptions-system-v)))))
+
+(defun View-process-init-internal-variables (use-last-sorter-and-filer)
+  "Init internal variables. 
+ (without `View-process-header-start').
+If USE-LAST-SORTER-AND-FILER is t, then 
+'View-process-actual-sorter-and-filter' will not be changed"
+  ;; don't replace blanks now
+  (setq View-process-field-blanks-already-replaced t) 
+  
+  (goto-char View-process-header-start)
+  (end-of-line)
+  (setq View-process-header-end (point))
+  ;;  (newline)
+  (forward-line)
+  (setq View-process-output-start (point))
+  (setq View-process-output-end (point-max))
+  (goto-char View-process-header-end)
+  (forward-word -1)
+  (setq View-process-max-fields (View-process-current-field-number))
+  (View-process-build-field-name-list)
+  (setq View-process-system-type (View-process-get-system-type))
+  (setq View-process-kill-signals (View-process-get-kill-signal-list
+				   View-process-system-type))
+  (setq View-process-field-name-descriptions
+	(View-process-get-field-name-description-list View-process-system-type)
+	)
+  ;; Replace the blanks the next time if it is necessary
+  (setq View-process-field-blanks-already-replaced nil)
+  (if (not use-last-sorter-and-filer)
+      (setq View-process-actual-sorter-and-filter
+	    View-process-sorter-and-filter))
+
+  (if View-process-pid-mark-alist
+      (progn
+	(setq View-process-last-pid-mark-alist View-process-pid-mark-alist)
+	(setq View-process-pid-mark-alist nil)))
+)
+
+(defun View-process-insert-short-key-descriptions ()
+  "Insert short key descriptions at the current point.
+If `View-process-display-short-key-descriptions' is nil, then
+nothing will be inserted."
+  (if View-process-display-short-key-descriptions
+      (let ((local-map (current-local-map)))
+	(use-local-map View-process-mode-map)
+	(insert 
+	 (substitute-command-keys
+	  (concat 
+	   "  \\[view-processes]: new output  "
+	   "\\[View-process-status]: new output with new options  "
+	   "     \\[revert-buffer]: update output  \n" 
+	   "  \\[View-process-filter-by-current-field-g]: field filter  "
+	   "\\[View-process-filter-g]: line filter  "
+	   "\\[View-process-sort-by-current-field-g]: sort  "
+	   "\\[View-process-reverse-g]: reverse  "
+	   "\\[View-process-send-signal-to-processes-g]: send signal  "
+	   "\\[View-process-quit]: quit\n")))
+	(use-local-map local-map))))
+
+(defun View-process-insert-uptime (&optional remote-host)
+  "Inserts uptime information at the current point.
+if `View-process-display-uptime' is nil, then nothing will be inserted.
+If REMOTE-HOST is non nil, then its the name of the remote host."
+  (if View-process-display-uptime
+      (progn
+;	(newline)
+	(if remote-host
+	    (call-process View-process-rsh-command
+			  nil
+			  t
+			  nil
+			  remote-host
+			  View-process-uptime-command)
+	  (call-process View-process-uptime-command
+			nil
+			t
+			nil)))))
+
+(defun View-process-insert-title-lines (command-switches 
+					remote-host
+					use-last-sorter-and-filter)
+  "Insert the title lines in the output lines.
+REMOTE-HOST is nil or the name of the host on which the 
+ps command was executed. USE-LAST-SORTER-AND-FILTER determines, if
+the last sorter and filter (from `View-process-actual-sorter-and-filter')
+are used."
+  (insert (or remote-host (system-name) "") 
+	  ;;(getenv "HOST") (getenv "HOSTNAME") "")
+	  ", "
+	  (current-time-string)
+	  ", "
+	  View-process-status-command 
+	  " " 
+	  command-switches
+	  "\n")
+  (View-process-insert-uptime remote-host)
+  (View-process-insert-short-key-descriptions)
+  (if (or (and use-last-sorter-and-filter
+	       View-process-actual-sorter-and-filter)
+	  View-process-sorter-and-filter)
+      (insert 
+       "This output is filtered! Look at `View-process-sorter-and-filter'.\n"))
+  (newline 1)
+  (setq View-process-ps-header-window-size
+	(+ View-process-ps-header-window-offset
+	   (count-lines (point-min) (point))
+	   (if (and (View-process-xemacs-p)
+		    (not (View-process-lemacs-p))
+		    View-process-header-mode-line-off)
+	       -1
+	     0))))
+
+(defun View-process-search-header-line-1 (header-dectection-list
+					  no-error-message)
+  "Internal funtion of `View-process-search-header-line'."
+  (cond (header-dectection-list
+	 (goto-char View-process-header-start)
+	 (if (search-forward (car header-dectection-list) nil t)
+	     (setq View-process-header-start 
+		   (View-process-return-beginning-of-line))
+	   (View-process-search-header-line-1 (cdr header-dectection-list)
+					      no-error-message)))
+	(t (setq mode-motion-hook nil) ; otherwise emacs hangs
+	   (if no-error-message
+	       nil
+	     (error (concat "ERROR: No header line detected! "
+			    "Look at View-process-header-line-detection-list!")
+		  )))))
+	     
+
+(defun View-process-search-header-line (&optional no-error-message)
+  "Function searches the headerline and sets `View-process-header-start'.
+The header line must have at least one of the words of the list
+`View-process-header-line-detection-list'.
+If NO-ERROR-MESSAGE is t and no header-line is found, then only 
+nil (without an error message) will be returned."
+  (save-excursion
+     (View-process-search-header-line-1 View-process-header-line-detection-list
+					no-error-message)
+    ))
+
+(defun View-process-save-position ()
+  "Saves the current line and column in a cons cell and returns it."
+  (save-restriction
+    (widen)
+    (if (< View-process-header-start (point-max))
+      (cons (- (count-lines (or View-process-header-start (point-min))
+			    (point))
+	       (if (= 0 (current-column))
+		   0
+		 1))
+	    (current-column))
+      nil)))
+
+(defun View-process-goto-position (position)
+  "Sets the point to the POSITION.
+POSITION is a cons cell with a linenumber and a column."
+  (if position
+      (save-restriction
+	(widen)
+	(goto-char View-process-header-start)
+	(forward-line (car position))
+	(move-to-column (cdr position) t)
+;	(setq temporary-goal-column (cdr position)) ; doesn't work :-(
+	)))
+
+;;;###autoload
+(defun View-process-status (command-switches 
+			    &optional remote-host
+			    use-last-sorter-and-filter)
+  "Prints a list with processes in the buffer `View-process-buffer-name'.
+COMMAND-SWITCHES is a string with the command switches (ie: -aux).
+IF the optional argument REMOTE-HOST is given, then the command will
+be executed on the REMOTE-HOST. If an prefix arg is given, then the 
+function asks for the name of the remote host.
+If USE-LAST-SORTER-AND-FILTER is t, then the last sorter and filter 
+commands are used. Otherwise the sorter and filter from the list
+'View-process-sorter-and-filter' are used."
+  (interactive 
+   (let ((View-process-stop-motion-help t))
+     (list 
+      (read-string "Command switches: "
+		   (or View-process-status-last-command-switches
+		       (if (bufferp (get-buffer View-process-buffer-name))
+			   (cdr 
+			    (assoc 
+			     'View-process-status-last-command-switches
+			     (buffer-local-variables 
+			      (get-buffer View-process-buffer-name)))))
+		       (if (string= "bsd" (View-process-bsd-or-system-v))
+			   View-process-status-command-switches-bsd
+			 View-process-status-command-switches-system-v))
+		   'View-process-status-history)
+      (if current-prefix-arg 
+	  (setq View-process-remote-host 
+		(read-string "Remote host name: "
+			     View-process-remote-host
+			     'View-process-remote-host-history))
+	(setq View-process-remote-host nil)))))
+  (View-process-save-old-window-configuration)
+  (let ((buffer (get-buffer-create View-process-buffer-name))
+	(position nil))
+;	(point-after-ps nil))
+    (if (window-minibuffer-p (selected-window))
+	(set-buffer buffer)
+      (switch-to-buffer buffer))
+
+    ;; set switches for the next view process command
+    (setq View-process-status-last-command-switches command-switches)
+    (if (string= "bsd" (View-process-bsd-or-system-v))
+	(setq View-process-status-command-switches-bsd command-switches)
+      (setq View-process-status-command-switches-system-v command-switches))
+
+    (setq buffer-read-only nil)
+    (if (not (= (point-min) (point-max)))
+	(progn
+	  (setq position (View-process-save-position))
+;	(setq point-after-ps (point-min))
+;      (setq point-after-ps (point))
+	  (erase-buffer)))
+    (View-process-insert-title-lines command-switches 
+				     remote-host
+				     use-last-sorter-and-filter)
+    (setq View-process-header-start (point))
+    (if remote-host
+	(call-process View-process-rsh-command
+		      nil
+		      t
+		      t
+		      remote-host
+		      (concat View-process-status-command 
+			      " " 
+			      command-switches))
+      (call-process View-process-status-command 
+		    nil 
+		    t 
+		    t 
+		    command-switches))
+    (View-process-search-header-line)
+    (setq View-process-output-end (point-max))
+    (View-process-replace-colons-with-blanks)
+    (View-process-insert-blanks-at-line-start)
+    (View-process-split-merged-fields View-process-insert-blank-alist)
+    (View-process-init-internal-variables use-last-sorter-and-filter)
+    (View-process-highlight-header-line)
+    (goto-char View-process-output-start)
+    (View-process-goto-position position) 
+;    (goto-char (cond ((> point-after-ps (point-max)) (point-max))
+;		     ((= point-after-ps (point-min)) View-process-output-start)
+;		     ((< point-after-ps View-process-output-start)
+;		      View-process-output-start)
+;		     (t point-after-ps)))
+    (setq buffer-read-only t)
+    (let ((View-process-stop-motion-help t))
+;    (setq View-process-stop-motion-help t)
+      (View-process-mode)
+;    (setq View-process-stop-motion-help nil)
+;      (View-process-redraw) ; only the first time (fixes an Emacs 19 bug)
+      )
+    ))
+
+(defun View-process-status-update ()
+  "Runs the `View-process-status' with the last switches
+and sorter and filter commands."
+  (interactive)
+  (if View-process-status-last-command-switches
+      (View-process-status View-process-status-last-command-switches
+			   View-process-remote-host
+			   t)
+    (error "ERROR: No view process buffer exists for update!")))
+
+(defun view-processes (&optional remote-host)
+  "Prints a list with processes in the buffer `View-process-buffer-name'.
+It calls the function `View-process-status' with default switches.
+As the default switches on BSD like systems the value of the variable
+`View-process-status-command-switches-bsd' is used. 
+On System V like systems the value of the variable
+`View-process-status-command-switches-system-v' is used.
+IF the optional argument REMOTE-HOST is given, then the command will
+be executed on the REMOTE-HOST. If an prefix arg is given, then the 
+function asks for the name of the remote host."
+  (interactive 
+   (let ((View-process-stop-motion-help t))
+     (list (if current-prefix-arg 
+	       (setq View-process-remote-host 
+		     (read-string "Remote host name: "
+				  View-process-remote-host
+				  'View-process-remote-host-history))
+	     (setq View-process-remote-host nil)))))
+  (if (string= "bsd" (nth 2 (View-process-get-system-type)))
+      (View-process-status View-process-status-command-switches-bsd
+			   View-process-remote-host)
+    (View-process-status View-process-status-command-switches-system-v
+			 remote-host)))
+
+;;; itimer functions (to repeat the ps output)
+
+(defun View-process-status-itimer-function ()
+  "Itimer function for updating the ps output."
+  (save-excursion
+    (save-window-excursion
+      (View-process-status-update)))
+  ;;(View-process-start-itimer)
+  )
+
+
+;;; help functions
+
+(defun View-process-show-pid-and-command-or-field-name ()
+  "Displays the pid and the command of the current line or the field name.
+If the point is at a blank, then the pid and the command of the current
+line are displayed. Otherwise the name of the field and its description
+are displayed."
+  (interactive)
+  (if (looking-at " ")
+      (View-process-show-pid-and-command)
+    (View-process-which-field-name)))
+
+(defun View-process-show-pid-and-command ()
+  "Displays the pid and the command of the current line.
+It assumes, that the command is displayed at the end of the line."
+  (interactive)
+  (if (>= (point) View-process-output-start)
+      (message "PID= %s, %s"
+	       (View-process-get-pid-from-current-line)
+	       (View-process-get-field-value-from-current-line 
+		View-process-max-fields
+		View-process-max-fields))))
+
+(defun View-process-show-field-names ()
+  "Displays the name(s) of the ps output field(s).
+If the point is at a blank, then the header line with all field names
+is displayed. Otherwise only the name of the field at the point is 
+displayed."
+  (interactive)
+  (if (looking-at " ")
+      (View-process-show-header-line)
+    (View-process-which-field-name)))
+
+(defun View-process-show-header-line ()
+  "Displays the header line in the buffer at the current line."
+  (interactive)
+  (save-window-excursion
+    (let ((header-line (save-restriction
+			 (widen)
+			 (concat
+				 (buffer-substring View-process-header-start
+						   View-process-header-end)
+				 "\n"))))
+      (momentary-string-display header-line
+				(View-process-return-beginning-of-line)))))
+
+(defun View-process-which-field-name ()
+  "Displays the name of the field under the point in the echo area."
+  (interactive)
+  (if (>= (point) View-process-header-start)
+      (let ((field-name (View-process-translate-field-position-to-name
+			 (View-process-current-field-number))))
+	(message 
+	 (View-process-replace-in-string 
+	  "%" 
+	  "%%" 
+	  (concat field-name
+		  ": "
+		  (View-process-get-field-name-description field-name)))))))
+
+(defun View-process-get-field-name-description (field-name)
+  "Returns a string with a desciption of the ps output field FIELD-NAME."
+  (let ((description 
+	 (or (car (cdr (assoc field-name
+			      View-process-field-name-descriptions)))
+	     (car (cdr (assoc field-name 
+			      View-process-field-name-descriptions-general))))
+	 ))
+    (if (stringp description)
+	description
+      (concat (car description)
+	      (View-process-get-value-description 
+	       (View-process-get-field-value-from-current-line
+		(View-process-translate-field-name-to-position field-name)
+		View-process-max-fields)
+	       (cdr description))))))
+
+(defun View-process-get-value-description (values value-descriptions)
+  "Returns a string with the description of the VALUES.
+VALUE-DESCRIPTIONS is an alist with the possible values and its
+descriptions."
+  (cond ((string= values "") "")
+	((or (eq (aref values 0) ?_) (eq (aref values 0) ? ))
+	 (View-process-get-value-description (substring values 1)
+					     value-descriptions))
+	(t (concat
+	    (car 
+	     (cdr 
+	      (assoc 
+	       (substring values 0 (string-match "[ _]" values))
+	       value-descriptions)))
+	    (if (string-match "[ _]" values)
+		(View-process-get-value-description
+		 (substring values (string-match "[ _]" values))
+		 value-descriptions)
+	      "")))))
+
+
+;;; sort functions
+
+(defun View-process-current-field-number ()
+  "Returns the field number of the point. 
+The functions fails with an error message, if the character under
+the point is a blank."
+  (View-process-replaces-blanks-in-fields-if-necessary)
+  (save-excursion
+    (if (looking-at " ")
+	(error "Point is on a blank and not in a field!")
+      (if (and (eq (point) (point-max))
+	       (eq (current-column) 0))
+	  (error "Point is not in a field!")
+	(let ((field-point (point))
+	      (i 0))
+	  (beginning-of-line)
+	  (skip-chars-forward " ")
+	  (while (>= field-point (point))
+	    (setq i (1+ i))
+	    (skip-chars-forward "^ ")
+	    (skip-chars-forward " "))
+	  i)))))
+	
+(defun View-process-sort-fields-in-region (field 
+					   beg 
+					   end 
+					   &optional sort-function)
+  "Sort lines in region by the ARGth field of each line.
+Fields are separated by whitespace and numbered from 1 up.
+With a negative arg, sorts by the ARGth field counted from the right.
+BEG and END specify region to sort.
+If the optional SORT-FUNCTION is nil, then the region is at first
+sorted with the function `sort-fields' and then with the function
+`sort-float-fields'. Otherwise a sort function like `sort-fields'
+must be specified."
+  (let ((position (View-process-save-position))
+;	(point (point))               ;; that's, because save-excursion
+;	(column (current-column))     ;; doesn't work :-(
+	(field-no (if (< field View-process-max-fields)
+		      field
+		    View-process-max-fields)))
+    (if sort-function
+	(eval (list sort-function field-no beg end))
+      (sort-fields field-no beg end)
+      (sort-float-fields field-no beg end))
+    (View-process-goto-position position)))
+;    (goto-char point)
+;    (goto-char (+ point (- column (current-column))))))
+
+(defun View-process-remove-sorter (sorter alist)
+  "Removes the SORTER entry from the ALIST."
+  (cond ((not alist) nil)
+	((eq sorter (car (car alist))) (cdr alist))
+	(t (cons (car alist) 
+		 (View-process-remove-sorter sorter (cdr alist))))))
+
+(defun View-process-sort-output-by-field (field-name
+					  &optional dont-remember)
+  "Sort the ps output by the field FIELD-NAME.
+If DONT-REMEMBER is t, then the filter command isn't inserted 
+in the `View-process-actual-sorter-and-filter' list."
+  (interactive 
+   (let ((View-process-stop-motion-help t))
+     (list
+      (completing-read "Field Name for sorting: "
+		       View-process-field-names
+		       nil
+		       t
+		       (car View-process-field-name-history)
+		       View-process-field-name-history))))
+  (setq buffer-read-only nil)
+  (View-process-sort-fields-in-region
+   (View-process-translate-field-name-to-position field-name)
+   View-process-output-start
+   View-process-output-end)
+  (setq buffer-read-only t)
+  (if (not dont-remember)
+      (setq View-process-actual-sorter-and-filter
+	    (append (View-process-remove-sorter
+		     'reverse
+		     (View-process-remove-sorter 
+		      'sort
+		      View-process-actual-sorter-and-filter))
+		    (list (list 'sort field-name))))))
+
+(defun View-process-sort-by-current-field-g ()
+  "Sort the ps output by the field under the point.
+It is a generic interface to `View-process-sort-region-by-current-field'
+and `View-process-sort-output-by-current-field'.The first will be called
+if a region is active and the other one if not.
+With a prefix arg, it uses the NTH field instead of the current one."
+  (interactive)
+  (if (View-process-region-active-p)
+      (call-interactively 'View-process-sort-region-by-current-field)
+    (call-interactively 'View-process-sort-output-by-current-field)))
+
+(defun View-process-sort-output-by-current-field (&optional nth dont-remember)
+  "Sort the whole ps output by the field under the point.
+With a prefix arg, it uses the NTH field instead of the current one.
+If DONT-REMEMBER is t, then the filter command isn't inserted 
+in the `View-process-actual-sorter-and-filter' list."
+  (interactive "P")
+  (let ((field-number (if nth
+			  (if (and (>= nth 1) (<= nth View-process-max-fields))
+			      nth
+			    (error "ERROR: Wrong field number!"))
+			(View-process-current-field-number))))
+    (setq buffer-read-only nil)
+    (View-process-sort-fields-in-region field-number
+					View-process-output-start
+					View-process-output-end)
+    (setq buffer-read-only t)
+    (if (not dont-remember)
+	(setq View-process-actual-sorter-and-filter
+	      (append (View-process-remove-sorter
+		       'reverse
+		       (View-process-remove-sorter 
+			'sort
+			View-process-actual-sorter-and-filter))
+		      (list 
+		       (list 'sort 
+			     (View-process-translate-field-position-to-name
+			      field-number))))))))
+
+(defun View-process-sort-region-by-current-field (&optional nth)
+  "Sort the region by the field under the point.
+With a prefix arg, it uses the NTH field instead of the current one."
+  (interactive "P")
+  (let ((field-number (if nth
+			  (if (and (>= nth 1) (<= nth View-process-max-fields))
+			      nth
+			    (error "ERROR: Wrong field number!"))
+			(View-process-current-field-number))))
+    (setq buffer-read-only nil)
+    (View-process-sort-fields-in-region 
+     field-number
+     (save-excursion
+       (goto-char (region-beginning))
+       (View-process-return-beginning-of-line))
+     (save-excursion
+       (goto-char (region-end))
+       (View-process-return-end-of-line)))
+    (setq buffer-read-only t)))
+
+(defun View-process-reverse-output (&optional dont-remember)
+  "Reverses the whole output lines.
+If DONT-REMEMBER is t, then the filter command isn't inserted 
+in the `View-process-actual-sorter-and-filter' list."
+  (interactive)
+  (setq buffer-read-only nil)
+  (let ((position (View-process-save-position)))
+;	(line (count-lines (point-min) (point)))
+;	(column (current-column)))
+    (reverse-region View-process-output-start View-process-output-end)
+    (View-process-goto-position position))
+;    (goto-line line)
+;    (beginning-of-line)
+;    (forward-char column))
+  (setq buffer-read-only t)
+  (if (not dont-remember)
+      (setq View-process-actual-sorter-and-filter
+	    (if (assq 'reverse View-process-actual-sorter-and-filter)
+		(View-process-remove-sorter 
+		 'reverse
+		 View-process-actual-sorter-and-filter)
+	      (append View-process-actual-sorter-and-filter
+		      (list (list 'reverse)))))))
+
+(defun View-process-reverse-region ()
+  "Reverses the output lines in the region."
+  (interactive)
+  (setq buffer-read-only nil)
+  (let ((region-beginning (if (< (region-beginning) (region-end))
+			      (region-beginning)
+			    (region-end)))
+	(region-end (if (> (region-end) (region-beginning))
+			(region-end)
+		      (region-beginning)))
+	(position (View-process-save-position)))
+;	(line (count-lines (point-min) (point)))
+;	(column (current-column)))
+    (reverse-region (if (< region-beginning View-process-output-start)
+			View-process-output-start
+		      (goto-char region-beginning)
+		      (View-process-return-beginning-of-line))
+		    (if (> region-end View-process-output-end)
+			View-process-output-end
+		      (goto-char region-end)
+		      (View-process-return-end-of-line)))
+    (View-process-goto-position position))
+;    (goto-line line)
+;    (beginning-of-line)
+;    (forward-char column))
+  (setq buffer-read-only t))
+
+(defun View-process-reverse-g ()
+  "Reverses the output lines.
+It is a generic interface to `View-process-reverse-region'
+and `View-process-reverse-output'. The first will be called
+if a region is active and the other one if not."
+  (interactive)
+  (if (View-process-region-active-p)
+      (call-interactively 'View-process-reverse-region)
+    (call-interactively 'View-process-reverse-output)))
+
+;;; filter functions
+
+(defun View-process-delete-region (start end)
+  "Stores deleted lines in `View-process-deleted-lines'."
+  (setq View-process-deleted-lines
+	(cons (buffer-substring start end)
+	      View-process-deleted-lines))
+  (delete-region start end))
+
+(defun View-process-remove-all-filter-and-sorter ()
+  "Undeletes all filtered lines from `View-process-deleted-lines'.
+It removes also all filter and sorter from the list
+`View-process-actual-sorter-and-filter'."
+  (interactive)
+  (let ((buffer-read-only))
+    (goto-char View-process-output-end)
+    (mapcar '(lambda (line)
+	       (insert line))
+	    View-process-deleted-lines)
+    (setq View-process-output-end (point))
+    (setq View-process-actual-sorter-and-filter nil)
+    (goto-char View-process-output-start)))
+
+(defun View-process-filter-fields-in-region (regexp 
+					     field-no 
+					     beg 
+					     end
+					     &optional exclude)
+  "Filters a region with a REGEXP in the field FIELD-NO.
+The region start is at BEG and the end at END. If FIELD-NO
+is nil, then the whole line is used. All lines which passes
+not the filter are deleted in the buffer, if EXCLUDE is nil.
+Otherwise only these lines are not deleted."
+  (save-restriction
+    (widen)
+    (let ((region-start (if (< beg end) beg end))
+	  (region-end (if (> beg end) beg end)))
+      (if (< region-start View-process-output-start)
+	  (setq region-start View-process-output-start))
+      (goto-char region-end)
+      (if field-no
+	  (while (>= (point) region-start)
+	    (if (string-match regexp 
+			      (View-process-get-field-value-from-current-line
+			       field-no
+			       View-process-max-fields))
+		(if exclude
+		    (View-process-delete-region 
+		     (1- (View-process-return-beginning-of-line))
+		     (View-process-return-end-of-line))
+		  (forward-line -1))
+	      (if exclude
+		  (forward-line -1)
+		(View-process-delete-region 
+		 (1- (View-process-return-beginning-of-line))
+		 (View-process-return-end-of-line)))
+	      ))
+	(beginning-of-line)
+	(while (>= (point) region-start)
+	  (if (search-forward-regexp regexp 
+				     (View-process-return-end-of-line) t)
+	      (if exclude
+		  (progn
+		    (View-process-delete-region 
+		     (1- (View-process-return-beginning-of-line))
+		     (View-process-return-end-of-line))
+		    (beginning-of-line))
+		(forward-line -1))
+	    (if exclude
+		(forward-line -1)
+	      (View-process-delete-region 
+	       (1- (View-process-return-beginning-of-line))
+	       (View-process-return-end-of-line))
+	      (beginning-of-line))
+	    )))
+      (goto-char region-start))
+    (setq View-process-output-end (point-max))
+    (if (> View-process-output-start View-process-output-end)
+	(progn
+	  (newline)
+	  (setq View-process-output-end View-process-output-start)))))
+
+(defun View-process-filter-output-by-field (field-name 
+					    regexp 
+					    &optional exclude
+					    dont-remember)
+  "Filter the whole output by the field FIELD-NAME with REGEXP.
+The matching lines are deleted, if EXCLUDE is t. The non matching
+lines are deleted, if EXCLUDE is nil. If you call this function
+interactive, then you can give a prefix arg to set EXCLUDE to non nil.
+If DONT-REMEMBER is t, then the filter command isn't inserted 
+in the `View-process-actual-sorter-and-filter' list."
+  (interactive 
+   (let ((View-process-stop-motion-help t))
+     (list
+      (completing-read "Field Name for filtering: "
+		       View-process-field-names
+		       nil
+		       t
+		       (car View-process-field-name-history)
+		       View-process-field-name-history)
+      (read-string "Regexp for filtering the output in the field: "
+		   (car View-process-filter-history)
+		   View-process-filter-history)
+      current-prefix-arg
+      )))
+  (setq buffer-read-only nil)
+  (View-process-filter-fields-in-region 
+   regexp
+   (View-process-translate-field-name-to-position field-name)
+   View-process-output-start
+   View-process-output-end
+   exclude)
+  (setq buffer-read-only t)
+  (if (not dont-remember)
+      (setq View-process-actual-sorter-and-filter
+	    (append View-process-actual-sorter-and-filter
+		    (list (list (if exclude 'exclude-filter 'filter)
+				field-name
+				regexp))))))
+
+(defun View-process-filter-output-by-current-field (regexp 
+						    &optional exclude
+						    dont-remember)
+  "Filter the whole output by the field under the point with REGEXP.
+The matching lines are deleted, if EXCLUDE is t. The non matching
+lines are deleted, if EXCLUDE is nil. If you call this function
+interactive, then you can give a prefix arg to set EXCLUDE to non nil.
+If DONT-REMEMBER is t, then the filter command isn't inserted 
+in the `View-process-actual-sorter-and-filte