Mercurial > emacs
annotate lisp/proced.el @ 94263:cd726e3a759a
Isearch help map.
author | Juri Linkov <juri@jurta.org> |
---|---|
date | Tue, 22 Apr 2008 20:32:56 +0000 |
parents | 6457a4cc8690 |
children | 97585dd63d91 |
rev | line source |
---|---|
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
1 ;;; proced.el --- operate on system processes like dired |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
2 |
93213
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
3 ;; Copyright (C) 2008 Free Software Foundation, Inc. |
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
4 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
5 ;; Author: Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
6 ;; Keywords: Processes, Unix |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
7 |
93213
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
9 |
93213
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify |
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 |
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
12 ;; the Free Software Foundation; either version 3, or (at your option) |
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
13 ;; any later version. |
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 |
93213
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
f51aae2fc6a4
Update copyright.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93212
diff
changeset
|
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
23 ;; Boston, MA 02110-1301, USA. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
24 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
25 ;;; Commentary: |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
26 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
27 ;; Proced makes an Emacs buffer containing a listing of the current system |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
28 ;; processes (using ps(1)). You can use the normal Emacs commands |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
29 ;; to move around in this buffer, and special Proced commands to operate |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
30 ;; on the processes listed. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
31 ;; |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
32 ;; To do: |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
33 ;; - sort by CPU time or other criteria |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
34 ;; - filter by user name or other criteria |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
35 ;; - automatic update of process list |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
36 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
37 ;;; Code: |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
38 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
39 (defgroup proced nil |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
40 "Proced mode." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
41 :group 'processes |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
42 :group 'unix |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
43 :prefix "proced-") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
44 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
45 (defcustom proced-procname-column-regexp "\\b\\(CMD\\|COMMAND\\)\\b" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
46 "If non-nil, regexp that defines the `proced-procname-column'." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
47 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
48 :type '(choice (const :tag "none" nil) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
49 (regexp :tag "regexp"))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
50 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
51 (defcustom proced-command-alist |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
52 (cond ((memq system-type '(berkeley-unix netbsd)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
53 '(("user" ("ps" "-uxgww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
54 ("user-running" ("ps" "-uxrgww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
55 ("all" ("ps" "-auxgww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
56 ("all-running" ("ps" "-auxrgww") 2))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
57 ((memq system-type '(linux lignux gnu/linux)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
58 `(("user" ("ps" "uxwww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
59 ("user-running" ("ps" "uxrwww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
60 ("all" ("ps" "auxwww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
61 ("all-running" ("ps" "auxrwww") 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
62 ("emacs" ("ps" "--pid" ,(number-to-string (emacs-pid)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
63 "--ppid" ,(number-to-string (emacs-pid)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
64 "uwww") 2))) |
94109
6457a4cc8690
(proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94108
diff
changeset
|
65 ((memq system-type '(darwin)) |
6457a4cc8690
(proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94108
diff
changeset
|
66 `(("user" ("ps" "-u" ,(number-to-string (user-uid))) 2) |
6457a4cc8690
(proced-command-alist): Add support for darwin.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94108
diff
changeset
|
67 ("all" ("ps" "-Au") 2))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
68 (t ; standard syntax doesn't allow us to list running processes only |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
69 `(("user" ("ps" "-fu" ,(number-to-string (user-uid))) 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
70 ("all" ("ps" "-ef") 2)))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
71 "Alist of commands to get list of processes. |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
72 Each element has the form (NAME COMMAND PID-COLUMN). |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
73 NAME is a shorthand name to select the type of listing. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
74 COMMAND is a list (COMMAND-NAME ARG1 ARG2 ...), |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
75 where COMMAND-NAME is the command to generate the listing (usually \"ps\"). |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
76 ARG1, ARG2, ... are arguments passed to COMMAND-NAME to generate |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
77 a particular listing. These arguments differ under various operating systems. |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
78 PID-COLUMN is the column number (starting from 1) of the process ID." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
79 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
80 :type '(repeat (group (string :tag "name") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
81 (cons (string :tag "command") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
82 (repeat (string :tag "option"))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
83 (integer :tag "PID column") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
84 (option (integer :tag "sort column"))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
85 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
86 (defcustom proced-command (if (zerop (user-real-uid)) "all" "user") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
87 "Name of process listing. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
88 Must be the car of an element of `proced-command-alist'." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
89 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
90 :type '(string :tag "name")) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
91 (make-variable-buffer-local 'proced-command) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
92 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
93 (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
|
94 "Name of signal function. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
95 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
|
96 the external command (usually \"kill\")." |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
97 :group 'proced |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
98 :type '(choice (function :tag "function") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
99 (string :tag "command"))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
100 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
101 (defcustom proced-signal-list |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
102 '(("HUP (1. Hangup)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
103 ("INT (2. Terminal interrupt)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
104 ("QUIT (3. Terminal quit)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
105 ("ABRT (6. Process abort)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
106 ("KILL (9. Kill -- cannot be caught or ignored)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
107 ("ALRM (14. Alarm Clock)") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
108 ("TERM (15. Termination)")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
109 "List of signals, used for minibuffer completion." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
110 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
111 :type '(repeat (string :tag "signal"))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
112 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
113 (defvar proced-marker-char ?* ; the answer is 42 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
114 "In proced, the current mark character.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
115 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
116 ;; face and font-lock code taken from dired |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
117 (defgroup proced-faces nil |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
118 "Faces used by Proced." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
119 :group 'proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
120 :group 'faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
121 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
122 (defface proced-header |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
123 '((t (:inherit font-lock-type-face))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
124 "Face used for proced headers." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
125 :group 'proced-faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
126 (defvar proced-header-face 'proced-header |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
127 "Face name used for proced headers.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
128 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
129 (defface proced-mark |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
130 '((t (:inherit font-lock-constant-face))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
131 "Face used for proced marks." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
132 :group 'proced-faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
133 (defvar proced-mark-face 'proced-mark |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
134 "Face name used for proced marks.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
135 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
136 (defface proced-marked |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
137 '((t (:inherit font-lock-warning-face))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
138 "Face used for marked processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
139 :group 'proced-faces) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
140 (defvar proced-marked-face 'proced-marked |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
141 "Face name used for marked processes.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
142 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
143 (defvar proced-re-mark "^[^ \n]" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
144 "Regexp matching a marked line. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
145 Important: the match ends just after the marker.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
146 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
147 (defvar proced-header-regexp "\\`.*$" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
148 "Regexp matching a header line.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
149 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
150 (defvar proced-procname-column nil |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
151 "Proced command column. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
152 Initialized based on `proced-procname-column-regexp'.") |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
153 (make-variable-buffer-local 'proced-procname-column) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
154 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
155 (defvar proced-font-lock-keywords |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
156 (list |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
157 ;; |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
158 ;; Process listing headers. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
159 (list proced-header-regexp '(0 proced-header-face)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
160 ;; |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
161 ;; Proced marks. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
162 (list proced-re-mark '(0 proced-mark-face)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
163 ;; |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
164 ;; Marked files. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
165 (list (concat "^[" (char-to-string proced-marker-char) "]") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
166 '(".+" (proced-move-to-procname) nil (0 proced-marked-face))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
167 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
168 (defvar proced-mode-map |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
169 (let ((km (make-sparse-keymap))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
170 (define-key km " " 'next-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
171 (define-key km "n" 'next-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
172 (define-key km "p" 'previous-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
173 (define-key km "\C-?" 'previous-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
174 (define-key km "h" 'describe-mode) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
175 (define-key km "?" 'proced-help) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
176 (define-key km "d" 'proced-mark) ; Dired compatibility |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
177 (define-key km "m" 'proced-mark) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
178 (define-key km "M" 'proced-mark-all) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
179 (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
|
180 (define-key km "\177" 'proced-unmark-backward) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
181 (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
|
182 (define-key km "t" 'proced-toggle-marks) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
183 (define-key km "h" 'proced-hide-processes) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
184 (define-key km "x" 'proced-send-signal) ; Dired compatibility |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
185 (define-key km "k" 'proced-send-signal) ; kill processes |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
186 (define-key km "l" 'proced-listing-type) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
187 (define-key km "g" 'revert-buffer) ; Dired compatibility |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
188 (define-key km "q" 'quit-window) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
189 (define-key km [remap undo] 'proced-undo) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
190 (define-key km [remap advertised-undo] 'proced-undo) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
191 km) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
192 "Keymap for proced commands") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
193 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
194 (easy-menu-define |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
195 proced-menu proced-mode-map "Proced Menu" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
196 '("Proced" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
197 ["Mark" proced-mark t] |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
198 ["Unmark" proced-unmark t] |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
199 ["Mark All" proced-mark-all t] |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
200 ["Unmark All" proced-unmark-all t] |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
201 ["Toggle Marks" proced-unmark-all t] |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
202 "--" |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
203 ["Hide Marked Processes" proced-hide-processes t] |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
204 "--" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
205 ["Revert" revert-buffer t] |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
206 ["Send signal" proced-send-signal t] |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
207 ["Change listing" proced-listing-type t])) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
208 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
209 (defconst proced-help-string |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
210 "(n)ext, (p)revious, (m)ark, (u)nmark, (k)ill, (q)uit (type ? for more help)" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
211 "Help string for proced.") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
212 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
213 (defun proced-marker-regexp () |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
214 (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
|
215 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
216 (defun proced-success-message (action count) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
217 (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
|
218 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
219 (defun proced-move-to-procname () |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
220 "Move to the beginning of the process name on the current line. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
221 Return the position of the beginning of the process name, or nil if none found." |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
222 (beginning-of-line) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
223 (if proced-procname-column |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
224 (forward-char proced-procname-column) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
225 (forward-char 2))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
226 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
227 (defsubst proced-skip-regexp () |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
228 "Regexp to skip in process listing." |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
229 (apply 'concat (make-list (1- (nth 2 (assoc proced-command |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
230 proced-command-alist))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
231 "\\s-+\\S-+"))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
232 |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
233 (define-derived-mode proced-mode nil "Proced" |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
234 "Mode for displaying UNIX system processes and sending signals to them. |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
235 Type \\[proced-mark-process] to mark a process for later commands. |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
236 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
|
237 |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
238 \\{proced-mode-map}" |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
239 (abbrev-mode 0) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
240 (auto-fill-mode 0) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
241 (setq buffer-read-only t |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
242 truncate-lines t) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
243 (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
|
244 (set (make-local-variable 'font-lock-defaults) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
245 '(proced-font-lock-keywords t nil nil beginning-of-line))) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
246 |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
247 ;; Proced mode is suitable only for specially formatted data. |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
248 (put 'proced-mode 'mode-class 'special) |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
249 |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
250 ;;;###autoload |
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
251 (defun proced (&optional arg) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
252 "Mode for displaying UNIX system processes and sending signals to them. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
253 Type \\[proced-mark-process] to mark a process for later commands. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
254 Type \\[proced-send-signal] to send signals to marked processes. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
255 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
256 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
|
257 information will be displayed but not selected. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
258 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
259 \\{proced-mode-map}" |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
260 (interactive "P") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
261 (let ((proced-buffer (get-buffer-create "*Process Info*")) new) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
262 (set-buffer proced-buffer) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
263 (setq new (zerop (buffer-size))) |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
264 (when new (proced-mode)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
265 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
266 (if (or new arg) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
267 (proced-update)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
268 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
269 (if arg |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
270 (display-buffer proced-buffer) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
271 (pop-to-buffer proced-buffer) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
272 (message (substitute-command-keys |
94108
7ab68bf3a905
(proced-mode): Redefine as just the major-mode.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94066
diff
changeset
|
273 "type \\[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
|
274 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
275 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
276 (defun proced-mark (&optional count) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
277 "Mark the current (or next COUNT) processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
278 (interactive "p") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
279 (proced-do-mark t count)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
280 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
281 (defun proced-unmark (&optional count) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
282 "Unmark the current (or next COUNT) processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
283 (interactive "p") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
284 (proced-do-mark nil count)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
285 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
286 (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
|
287 "Unmark the previous (or COUNT previous) processes." |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
288 (interactive "p") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
289 (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
|
290 |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
291 (defun proced-do-mark (mark &optional count) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
292 "Mark the current (or next ARG) processes using MARK." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
293 (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
|
294 (let ((backward (< count 0)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
295 (line (line-number-at-pos)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
296 buffer-read-only) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
297 ;; do nothing in the first line |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
298 (unless (= line 1) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
299 (setq count (1+ (if (<= 0 count) count |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
300 (min (- line 2) (abs count))))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
301 (beginning-of-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
302 (while (not (or (zerop (setq count (1- count))) (eobp))) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
303 (proced-insert-mark mark backward)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
304 (proced-move-to-procname)))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
305 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
306 (defun proced-mark-all () |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
307 "Mark all processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
308 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
309 (proced-do-mark-all t)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
310 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
311 (defun proced-unmark-all () |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
312 "Unmark all processes." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
313 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
314 (proced-do-mark-all nil)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
315 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
316 (defun proced-do-mark-all (mark) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
317 "Mark all processes using MARK." |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
318 (let (buffer-read-only) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
319 (save-excursion |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
320 (goto-line 2) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
321 (while (not (eobp)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
322 (proced-insert-mark mark))))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
323 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
324 (defun proced-toggle-marks () |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
325 "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
|
326 (interactive) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
327 (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
|
328 buffer-read-only) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
329 (save-excursion |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
330 (goto-line 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
331 (while (not (eobp)) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
332 (cond ((looking-at mark-re) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
333 (proced-insert-mark nil)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
334 ((looking-at " ") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
335 (proced-insert-mark t)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
336 (t |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
337 (forward-line 1))))))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
338 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
339 (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
|
340 "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
|
341 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
|
342 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
|
343 (if backward (forward-line -1)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
344 (insert (if mark proced-marker-char ?\s)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
345 (delete-char 1) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
346 (unless backward (forward-line))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
347 |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
348 ;; 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
|
349 ;; 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
|
350 ;; include the current line, whereas `dired-mark' for negative args operates |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
351 ;; on the preceding lines. Here we are consistent with `dired-mark'. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
352 (defun proced-hide-processes (&optional arg quiet) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
353 "Hide marked processes. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
354 With prefix ARG, hide that many lines starting with the current line. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
355 \(A negative argument hides backward.) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
356 If QUIET is non-nil suppress status message. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
357 Returns count of hidden lines." |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
358 (interactive "P") |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
359 (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
|
360 (count 0) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
361 buffer-read-only) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
362 (save-excursion |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
363 (if arg |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
364 ;; Hide ARG lines starting with the current line. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
365 (let ((line (line-number-at-pos))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
366 ;; do nothing in the first line |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
367 (unless (= line 1) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
368 (delete-region (line-beginning-position) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
369 (save-excursion |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
370 (if (<= 0 arg) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
371 (setq count (- arg (forward-line arg))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
372 (setq count (min (- line 2) (abs arg))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
373 (forward-line (- count))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
374 (point))))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
375 ;; Hide marked lines |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
376 (goto-line 2) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
377 (while (and (not (eobp)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
378 (re-search-forward mark-re nil t)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
379 (delete-region (match-beginning 0) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
380 (save-excursion (forward-line) (point))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
381 (setq count (1+ count))))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
382 (unless (zerop count) (proced-move-to-procname)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
383 (unless quiet |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
384 (proced-success-message "Hid" count)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
385 count)) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
386 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
387 (defun proced-listing-type (command) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
388 "Select `proced' listing type COMMAND from `proced-command-alist'." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
389 (interactive |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
390 (list (completing-read "Listing type: " proced-command-alist nil t))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
391 (setq proced-command command) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
392 (proced-update)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
393 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
394 (defun proced-update (&optional quiet) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
395 "Update the `proced' process information. Preserves point and marks." |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
396 ;; This is the main function that generates and updates the process listing. |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
397 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
398 (or quiet (message "Updating process information...")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
399 (let* ((command (cdr (assoc proced-command proced-command-alist))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
400 (regexp (concat (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\)")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
401 (old-pos (if (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
402 (beginning-of-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
403 (looking-at (concat "^[* ]" regexp))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
404 (cons (match-string-no-properties 1) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
405 (current-column)))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
406 buffer-read-only plist) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
407 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
408 ;; remember marked processes (whatever the mark was) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
409 (while (re-search-forward (concat "^\\(\\S-\\)" regexp) nil t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
410 (push (cons (match-string-no-properties 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
411 (match-string-no-properties 1)) plist)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
412 ;; generate new listing |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
413 (erase-buffer) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
414 (apply 'call-process (caar command) nil t nil (cdar command)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
415 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
416 (while (not (eobp)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
417 (insert " ") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
418 (forward-line)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
419 ;; (delete-trailing-whitespace) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
420 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
421 (while (re-search-forward "[ \t\r]+$" nil t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
422 (delete-region (match-beginning 0) (match-end 0))) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
423 (set-buffer-modified-p nil) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
424 ;; set `proced-procname-column' |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
425 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
426 (and proced-procname-column-regexp |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
427 (re-search-forward proced-procname-column-regexp nil t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
428 (setq proced-procname-column (1- (match-beginning 0)))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
429 ;; restore process marks |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
430 (if plist |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
431 (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
432 (goto-line 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
433 (let (mark) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
434 (while (re-search-forward (concat "^" regexp) nil t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
435 (if (setq mark (assoc (match-string-no-properties 1) plist)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
436 (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
437 (beginning-of-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
438 (insert (cdr mark)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
439 (delete-char 1))))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
440 ;; restore buffer position (if possible) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
441 (goto-line 2) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
442 (if (and old-pos |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
443 (re-search-forward |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
444 (concat "^[* ]" (proced-skip-regexp) "\\s-+" (car old-pos) "\\>") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
445 nil t)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
446 (progn |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
447 (beginning-of-line) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
448 (forward-char (cdr old-pos))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
449 (proced-move-to-procname)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
450 (or quiet (input-pending-p) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
451 (message "Updating process information...done.")))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
452 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
453 (defun proced-revert (&rest args) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
454 "Analog of `revert-buffer'." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
455 (proced-update)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
456 |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
457 ;; I do not want to reinvent the wheel. Should we rename `dired-pop-to-buffer' |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
458 ;; and move it to simple.el so that proced and ibuffer can easily use it, too? |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
459 (autoload 'dired-pop-to-buffer "dired") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
460 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
461 (defun proced-send-signal (&optional signal) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
462 "Send a SIGNAL to the marked processes. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
463 SIGNAL may be a string (HUP, INT, TERM, etc.) or a number. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
464 If SIGNAL is nil display marked processes and query interactively for SIGNAL." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
465 (interactive) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
466 (let ((regexp (concat (proced-marker-regexp) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
467 (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\).*$")) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
468 plist) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
469 ;; collect marked processes |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
470 (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
471 (goto-char (point-min)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
472 (while (re-search-forward regexp nil t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
473 (push (cons (match-string-no-properties 1) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
474 ;; How much info should we collect here? Would it be |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
475 ;; better to collect only the PID (to avoid ambiguities) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
476 ;; and the command name? |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
477 (substring (match-string-no-properties 0) 2)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
478 plist))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
479 (if (not plist) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
480 (message "No processes marked") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
481 (unless signal |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
482 ;; Display marked processes (code taken from `dired-mark-pop-up'). |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
483 (let ((bufname " *Marked Processes*") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
484 (header (save-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
485 (goto-char (+ 2 (point-min))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
486 (buffer-substring-no-properties |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
487 (point) (line-end-position))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
488 (with-current-buffer (get-buffer-create bufname) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
489 (setq truncate-lines t) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
490 (erase-buffer) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
491 (insert header "\n") |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
492 (dolist (proc plist) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
493 (insert (cdr proc) "\n")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
494 (save-window-excursion |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
495 (dired-pop-to-buffer bufname) ; all we need |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
496 (let* ((completion-ignore-case t) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
497 (pnum (if (= 1 (length plist)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
498 "1 process" |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
499 (format "%d processes" (length plist)))) |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
500 ;; The following is an ugly hack. Is there a better way |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
501 ;; to help people like me to remember the signals and |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
502 ;; their meanings? |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
503 (tmp (completing-read (concat "Send signal [" pnum |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
504 "] (default TERM): ") |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
505 proced-signal-list |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
506 nil nil nil nil "TERM"))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
507 (setq signal (if (string-match "^\\(\\S-+\\)\\s-" tmp) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
508 (match-string 1 tmp) tmp)))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
509 ;; send signal |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
510 (let ((count 0) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
511 err-list) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
512 (if (functionp proced-signal-function) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
513 ;; use built-in `signal-process' |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
514 (let ((signal (if (stringp signal) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
515 (if (string-match "\\`[0-9]+\\'" signal) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
516 (string-to-number signal) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
517 (make-symbol signal)) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
518 signal))) ; number |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
519 (dolist (process plist) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
520 (if (zerop (funcall |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
521 proced-signal-function |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
522 (string-to-number (car process)) signal)) |
94066
f446992a6a91
(proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94063
diff
changeset
|
523 (setq count (1+ count)) |
f446992a6a91
(proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94063
diff
changeset
|
524 (push (cdr process) err-list)))) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
525 ;; use external system call |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
526 (let ((signal (concat "-" (if (numberp signal) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
527 (number-to-string signal) signal)))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
528 (dolist (process plist) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
529 (if (zerop (call-process |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
530 proced-signal-function nil 0 nil |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
531 signal (car process))) |
94066
f446992a6a91
(proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94063
diff
changeset
|
532 (setq count (1+ count)) |
f446992a6a91
(proced-send-signal): Fix error recognition.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
94063
diff
changeset
|
533 (push (cdr process) err-list))))) |
94063
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
534 (if err-list |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
535 ;; FIXME: that's not enough to display the errors. |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
536 (message "%s: %s" signal err-list) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
537 (proced-success-message "Sent signal to" count))) |
ab8c45d22418
(proced-command-alist): Remove sort column.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93248
diff
changeset
|
538 ;; final clean-up |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
539 (run-hooks 'proced-after-send-signal-hook))))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
540 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
541 (defun proced-help () |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
542 "Provide help for the `proced' user." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
543 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
544 (if (eq last-command 'proced-help) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
545 (describe-mode) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
546 (message proced-help-string))) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
547 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
548 (defun proced-undo () |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
549 "Undo in a proced buffer. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
550 This doesn't recover killed processes, it just undoes changes in the proced |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
551 buffer. You can use it to recover marks." |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
552 (interactive) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
553 (let (buffer-read-only) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
554 (undo)) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
555 (message "Change in proced buffer undone. |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
556 Killed processes cannot be recovered by Emacs.")) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
557 |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
558 (provide 'proced) |
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
559 |
93248
072dbbf778d2
Add arch-tag.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
93213
diff
changeset
|
560 ;; arch-tag: a6e312ad-9032-45aa-972d-31a8cfc545af |
93212
134b2dc25692
proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff
changeset
|
561 ;;; proced.el ends here. |