annotate lisp/proced.el @ 97206:03666fbbecf2

(EmacsApp -application:openFiles:): GNUStep does not define NSApplicationDelegateReplySuccess. (EmacsView -converstationIdentifier): Use long instead of NSInteger for GNUStep, since it doesn't have NSInteger.
author Chong Yidong <cyd@stupidchicken.com>
date Fri, 01 Aug 2008 16:07:49 +0000
parents 9ebcc98e40f8
children 5cd3eb14e72e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
1 ;;; proced.el --- operate on system processes like dired
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
2
93213
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
3 ;; Copyright (C) 2008 Free Software Foundation, Inc.
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
4
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
5 ;; Author: Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
6 ;; Keywords: Processes, Unix
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
7
93213
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
8 ;; This file is part of GNU Emacs.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
9
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94621
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
93213
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94621
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94621
diff changeset
13 ;; (at your option) any later version.
93213
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
14
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f51aae2fc6a4 Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93212
diff changeset
18 ;; GNU General Public License for more details.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
19
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
94678
ee5932bf781d Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 94621
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
22
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
23 ;;; Commentary:
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
24
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
25 ;; Proced makes an Emacs buffer containing a listing of the current system
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
26 ;; processes (using ps(1)). You can use the normal Emacs commands
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
27 ;; to move around in this buffer, and special Proced commands to operate
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
28 ;; on the processes listed.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
29 ;;
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
30 ;; To do:
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
31 ;; - decompose ps(1) output into columns (for `proced-header-alist')
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
32 ;; How can we identify columns that may contain whitespace
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
33 ;; and that can be either right or left justified?
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
34 ;; Use a "grammar table"?
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
35 ;; - sort the "cooked" values used in the output format fields
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
36 ;; if ps(1) doesn't support the requested sorting scheme
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
37 ;; - filter by user name or other criteria
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
38 ;; - automatic update of process list
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
39
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
40 ;;; Code:
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
41
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
42 (defgroup proced nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
43 "Proced mode."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
44 :group 'processes
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
45 :group 'unix
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
46 :prefix "proced-")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
47
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
48 ;; FIXME: a better approach instead of PID-COLUMN would be based
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
49 ;; on `proced-header-alist' once we have a reliable scheme to set this variable
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
50 (defcustom proced-command-alist
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
51 (cond ((memq system-type '(berkeley-unix))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
52 '(("user" ("ps" "-uxgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
53 ("user-running" ("ps" "-uxrgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
54 ("all" ("ps" "-auxgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
55 ("all-running" ("ps" "-auxrgww") 2)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
56 ((memq system-type '(gnu gnu/linux)) ; BSD syntax
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
57 `(("user" ("ps" "uxwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
58 ("user-running" ("ps" "uxrwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
59 ("all" ("ps" "auxwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
60 ("all-running" ("ps" "auxrwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
61 ("emacs" ("ps" "--pid" ,(number-to-string (emacs-pid))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
62 "--ppid" ,(number-to-string (emacs-pid))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
63 "uwww") 2)))
94109
6457a4cc8690 (proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94108
diff changeset
64 ((memq system-type '(darwin))
6457a4cc8690 (proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94108
diff changeset
65 `(("user" ("ps" "-u" ,(number-to-string (user-uid))) 2)
6457a4cc8690 (proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94108
diff changeset
66 ("all" ("ps" "-Au") 2)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
67 (t ; standard UNIX syntax; doesn't allow to list running processes only
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
68 `(("user" ("ps" "-fu" ,(number-to-string (user-uid))) 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
69 ("all" ("ps" "-ef") 2))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
70 "Alist of commands to get list of processes.
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
71 Each element has the form (NAME COMMAND PID-COLUMN).
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
72 NAME is a shorthand name to select the type of listing.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
73 COMMAND is a list (COMMAND-NAME ARG1 ARG2 ...),
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
74 where COMMAND-NAME is the command to generate the listing (usually \"ps\").
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
75 ARG1, ARG2, ... are arguments passed to COMMAND-NAME to generate
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
76 a particular listing. These arguments differ under various operating systems.
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
77 PID-COLUMN is the column number (starting from 1) of the process ID."
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
78 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
79 :type '(repeat (group (string :tag "name")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
80 (cons (string :tag "command")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
81 (repeat (string :tag "option")))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
82 (integer :tag "PID column"))))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
83
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
84 (defcustom proced-command (if (zerop (user-real-uid)) "all" "user")
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
85 "Name of process listing.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
86 Must be the car of an element of `proced-command-alist'."
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
87 :group 'proced
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
88 :type '(string :tag "name"))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
89 (make-variable-buffer-local 'proced-command)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
90
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
91 ;; Should we incorporate in NAME that sorting can be done in ascending
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
92 ;; or descending order? Then we couldn't associate NAME anymore with one
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
93 ;; of the headers in the output of ps(1).
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
94 ;; FIXME: A sorting scheme without options or with an option being a symbol
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
95 ;; should be implemented in elisp
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
96 (defcustom proced-sorting-schemes-alist
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
97 (cond ((memq system-type '(gnu gnu/linux)) ; GNU long options
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
98 '(("%CPU" "--sort" "-pcpu") ; descending order
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
99 ("%MEM" "--sort" "-pmem") ; descending order
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
100 ("COMMAND" "--sort" "args")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
101 ("PID" "--sort" "pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
102 ("PGID,PID" "--sort" "pgid,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
103 ("PPID,PID" "--sort" "ppid,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
104 ("RSS" "--sort" "rss,pid") ; equal RSS's are rare
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
105 ("STAT,PID" "--sort" "stat,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
106 ("START" "--sort" "start_time")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
107 ("TIME" "--sort" "cputime")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
108 ("TTY,PID" "--sort" "tty,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
109 ("UID,PID" "--sort" "uid,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
110 ("USER,PID" "--sort" "user,pid")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
111 ("VSZ,PID" "--sort" "vsz,pid"))))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
112 "Alist of sorting schemes.
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
113 Each element is a list (NAME OPTION1 OPTION2 ...).
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
114 NAME denotes the sorting scheme. It is the name of a header or a
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
115 comma-separated sequence of headers in the output of ps(1).
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
116 OPTION1, OPTION2, ... are options defining the sorting scheme."
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
117 :group 'proced
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
118 :type '(repeat (cons (string :tag "name")
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
119 (repeat (string :tag "option")))))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
120
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
121 (defcustom proced-sorting-scheme nil
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
122 "Proced sorting type.
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
123 Must be the car of an element of `proced-sorting-schemes-alist' or nil."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
124 :group 'proced
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
125 :type `(choice ,@(append '((const nil)) ; sorting type may be nil
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
126 (mapcar (lambda (item)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
127 (list 'const (car item)))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
128 proced-sorting-schemes-alist))))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
129 (make-variable-buffer-local 'proced-sorting-scheme)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
130
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
131 (defcustom proced-goal-header-re "\\b\\(CMD\\|COMMAND\\)\\b"
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
132 "If non-nil, regexp that defines the `proced-goal-column'."
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
133 :group 'proced
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
134 :type '(choice (const :tag "none" nil)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
135 (regexp :tag "regexp")))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
136
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
137 (defcustom proced-signal-function 'signal-process
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
138 "Name of signal function.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
139 It can be an elisp function (usually `signal-process') or a string specifying
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
140 the external command (usually \"kill\")."
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
141 :group 'proced
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
142 :type '(choice (function :tag "function")
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
143 (string :tag "command")))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
144
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
145 (defcustom proced-signal-list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
146 '(("HUP (1. Hangup)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
147 ("INT (2. Terminal interrupt)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
148 ("QUIT (3. Terminal quit)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
149 ("ABRT (6. Process abort)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
150 ("KILL (9. Kill -- cannot be caught or ignored)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
151 ("ALRM (14. Alarm Clock)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
152 ("TERM (15. Termination)"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
153 "List of signals, used for minibuffer completion."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
154 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
155 :type '(repeat (string :tag "signal")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
156
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
157 ;; Internal variables
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
158 (defvar proced-marker-char ?* ; the answer is 42
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
159 "In proced, the current mark character.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
160
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
161 ;; face and font-lock code taken from dired
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
162 (defgroup proced-faces nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
163 "Faces used by Proced."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
164 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
165 :group 'faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
166
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
167 (defface proced-mark
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
168 '((t (:inherit font-lock-constant-face)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
169 "Face used for proced marks."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
170 :group 'proced-faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
171 (defvar proced-mark-face 'proced-mark
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
172 "Face name used for proced marks.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
173
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
174 (defface proced-marked
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
175 '((t (:inherit font-lock-warning-face)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
176 "Face used for marked processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
177 :group 'proced-faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
178 (defvar proced-marked-face 'proced-marked
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
179 "Face name used for marked processes.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
180
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
181 (defvar proced-re-mark "^[^ \n]"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
182 "Regexp matching a marked line.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
183 Important: the match ends just after the marker.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
184
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
185 (defvar proced-goal-column nil
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
186 "Proced goal column. Initialized based on `proced-goal-header-re'.")
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
187 (make-variable-buffer-local 'proced-goal-column)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
188
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
189 (defvar proced-font-lock-keywords
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
190 (list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
191 ;;
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
192 ;; Proced marks.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
193 (list proced-re-mark '(0 proced-mark-face))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
194 ;;
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
195 ;; Marked files.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
196 (list (concat "^[" (char-to-string proced-marker-char) "]")
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
197 '(".+" (proced-move-to-goal-column) nil (0 proced-marked-face)))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
198
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
199 (defvar proced-mode-map
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
200 (let ((km (make-sparse-keymap)))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
201 ;; moving
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
202 (define-key km " " 'proced-next-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
203 (define-key km "n" 'proced-next-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
204 (define-key km "p" 'proced-previous-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
205 (define-key km "\C-n" 'proced-next-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
206 (define-key km "\C-p" 'proced-previous-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
207 (define-key km "\C-?" 'proced-previous-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
208 (define-key km [down] 'proced-next-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
209 (define-key km [up] 'proced-previous-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
210 ;; marking
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
211 (define-key km "d" 'proced-mark) ; Dired compatibility
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
212 (define-key km "m" 'proced-mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
213 (define-key km "u" 'proced-unmark)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
214 (define-key km "\177" 'proced-unmark-backward)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
215 (define-key km "M" 'proced-mark-all)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
216 (define-key km "U" 'proced-unmark-all)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
217 (define-key km "t" 'proced-toggle-marks)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
218 ;; sorting
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
219 (define-key km "sc" 'proced-sort-pcpu)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
220 (define-key km "sm" 'proced-sort-pmem)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
221 (define-key km "sp" 'proced-sort-pid)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
222 (define-key km "ss" 'proced-sort-start)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
223 (define-key km "sS" 'proced-sort)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
224 (define-key km "st" 'proced-sort-time)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
225 ;; operate
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
226 (define-key km "h" 'proced-hide-processes)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
227 (define-key km "x" 'proced-send-signal) ; Dired compatibility
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
228 (define-key km "k" 'proced-send-signal) ; kill processes
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
229 ;; misc
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
230 (define-key km "l" 'proced-listing-type)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
231 (define-key km "g" 'revert-buffer) ; Dired compatibility
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
232 (define-key km "h" 'describe-mode)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
233 (define-key km "?" 'proced-help)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
234 (define-key km "q" 'quit-window)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
235 (define-key km [remap undo] 'proced-undo)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
236 (define-key km [remap advertised-undo] 'proced-undo)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
237 km)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
238 "Keymap for proced commands")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
239
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
240 (easy-menu-define
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
241 proced-menu proced-mode-map "Proced Menu"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
242 '("Proced"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
243 ["Mark" proced-mark t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
244 ["Unmark" proced-unmark t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
245 ["Mark All" proced-mark-all t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
246 ["Unmark All" proced-unmark-all t]
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
247 ["Toggle Marks" proced-unmark-all t]
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
248 "--"
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
249 ["Sort" proced-sort t]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
250 ["Sort by %CPU" proced-sort-pcpu (proced-sorting-scheme-p "%CPU")]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
251 ["Sort by %MEM" proced-sort-pmem (proced-sorting-scheme-p "%MEM")]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
252 ["Sort by PID" proced-sort-pid (proced-sorting-scheme-p "PID")]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
253 ["Sort by START" proced-sort-start (proced-sorting-scheme-p "START")]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
254 ["Sort by TIME" proced-sort-time (proced-sorting-scheme-p "TIME")]
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
255 "--"
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
256 ["Hide Marked Processes" proced-hide-processes t]
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
257 "--"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
258 ["Revert" revert-buffer t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
259 ["Send signal" proced-send-signal t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
260 ["Change listing" proced-listing-type t]))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
261
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
262 (defconst proced-help-string
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
263 "(n)ext, (p)revious, (m)ark, (u)nmark, (k)ill, (q)uit (type ? for more help)"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
264 "Help string for proced.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
265
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
266 (defvar proced-header-line nil
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
267 "Headers in Proced buffer as a string.")
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
268 (make-variable-buffer-local 'proced-header-line)
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
269
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
270 (defvar proced-header-alist nil
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
271 "Alist of headers in Proced buffer.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
272 Each element is of the form (NAME START END JUSTIFY).
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
273 NAME is name of header in the output of ps(1).
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
274 START and END are column numbers starting from 0.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
275 END is t if there is no end column for that field.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
276 JUSTIFY is 'left or 'right for left or right-justified output of ps(1).")
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
277 (make-variable-buffer-local 'proced-header-alist)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
278
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
279 (defvar proced-sorting-schemes-re nil
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
280 "Regexp to match valid sorting schemes.")
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
281 (make-variable-buffer-local 'proced-sorting-schemes-re)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
282
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
283 ;; helper functions
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
284 (defun proced-marker-regexp ()
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
285 "Return regexp matching `proced-marker-char'."
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
286 ;; `proced-marker-char' must appear in column zero
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
287 (concat "^" (regexp-quote (char-to-string proced-marker-char))))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
288
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
289 (defun proced-success-message (action count)
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
290 "Display success message for ACTION performed for COUNT processes."
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
291 (message "%s %s process%s" action count (if (= 1 count) "" "es")))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
292
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
293 (defun proced-move-to-goal-column ()
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
294 "Move to `proced-goal-column' if non-nil."
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
295 (beginning-of-line)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
296 (if proced-goal-column
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
297 (forward-char proced-goal-column)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
298 (forward-char 2)))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
299
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
300 ;; FIXME: a better approach would be based on `proced-header-alist'
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
301 ;; once we have a reliable scheme to set this variable
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
302 (defsubst proced-skip-regexp ()
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
303 "Regexp to skip in process listing to find PID column."
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
304 (apply 'concat (make-list (1- (nth 2 (assoc proced-command
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
305 proced-command-alist)))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
306 "\\s-+\\S-+")))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
307
94108
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
308 (define-derived-mode proced-mode nil "Proced"
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
309 "Mode for displaying UNIX system processes and sending signals to them.
96824
9ebcc98e40f8 (proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents: 95300
diff changeset
310 Type \\<proced-mode-map>\\[proced-mark] to mark a process for later commands.
94108
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
311 Type \\[proced-send-signal] to send signals to marked processes.
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
312
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
313 \\{proced-mode-map}"
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
314 (abbrev-mode 0)
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
315 (auto-fill-mode 0)
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
316 (setq buffer-read-only t
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
317 truncate-lines t
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
318 header-line-format '(:eval (proced-header-line)))
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
319 (add-hook 'post-command-hook 'force-mode-line-update nil t)
94108
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
320 (set (make-local-variable 'revert-buffer-function) 'proced-revert)
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
321 (set (make-local-variable 'font-lock-defaults)
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
322 '(proced-font-lock-keywords t nil nil beginning-of-line)))
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
323
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
324 ;; Proced mode is suitable only for specially formatted data.
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
325 (put 'proced-mode 'mode-class 'special)
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
326
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
327 ;;;###autoload
7ab68bf3a905 (proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 94066
diff changeset
328 (defun proced (&optional arg)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
329 "Mode for displaying UNIX system processes and sending signals to them.
96824
9ebcc98e40f8 (proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents: 95300
diff changeset
330 Type \\<proced-mode-map>\\[proced-mark] to mark a process for later commands.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
331 Type \\[proced-send-signal] to send signals to marked processes.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
332
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
333 If invoked with optional ARG the window displaying the process
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
334 information will be displayed but not selected.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
335
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
336 \\{proced-mode-map}"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
337 (interactive "P")
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
338 (let ((buffer (get-buffer-create "*Proced*")) new)
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
339 (set-buffer buffer)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
340 (setq new (zerop (buffer-size)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
341 (if new (proced-mode))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
342
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
343 (if (or new arg)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
344 (proced-update))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
345
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
346 (if arg
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
347 (display-buffer buffer)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
348 (pop-to-buffer buffer)
96824
9ebcc98e40f8 (proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents: 95300
diff changeset
349 (message
9ebcc98e40f8 (proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents: 95300
diff changeset
350 (substitute-command-keys
9ebcc98e40f8 (proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents: 95300
diff changeset
351 "Type \\<proced-mode-map>\\[quit-window] to quit, \\[proced-help] for help")))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
352
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
353 (defun proced-next-line (arg)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
354 "Move down lines then position at `proced-goal-column'.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
355 Optional prefix ARG says how many lines to move; default is one line."
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
356 (interactive "p")
95300
cf89ac5d2869 (proced-next-line, proced-previous-line): Avoid calling `next-line'
John Paul Wallington <jpw@pobox.com>
parents: 95286
diff changeset
357 (forward-line arg)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
358 (proced-move-to-goal-column))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
359
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
360 (defun proced-previous-line (arg)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
361 "Move up lines then position at `proced-goal-column'.
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
362 Optional prefix ARG says how many lines to move; default is one line."
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
363 (interactive "p")
95300
cf89ac5d2869 (proced-next-line, proced-previous-line): Avoid calling `next-line'
John Paul Wallington <jpw@pobox.com>
parents: 95286
diff changeset
364 (forward-line (- arg))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
365 (proced-move-to-goal-column))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
366
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
367 (defun proced-mark (&optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
368 "Mark the current (or next COUNT) processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
369 (interactive "p")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
370 (proced-do-mark t count))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
371
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
372 (defun proced-unmark (&optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
373 "Unmark the current (or next COUNT) processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
374 (interactive "p")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
375 (proced-do-mark nil count))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
376
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
377 (defun proced-unmark-backward (&optional count)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
378 "Unmark the previous (or COUNT previous) processes."
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
379 ;; Analogous to `dired-unmark-backward',
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
380 ;; but `ibuffer-unmark-backward' behaves different.
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
381 (interactive "p")
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
382 (proced-do-mark nil (- (or count 1))))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
383
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
384 (defun proced-do-mark (mark &optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
385 "Mark the current (or next ARG) processes using MARK."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
386 (or count (setq count 1))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
387 (let ((backward (< count 0))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
388 buffer-read-only)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
389 (setq count (1+ (if (<= 0 count) count
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
390 (min (1- (line-number-at-pos)) (abs count)))))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
391 (beginning-of-line)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
392 (while (not (or (zerop (setq count (1- count))) (eobp)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
393 (proced-insert-mark mark backward))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
394 (proced-move-to-goal-column)))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
395
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
396 (defun proced-mark-all ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
397 "Mark all processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
398 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
399 (proced-do-mark-all t))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
400
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
401 (defun proced-unmark-all ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
402 "Unmark all processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
403 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
404 (proced-do-mark-all nil))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
405
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
406 (defun proced-do-mark-all (mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
407 "Mark all processes using MARK."
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
408 (let (buffer-read-only)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
409 (save-excursion
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
410 (goto-char (point-min))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
411 (while (not (eobp))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
412 (proced-insert-mark mark)))))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
413
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
414 (defun proced-toggle-marks ()
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
415 "Toggle marks: marked processes become unmarked, and vice versa."
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
416 (interactive)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
417 (let ((mark-re (proced-marker-regexp))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
418 buffer-read-only)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
419 (save-excursion
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
420 (goto-char (point-min))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
421 (while (not (eobp))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
422 (cond ((looking-at mark-re)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
423 (proced-insert-mark nil))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
424 ((looking-at " ")
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
425 (proced-insert-mark t))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
426 (t
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
427 (forward-line 1)))))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
428
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
429 (defun proced-insert-mark (mark &optional backward)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
430 "If MARK is non-nil, insert `proced-marker-char'.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
431 If BACKWARD is non-nil, move one line backwards before inserting the mark.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
432 Otherwise move one line forward after inserting the mark."
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
433 (if backward (forward-line -1))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
434 (insert (if mark proced-marker-char ?\s))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
435 (delete-char 1)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
436 (unless backward (forward-line)))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
437
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
438 ;; Mostly analog of `dired-do-kill-lines'.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
439 ;; However, for negative args the target lines of `dired-do-kill-lines'
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
440 ;; include the current line, whereas `dired-mark' for negative args operates
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
441 ;; on the preceding lines. Here we are consistent with `dired-mark'.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
442 (defun proced-hide-processes (&optional arg quiet)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
443 "Hide marked processes.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
444 With prefix ARG, hide that many lines starting with the current line.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
445 \(A negative argument hides backward.)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
446 If QUIET is non-nil suppress status message.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
447 Returns count of hidden lines."
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
448 (interactive "P")
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
449 (let ((mark-re (proced-marker-regexp))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
450 (count 0)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
451 buffer-read-only)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
452 (save-excursion
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
453 (if arg
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
454 ;; Hide ARG lines starting with the current line.
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
455 (delete-region (line-beginning-position)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
456 (save-excursion
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
457 (if (<= 0 arg)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
458 (setq count (- arg (forward-line arg)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
459 (setq count (min (1- (line-number-at-pos))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
460 (abs arg)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
461 (forward-line (- count)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
462 (point)))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
463 ;; Hide marked lines
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
464 (while (and (not (eobp))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
465 (re-search-forward mark-re nil t))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
466 (delete-region (match-beginning 0)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
467 (save-excursion (forward-line) (point)))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
468 (setq count (1+ count)))))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
469 (unless (zerop count) (proced-move-to-goal-column))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
470 (unless quiet (proced-success-message "Hid" count))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
471 count))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
472
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
473 (defun proced-listing-type (command)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
474 "Select `proced' listing type COMMAND from `proced-command-alist'."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
475 (interactive
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
476 (list (completing-read "Listing type: " proced-command-alist nil t)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
477 (setq proced-command command)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
478 (proced-update))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
479
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
480 ;; adopted from `ruler-mode-space'
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
481 (defsubst proced-header-space (width)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
482 "Return a single space string of WIDTH times the normal character width."
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
483 (propertize " " 'display (list 'space :width width)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
484
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
485 ;; header line: code inspired by `ruler-mode-ruler'
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
486 (defun proced-header-line ()
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
487 "Return header line for Proced buffer."
95286
3680efd5ada2 (proced-header-line): Use the :align-to 0 feature
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95168
diff changeset
488 (list (propertize " " 'display '(space :align-to 0))
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
489 (replace-regexp-in-string
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
490 "%" "%%" (substring proced-header-line (window-hscroll)))))
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
491
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
492 (defun proced-update (&optional quiet)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
493 "Update the `proced' process information. Preserves point and marks."
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
494 ;; This is the main function that generates and updates the process listing.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
495 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
496 (or quiet (message "Updating process information..."))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
497 (let* ((command (cadr (assoc proced-command proced-command-alist)))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
498 (regexp (concat (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\)"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
499 (old-pos (if (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
500 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
501 (looking-at (concat "^[* ]" regexp)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
502 (cons (match-string-no-properties 1)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
503 (current-column))))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
504 buffer-read-only mp-list)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
505 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
506 ;; remember marked processes (whatever the mark was)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
507 (while (re-search-forward (concat "^\\(\\S-\\)" regexp) nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
508 (push (cons (match-string-no-properties 2)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
509 (match-string-no-properties 1)) mp-list))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
510 ;; generate new listing
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
511 (erase-buffer)
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
512 (apply 'call-process (car command) nil t nil
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
513 (append (cdr command) (cdr (assoc proced-sorting-scheme
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
514 proced-sorting-schemes-alist))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
515 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
516 (while (not (eobp))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
517 (insert " ")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
518 (forward-line))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
519 ;; (delete-trailing-whitespace)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
520 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
521 (while (re-search-forward "[ \t\r]+$" nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
522 (delete-region (match-beginning 0) (match-end 0)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
523 (goto-char (point-min))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
524 (let ((lep (line-end-position)))
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
525 (setq proced-header-line (buffer-substring-no-properties (point) lep))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
526 (setq proced-header-alist nil)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
527 ;; FIXME: handle left/right justification properly
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
528 (while (re-search-forward "\\([^ \t\n]+\\)[ \t]*\\($\\)?" lep t)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
529 (push (list (match-string-no-properties 1)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
530 ;; take the column number starting from zero
95286
3680efd5ada2 (proced-header-line): Use the :align-to 0 feature
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95168
diff changeset
531 (- (match-beginning 0) (point-min))
3680efd5ada2 (proced-header-line): Use the :align-to 0 feature
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95168
diff changeset
532 (or (not (not (match-beginning 2)))
3680efd5ada2 (proced-header-line): Use the :align-to 0 feature
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 95168
diff changeset
533 (- (match-end 0) (point-min)))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
534 'left)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
535 proced-header-alist)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
536 (let ((temp (regexp-opt (mapcar 'car proced-header-alist) t)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
537 (setq proced-sorting-schemes-re
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
538 (concat "\\`" temp "\\(," temp "\\)*\\'")))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
539 ;; remove header line from ps(1) output
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
540 (goto-char (point-min))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
541 (delete-region (point)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
542 (save-excursion (forward-line) (point)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
543 (set-buffer-modified-p nil)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
544 ;; set `proced-goal-column'
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
545 (if proced-goal-header-re
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
546 (let ((hlist proced-header-alist) header)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
547 (while (setq header (pop hlist))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
548 (if (string-match proced-goal-header-re (car header))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
549 (setq proced-goal-column
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
550 (if (eq 'left (nth 3 header))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
551 (nth 1 header) (nth 2 header))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
552 hlist nil)))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
553 ;; restore process marks
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
554 (if mp-list
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
555 (save-excursion
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
556 (goto-char (point-min))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
557 (let (mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
558 (while (re-search-forward (concat "^" regexp) nil t)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
559 (if (setq mark (assoc (match-string-no-properties 1) mp-list))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
560 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
561 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
562 (insert (cdr mark))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
563 (delete-char 1)))))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
564 ;; restore buffer position (if possible)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
565 (goto-char (point-min))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
566 (if (and old-pos
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
567 (re-search-forward
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
568 (concat "^[* ]" (proced-skip-regexp) "\\s-+" (car old-pos) "\\>")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
569 nil t))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
570 (progn
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
571 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
572 (forward-char (cdr old-pos)))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
573 (proced-move-to-goal-column))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
574 ;; update modeline
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
575 ;; Does the long mode-name clutter the modeline?
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
576 (setq mode-name (concat "Proced: " proced-command
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
577 (if proced-sorting-scheme
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
578 (concat " by " proced-sorting-scheme)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
579 "")))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
580 (force-mode-line-update)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
581 ;; done
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
582 (or quiet (input-pending-p)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
583 (message "Updating process information...done."))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
584
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
585 (defun proced-revert (&rest args)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
586 "Analog of `revert-buffer'."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
587 (proced-update))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
588
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
589 ;; I do not want to reinvent the wheel. Should we rename `dired-pop-to-buffer'
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
590 ;; and move it to window.el so that proced and ibuffer can easily use it, too?
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
591 ;; What about functions like `appt-disp-window' that use
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
592 ;; `shrink-window-if-larger-than-buffer'?
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
593 (autoload 'dired-pop-to-buffer "dired")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
594
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
595 (defun proced-send-signal (&optional signal)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
596 "Send a SIGNAL to the marked processes.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
597 SIGNAL may be a string (HUP, INT, TERM, etc.) or a number.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
598 If SIGNAL is nil display marked processes and query interactively for SIGNAL."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
599 (interactive)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
600 (let ((regexp (concat (proced-marker-regexp)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
601 (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\).*$"))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
602 process-list)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
603 ;; collect marked processes
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
604 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
605 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
606 (while (re-search-forward regexp nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
607 (push (cons (match-string-no-properties 1)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
608 ;; How much info should we collect here? Would it be
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
609 ;; better to collect only the PID (to avoid ambiguities)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
610 ;; and the command name?
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
611 (substring (match-string-no-properties 0) 2))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
612 process-list)))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
613 (setq process-list (nreverse process-list))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
614 (if (not process-list)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
615 (message "No processes marked")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
616 (unless signal
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
617 ;; Display marked processes (code taken from `dired-mark-pop-up').
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
618 (let ((bufname " *Marked Processes*")
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
619 (header proced-header-line)) ; inherit header line
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
620 (with-current-buffer (get-buffer-create bufname)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
621 (setq truncate-lines t
95168
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
622 proced-header-line header
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
623 header-line-format '(:eval (proced-header-line)))
a031e38a88d4 (proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 95135
diff changeset
624 (add-hook 'post-command-hook 'force-mode-line-update nil t)
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
625 (erase-buffer)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
626 (dolist (process process-list)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
627 (insert " " (cdr process) "\n"))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
628 (save-window-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
629 (dired-pop-to-buffer bufname) ; all we need
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
630 (let* ((completion-ignore-case t)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
631 (pnum (if (= 1 (length process-list))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
632 "1 process"
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
633 (format "%d processes" (length process-list))))
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
634 ;; The following is an ugly hack. Is there a better way
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
635 ;; to help people like me to remember the signals and
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
636 ;; their meanings?
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
637 (tmp (completing-read (concat "Send signal [" pnum
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
638 "] (default TERM): ")
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
639 proced-signal-list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
640 nil nil nil nil "TERM")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
641 (setq signal (if (string-match "^\\(\\S-+\\)\\s-" tmp)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
642 (match-string 1 tmp) tmp))))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
643 ;; send signal
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
644 (let ((count 0)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
645 err-list)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
646 (if (functionp proced-signal-function)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
647 ;; use built-in `signal-process'
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
648 (let ((signal (if (stringp signal)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
649 (if (string-match "\\`[0-9]+\\'" signal)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
650 (string-to-number signal)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
651 (make-symbol signal))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
652 signal))) ; number
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
653 (dolist (process process-list)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
654 (if (zerop (funcall
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
655 proced-signal-function
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
656 (string-to-number (car process)) signal))
94066
f446992a6a91 (proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94063
diff changeset
657 (setq count (1+ count))
f446992a6a91 (proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94063
diff changeset
658 (push (cdr process) err-list))))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
659 ;; use external system call
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
660 (let ((signal (concat "-" (if (numberp signal)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
661 (number-to-string signal) signal))))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
662 (dolist (process process-list)
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
663 (if (zerop (call-process
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
664 proced-signal-function nil 0 nil
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
665 signal (car process)))
94066
f446992a6a91 (proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94063
diff changeset
666 (setq count (1+ count))
f446992a6a91 (proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94063
diff changeset
667 (push (cdr process) err-list)))))
94063
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
668 (if err-list
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
669 ;; FIXME: that's not enough to display the errors.
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
670 (message "%s: %s" signal err-list)
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
671 (proced-success-message "Sent signal to" count)))
ab8c45d22418 (proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93248
diff changeset
672 ;; final clean-up
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
673 (run-hooks 'proced-after-send-signal-hook)))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
674
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
675 (defun proced-help ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
676 "Provide help for the `proced' user."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
677 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
678 (if (eq last-command 'proced-help)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
679 (describe-mode)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
680 (message proced-help-string)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
681
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
682 (defun proced-undo ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
683 "Undo in a proced buffer.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
684 This doesn't recover killed processes, it just undoes changes in the proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
685 buffer. You can use it to recover marks."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
686 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
687 (let (buffer-read-only)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
688 (undo))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
689 (message "Change in Proced buffer undone.
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
690 Killed processes cannot be recovered by Emacs."))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
691
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
692 ;;; Sorting
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
693 (defun proced-sort (scheme)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
694 "Sort Proced buffer using SCHEME.
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
695 When called interactively, an empty string means nil, i.e., no sorting."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
696 (interactive
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
697 (list (let* ((completion-ignore-case t)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
698 ;; restrict completion list to applicable sorting schemes
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
699 (completion-list
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
700 (apply 'append
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
701 (mapcar (lambda (x)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
702 (if (string-match proced-sorting-schemes-re
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
703 (car x))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
704 (list (car x))))
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
705 proced-sorting-schemes-alist)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
706 (scheme (completing-read "Sorting type: "
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
707 completion-list nil t)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
708 (if (string= "" scheme) nil scheme))))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
709 (if (proced-sorting-scheme-p scheme)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
710 (progn
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
711 (setq proced-sorting-scheme scheme)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
712 (proced-update))
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
713 (error "Proced sorting scheme %s not applicable" scheme)))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
714
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
715 (defun proced-sorting-scheme-p (scheme)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
716 "Return non-nil if SCHEME is an applicable sorting scheme.
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
717 SCHEME must be a string or nil."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
718 (or (not scheme)
95135
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
719 (and (string-match proced-sorting-schemes-re scheme)
33ea0b47d336 (proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94678
diff changeset
720 (assoc scheme proced-sorting-schemes-alist))))
94621
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
721
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
722 (defun proced-sort-pcpu ()
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
723 "Sort Proced buffer by percentage CPU time (%CPU)."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
724 (interactive)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
725 (proced-sort "%CPU"))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
726
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
727 (defun proced-sort-pmem ()
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
728 "Sort Proced buffer by percentage memory usage (%MEM)."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
729 (interactive)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
730 (proced-sort "%MEM"))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
731
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
732 (defun proced-sort-pid ()
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
733 "Sort Proced buffer by PID."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
734 (interactive)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
735 (proced-sort "PID"))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
736
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
737 (defun proced-sort-start ()
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
738 "Sort Proced buffer by time the command started (START)."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
739 (interactive)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
740 (proced-sort "START"))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
741
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
742 (defun proced-sort-time ()
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
743 "Sort Proced buffer by cumulative CPU time (TIME)."
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
744 (interactive)
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
745 (proced-sort "TIME"))
97585dd63d91 (proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 94109
diff changeset
746
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
747 (provide 'proced)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
748
93248
072dbbf778d2 Add arch-tag.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93213
diff changeset
749 ;; arch-tag: a6e312ad-9032-45aa-972d-31a8cfc545af
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
750 ;;; proced.el ends here.