Mercurial > emacs
annotate lisp/proced.el @ 101833:97ed2489367d
2009-02-06 Carsten Dominik <dominik@science.uva.nl>
* org-exp.el (org-export-preprocess-string): Fix bug with skipping
text before first headline.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 06 Feb 2009 11:47:58 +0000 |
parents | a9dc0e7c3f2b |
children | 18c7189fe029 |
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 |
100908 | 3 ;; Copyright (C) 2008, 2009 Free Software Foundation, Inc. |
93213
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 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
25 ;; Proced makes an Emacs buffer containing a listing of the current |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
26 ;; system processes. You can use the normal Emacs commands to move around |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
27 ;; in this buffer, and special Proced commands to operate on the processes |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
28 ;; listed. See `proced-mode' for getting started. |
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: |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
31 ;; - interactive temporary customizability of flags in `proced-grammar-alist' |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
32 ;; - allow "sudo kill PID", "renice PID" |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
33 ;; |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
34 ;; Thoughts and Ideas |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
35 ;; - Currently, `system-process-attributes' returns the list of |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
36 ;; command-line arguments of a process as one concatenated string. |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
37 ;; This format is compatible with `shell-command'. Also, under |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
38 ;; MS-Windows, the command-line arguments are actually stored as a |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
39 ;; single string, so that it is impossible to reverse-engineer it back |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
40 ;; into separate arguments. Alternatively, `system-process-attributes' |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
41 ;; could (try to) return a list of strings that correspond to individual |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
42 ;; command-line arguments. Then one could feed such a list of |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
43 ;; command-line arguments into `call-process' or `start-process'. |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
44 ;; Are there real-world applications when such a feature would be useful? |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
45 ;; What about something like `proced-restart-pid'? |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
46 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
47 ;;; Code: |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
48 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
49 (require 'time-date) ; for `with-decoded-time-value' |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
50 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
51 (defgroup proced nil |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
52 "Proced mode." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
53 :group 'processes |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
54 :group 'unix |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
55 :prefix "proced-") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
56 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
57 (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
|
58 "Name of signal function. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
59 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
|
60 the external command (usually \"kill\")." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
61 :group 'proced |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
62 :type '(choice (function :tag "function") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
63 (string :tag "command"))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
64 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
65 (defcustom proced-signal-list |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
66 '( ;; signals supported on all POSIX compliant systems |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
67 ("HUP (1. Hangup)") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
68 ("INT (2. Terminal interrupt)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
69 ("QUIT (3. Terminal quit)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
70 ("ABRT (6. Process abort)") |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
71 ("KILL (9. Kill - cannot be caught or ignored)") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
72 ("ALRM (14. Alarm Clock)") |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
73 ("TERM (15. Termination)") |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
74 ;; POSIX 1003.1-2001 |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
75 ;; Which systems do not support these signals so that we can |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
76 ;; exclude them from `proced-signal-list'? |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
77 ("CONT (Continue executing)") |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
78 ("STOP (Stop executing / pause - cannot be caught or ignored)") |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
79 ("TSTP (Terminal stop / pause)")) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
80 "List of signals, used for minibuffer completion." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
81 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
82 :type '(repeat (string :tag "signal"))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
83 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
84 ;; For which attributes can we use a fixed width of the output field? |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
85 ;; A fixed width speeds up formatting, yet it can make |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
86 ;; `proced-grammar-alist' system-dependent. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
87 ;; (If proced runs like top(1) we want it to be fast.) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
88 ;; |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
89 ;; If it is impossible / unlikely that an attribute has the same value |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
90 ;; for two processes, then sorting can be based on one ordinary (fast) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
91 ;; predicate like `<'. Otherwise, a list of proced predicates can be used |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
92 ;; to refine the sort. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
93 ;; |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
94 ;; It would be neat if one could temporarily override the following |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
95 ;; predefined rules. |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
96 (defcustom proced-grammar-alist |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
97 '( ;; attributes defined in `system-process-attributes' |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
98 (euid "EUID" "%d" right proced-< nil (euid pid) (nil t nil)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
99 (user "USER" nil left proced-string-lessp nil (user pid) (nil t nil)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
100 (egid "EGID" "%d" right proced-< nil (egid euid pid) (nil t nil)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
101 (group "GROUP" nil left proced-string-lessp nil (group user pid) (nil t nil)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
102 (comm "COMMAND" nil left proced-string-lessp nil (comm pid) (nil t nil)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
103 (state "STAT" nil left proced-string-lessp nil (state pid) (nil t nil)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
104 (ppid "PPID" "%d" right proced-< nil (ppid pid) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
105 ((lambda (ppid) (proced-filter-parents proced-process-alist ppid)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
106 "refine to process parents")) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
107 (pgrp "PGRP" "%d" right proced-< nil (pgrp euid pid) (nil t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
108 (sess "SESS" "%d" right proced-< nil (sess pid) (nil t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
109 (ttname "TTY" proced-format-ttname left proced-string-lessp nil (ttname pid) (nil t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
110 (tpgid "TPGID" "%d" right proced-< nil (tpgid pid) (nil t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
111 (minflt "MINFLT" "%d" right proced-< nil (minflt pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
112 (majflt "MAJFLT" "%d" right proced-< nil (majflt pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
113 (cminflt "CMINFLT" "%d" right proced-< nil (cminflt pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
114 (cmajflt "CMAJFLT" "%d" right proced-< nil (cmajflt pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
115 (utime "UTIME" proced-format-time right proced-time-lessp t (utime pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
116 (stime "STIME" proced-format-time right proced-time-lessp t (stime pid) (nil t t)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
117 (time "TIME" proced-format-time right proced-time-lessp t (time pid) (nil t t)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
118 (cutime "CUTIME" proced-format-time right proced-time-lessp t (cutime pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
119 (cstime "CSTIME" proced-format-time right proced-time-lessp t (cstime pid) (nil t t)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
120 (ctime "CTIME" proced-format-time right proced-time-lessp t (ctime pid) (nil t t)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
121 (pri "PR" "%d" right proced-< t (pri pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
122 (nice "NI" "%3d" 3 proced-< t (nice pid) (t t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
123 (thcount "THCOUNT" "%d" right proced-< t (thcount pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
124 (start "START" proced-format-start 6 proced-time-lessp nil (start pid) (t t nil)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
125 (vsize "VSIZE" "%d" right proced-< t (vsize pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
126 (rss "RSS" "%d" right proced-< t (rss pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
127 (etime "ETIME" proced-format-time right proced-time-lessp t (etime pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
128 (pcpu "%CPU" "%.1f" right proced-< t (pcpu pid) (nil t t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
129 (pmem "%MEM" "%.1f" right proced-< t (pmem pid) (nil t t)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
130 (args "ARGS" proced-format-args left proced-string-lessp nil (args pid) (nil t nil)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
131 ;; |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
132 ;; attributes defined by proced (see `proced-process-attributes') |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
133 (pid "PID" "%d" right proced-< nil (pid) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
134 ((lambda (ppid) (proced-filter-children proced-process-alist ppid)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
135 "refine to process children")) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
136 ;; process tree |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
137 (tree "TREE" proced-format-tree left nil nil nil nil)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
138 "Alist of rules for handling Proced attributes. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
139 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
140 Each element has the form |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
141 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
142 (KEY NAME FORMAT JUSTIFY PREDICATE REVERSE SORT-SCHEME REFINER). |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
143 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
144 Symbol KEY is the car of a process attribute. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
145 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
146 String NAME appears in the header line. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
147 |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
148 FORMAT specifies the format for displaying the attribute values. It can |
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
149 be a string passed to `format'. It can be a function called with one |
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
150 argument, the value of the attribute. The value nil means take as is. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
151 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
152 If JUSTIFY is an integer, its modulus gives the width of the attribute |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
153 values formatted with FORMAT. If JUSTIFY is positive, NAME appears |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
154 right-justified, otherwise it appears left-justified. If JUSTIFY is 'left |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
155 or 'right, the field width is calculated from all field values in the listing. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
156 If JUSTIFY is 'left, the field values are formatted left-justified and |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
157 right-justified otherwise. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
158 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
159 PREDICATE is the predicate for sorting and filtering the process listing |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
160 based on attribute KEY. PREDICATE takes two arguments P1 and P2, |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
161 the corresponding attribute values of two processes. PREDICATE should |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
162 return 'equal if P1 has same rank like P2. Any other non-nil value says |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
163 that P1 is \"less than\" P2, or nil if not. |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
164 If PREDICATE is nil the attribute cannot be sorted. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
165 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
166 PREDICATE defines an ascending sort order. REVERSE is non-nil if the sort |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
167 order is descending. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
168 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
169 SORT-SCHEME is a list (KEY1 KEY2 ...) defining a hierarchy of rules |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
170 for sorting the process listing. KEY1, KEY2, ... are KEYs appearing as cars |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
171 of `proced-grammar-alist'. First the PREDICATE of KEY1 is evaluated. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
172 If it yields non-equal, it defines the sort order for the corresponding |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
173 processes. If it evaluates to 'equal the PREDICATE of KEY2 is evaluated, etc. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
174 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
175 REFINER can be a list of flags (LESS-B EQUAL-B LARGER-B) used by the command |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
176 `proced-refine' (see there) to refine the listing based on attribute KEY. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
177 This command compares the value of attribute KEY of every process with |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
178 the value of attribute KEY of the process at the position of point |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
179 using PREDICATE. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
180 If PREDICATE yields non-nil, the process is accepted if LESS-B is non-nil. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
181 If PREDICATE yields 'equal, the process is accepted if EQUAL-B is non-nil. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
182 If PREDICATE yields nil, the process is accepted if LARGER-B is non-nil. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
183 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
184 REFINER can also be a list (FUNCTION HELP-ECHO). |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
185 FUNCTION is called with one argument, the PID of the process at the position |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
186 of point. The function must return a list of PIDs that is used for the refined |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
187 listing. HELP-ECHO is a string that is shown when mouse is over this field. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
188 |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
189 If REFINER is nil no refinement is done." |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
190 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
191 :type '(repeat (list :tag "Attribute" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
192 (symbol :tag "Key") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
193 (string :tag "Header") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
194 (choice :tag "Format" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
195 (const :tag "None" nil) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
196 (string :tag "Format String") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
197 (function :tag "Formatting Function")) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
198 (choice :tag "Justification" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
199 (const :tag "left" left) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
200 (const :tag "right" right) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
201 (integer :tag "width")) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
202 (choice :tag "Predicate" |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
203 (const :tag "None" nil) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
204 (function :tag "Function")) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
205 (boolean :tag "Descending Sort Order") |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
206 (repeat :tag "Sort Scheme" (symbol :tag "Key")) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
207 (choice :tag "Refiner" |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
208 (const :tag "None" nil) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
209 (list (function :tag "Refinement Function") |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
210 (string :tag "Help echo")) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
211 (list :tag "Refine Flags" |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
212 (boolean :tag "Less") |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
213 (boolean :tag "Equal") |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
214 (boolean :tag "Larger")))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
215 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
216 (defcustom proced-custom-attributes nil |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
217 "List of functions defining custom attributes. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
218 This variable extends the functionality of `proced-process-attributes'. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
219 Each function is called with one argument, the list of attributes |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
220 of a system process. It returns a cons cell of the form (KEY . VALUE) |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
221 like `system-process-attributes'. This cons cell is appended to the list |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
222 returned by `proced-process-attributes'. |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
223 If the function returns nil, the value is ignored." |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
224 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
225 :type '(repeat (function :tag "Attribute"))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
226 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
227 ;; Formatting and sorting rules are defined "per attribute". If formatting |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
228 ;; and / or sorting should use more than one attribute, it appears more |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
229 ;; transparent to define a new derived attribute, so that formatting and |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
230 ;; sorting can use them consistently. (Are there exceptions to this rule? |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
231 ;; Would it be advantageous to have yet more general methods available?) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
232 ;; Sorting can also be based on attributes that are invisible in the listing. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
233 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
234 (defcustom proced-format-alist |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
235 '((short user pid tree pcpu pmem start time (args comm)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
236 (medium user pid tree pcpu pmem vsize rss ttname state start time (args comm)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
237 (long user euid group pid tree pri nice pcpu pmem vsize rss ttname state |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
238 start time (args comm)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
239 (verbose user euid group egid pid ppid tree pgrp sess pri nice pcpu pmem |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
240 state thcount vsize rss ttname tpgid minflt majflt cminflt cmajflt |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
241 start time utime stime ctime cutime cstime etime (args comm))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
242 "Alist of formats of listing. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
243 The car of each element is a symbol, the name of the format. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
244 The cdr is a list of attribute keys appearing in `proced-grammar-alist'. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
245 An element of this list may also be a list of attribute keys that specifies |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
246 alternatives. If the first attribute is absent for a process, use the second |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
247 one, etc." |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
248 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
249 :type '(alist :key-type (symbol :tag "Format Name") |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
250 :value-type (repeat :tag "Keys" |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
251 (choice (symbol :tag "") |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
252 (repeat :tag "Alternative Keys" |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
253 (symbol :tag "")))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
254 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
255 (defcustom proced-format 'short |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
256 "Current format of Proced listing. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
257 It can be the car of an element of `proced-format-alist'. |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
258 It can also be a list of keys appearing in `proced-grammar-alist'." |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
259 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
260 :type '(choice (symbol :tag "Format Name") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
261 (repeat :tag "Keys" (symbol :tag "")))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
262 (make-variable-buffer-local 'proced-format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
263 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
264 ;; FIXME: is there a better name for filter `user' that does not coincide |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
265 ;; with an attribute key? |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
266 (defcustom proced-filter-alist |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
267 `((user (user . ,(concat "\\`" (user-real-login-name) "\\'"))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
268 (user-running (user . ,(concat "\\`" (user-real-login-name) "\\'")) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
269 (state . "\\`[Rr]\\'")) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
270 (all) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
271 (all-running (state . "\\`[Rr]\\'")) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
272 (emacs (fun-all . (lambda (list) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
273 (proced-filter-children list ,(emacs-pid)))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
274 "Alist of process filters. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
275 The car of each element is a symbol, the name of the filter. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
276 The cdr is a list of elementary filters that are applied to every process. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
277 A process is displayed if it passes all elementary filters of a selected |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
278 filter. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
279 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
280 An elementary filter can be one of the following: |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
281 \(KEY . REGEXP) If value of attribute KEY matches REGEXP, |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
282 accept this process. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
283 \(KEY . FUN) Apply function FUN to attribute KEY. Accept this process, |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
284 if FUN returns non-nil. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
285 \(function . FUN) For each process, apply function FUN to list of attributes |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
286 of each. Accept the process if FUN returns non-nil. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
287 \(fun-all . FUN) Apply function FUN to entire process list. |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
288 FUN must return the filtered list." |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
289 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
290 :type '(repeat (cons :tag "Filter" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
291 (symbol :tag "Filter Name") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
292 (repeat :tag "Filters" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
293 (choice (cons :tag "Key . Regexp" (symbol :tag "Key") regexp) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
294 (cons :tag "Key . Function" (symbol :tag "Key") function) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
295 (cons :tag "Function" (const :tag "Key: function" function) function) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
296 (cons :tag "Fun-all" (const :tag "Key: fun-all" fun-all) function)))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
297 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
298 (defcustom proced-filter 'user |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
299 "Current filter of proced listing. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
300 It can be the car of an element of `proced-filter-alist'. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
301 It can also be a list of elementary filters as in the cdrs of the elements |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
302 of `proced-filter-alist'." |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
303 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
304 :type '(choice (symbol :tag "Filter Name") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
305 (repeat :tag "Filters" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
306 (choice (cons :tag "Key . Regexp" (symbol :tag "Key") regexp) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
307 (cons :tag "Key . Function" (symbol :tag "Key") function) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
308 (cons :tag "Function" (const :tag "Key: function" function) function) |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
309 (cons :tag "Fun-all" (const :tag "Key: fun-all" fun-all) function))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
310 (make-variable-buffer-local 'proced-filter) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
311 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
312 (defcustom proced-sort 'pcpu |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
313 "Current sort scheme for proced listing. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
314 It must be the KEY of an element of `proced-grammar-alist'. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
315 It can also be a list of KEYs as in the SORT-SCHEMEs of the elements |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
316 of `proced-grammar-alist'." |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
317 :group 'proced |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
318 :type '(choice (symbol :tag "Sort Scheme") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
319 (repeat :tag "Key List" (symbol :tag "Key")))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
320 (make-variable-buffer-local 'proced-format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
321 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
322 (defcustom proced-descend t |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
323 "Non-nil if proced listing is sorted in descending order." |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
324 :group 'proced |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
325 :type '(boolean :tag "Descending Sort Order")) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
326 (make-variable-buffer-local 'proced-descend) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
327 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
328 (defcustom proced-goal-attribute 'args |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
329 "If non-nil, key of the attribute that defines the `goal-column'." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
330 :group 'proced |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
331 :type '(choice (const :tag "none" nil) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
332 (symbol :tag "key"))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
333 |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
334 (defcustom proced-auto-update-interval 5 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
335 "Time interval in seconds for auto updating Proced buffers." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
336 :group 'proced |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
337 :type 'integer) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
338 |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
339 (defcustom proced-auto-update-flag nil |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
340 "Non-nil for auto update of a Proced buffer. |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
341 Can be changed interactively via `proced-toggle-auto-update'." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
342 :group 'proced |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
343 :type 'boolean) |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
344 (make-variable-buffer-local 'proced-auto-update-flag) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
345 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
346 (defcustom proced-tree-flag nil |
100763
6a68c7a91e31
* proced.el (proced-tree-flag): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
100752
diff
changeset
|
347 "Non-nil for display of Proced buffer as process tree." |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
348 :group 'proced |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
349 :type 'boolean) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
350 (make-variable-buffer-local 'proced-tree-flag) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
351 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
352 (defcustom proced-post-display-hook nil |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
353 "Normal hook run after displaying or updating a Proced buffer. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
354 May be used to adapt the window size via `fit-window-to-buffer'." |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
355 :type 'hook |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
356 :options '(fit-window-to-buffer) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
357 :group 'proced) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
358 |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
359 ;; Internal variables |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
360 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
361 (defvar proced-available (not (null (list-system-processes))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
362 "Non-nil means Proced is known to work on this system.") |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
363 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
364 (defvar proced-process-alist nil |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
365 "Alist of processes displayed by Proced. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
366 The car of each element is the PID, and the cdr is a list of |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
367 cons pairs, see `proced-process-attributes'.") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
368 (make-variable-buffer-local 'proced-process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
369 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
370 (defvar proced-sort-internal nil |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
371 "Sort scheme for listing (internal format). |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
372 It is a list of lists (KEY PREDICATE REVERSE).") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
373 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
374 (defvar proced-marker-char ?* ; the answer is 42 |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
375 "In Proced, the current mark character.") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
376 |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
377 ;; Faces and font-lock code taken from dired, |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
378 ;; but face variables are deprecated for new code. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
379 (defgroup proced-faces nil |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
380 "Faces used by Proced." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
381 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
382 :group 'faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
383 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
384 (defface proced-mark |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
385 '((t (:inherit font-lock-constant-face))) |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
386 "Face used for Proced marks." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
387 :group 'proced-faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
388 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
389 (defface proced-marked |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
390 '((t (:inherit font-lock-warning-face))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
391 "Face used for marked processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
392 :group 'proced-faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
393 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
394 (defface proced-sort-header |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
395 '((t (:inherit font-lock-keyword-face))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
396 "Face used for header of attribute used for sorting." |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
397 :group 'proced-faces) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
398 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
399 (defvar proced-re-mark "^[^ \n]" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
400 "Regexp matching a marked line. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
401 Important: the match ends just after the marker.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
402 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
403 (defvar proced-header-line nil |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
404 "Headers in Proced buffer as a string.") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
405 (make-variable-buffer-local 'proced-header-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
406 |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
407 (defvar proced-temp-alist nil |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
408 "Temporary alist (internal variable).") |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
409 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
410 (defvar proced-process-tree nil |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
411 "Proced process tree (internal variable).") |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
412 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
413 (defvar proced-tree-depth nil |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
414 "Internal variable for depth of Proced process tree.") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
415 |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
416 (defvar proced-auto-update-timer nil |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
417 "Stores if Proced auto update timer is already installed.") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
418 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
419 (defvar proced-log-buffer "*Proced log*" |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
420 "Name of Proced Log buffer.") |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
421 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
422 (defconst proced-help-string |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
423 "(n)ext, (p)revious, (m)ark, (u)nmark, (k)ill, (q)uit (type ? for more help)" |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
424 "Help string for Proced.") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
425 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
426 (defconst proced-header-help-echo |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
427 "mouse-1, mouse-2: sort by attribute %s%s (%s)" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
428 "Help string shown when mouse is over a sortable header.") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
429 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
430 (defconst proced-field-help-echo |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
431 "mouse-2, RET: refine by attribute %s %s" |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
432 "Help string shown when mouse is over a refinable field.") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
433 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
434 (defvar proced-font-lock-keywords |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
435 `(;; (Any) proced marks. |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
436 (,proced-re-mark . 'proced-mark) |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
437 ;; Processes marked with `proced-marker-char' |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
438 ;; Should we make sure that only certain attributes are font-locked? |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
439 (,(concat "^[" (char-to-string proced-marker-char) "]") |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
440 ".+" (proced-move-to-goal-column) nil (0 'proced-marked)))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
441 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
442 (defvar proced-mode-map |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
443 (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
|
444 ;; moving |
100743
9fcd5ffe18c5
(proced-mode-map): Bind " " to next-line instead of the
Juri Linkov <juri@jurta.org>
parents:
100735
diff
changeset
|
445 (define-key km " " 'next-line) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
446 (define-key km "n" 'next-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
447 (define-key km "p" 'previous-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
448 (define-key km "\C-n" 'next-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
449 (define-key km "\C-p" 'previous-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
450 (define-key km "\C-?" 'previous-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
451 (define-key km [down] 'next-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
452 (define-key km [up] 'previous-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
|
453 ;; marking |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
454 (define-key km "d" 'proced-mark) ; Dired compatibility ("delete") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
455 (define-key km "m" 'proced-mark) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
456 (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
|
457 (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
|
458 (define-key km "M" 'proced-mark-all) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
459 (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
|
460 (define-key km "t" 'proced-toggle-marks) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
461 (define-key km "C" 'proced-mark-children) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
462 (define-key km "P" 'proced-mark-parents) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
463 ;; filtering |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
464 (define-key km "f" 'proced-filter-interactive) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
465 (define-key km [mouse-2] 'proced-refine) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
466 (define-key km "\C-m" 'proced-refine) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
467 ;; sorting |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
468 (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
|
469 (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
|
470 (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
|
471 (define-key km "ss" 'proced-sort-start) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
472 (define-key km "sS" 'proced-sort-interactive) |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
473 (define-key km "st" 'proced-sort-time) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
474 (define-key km "su" 'proced-sort-user) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
475 ;; similar to `Buffer-menu-sort-by-column' |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
476 (define-key km [header-line mouse-1] 'proced-sort-header) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
477 (define-key km [header-line mouse-2] 'proced-sort-header) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
478 (define-key km "T" 'proced-toggle-tree) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
479 ;; formatting |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
480 (define-key km "F" 'proced-format-interactive) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
481 ;; operate |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
482 (define-key km "o" 'proced-omit-processes) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
483 (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
|
484 (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
|
485 ;; misc |
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
486 (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
|
487 (define-key km "?" 'proced-help) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
488 (define-key km [remap undo] 'proced-undo) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
489 (define-key km [remap advertised-undo] 'proced-undo) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
490 ;; Additional keybindings are inherited from `special-mode-map' |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
491 km) |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
492 "Keymap for Proced commands.") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
493 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
494 (easy-menu-define |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
495 proced-menu proced-mode-map "Proced Menu" |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
496 `("Proced" |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
497 ["Mark" proced-mark |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
498 :help "Mark Current Process"] |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
499 ["Unmark" proced-unmark |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
500 :help "Unmark Current Process"] |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
501 ["Mark All" proced-mark-all |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
502 :help "Mark All Processes"] |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
503 ["Unmark All" proced-unmark-all |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
504 :help "Unmark All Process"] |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
505 ["Toggle Marks" proced-toggle-marks |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
506 :help "Marked Processes Become Unmarked, and Vice Versa"] |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
507 ["Mark Children" proced-mark-children |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
508 :help "Mark Current Process and its Children"] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
509 ["Mark Parents" proced-mark-parents |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
510 :help "Mark Current Process and its Parents"] |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
511 "--" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
512 ("Filters" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
513 :help "Select Filter for Process Listing" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
514 ,@(mapcar (lambda (el) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
515 (let ((filter (car el))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
516 `[,(symbol-name filter) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
517 (proced-filter-interactive ',filter) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
518 :style radio |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
519 :selected (eq proced-filter ',filter)])) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
520 proced-filter-alist)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
521 ("Sorting" |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
522 :help "Select Sort Scheme" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
523 ["Sort..." proced-sort-interactive |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
524 :help "Sort Process List"] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
525 "--" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
526 ["Sort by %CPU" proced-sort-pcpu] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
527 ["Sort by %MEM" proced-sort-pmem] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
528 ["Sort by PID" proced-sort-pid] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
529 ["Sort by START" proced-sort-start] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
530 ["Sort by TIME" proced-sort-time] |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
531 ["Sort by USER" proced-sort-user]) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
532 ("Formats" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
533 :help "Select Format for Process Listing" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
534 ,@(mapcar (lambda (el) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
535 (let ((format (car el))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
536 `[,(symbol-name format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
537 (proced-format-interactive ',format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
538 :style radio |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
539 :selected (eq proced-format ',format)])) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
540 proced-format-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
541 ["Tree Display" proced-toggle-tree |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
542 :style toggle |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
543 :selected (eval proced-tree-flag) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
544 :help "Display Proced Buffer as Process Tree"] |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
545 "--" |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
546 ["Omit Marked Processes" proced-omit-processes |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
547 :help "Omit Marked Processes in Process Listing."] |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
548 "--" |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
549 ["Revert" revert-buffer |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
550 :help "Revert Process Listing"] |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
551 ["Auto Update" proced-toggle-auto-update |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
552 :style toggle |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
553 :selected (eval proced-auto-update-flag) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
554 :help "Auto Update of Proced Buffer"] |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
555 ["Send signal" proced-send-signal |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
556 :help "Send Signal to Marked Processes"])) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
557 |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
558 ;; helper functions |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
559 (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
|
560 "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
|
561 ;; `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
|
562 (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
|
563 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
564 (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
|
565 "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
|
566 (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
|
567 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
568 ;; Unlike dired, we do not define our own commands for vertical motion. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
569 ;; If `goal-column' is set, `next-line' and `previous-line' are fancy |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
570 ;; commands to satisfy our modest needs. If `proced-goal-attribute' |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
571 ;; and/or `goal-column' are not set, `next-line' and `previous-line' |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
572 ;; are really what we need to preserve the column of point. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
573 ;; We use `proced-move-to-goal-column' for "non-interactive" cases only |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
574 ;; to get a well-defined position of point. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
575 |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
576 (defun proced-move-to-goal-column () |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
577 "Move to `goal-column' if non-nil. Return position of point." |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
578 (beginning-of-line) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
579 (unless (eobp) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
580 (if goal-column |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
581 (forward-char goal-column) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
582 (forward-char 2))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
583 (point)) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
584 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
585 (defun proced-header-line () |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
586 "Return header line for Proced buffer." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
587 (list (propertize " " 'display '(space :align-to 0)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
588 (replace-regexp-in-string ;; preserve text properties |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
589 "\\(%\\)" "\\1\\1" (substring proced-header-line (window-hscroll))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
590 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
591 (defun proced-pid-at-point () |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
592 "Return pid of system process at point. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
593 Return nil if point is not on a process line." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
594 (save-excursion |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
595 (beginning-of-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
596 (if (looking-at "^. .") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
597 (get-text-property (match-end 0) 'proced-pid)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
598 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
599 ;; proced mode |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
600 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
601 (define-derived-mode proced-mode special-mode "Proced" |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
602 "Mode for displaying UNIX system processes and sending signals to them. |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
603 Type \\[proced] to start a Proced session. In a Proced buffer |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
604 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
|
605 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
|
606 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
607 The initial content of a listing is defined by the variable `proced-filter' |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
608 and the variable `proced-format'. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
609 The variable `proced-filter' specifies which system processes are displayed. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
610 The variable `proced-format' specifies which attributes are displayed for |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
611 each process. Type \\[proced-filter-interactive] and \\[proced-format-interactive] |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
612 to change the values of `proced-filter' and `proced-format'. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
613 The current value of the variable `proced-filter' is indicated in the |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
614 mode line. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
615 |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
616 The sort order of Proced listings is defined by the variable `proced-sort'. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
617 Type \\[proced-sort-interactive] or click on a header in the header line |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
618 to change the sort scheme. The current sort scheme is indicated in the |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
619 mode line, using \"+\" or \"-\" for ascending or descending sort order. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
620 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
621 Type \\[proced-toggle-tree] to toggle whether the listing is |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
622 displayed as process tree. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
623 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
624 An existing Proced listing can be refined by typing \\[proced-refine]. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
625 Refining an existing listing does not update the variable `proced-filter'. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
626 |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
627 The attribute-specific rules for formatting, filtering, sorting, and refining |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
628 are defined in `proced-grammar-alist'. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
629 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
630 After displaying or updating a Proced buffer, Proced runs the normal hook |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
631 `proced-post-display-hook'. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
632 |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
633 \\{proced-mode-map}" |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
634 (abbrev-mode 0) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
635 (auto-fill-mode 0) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
636 (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
|
637 truncate-lines t |
a031e38a88d4
(proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
95135
diff
changeset
|
638 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
|
639 (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
|
640 (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
|
641 (set (make-local-variable 'font-lock-defaults) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
642 '(proced-font-lock-keywords t nil nil beginning-of-line)) |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
643 (if (and (not proced-auto-update-timer) proced-auto-update-interval) |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
644 (setq proced-auto-update-timer |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
645 (run-at-time t proced-auto-update-interval |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
646 'proced-auto-update-timer)))) |
99735
bb974924d581
(proced-available): New variable.
Glenn Morris <rgm@gnu.org>
parents:
99726
diff
changeset
|
647 |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
648 ;;;###autoload |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
649 (defun proced (&optional arg) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
650 "Generate a listing of UNIX system processes. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
651 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
|
652 information will be displayed but not selected. |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
653 Runs the normal hook `proced-post-display-hook'. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
654 |
99726
38b176122f90
(proced, proced-format-time): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents:
98249
diff
changeset
|
655 See `proced-mode' for a description of features available in Proced buffers." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
656 (interactive "P") |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
657 (unless proced-available |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
658 (error "Proced is not available on this system")) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
659 (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
|
660 (set-buffer buffer) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
661 (setq new (zerop (buffer-size))) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
662 (when new |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
663 (proced-mode) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
664 ;; `proced-update' runs `proced-post-display-hook' only if the |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
665 ;; Proced buffer has been selected. Yet the following call of |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
666 ;; `proced-update' is for an empty Proced buffer that has not |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
667 ;; yet been selected. Therefore we need to call |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
668 ;; `proced-post-display-hook' below. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
669 (proced-update t)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
670 (if arg |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
671 (progn |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
672 (display-buffer buffer) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
673 (with-current-buffer buffer |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
674 (run-hooks 'proced-post-display-hook))) |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
675 (pop-to-buffer buffer) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
676 (run-hooks 'proced-post-display-hook) |
96824
9ebcc98e40f8
(proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents:
95300
diff
changeset
|
677 (message |
9ebcc98e40f8
(proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents:
95300
diff
changeset
|
678 (substitute-command-keys |
9ebcc98e40f8
(proced-mode, proced): Add \\<proced-mode-map> to docstrings.
Juri Linkov <juri@jurta.org>
parents:
95300
diff
changeset
|
679 "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
|
680 |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
681 (defun proced-auto-update-timer () |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
682 "Auto-update Proced buffers using `run-at-time'." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
683 (dolist (buf (buffer-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
684 (with-current-buffer buf |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
685 (if (and (eq major-mode 'proced-mode) |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
686 proced-auto-update-flag) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
687 (proced-update t 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
|
688 |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
689 (defun proced-toggle-auto-update (arg) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
690 "Change whether this Proced buffer is updated automatically. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
691 With prefix ARG, update this buffer automatically if ARG is positive, |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
692 otherwise do not update. Sets the variable `proced-auto-update-flag'. |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
693 The time interval for updates is specified via `proced-auto-update-interval'." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
694 (interactive (list (or current-prefix-arg 'toggle))) |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
695 (setq proced-auto-update-flag |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
696 (cond ((eq arg 'toggle) (not proced-auto-update-flag)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
697 (arg (> (prefix-numeric-value arg) 0)) |
100421
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
698 (t (not proced-auto-update-flag)))) |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
699 (message "Proced auto update %s" |
0b3bb7c982eb
(proced-auto-update-interval): Renamed from proced-timer-interval.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
99735
diff
changeset
|
700 (if proced-auto-update-flag "enabled" "disabled"))) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
701 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
702 ;;; Mark |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
703 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
704 (defun proced-mark (&optional count) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
705 "Mark the current (or next COUNT) processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
706 (interactive "p") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
707 (proced-do-mark t count)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
708 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
709 (defun proced-unmark (&optional count) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
710 "Unmark the current (or next COUNT) processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
711 (interactive "p") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
712 (proced-do-mark nil count)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
713 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
714 (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
|
715 "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
|
716 ;; 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
|
717 ;; 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
|
718 (interactive "p") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
719 (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
|
720 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
721 (defun proced-do-mark (mark &optional count) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
722 "Mark the current (or next COUNT) processes using MARK." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
723 (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
|
724 (let ((backward (< count 0)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
725 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
|
726 (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
|
727 (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
|
728 (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
|
729 (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
|
730 (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
|
731 (proced-move-to-goal-column))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
732 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
733 (defun proced-toggle-marks () |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
734 "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
|
735 (interactive) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
736 (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
|
737 buffer-read-only) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
738 (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
|
739 (goto-char (point-min)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
740 (while (not (eobp)) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
741 (cond ((looking-at mark-re) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
742 (proced-insert-mark nil)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
743 ((looking-at " ") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
744 (proced-insert-mark t)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
745 (t |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
746 (forward-line 1))))))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
747 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
748 (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
|
749 "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
|
750 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
|
751 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
|
752 (if backward (forward-line -1)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
753 (insert (if mark proced-marker-char ?\s)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
754 (delete-char 1) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
755 (unless backward (forward-line))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
756 |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
757 (defun proced-mark-all () |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
758 "Mark all processes. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
759 If `transient-mark-mode' is turned on and the region is active, |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
760 mark the region." |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
761 (interactive) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
762 (proced-do-mark-all t)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
763 |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
764 (defun proced-unmark-all () |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
765 "Unmark all processes. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
766 If `transient-mark-mode' is turned on and the region is active, |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
767 unmark the region." |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
768 (interactive) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
769 (proced-do-mark-all nil)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
770 |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
771 (defun proced-do-mark-all (mark) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
772 "Mark all processes using MARK. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
773 If `transient-mark-mode' is turned on and the region is active, |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
774 mark the region." |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
775 (let* ((count 0) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
776 (proced-marker-char (if mark proced-marker-char ?\s)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
777 (marker-re (proced-marker-regexp)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
778 end buffer-read-only) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
779 (save-excursion |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
780 (if (use-region-p) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
781 ;; Operate even on those lines that are only partially a part |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
782 ;; of region. This appears most consistent with |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
783 ;; `proced-move-to-goal-column'. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
784 (progn (setq end (save-excursion |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
785 (goto-char (region-end)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
786 (unless (looking-at "^") (forward-line)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
787 (point))) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
788 (goto-char (region-beginning)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
789 (unless (looking-at "^") (beginning-of-line))) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
790 (goto-char (point-min)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
791 (setq end (point-max))) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
792 (while (< (point) end) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
793 (unless (looking-at marker-re) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
794 (setq count (1+ count)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
795 (insert proced-marker-char) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
796 (delete-char 1)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
797 (forward-line)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
798 (proced-success-message (if mark "Marked" "Unmarked") count)))) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
799 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
800 (defun proced-mark-children (ppid &optional omit-ppid) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
801 "Mark child processes of process PPID. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
802 Also mark process PPID unless prefix OMIT-PPID is non-nil." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
803 (interactive (list (proced-pid-at-point) current-prefix-arg)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
804 (proced-mark-process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
805 (proced-filter-children proced-process-alist ppid omit-ppid))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
806 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
807 (defun proced-mark-parents (cpid &optional omit-cpid) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
808 "Mark parent processes of process CPID. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
809 Also mark CPID unless prefix OMIT-CPID is non-nil." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
810 (interactive (list (proced-pid-at-point) current-prefix-arg)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
811 (proced-mark-process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
812 (proced-filter-parents proced-process-alist cpid omit-cpid))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
813 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
814 (defun proced-mark-process-alist (process-alist &optional quiet) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
815 "Mark processes in PROCESS-ALIST. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
816 If QUIET is non-nil suppress status message." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
817 (let ((count 0)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
818 (if process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
819 (let (buffer-read-only) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
820 (save-excursion |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
821 (goto-char (point-min)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
822 (while (not (eobp)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
823 (when (assq (proced-pid-at-point) process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
824 (insert proced-marker-char) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
825 (delete-char 1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
826 (setq count (1+ count))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
827 (forward-line))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
828 (unless quiet |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
829 (proced-success-message "Marked" count)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
830 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
831 ;; 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
|
832 ;; 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
|
833 ;; include the current line, whereas `dired-mark' for negative args operates |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
834 ;; on the preceding lines. Here we are consistent with `dired-mark'. |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
835 (defun proced-omit-processes (&optional arg quiet) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
836 "Omit marked processes. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
837 With prefix ARG, omit that many lines starting with the current line. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
838 \(A negative argument omits backward.) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
839 If `transient-mark-mode' is turned on and the region is active, |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
840 omit the processes in region. |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
841 If QUIET is non-nil suppress status message. |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
842 Returns count of omitted lines." |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
843 (interactive "P") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
844 (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
|
845 (count 0) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
846 buffer-read-only) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
847 (cond ((use-region-p) ;; Omit active region |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
848 (let ((lines (count-lines (region-beginning) (region-end)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
849 (save-excursion |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
850 (goto-char (region-beginning)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
851 (while (< count lines) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
852 (proced-omit-process) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
853 (setq count (1+ count)))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
854 ((not arg) ;; Omit marked lines |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
855 (save-excursion |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
856 (goto-char (point-min)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
857 (while (and (not (eobp)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
858 (re-search-forward mark-re nil t)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
859 (proced-omit-process) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
860 (setq count (1+ count))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
861 ((< 0 arg) ;; Omit forward |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
862 (while (and (not (eobp)) (< count arg)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
863 (proced-omit-process) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
864 (setq count (1+ count)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
865 ((< arg 0) ;; Omit backward |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
866 (while (and (not (bobp)) (< count (- arg))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
867 (forward-line -1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
868 (proced-omit-process) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
869 (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
|
870 (unless (zerop count) (proced-move-to-goal-column)) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
871 (unless quiet (proced-success-message "Omitted" count)) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
872 count)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
873 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
874 (defun proced-omit-process () |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
875 "Omit process from listing point is on. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
876 Update `proced-process-alist' accordingly." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
877 (setq proced-process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
878 (assq-delete-all (proced-pid-at-point) proced-process-alist)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
879 (delete-region (line-beginning-position) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
880 (save-excursion (forward-line) (point)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
881 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
882 ;;; Filtering |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
883 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
884 (defun proced-filter (process-alist filter-list) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
885 "Apply FILTER-LIST to PROCESS-ALIST. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
886 Return the filtered process list." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
887 (if (symbolp filter-list) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
888 (setq filter-list (cdr (assq filter-list proced-filter-alist)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
889 (dolist (filter filter-list) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
890 (let (new-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
891 (cond ( ;; apply function to entire process list |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
892 (eq (car filter) 'fun-all) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
893 (setq new-alist (funcall (cdr filter) process-alist))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
894 ( ;; apply predicate to each list of attributes |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
895 (eq (car filter) 'function) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
896 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
897 (if (funcall (car filter) (cdr process)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
898 (push process new-alist)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
899 (t ;; apply predicate to specified attribute |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
900 (let ((fun (if (stringp (cdr filter)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
901 `(lambda (val) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
902 (string-match ,(cdr filter) val)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
903 (cdr filter))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
904 value) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
905 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
906 (setq value (cdr (assq (car filter) (cdr process)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
907 (if (and value (funcall fun value)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
908 (push process new-alist)))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
909 (setq process-alist new-alist))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
910 process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
911 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
912 (defun proced-filter-interactive (scheme) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
913 "Filter Proced buffer using SCHEME. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
914 When called interactively, an empty string means nil, i.e., no filtering. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
915 Set variable `proced-filter' to SCHEME. Revert listing." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
916 (interactive |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
917 (let ((scheme (completing-read "Filter: " |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
918 proced-filter-alist nil t))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
919 (list (if (string= "" scheme) nil (intern scheme))))) |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
920 ;; only update if necessary |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
921 (unless (eq proced-filter scheme) |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
922 (setq proced-filter scheme) |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
923 (proced-update t))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
924 |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
925 (defun proced-filter-parents (process-alist pid &optional omit-pid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
926 "For PROCESS-ALIST return list of parent processes of PID. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
927 This list includes PID unless OMIT-PID is non-nil." |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
928 (let ((parent-list (unless omit-pid (list (assq pid process-alist)))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
929 (process (assq pid process-alist)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
930 ppid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
931 (while (and (setq ppid (cdr (assq 'ppid (cdr process)))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
932 ;; Ignore a PPID that equals PID. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
933 (/= ppid pid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
934 ;; Accept only PPIDs that correspond to members in PROCESS-ALIST. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
935 (setq process (assq ppid process-alist))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
936 (setq pid ppid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
937 (push process parent-list)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
938 parent-list)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
939 |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
940 (defun proced-filter-children (process-alist ppid &optional omit-ppid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
941 "For PROCESS-ALIST return list of child processes of PPID. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
942 This list includes PPID unless OMIT-PPID is non-nil." |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
943 (let ((proced-temp-alist (proced-children-alist process-alist)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
944 new-alist) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
945 (dolist (pid (proced-children-pids ppid)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
946 (push (assq pid process-alist) new-alist)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
947 (if omit-ppid |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
948 (assq-delete-all ppid new-alist) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
949 new-alist))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
950 |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
951 ;;; Process tree |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
952 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
953 (defun proced-children-alist (process-alist) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
954 "Return children alist for PROCESS-ALIST. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
955 The children alist has elements (PPID PID1 PID2 ...). |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
956 PPID is a parent PID. PID1, PID2, ... are the child processes of PPID. |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
957 The children alist inherits the sorting order of PROCESS-ALIST. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
958 The list of children does not include grandchildren." |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
959 ;; The PPIDs inherit the sorting order of PROCESS-ALIST. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
960 (let ((process-tree (mapcar (lambda (a) (list (car a))) process-alist)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
961 ppid) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
962 (dolist (process process-alist) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
963 (setq ppid (cdr (assq 'ppid (cdr process)))) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
964 (if (and ppid |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
965 ;; Ignore a PPID that equals PID. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
966 (/= ppid (car process)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
967 ;; Accept only PPIDs that correspond to members in PROCESS-ALIST. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
968 (assq ppid process-alist)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
969 (let ((temp-alist process-tree) elt) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
970 (while (setq elt (pop temp-alist)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
971 (when (eq ppid (car elt)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
972 (setq temp-alist nil) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
973 (setcdr elt (cons (car process) (cdr elt)))))))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
974 ;; The child processes inherit the sorting order of PROCESS-ALIST. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
975 (setq process-tree |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
976 (mapcar (lambda (a) (cons (car a) (nreverse (cdr a)))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
977 process-tree)))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
978 |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
979 (defun proced-children-pids (ppid) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
980 "Return list of children PIDs of PPID (including PPID)." |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
981 (let ((cpids (cdr (assq ppid proced-temp-alist)))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
982 (if cpids |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
983 (cons ppid (apply 'append (mapcar 'proced-children-pids cpids))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
984 (list ppid)))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
985 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
986 (defun proced-process-tree (process-alist) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
987 "Return process tree for PROCESS-ALIST. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
988 It is an alist of alists where the car of each alist is a parent process |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
989 and the cdr is a list of child processes according to the ppid attribute |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
990 of these processes. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
991 The process tree inherits the sorting order of PROCESS-ALIST." |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
992 (let ((proced-temp-alist (proced-children-alist process-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
993 pid-alist proced-process-tree) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
994 (while (setq pid-alist (pop proced-temp-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
995 (push (proced-process-tree-internal pid-alist) proced-process-tree)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
996 (nreverse proced-process-tree))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
997 |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
998 (defun proced-process-tree-internal (pid-alist) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
999 "Helper function for `proced-process-tree'." |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1000 (let ((cpid-list (cdr pid-alist)) cpid-alist cpid) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1001 (while (setq cpid (car cpid-list)) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1002 (if (setq cpid-alist (assq cpid proced-temp-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1003 ;; Unprocessed part of process tree that needs to be |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1004 ;; analyzed recursively. |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1005 (progn |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1006 (setq proced-temp-alist |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1007 (assq-delete-all cpid proced-temp-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1008 (setcar cpid-list (proced-process-tree-internal cpid-alist))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1009 ;; We already processed this subtree and take it "as is". |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1010 (setcar cpid-list (assq cpid proced-process-tree)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1011 (setq proced-process-tree |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1012 (assq-delete-all cpid proced-process-tree))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1013 (pop cpid-list))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1014 pid-alist) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1015 |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1016 (defun proced-toggle-tree (arg) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1017 "Toggle the display of the process listing as process tree. |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1018 With prefix ARG, display as process tree if ARG is positive, otherwise |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1019 do not display as process tree. Sets the variable `proced-tree-flag'. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1020 |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1021 The process tree is generated from the selected processes in the |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1022 Proced buffer (that is, the processes in `proced-process-alist'). |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1023 All processes that do not have a parent process in this list |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1024 according to their ppid attribute become the root of a process tree. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1025 Each parent process is followed by its child processes. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1026 The process tree inherits the chosen sorting order of the process listing, |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1027 that is, child processes of the same parent process are sorted using |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1028 the selected sorting order." |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1029 (interactive (list (or current-prefix-arg 'toggle))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1030 (setq proced-tree-flag |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1031 (cond ((eq arg 'toggle) (not proced-tree-flag)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1032 (arg (> (prefix-numeric-value arg) 0)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1033 (t (not proced-tree-flag)))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1034 (proced-update) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1035 (message "Proced process tree display %s" |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1036 (if proced-tree-flag "enabled" "disabled"))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1037 |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1038 (defun proced-tree (process-alist) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1039 "Rearrange PROCESS-ALIST as process tree. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1040 If `proced-tree-flag' is non-nil, rearrange PROCESS-ALIST such that |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1041 every processes is followed by its child processes. Each process |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1042 gets a tree attribute that specifies the depth of the process in the tree. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1043 A root process is a process with no parent within PROCESS-ALIST according |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1044 to its value of the ppid attribute. It has depth 0. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1045 |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1046 If `proced-tree-flag' is nil, remove the tree attribute. |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1047 Return the rearranged process list." |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1048 (if proced-tree-flag |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1049 ;; add tree attribute |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1050 (let ((process-tree (proced-process-tree process-alist)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1051 (proced-tree-depth 0) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1052 (proced-temp-alist process-alist) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1053 proced-process-tree pt) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1054 (while (setq pt (pop process-tree)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1055 (proced-tree-insert pt)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1056 (nreverse proced-process-tree)) |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1057 ;; remove tree attribute |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1058 (let ((process-alist process-alist)) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1059 (while process-alist |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1060 (setcar process-alist |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1061 (assq-delete-all 'tree (car process-alist))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1062 (pop process-alist))) |
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1063 process-alist)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1064 |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1065 (defun proced-tree-insert (process-tree) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1066 "Helper function for `proced-tree'." |
100752
3bd2bab6d80f
(proced-temp-alist): Renamed from variable proced-children-alist.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100743
diff
changeset
|
1067 (let ((pprocess (assq (car process-tree) proced-temp-alist))) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1068 (push (append (list (car pprocess)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1069 (list (cons 'tree proced-tree-depth)) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1070 (cdr pprocess)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1071 proced-process-tree) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1072 (if (cdr process-tree) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1073 (let ((proced-tree-depth (1+ proced-tree-depth))) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1074 (mapc 'proced-tree-insert (cdr process-tree)))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1075 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1076 ;; Refining |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1077 |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1078 ;; Filters are used to select the processes in a new listing. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1079 ;; Refiners are used to narrow down further (interactively) the processes |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1080 ;; in an existing listing. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1081 |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1082 (defun proced-refine (&optional event) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1083 "Refine Proced listing by comparing with the attribute value at point. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1084 Optional EVENT is the location of the Proced field. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1085 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1086 Refinement is controlled by the REFINER defined for each attribute ATTR |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1087 in `proced-grammar-alist'. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1088 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1089 If REFINER is a list of flags and point is on a process's value of ATTR, |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1090 this command compares the value of ATTR of every process with the value |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1091 of ATTR of the process at the position of point. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1092 |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1093 The predicate for the comparison of two ATTR values is defined |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1094 in `proced-grammar-alist'. For each return value of the predicate |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1095 a refine flag is defined in `proced-grammar-alist'. One can select |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1096 processes for which the value of ATTR is \"less than\", \"equal\", |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1097 and / or \"larger\" than ATTR of the process point is on. A process |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1098 is included in the new listing if the refine flag for the corresponding |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1099 return value of the predicate is non-nil. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1100 The help-echo string for `proced-refine' uses \"+\" or \"-\" to indicate |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1101 the current values of these refine flags. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1102 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1103 If REFINER is a cons pair (FUNCTION . HELP-ECHO), FUNCTION is called |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1104 with one argument, the PID of the process at the position of point. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1105 The function must return a list of PIDs that is used for the refined |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1106 listing. HELP-ECHO is a string that is shown when mouse is over this field. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1107 |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1108 This command refines an already existing process listing generated initially |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1109 based on the value of the variable `proced-filter'. It does not change |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1110 this variable. It does not revert the listing. If you frequently need |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1111 a certain refinement, consider defining a new filter in `proced-filter-alist'." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1112 (interactive (list last-input-event)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1113 (if event (posn-set-point (event-end event))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1114 (let ((key (get-text-property (point) 'proced-key)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1115 (pid (get-text-property (point) 'proced-pid))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1116 (if (and key pid) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1117 (let* ((grammar (assq key proced-grammar-alist)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1118 (refiner (nth 7 grammar))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1119 (when refiner |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1120 (cond ((functionp (car refiner)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1121 (setq proced-process-alist (funcall (car refiner) pid))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1122 ((consp refiner) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1123 (let ((predicate (nth 4 grammar)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1124 (ref (cdr (assq key (cdr (assq pid proced-process-alist))))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1125 val new-alist) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1126 (dolist (process proced-process-alist) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1127 (setq val (funcall predicate (cdr (assq key (cdr process))) ref)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1128 (if (cond ((not val) (nth 2 refiner)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1129 ((eq val 'equal) (nth 1 refiner)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1130 (val (car refiner))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1131 (push process new-alist))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1132 (setq proced-process-alist new-alist)))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1133 ;; Do not revert listing. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1134 (proced-update))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1135 (message "No refiner defined here.")))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1136 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1137 ;; Proced predicates for sorting and filtering are based on a three-valued |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1138 ;; logic: |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1139 ;; Predicates take two arguments P1 and P2, the corresponding attribute |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1140 ;; values of two processes. Predicates should return 'equal if P1 has |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1141 ;; same rank like P2. Any other non-nil value says that P1 is "less than" P2, |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1142 ;; or nil if not. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1143 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1144 (defun proced-< (num1 num2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1145 "Return t if NUM1 less than NUM2. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1146 Return `equal' if NUM1 equals NUM2. Return nil if NUM1 greater than NUM2." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1147 (if (= num1 num2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1148 'equal |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1149 (< num1 num2))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1150 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1151 (defun proced-string-lessp (s1 s2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1152 "Return t if string S1 is less than S2 in lexicographic order. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1153 Return `equal' if S1 and S2 have identical contents. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1154 Return nil otherwise." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1155 (if (string= s1 s2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1156 'equal |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1157 (string-lessp s1 s2))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1158 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1159 (defun proced-time-lessp (t1 t2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1160 "Return t if time value T1 is less than time value T2. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1161 Return `equal' if T1 equals T2. Return nil otherwise." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1162 (with-decoded-time-value ((high1 low1 micro1 t1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1163 (high2 low2 micro2 t2)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1164 (cond ((< high1 high2)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1165 ((< high2 high1) nil) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1166 ((< low1 low2)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1167 ((< low2 low1) nil) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1168 ((< micro1 micro2)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1169 ((< micro2 micro1) nil) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1170 (t 'equal)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1171 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1172 ;;; Sorting |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1173 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1174 (defsubst proced-xor (b1 b2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1175 "Return the logical exclusive or of args B1 and B2." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1176 (and (or b1 b2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1177 (not (and b1 b2)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1178 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1179 (defun proced-sort-p (p1 p2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1180 "Predicate for sorting processes P1 and P2." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1181 (if (not (cdr proced-sort-internal)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1182 ;; only one predicate: fast scheme |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1183 (let* ((sorter (car proced-sort-internal)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1184 (k1 (cdr (assq (car sorter) (cdr p1)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1185 (k2 (cdr (assq (car sorter) (cdr p2))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1186 ;; if the attributes are undefined, we should really abort sorting |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1187 (if (and k1 k2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1188 (proced-xor (funcall (nth 1 sorter) k1 k2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1189 (nth 2 sorter)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1190 (let ((sort-list proced-sort-internal) sorter predicate k1 k2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1191 (catch 'done |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1192 (while (setq sorter (pop sort-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1193 (setq k1 (cdr (assq (car sorter) (cdr p1))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1194 k2 (cdr (assq (car sorter) (cdr p2))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1195 predicate |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1196 (if (and k1 k2) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1197 (funcall (nth 1 sorter) k1 k2))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1198 (if (not (eq predicate 'equal)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1199 (throw 'done (proced-xor predicate (nth 2 sorter))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1200 (eq t predicate))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1201 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1202 (defun proced-sort (process-alist sorter descend) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1203 "Sort PROCESS-ALIST using scheme SORTER. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1204 SORTER is a scheme like `proced-sort'. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1205 DESCEND is non-nil if the first element of SORTER is sorted |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1206 in descending order. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1207 Return the sorted process list." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1208 ;; translate SORTER into a list of lists (KEY PREDICATE REVERSE) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1209 (setq proced-sort-internal |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1210 (mapcar (lambda (arg) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1211 (let ((grammar (assq arg proced-grammar-alist))) |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1212 (unless (nth 4 grammar) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1213 (error "Attribute %s not sortable" (car grammar))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1214 (list arg (nth 4 grammar) (nth 5 grammar)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1215 (cond ((listp sorter) sorter) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1216 ((and (symbolp sorter) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1217 (nth 6 (assq sorter proced-grammar-alist)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1218 ((symbolp sorter) (list sorter)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1219 (t (error "Sorter undefined %s" sorter))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1220 (if proced-sort-internal |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1221 (progn |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1222 ;; splice DESCEND into the list |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1223 (setcar proced-sort-internal |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1224 (list (caar proced-sort-internal) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1225 (nth 1 (car proced-sort-internal)) descend)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1226 (sort process-alist 'proced-sort-p)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1227 process-alist)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1228 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1229 (defun proced-sort-interactive (scheme &optional arg) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1230 "Sort Proced buffer using SCHEME. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1231 When called interactively, an empty string means nil, i.e., no sorting. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1232 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1233 Prefix ARG controls sort order: |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1234 - If prefix ARG is positive (negative), sort in ascending (descending) order. |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1235 - If ARG is nil or 'no-arg and SCHEME is equal to the previous sorting scheme, |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1236 reverse the sorting order. |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1237 - If ARG is nil or 'no-arg and SCHEME differs from the previous sorting scheme, |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1238 adopt the sorting order defined for SCHEME in `proced-grammar-alist'. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1239 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1240 Set variable `proced-sort' to SCHEME. The current sort scheme is displayed |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1241 in the mode line, using \"+\" or \"-\" for ascending or descending order." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1242 (interactive |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1243 (let* (choices |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1244 (scheme (completing-read "Sort attribute: " |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1245 (dolist (grammar proced-grammar-alist choices) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1246 (if (nth 4 grammar) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1247 (push (list (car grammar)) choices))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1248 nil t))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1249 (list (if (string= "" scheme) nil (intern scheme)) |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1250 ;; like 'toggle in `define-derived-mode' |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1251 (or current-prefix-arg 'no-arg)))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1252 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1253 (setq proced-descend |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1254 ;; If `proced-sort-interactive' is called repeatedly for the same |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1255 ;; sort key, the sort order is reversed. |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1256 (cond ((and (eq arg 'no-arg) (equal proced-sort scheme)) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1257 (not proced-descend)) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1258 ((eq arg 'no-arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1259 (nth 5 (assq (if (consp scheme) (car scheme) scheme) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1260 proced-grammar-alist))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1261 (arg (< (prefix-numeric-value arg) 0)) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1262 ((equal proced-sort scheme) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1263 (not proced-descend)) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1264 (t (nth 5 (assq (if (consp scheme) (car scheme) scheme) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1265 proced-grammar-alist)))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1266 proced-sort scheme) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1267 (proced-update)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1268 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1269 (defun proced-sort-pcpu (&optional arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1270 "Sort Proced buffer by percentage CPU time (%CPU). |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1271 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1272 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1273 (proced-sort-interactive 'pcpu arg)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1274 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1275 (defun proced-sort-pmem (&optional arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1276 "Sort Proced buffer by percentage memory usage (%MEM). |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1277 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1278 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1279 (proced-sort-interactive 'pmem arg)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1280 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1281 (defun proced-sort-pid (&optional arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1282 "Sort Proced buffer by PID. |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1283 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1284 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1285 (proced-sort-interactive 'pid arg)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1286 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1287 (defun proced-sort-start (&optional arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1288 "Sort Proced buffer by time the command started (START). |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1289 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1290 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1291 (proced-sort-interactive 'start arg)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1292 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1293 (defun proced-sort-time (&optional arg) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1294 "Sort Proced buffer by CPU time (TIME). |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1295 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1296 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1297 (proced-sort-interactive 'time arg)) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1298 |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1299 (defun proced-sort-user (&optional arg) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1300 "Sort Proced buffer by USER. |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1301 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1302 (interactive (list (or current-prefix-arg 'no-arg))) |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1303 (proced-sort-interactive 'user arg)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1304 |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1305 (defun proced-sort-header (event &optional arg) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1306 "Sort Proced listing based on an attribute. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1307 EVENT is a mouse event with starting position in the header line. |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
1308 It is converted to the corresponding attribute key. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1309 This command updates the variable `proced-sort'. |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1310 Prefix ARG controls sort order, see `proced-sort-interactive'." |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1311 (interactive (list last-input-event (or last-prefix-arg 'no-arg))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1312 (let ((start (event-start event)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1313 col key) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1314 (save-selected-window |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1315 (select-window (posn-window start)) |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1316 (setq col (+ (1- (car (posn-actual-col-row start))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1317 (window-hscroll))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1318 (when (and (<= 0 col) (< col (length proced-header-line))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1319 (setq key (get-text-property col 'proced-key proced-header-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1320 (if key |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1321 (proced-sort-interactive key arg) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1322 (message "No sorter defined here.")))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1323 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1324 ;;; Formating |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1325 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1326 (defun proced-format-time (time) |
99726
38b176122f90
(proced, proced-format-time): Doc fixes.
Glenn Morris <rgm@gnu.org>
parents:
98249
diff
changeset
|
1327 "Format time interval TIME." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1328 (let* ((ftime (float-time time)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1329 (days (truncate ftime 86400)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1330 (ftime (mod ftime 86400)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1331 (hours (truncate ftime 3600)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1332 (ftime (mod ftime 3600)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1333 (minutes (truncate ftime 60)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1334 (seconds (mod ftime 60))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1335 (cond ((< 0 days) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1336 (format "%d-%02d:%02d:%02d" days hours minutes seconds)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1337 ((< 0 hours) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1338 (format "%02d:%02d:%02d" hours minutes seconds)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1339 (t |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1340 (format "%02d:%02d" minutes seconds))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1341 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1342 (defun proced-format-start (start) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1343 "Format time START. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1344 The return string is always 6 characters wide." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1345 (let ((d-start (decode-time start)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1346 (d-current (decode-time))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1347 (cond ( ;; process started in previous years |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1348 (< (nth 5 d-start) (nth 5 d-current)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1349 (format-time-string " %Y" start)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1350 ;; process started today |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1351 ((and (= (nth 3 d-start) (nth 3 d-current)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1352 (= (nth 4 d-start) (nth 4 d-current))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1353 (format-time-string " %H:%M" start)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1354 (t ;; process started this year |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1355 (format-time-string "%b %e" start))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1356 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1357 (defun proced-format-ttname (ttname) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1358 "Format attribute TTNAME, omitting path \"/dev/\"." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1359 ;; Does this work for all systems? |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1360 (substring ttname (if (string-match "\\`/dev/" ttname) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1361 (match-end 0) 0))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1362 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1363 (defun proced-format-tree (tree) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1364 "Format attribute TREE." |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1365 (concat (make-string tree ?\s) (number-to-string tree))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1366 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1367 ;; Proced assumes that every process occupies only one line in the listing. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1368 (defun proced-format-args (args) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1369 "Format attribute ARGS. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1370 Replace newline characters by \"^J\" (two characters)." |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1371 (replace-regexp-in-string "\n" "^J" args)) |
95168
a031e38a88d4
(proced-header-line): New variable and new function.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
95135
diff
changeset
|
1372 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1373 (defun proced-format (process-alist format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1374 "Display PROCESS-ALIST using FORMAT." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1375 (if (symbolp format) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1376 (setq format (cdr (assq format proced-format-alist)))) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1377 |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1378 ;; Not all systems give us all attributes. We take `emacs-pid' as a |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1379 ;; representative process PID. If FORMAT contains a list of alternative |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1380 ;; attributes, we take the first attribute that is non-nil for `emacs-pid'. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1381 ;; If none of the alternatives is non-nil, the attribute is ignored |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1382 ;; in the listing. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1383 (let ((standard-attributes |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1384 (car (proced-process-attributes (list (emacs-pid))))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1385 new-format fmi) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1386 (if (and proced-tree-flag |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1387 (assq 'ppid standard-attributes)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1388 (push (cons 'tree 0) standard-attributes)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1389 (dolist (fmt format) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1390 (if (symbolp fmt) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1391 (if (assq fmt standard-attributes) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1392 (push fmt new-format)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1393 (while (setq fmi (pop fmt)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1394 (when (assq fmi standard-attributes) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1395 (push fmi new-format) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1396 (setq fmt nil))))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1397 (setq format (nreverse new-format))) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1398 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1399 (insert (make-string (length process-alist) ?\n)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1400 (let ((whitespace " ") (unknown "?") |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1401 (sort-key (if (consp proced-sort) (car proced-sort) proced-sort)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1402 header-list grammar) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1403 ;; Loop over all attributes |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1404 (while (setq grammar (assq (pop format) proced-grammar-alist)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1405 (let* ((key (car grammar)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1406 (fun (cond ((stringp (nth 2 grammar)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1407 `(lambda (arg) (format ,(nth 2 grammar) arg))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1408 ((not (nth 2 grammar)) 'identity) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1409 ( t (nth 2 grammar)))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1410 (whitespace (if format whitespace "")) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1411 ;; Text properties: |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1412 ;; We use the text property `proced-key' to store in each |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1413 ;; field the corresponding key. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1414 ;; Of course, the sort predicate appearing in help-echo |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1415 ;; is only part of the story. But it gives the main idea. |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1416 (hprops |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1417 (if (nth 4 grammar) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1418 (let ((descend (if (eq key sort-key) proced-descend (nth 5 grammar)))) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1419 `(proced-key ,key mouse-face highlight |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1420 help-echo ,(format proced-header-help-echo |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1421 (if descend "-" "+") |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1422 (nth 1 grammar) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1423 (if descend "descending" "ascending")))))) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1424 (refiner (nth 7 grammar)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1425 (fprops |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1426 (cond ((functionp (car refiner)) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1427 `(proced-key ,key mouse-face highlight |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1428 help-echo ,(format "mouse-2, RET: %s" |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1429 (nth 1 refiner)))) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1430 ((consp refiner) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1431 `(proced-key ,key mouse-face highlight |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1432 help-echo ,(format "mouse-2, RET: refine by attribute %s %s" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1433 (nth 1 grammar) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1434 (mapconcat (lambda (s) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1435 (if s "+" "-")) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1436 refiner "")))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1437 value) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1438 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1439 ;; highlight the header of the sort column |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1440 (if (eq key sort-key) |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1441 (setq hprops (append '(face proced-sort-header) hprops))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1442 (goto-char (point-min)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1443 (cond ( ;; fixed width of output field |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1444 (numberp (nth 3 grammar)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1445 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1446 (end-of-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1447 (setq value (cdr (assq key (cdr process)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1448 (insert (if value |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1449 (apply 'propertize (funcall fun value) fprops) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1450 (format (concat "%" (number-to-string (nth 3 grammar)) "s") |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1451 unknown)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1452 whitespace) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1453 (forward-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1454 (push (format (concat "%" (number-to-string (nth 3 grammar)) "s") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1455 (apply 'propertize (nth 1 grammar) hprops)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1456 header-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1457 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1458 ( ;; last field left-justified |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1459 (and (not format) (eq 'left (nth 3 grammar))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1460 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1461 (end-of-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1462 (setq value (cdr (assq key (cdr process)))) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1463 (insert (if value (apply 'propertize (funcall fun value) fprops) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1464 unknown)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1465 (forward-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1466 (push (apply 'propertize (nth 1 grammar) hprops) header-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1467 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1468 (t ;; calculated field width |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1469 (let ((width (length (nth 1 grammar))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1470 field-list value) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1471 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1472 (setq value (cdr (assq key (cdr process)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1473 (if value |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1474 (setq value (apply 'propertize (funcall fun value) fprops) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1475 width (max width (length value)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1476 field-list (cons value field-list)) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1477 (push unknown field-list) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1478 (setq width (max width (length unknown))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1479 (let ((afmt (concat "%" (if (eq 'left (nth 3 grammar)) "-" "") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1480 (number-to-string width) "s"))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1481 (push (format afmt (apply 'propertize (nth 1 grammar) hprops)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1482 header-list) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1483 (dolist (value (nreverse field-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1484 (end-of-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1485 (insert (format afmt value) whitespace) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1486 (forward-line)))))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1487 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1488 ;; final cleanup |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1489 (goto-char (point-min)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1490 (dolist (process process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1491 ;; We use the text property `proced-pid' to store in each line |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1492 ;; the corresponding pid |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1493 (put-text-property (point) (line-end-position) 'proced-pid (car process)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1494 (forward-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1495 ;; Set header line |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1496 (setq proced-header-line |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1497 (mapconcat 'identity (nreverse header-list) whitespace)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1498 (if (string-match "[ \t]+$" proced-header-line) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1499 (setq proced-header-line (substring proced-header-line 0 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1500 (match-beginning 0)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1501 ;; (delete-trailing-whitespace) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1502 (goto-char (point-min)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1503 (while (re-search-forward "[ \t\r]+$" nil t) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1504 (delete-region (match-beginning 0) (match-end 0))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1505 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1506 (defun proced-format-interactive (scheme &optional revert) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1507 "Format Proced buffer using SCHEME. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1508 When called interactively, an empty string means nil, i.e., no formatting. |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1509 Set variable `proced-format' to SCHEME. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1510 With prefix REVERT non-nil revert listing." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1511 (interactive |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1512 (let ((scheme (completing-read "Format: " |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1513 proced-format-alist nil t))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1514 (list (if (string= "" scheme) nil (intern scheme)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1515 current-prefix-arg))) |
98172
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1516 ;; only update if necessary |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1517 (when (or (not (eq proced-format scheme)) revert) |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1518 (setq proced-format scheme) |
87d64c3d48ac
(proced-mark-face, proced-marked-face)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98162
diff
changeset
|
1519 (proced-update revert))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1520 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1521 ;; generate listing |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1522 |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1523 (defun proced-process-attributes (&optional pid-list) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1524 "Return alist of attributes for each system process. |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1525 This alist can be customized via `proced-custom-attributes'. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1526 Optional arg PID-LIST is a list of PIDs of system process that are analyzed. |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1527 If no attributes are known for a process (possibly because it already died) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1528 the process is ignored." |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1529 ;; Should we make it customizable whether processes with empty attribute |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1530 ;; lists are ignored? When would such processes be of interest? |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1531 (let (process-alist attributes attr) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1532 (dolist (pid (or pid-list (list-system-processes)) process-alist) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1533 (when (setq attributes (system-process-attributes pid)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1534 (setq attributes (cons (cons 'pid pid) attributes)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1535 (dolist (fun proced-custom-attributes) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1536 (if (setq attr (funcall fun attributes)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1537 (push attr attributes))) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1538 (push (cons pid attributes) process-alist))))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1539 |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1540 (defun proced-update (&optional revert quiet) |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
1541 "Update the Proced process information. Preserves point and marks. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1542 With prefix REVERT non-nil, revert listing. |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1543 Suppress status information if QUIET is nil. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1544 After updating a displayed Proced buffer run the normal hook |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1545 `proced-post-display-hook'." |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
1546 ;; This is the main function that generates and updates the process listing. |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1547 (interactive "P") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1548 (setq revert (or revert (not proced-process-alist))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1549 (or quiet (message (if revert "Updating process information..." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1550 "Updating process display..."))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1551 (if revert ;; evaluate all processes |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1552 (setq proced-process-alist (proced-process-attributes))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1553 ;; filtering and sorting |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1554 (setq proced-process-alist |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1555 (proced-sort (proced-filter proced-process-alist proced-filter) |
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1556 proced-sort proced-descend)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1557 |
100735
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1558 ;; display as process tree? |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1559 (setq proced-process-alist |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1560 (proced-tree proced-process-alist)) |
8ec0632b600c
(proced-grammar-alist): Allow predicate nil. New attribute tree.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100570
diff
changeset
|
1561 |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1562 ;; It is useless to keep undo information if we revert, filter, or |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1563 ;; refine the listing so that `proced-process-alist' has changed. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1564 ;; We could keep the undo information if we only re-sort the buffer. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1565 ;; Would that be useful? Re-re-sorting is easy, too. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1566 (if (consp buffer-undo-list) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1567 (setq buffer-undo-list nil)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1568 (let ((buffer-undo-list t) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1569 ;; If point is on a field, we try to return point to that field. |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1570 ;; Otherwise we try to return to the same column |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1571 (old-pos (let ((pid (proced-pid-at-point)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1572 (key (get-text-property (point) 'proced-key))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1573 (list pid key ; can both be nil |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1574 (if key |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1575 (if (get-text-property (1- (point)) 'proced-key) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1576 (- (point) (previous-single-property-change |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1577 (point) 'proced-key)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1578 0) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1579 (current-column))))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1580 buffer-read-only mp-list) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1581 ;; remember marked processes (whatever the mark was) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1582 (goto-char (point-min)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1583 (while (re-search-forward "^\\(\\S-\\)" nil t) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1584 (push (cons (save-match-data (proced-pid-at-point)) |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
1585 (match-string-no-properties 1)) mp-list)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1586 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1587 ;; generate listing |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1588 (erase-buffer) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1589 (proced-format proced-process-alist proced-format) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1590 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1591 (while (not (eobp)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1592 (insert " ") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1593 (forward-line)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1594 (setq proced-header-line (concat " " proced-header-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1595 (if revert (set-buffer-modified-p nil)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1596 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1597 ;; set `goal-column' |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1598 (let ((grammar (assq proced-goal-attribute proced-grammar-alist))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1599 (setq goal-column ;; set to nil if no match |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1600 (if (and grammar |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1601 (not (zerop (buffer-size))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1602 (string-match (regexp-quote (nth 1 grammar)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1603 proced-header-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1604 (if (nth 3 grammar) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1605 (match-beginning 0) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1606 (match-end 0))))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1607 |
98249
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
1608 ;; Restore process marks and buffer position (if possible). |
538f59dc1be8
(proced-grammar-alist, proced-custom-attributes)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98172
diff
changeset
|
1609 ;; Sometimes this puts point in the middle of the proced buffer |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1610 ;; where it is not interesting. Is there a better / more flexible solution? |
95135
33ea0b47d336
(proced-goal-header-re): Renamed from proced-procname-column-regexp.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94678
diff
changeset
|
1611 (goto-char (point-min)) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1612 (let (pid mark new-pos) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1613 (if (or mp-list (car old-pos)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1614 (while (not (eobp)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1615 (setq pid (proced-pid-at-point)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1616 (when (setq mark (assq pid mp-list)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1617 (insert (cdr mark)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1618 (delete-char 1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1619 (beginning-of-line)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1620 (when (eq (car old-pos) pid) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1621 (if (nth 1 old-pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1622 (let ((limit (line-end-position)) pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1623 (while (and (not new-pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1624 (setq pos (next-property-change (point) nil limit))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1625 (goto-char pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1626 (when (eq (nth 1 old-pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1627 (get-text-property (point) 'proced-key)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1628 (forward-char (min (nth 2 old-pos) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1629 (- (next-property-change (point)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1630 (point)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1631 (setq new-pos (point)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1632 (unless new-pos |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1633 ;; we found the process, but the field of point |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1634 ;; is not listed anymore |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1635 (setq new-pos (proced-move-to-goal-column)))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1636 (setq new-pos (min (+ (line-beginning-position) (nth 2 old-pos)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1637 (line-end-position))))) |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1638 (forward-line))) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1639 (if new-pos |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1640 (goto-char new-pos) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1641 (goto-char (point-min)) |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1642 (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
|
1643 ;; update modeline |
98162
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1644 ;; Does the long `mode-name' clutter the modeline? It would be nice |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1645 ;; to have some other location for displaying the values of the various |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1646 ;; flags that affect the behavior of proced (flags one might want |
d5c5ea23d8ea
(proced-sort-header): New face.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
98064
diff
changeset
|
1647 ;; to change on the fly). Where?? |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1648 (setq mode-name |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1649 (concat "Proced" |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1650 (if proced-filter |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1651 (concat ": " (symbol-name proced-filter)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1652 "") |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1653 (if proced-sort |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1654 (let* ((key (if (consp proced-sort) (car proced-sort) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1655 proced-sort)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1656 (grammar (assq key proced-grammar-alist))) |
100422
b3edbaf87682
(proced-grammar-alist): Allow refiner elements that
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100421
diff
changeset
|
1657 (concat " by " (if proced-descend "-" "+") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1658 (nth 1 grammar))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1659 ""))) |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
1660 (force-mode-line-update) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1661 ;; run `proced-post-display-hook' only for a displayed buffer. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1662 (if (get-buffer-window) (run-hooks 'proced-post-display-hook)) |
94621
97585dd63d91
(proced-command-alist): Fix system-type values. Fix defcustom.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94109
diff
changeset
|
1663 ;; done |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1664 (or quiet (input-pending-p) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1665 (message (if revert "Updating process information...done." |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1666 "Updating process display...done."))))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1667 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1668 (defun proced-revert (&rest args) |
100424
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1669 "Reevaluate the process listing based on the currently running processes. |
586161dec886
(proced-sort-interactive, proced-sort-pcpu)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100422
diff
changeset
|
1670 Preserves point and marks." |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1671 (proced-update t)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1672 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1673 (defun proced-send-signal (&optional signal) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1674 "Send a SIGNAL to the marked processes. |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1675 If no process is marked, operate on current process. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1676 SIGNAL may be a string (HUP, INT, TERM, etc.) or a number. |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1677 If SIGNAL is nil display marked processes and query interactively for SIGNAL. |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1678 After sending the signal, this command runs the normal hook |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1679 `proced-after-send-signal-hook'." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1680 (interactive) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1681 (let ((regexp (proced-marker-regexp)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1682 process-alist) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1683 ;; collect marked processes |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1684 (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1685 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1686 (while (re-search-forward regexp nil t) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1687 (push (cons (proced-pid-at-point) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1688 ;; How much info should we collect here? |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1689 (buffer-substring-no-properties |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1690 (+ 2 (line-beginning-position)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1691 (line-end-position))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1692 process-alist))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1693 (setq process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1694 (if process-alist |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1695 (nreverse process-alist) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1696 ;; take current process |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1697 (list (cons (proced-pid-at-point) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1698 (buffer-substring-no-properties |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1699 (+ 2 (line-beginning-position)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1700 (line-end-position)))))) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1701 (unless signal |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1702 ;; Display marked processes (code taken from `dired-mark-pop-up'). |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1703 (let ((bufname " *Marked Processes*") |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1704 (header-line (substring-no-properties proced-header-line))) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1705 (with-current-buffer (get-buffer-create bufname) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1706 (setq truncate-lines t |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1707 proced-header-line header-line ; inherit header line |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1708 header-line-format '(:eval (proced-header-line))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1709 (add-hook 'post-command-hook 'force-mode-line-update nil t) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1710 (erase-buffer) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1711 (dolist (process process-alist) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1712 (insert " " (cdr process) "\n")) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1713 (save-window-excursion |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1714 (pop-to-buffer (current-buffer)) |
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1715 (fit-window-to-buffer (get-buffer-window) nil 1) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1716 (let* ((completion-ignore-case t) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1717 (pnum (if (= 1 (length process-alist)) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1718 "1 process" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1719 (format "%d processes" (length process-alist)))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1720 ;; The following is an ugly hack. Is there a better way |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1721 ;; to help people like me to remember the signals and |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1722 ;; their meanings? |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1723 (tmp (completing-read (concat "Send signal [" pnum |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1724 "] (default TERM): ") |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1725 proced-signal-list |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1726 nil nil nil nil "TERM"))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1727 (setq signal (if (string-match "^\\(\\S-+\\)\\s-" tmp) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1728 (match-string 1 tmp) tmp)))))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1729 ;; send signal |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1730 (let ((count 0) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1731 failures) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1732 ;; Why not always use `signal-process'? See |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1733 ;; http://lists.gnu.org/archive/html/emacs-devel/2008-03/msg02955.html |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1734 (if (functionp proced-signal-function) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1735 ;; use built-in `signal-process' |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1736 (let ((signal (if (stringp signal) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1737 (if (string-match "\\`[0-9]+\\'" signal) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1738 (string-to-number signal) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1739 (make-symbol signal)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1740 signal))) ; number |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1741 (dolist (process process-alist) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1742 (condition-case err |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1743 (if (zerop (funcall |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1744 proced-signal-function (car process) signal)) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1745 (setq count (1+ count)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1746 (proced-log "%s\n" (cdr process)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1747 (push (cdr process) failures)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1748 (error ; catch errors from failed signals |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1749 (proced-log "%s\n" err) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1750 (proced-log "%s\n" (cdr process)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1751 (push (cdr process) failures))))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1752 ;; use external system call |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1753 (let ((signal (concat "-" (if (numberp signal) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1754 (number-to-string signal) signal)))) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1755 (dolist (process process-alist) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1756 (with-temp-buffer |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1757 (condition-case err |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1758 (if (zerop (call-process |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1759 proced-signal-function nil t nil |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1760 signal (number-to-string (car process)))) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1761 (setq count (1+ count)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1762 (proced-log (current-buffer)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1763 (proced-log "%s\n" (cdr process)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1764 (push (cdr process) failures)) |
100847
883cbe72dc04
(proced-grammar-alist): Refiner can be a list (function help-echo)
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
100763
diff
changeset
|
1765 (error ; catch errors from failed signals |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1766 (proced-log (current-buffer)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1767 (proced-log "%s\n" (cdr process)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1768 (push (cdr process) failures))))))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1769 (if failures |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1770 ;; Proced error message are not always very precise. |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1771 ;; Can we issue a useful one-line summary in the |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1772 ;; message area (using FAILURES) if only one signal failed? |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1773 (proced-log-summary |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1774 signal |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1775 (format "%d of %d signal%s failed" |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1776 (length failures) (length process-alist) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1777 (if (= 1 (length process-alist)) "" "s"))) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1778 (proced-success-message "Sent signal to" count))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1779 ;; final clean-up |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1780 (run-hooks 'proced-after-send-signal-hook)))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1781 |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1782 ;; similar to `dired-why' |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1783 (defun proced-why () |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1784 "Pop up a buffer with error log output from Proced. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1785 A group of errors from a single command ends with a formfeed. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1786 Thus, use \\[backward-page] to find the beginning of a group of errors." |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1787 (interactive) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1788 (if (get-buffer proced-log-buffer) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1789 (save-selected-window |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1790 ;; move `proced-log-buffer' to the front of the buffer list |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1791 (select-window (display-buffer (get-buffer proced-log-buffer))) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1792 (setq truncate-lines t) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1793 (set-buffer-modified-p nil) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1794 (setq buffer-read-only t) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1795 (goto-char (point-max)) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1796 (forward-line -1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1797 (backward-page 1) |
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1798 (recenter 0)))) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1799 |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1800 ;; similar to `dired-log' |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1801 (defun proced-log (log &rest args) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1802 "Log a message or the contents of a buffer. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1803 If LOG is a string and there are more args, it is formatted with |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1804 those ARGS. Usually the LOG string ends with a \\n. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1805 End each bunch of errors with (proced-log t signal): |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1806 this inserts the current time, buffer and signal at the start of the page, |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1807 and \f (formfeed) at the end." |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1808 (let ((obuf (current-buffer))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1809 (with-current-buffer (get-buffer-create proced-log-buffer) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1810 (goto-char (point-max)) |
98064
9ec9b806fd81
Require time-date.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97524
diff
changeset
|
1811 (let (buffer-read-only) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1812 (cond ((stringp log) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1813 (insert (if args |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1814 (apply 'format log args) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1815 log))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1816 ((bufferp log) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1817 (insert-buffer-substring log)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1818 ((eq t log) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1819 (backward-page 1) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1820 (unless (bolp) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1821 (insert "\n")) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1822 (insert (current-time-string) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1823 "\tBuffer `" (buffer-name obuf) "', " |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1824 (format "signal `%s'\n" (car args))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1825 (goto-char (point-max)) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1826 (insert "\f\n"))))))) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1827 |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1828 ;; similar to `dired-log-summary' |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1829 (defun proced-log-summary (signal string) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1830 "State a summary of SIGNAL's failures, in echo area and log buffer. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1831 STRING is an overall summary of the failures." |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1832 (message "Signal %s: %s--type ? for details" signal string) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1833 ;; Log a summary describing a bunch of errors. |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1834 (proced-log (concat "\n" string "\n")) |
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1835 (proced-log t signal)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1836 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1837 (defun proced-help () |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
1838 "Provide help for the Proced user." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1839 (interactive) |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1840 (proced-why) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1841 (if (eq last-command 'proced-help) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1842 (describe-mode) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1843 (message proced-help-string))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1844 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1845 (defun proced-undo () |
100570
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
1846 "Undo in a Proced buffer. |
496de5bd1f6d
* proced.el (proced-grammar-alist): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
100424
diff
changeset
|
1847 This doesn't recover killed processes, it just undoes changes in the Proced |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1848 buffer. You can use it to recover marks." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1849 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1850 (let (buffer-read-only) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1851 (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
|
1852 (message "Change in Proced buffer undone. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1853 Killed processes cannot be recovered by Emacs.")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1854 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1855 (provide 'proced) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
1856 |
93248
072dbbf778d2
Add arch-tag.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93213
diff
changeset
|
1857 ;; arch-tag: a6e312ad-9032-45aa-972d-31a8cfc545af |
97522
ce7e3551dd0e
(proced-signal-list): Add POSIX 1003.1-2001 signals.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
97317
diff
changeset
|
1858 ;;; proced.el ends here |