annotate lisp/proced.el @ 94022:0f09322aedec

Move non-autoloaded define-obsolete-variable-alias calls for defcustoms not in dumped files before the associated defcustom.
author Glenn Morris <rgm@gnu.org>
date Sat, 12 Apr 2008 03:12:29 +0000
parents 072dbbf778d2
children ab8c45d22418
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
1 ;;; proced.el --- operate on processes like dired
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
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
27 ;; Proced makes an Emacs buffer containing a listing of the current processes
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
28 ;; (using ps(1)). You can use the normal Emacs commands to move around in
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
29 ;; this buffer, and special Proced commands to operate on the processes listed.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
30 ;;
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
31 ;; To autoload, use
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
32 ;; (autoload 'proced "proced" nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
33 ;; in your .emacs file.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
34 ;;
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
35 ;; Is there a need for additional features like:
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
36 ;; - automatic update of process list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
37 ;; - sort by CPU time or other criteria
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
38 ;; - filter by user name or other criteria
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
39
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
40 ;;; Code:
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
41
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
42 (defgroup proced nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
43 "Proced mode."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
44 :group 'processes
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
45 :group 'unix
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
46 :prefix "proced-")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
47
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
48 (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
49 "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
50 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
51 :type '(choice (const :tag "none" nil)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
52 (regexp :tag "regexp")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
53
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
54 (defcustom proced-command-alist
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
55 (cond ((memq system-type '(berkeley-unix netbsd))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
56 '(("user" ("ps" "-uxgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
57 ("user-running" ("ps" "-uxrgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
58 ("all" ("ps" "-auxgww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
59 ("all-running" ("ps" "-auxrgww") 2)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
60 ((memq system-type '(linux lignux gnu/linux))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
61 `(("user" ("ps" "uxwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
62 ("user-running" ("ps" "uxrwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
63 ("all" ("ps" "auxwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
64 ("all-running" ("ps" "auxrwww") 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
65 ("emacs" ("ps" "--pid" ,(number-to-string (emacs-pid))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
66 "--ppid" ,(number-to-string (emacs-pid))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
67 "uwww") 2)))
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.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
72 Each element has the form (NAME COMMAND PID-COLUMN SORT-COLUMN).
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.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
78 PID-COLUMN is the column number (starting from 1) of the process ID.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
79 SORT-COLUMN is the column number used for sorting the process listing
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
80 \(must be a numeric field). If nil, the process listing is not sorted."
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 (group (string :tag "name")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
83 (cons (string :tag "command")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
84 (repeat (string :tag "option")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
85 (integer :tag "PID column")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
86 (option (integer :tag "sort column")))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
87
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
88 (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
89 "Name of process listing.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
90 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
91 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
92 :type '(string :tag "name"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
93
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
94 (defcustom proced-kill-program "kill"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
95 "Name of kill command (usually `kill')."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
96 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
97 :type '(string :tag "command"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
98
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
99 (defcustom proced-signal-list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
100 '(("HUP (1. Hangup)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
101 ("INT (2. Terminal interrupt)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
102 ("QUIT (3. Terminal quit)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
103 ("ABRT (6. Process abort)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
104 ("KILL (9. Kill -- cannot be caught or ignored)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
105 ("ALRM (14. Alarm Clock)")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
106 ("TERM (15. Termination)"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
107 "List of signals, used for minibuffer completion."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
108 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
109 :type '(repeat (string :tag "signal")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
110
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
111 (defvar proced-marker-char ?* ; the answer is 42
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
112 "In proced, the current mark character.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
113
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
114 ;; face and font-lock code taken from dired
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
115 (defgroup proced-faces nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
116 "Faces used by Proced."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
117 :group 'proced
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
118 :group 'faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
119
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
120 (defface proced-header
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
121 '((t (:inherit font-lock-type-face)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
122 "Face used for proced headers."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
123 :group 'proced-faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
124 (defvar proced-header-face 'proced-header
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
125 "Face name used for proced headers.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
126
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
127 (defface proced-mark
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
128 '((t (:inherit font-lock-constant-face)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
129 "Face used for proced marks."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
130 :group 'proced-faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
131 (defvar proced-mark-face 'proced-mark
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
132 "Face name used for proced marks.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
133
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
134 (defface proced-marked
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
135 '((t (:inherit font-lock-warning-face)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
136 "Face used for marked processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
137 :group 'proced-faces)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
138 (defvar proced-marked-face 'proced-marked
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
139 "Face name used for marked processes.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
140
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
141 (defvar proced-re-mark "^[^ \n]"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
142 "Regexp matching a marked line.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
143 Important: the match ends just after the marker.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
144
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
145 (defvar proced-header-regexp "\\`.*$"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
146 "Regexp matching a header line.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
147
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
148 (defvar proced-procname-column nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
149 "Proced command column.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
150 Initialized based on `proced-procname-column-regexp'.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
151
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
152 (defvar proced-font-lock-keywords
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
153 (list
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 ;; Process listing headers.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
156 (list proced-header-regexp '(0 proced-header-face))
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 ;; Proced marks.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
159 (list proced-re-mark '(0 proced-mark-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 ;; Marked files.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
162 (list (concat "^[" (char-to-string proced-marker-char) "]")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
163 '(".+" (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
164
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
165 (defvar proced-mode-map
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
166 (let ((km (make-sparse-keymap)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
167 (define-key km " " 'next-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
168 (define-key km "n" 'next-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
169 (define-key km "p" 'previous-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
170 (define-key km "\C-?" 'previous-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
171 (define-key km "h" 'describe-mode)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
172 (define-key km "?" 'proced-help)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
173 (define-key km "d" 'proced-mark) ; Dired compatibility
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
174 (define-key km "m" 'proced-mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
175 (define-key km "M" 'proced-mark-all)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
176 (define-key km "g" 'revert-buffer) ; Dired compatibility
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
177 (define-key km "q" 'quit-window)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
178 (define-key km "u" 'proced-unmark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
179 (define-key km "U" 'proced-unmark-all)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
180 (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
181 (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
182 (define-key km "l" 'proced-listing-type)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
183 (define-key km [remap undo] 'proced-undo)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
184 (define-key km [remap advertised-undo] 'proced-undo)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
185 km)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
186 "Keymap for proced commands")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
187
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
188 (easy-menu-define
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
189 proced-menu proced-mode-map "Proced Menu"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
190 '("Proced"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
191 ["Mark" proced-mark t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
192 ["Unmark" proced-unmark t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
193 ["Mark All" proced-mark-all t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
194 ["Unmark All" proced-unmark-all t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
195 "--"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
196 ["Revert" revert-buffer t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
197 ["Send signal" proced-send-signal t]
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
198 ["Change listing" proced-listing-type t]))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
199
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
200 (defconst proced-help-string
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
201 "(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
202 "Help string for proced.")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
203
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
204 (defun proced-mode (&optional arg)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
205 "Mode for displaying UNIX processes and sending signals to them.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
206 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
207 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
208
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
209 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
210 information will be displayed but not selected.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
211
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
212 \\{proced-mode-map}"
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
213 (interactive "P")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
214 (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
215 (set-buffer proced-buffer)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
216 (setq new (zerop (buffer-size)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
217 (when new
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
218 (kill-all-local-variables)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
219 (use-local-map proced-mode-map)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
220 (abbrev-mode 0)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
221 (auto-fill-mode 0)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
222 (setq buffer-read-only t
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
223 truncate-lines t
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
224 major-mode 'proced-mode
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
225 mode-name "Proced")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
226 (set (make-local-variable 'revert-buffer-function) 'proced-revert)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
227 (set (make-local-variable 'font-lock-defaults)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
228 '(proced-font-lock-keywords t nil nil beginning-of-line)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
229
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
230 (if (or new arg)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
231 (proced-update))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
232
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
233 (if arg
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
234 (display-buffer proced-buffer)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
235 (pop-to-buffer proced-buffer)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
236 (message (substitute-command-keys
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
237 "type \\[quit-window] to quit, \\[proced-help] for help")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
238 (if new (run-mode-hooks 'proced-mode-hook))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
239
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
240 ;; Proced mode is suitable only for specially formatted data.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
241 (put 'proced-mode 'mode-class 'special)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
242
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
243 (fset 'proced 'proced-mode)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
244
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
245 (defun proced-move-to-procname ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
246 "Move to the beginning of the process name on the current line.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
247 Return the position of the beginning of the process name, or nil if none found."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
248 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
249 (if proced-procname-column
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
250 (forward-char proced-procname-column)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
251 (forward-char 2)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
252
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
253 (defun proced-mark (&optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
254 "Mark the current (or next COUNT) processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
255 (interactive "p")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
256 (proced-do-mark t count))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
257
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
258 (defun proced-unmark (&optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
259 "Unmark the current (or next COUNT) processes."
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 (proced-do-mark nil count))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
262
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
263 (defun proced-do-mark (mark &optional count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
264 "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
265 (or count (setq count 1))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
266 (let ((n (if (<= 0 count) 1 -1))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
267 (line (line-number-at-pos))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
268 buffer-read-only)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
269 ;; do nothing in the first line
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
270 (unless (= line 1)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
271 (setq count (1+ (cond ((<= 0 count) count)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
272 ((< (abs count) line) (abs count))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
273 (t (1- line)))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
274 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
275 (while (not (or (zerop (setq count (1- count))) (eobp)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
276 (proced-insert-mark mark n))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
277 (proced-move-to-procname))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
278
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
279 (defun proced-mark-all ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
280 "Mark all processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
281 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
282 (proced-do-mark-all t))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
283
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
284 (defun proced-unmark-all ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
285 "Unmark all processes."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
286 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
287 (proced-do-mark-all nil))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
288
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
289 (defun proced-do-mark-all (mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
290 "Mark all processes using MARK."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
291 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
292 (let (buffer-read-only)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
293 (goto-line 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
294 (while (not (eobp))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
295 (proced-insert-mark mark 1)))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
296
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
297 (defun proced-insert-mark (mark n)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
298 "If MARK is non-nil, insert `proced-marker-char', move N lines."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
299 ;; Do we need other marks besides `proced-marker-char'?
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
300 (insert (if mark proced-marker-char ?\s))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
301 (delete-char 1)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
302 (forward-line n))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
303
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
304 (defun proced-listing-type (command)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
305 "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
306 (interactive
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
307 (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
308 (setq proced-command command)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
309 (proced-update))
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 (defsubst proced-skip-regexp ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
312 "Regexp to skip in process listing."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
313 (apply 'concat (make-list (1- (nth 2 (assoc proced-command
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
314 proced-command-alist)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
315 "\\s-+\\S-+")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
316
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
317 (defun proced-update (&optional quiet)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
318 "Update the `proced' process information. Preserves point and marks."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
319 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
320 (or quiet (message "Updating process information..."))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
321 (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
322 (regexp (concat (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\)"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
323 (old-pos (if (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
324 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
325 (looking-at (concat "^[* ]" regexp)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
326 (cons (match-string-no-properties 1)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
327 (current-column))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
328 buffer-read-only plist)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
329 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
330 ;; remember marked processes (whatever the mark was)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
331 (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
332 (push (cons (match-string-no-properties 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
333 (match-string-no-properties 1)) plist))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
334 ;; generate new listing
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
335 (erase-buffer)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
336 (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
337 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
338 (while (not (eobp))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
339 (insert " ")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
340 (forward-line))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
341 ;; (delete-trailing-whitespace)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
342 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
343 (while (re-search-forward "[ \t\r]+$" nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
344 (delete-region (match-beginning 0) (match-end 0)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
345 ;; set `proced-procname-column'
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
346 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
347 (and proced-procname-column-regexp
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
348 (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
349 (setq proced-procname-column (1- (match-beginning 0))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
350 ;; sort fields
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
351 (goto-line 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
352 (if (nth 2 command)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
353 (sort-numeric-fields (nth 2 command) (point) (point-max)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
354 (set-buffer-modified-p nil)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
355 ;; restore process marks
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
356 (if plist
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
357 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
358 (goto-line 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
359 (let (mark)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
360 (while (re-search-forward (concat "^" regexp) nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
361 (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
362 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
363 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
364 (insert (cdr mark))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
365 (delete-char 1)))))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
366 ;; restore buffer position (if possible)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
367 (goto-line 2)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
368 (if (and old-pos
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
369 (re-search-forward
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
370 (concat "^[* ]" (proced-skip-regexp) "\\s-+" (car old-pos) "\\>")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
371 nil t))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
372 (progn
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
373 (beginning-of-line)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
374 (forward-char (cdr old-pos)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
375 (proced-move-to-procname))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
376 (or quiet (input-pending-p)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
377 (message "Updating process information...done."))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
378
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
379 (defun proced-revert (&rest args)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
380 "Analog of `revert-buffer'."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
381 (proced-update))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
382
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
383 ;; I do not want to reinvent the wheel
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
384 (autoload 'dired-pop-to-buffer "dired")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
385
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
386 (defun proced-send-signal (&optional signal)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
387 "Send a SIGNAL to the marked processes.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
388 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
389 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
390 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
391 (let ((regexp (concat "^\\*" (proced-skip-regexp) "\\s-+\\([0-9]+\\>\\).*$"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
392 plist)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
393 ;; collect marked processes
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
394 (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
395 (goto-char (point-min))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
396 (while (re-search-forward regexp nil t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
397 (push (cons (match-string-no-properties 1)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
398 (substring (match-string-no-properties 0) 2))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
399 plist)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
400 (if (not plist)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
401 (message "No processes marked")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
402 (unless signal
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
403 ;; 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
404 ;; We include all process information to distinguish multiple
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
405 ;; instances of the same program.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
406 (let ((bufname " *Marked Processes*")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
407 (header (save-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
408 (goto-char (+ 2 (point-min)))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
409 (buffer-substring-no-properties
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
410 (point) (line-end-position)))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
411 (with-current-buffer (get-buffer-create bufname)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
412 (setq truncate-lines t)
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 (insert header "\n")
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
415 (dolist (proc plist)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
416 (insert (cdr proc) "\n"))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
417 (save-window-excursion
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
418 (dired-pop-to-buffer bufname) ; all we need
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
419 (let* ((completion-ignore-case t)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
420 ;; 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
421 ;; 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
422 ;; their meanings?
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
423 (tmp (completing-read "Signal (default TERM): "
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
424 proced-signal-list
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
425 nil nil nil nil "TERM")))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
426 (setq signal (if (string-match "^\\(\\S-+\\)\\s-" tmp)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
427 (match-string 1 tmp) tmp))))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
428 ;; send signal
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
429 (apply 'call-process proced-kill-program nil 0 nil
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
430 (concat "-" (if (numberp signal)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
431 (number-to-string signal) signal))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
432 (mapcar 'car plist))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
433 (run-hooks 'proced-after-send-signal-hook)))))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
434
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
435 (defun proced-help ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
436 "Provide help for the `proced' user."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
437 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
438 (if (eq last-command 'proced-help)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
439 (describe-mode)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
440 (message proced-help-string)))
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 (defun proced-undo ()
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
443 "Undo in a proced buffer.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
444 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
445 buffer. You can use it to recover marks."
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
446 (interactive)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
447 (let (buffer-read-only)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
448 (undo))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
449 (message "Change in proced buffer undone.
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
450 Killed processes cannot be recovered by Emacs."))
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
451
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
452 (provide 'proced)
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
453
93248
072dbbf778d2 Add arch-tag.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents: 93213
diff changeset
454 ;; arch-tag: a6e312ad-9032-45aa-972d-31a8cfc545af
93212
134b2dc25692 proced.el: New file.
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de>
parents:
diff changeset
455 ;;; proced.el ends here.