diff options
| author | Stefan Monnier | 2009-08-30 03:46:18 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2009-08-30 03:46:18 +0000 |
| commit | 9a9af856bceb9ba22a82a9a1b14f4a0abd1f8f7e (patch) | |
| tree | 47d06c61d07caee598cc010d73b4e9bc32e432dc | |
| parent | 94862c1b43d917ba8f1b1abae6ccf4d4d7fb11b9 (diff) | |
| download | emacs-9a9af856bceb9ba22a82a9a1b14f4a0abd1f8f7e.tar.gz emacs-9a9af856bceb9ba22a82a9a1b14f4a0abd1f8f7e.zip | |
(proced-signal-list): Make it an alist.
(proced-grammar-alist): Capitalize names.
(proced-send-signal): Use a non-hidden buffer (since it's displayed).
Disable undo manually and make it read-only.
Use completion-annotate-function.
| -rw-r--r-- | lisp/ChangeLog | 6 | ||||
| -rw-r--r-- | lisp/proced.el | 100 |
2 files changed, 57 insertions, 49 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d3eb3e405be..c67c63953f5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2009-08-30 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2009-08-30 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * proced.el (proced-signal-list): Make it an alist. | ||
| 4 | (proced-grammar-alist): Capitalize names. | ||
| 5 | (proced-send-signal): Use a non-hidden buffer (since it's displayed). | ||
| 6 | Disable undo manually and make it read-only. | ||
| 7 | Use completion-annotate-function. | ||
| 8 | |||
| 3 | * minibuffer.el (minibuffer-message): If the current buffer is not | 9 | * minibuffer.el (minibuffer-message): If the current buffer is not |
| 4 | a minibuffer, insert the message in the echo area rather than at the | 10 | a minibuffer, insert the message in the echo area rather than at the |
| 5 | end of the buffer. | 11 | end of the buffer. |
diff --git a/lisp/proced.el b/lisp/proced.el index f529ac72c2c..43986494375 100644 --- a/lisp/proced.el +++ b/lisp/proced.el | |||
| @@ -64,22 +64,23 @@ the external command (usually \"kill\")." | |||
| 64 | 64 | ||
| 65 | (defcustom proced-signal-list | 65 | (defcustom proced-signal-list |
| 66 | '( ;; signals supported on all POSIX compliant systems | 66 | '( ;; signals supported on all POSIX compliant systems |
| 67 | ("HUP (1. Hangup)") | 67 | ("HUP" . " (1. Hangup)") |
| 68 | ("INT (2. Terminal interrupt)") | 68 | ("INT" . " (2. Terminal interrupt)") |
| 69 | ("QUIT (3. Terminal quit)") | 69 | ("QUIT" . " (3. Terminal quit)") |
| 70 | ("ABRT (6. Process abort)") | 70 | ("ABRT" . " (6. Process abort)") |
| 71 | ("KILL (9. Kill - cannot be caught or ignored)") | 71 | ("KILL" . " (9. Kill - cannot be caught or ignored)") |
| 72 | ("ALRM (14. Alarm Clock)") | 72 | ("ALRM" . " (14. Alarm Clock)") |
| 73 | ("TERM (15. Termination)") | 73 | ("TERM" . " (15. Termination)") |
| 74 | ;; POSIX 1003.1-2001 | 74 | ;; POSIX 1003.1-2001 |
| 75 | ;; Which systems do not support these signals so that we can | 75 | ;; Which systems do not support these signals so that we can |
| 76 | ;; exclude them from `proced-signal-list'? | 76 | ;; exclude them from `proced-signal-list'? |
| 77 | ("CONT (Continue executing)") | 77 | ("CONT" . " (Continue executing)") |
| 78 | ("STOP (Stop executing / pause - cannot be caught or ignored)") | 78 | ("STOP" . " (Stop executing / pause - cannot be caught or ignored)") |
| 79 | ("TSTP (Terminal stop / pause)")) | 79 | ("TSTP" . " (Terminal stop / pause)")) |
| 80 | "List of signals, used for minibuffer completion." | 80 | "List of signals, used for minibuffer completion." |
| 81 | :group 'proced | 81 | :group 'proced |
| 82 | :type '(repeat (string :tag "signal"))) | 82 | :type '(repeat (cons (string :tag "signal name") |
| 83 | (string :tag "description")))) | ||
| 83 | 84 | ||
| 84 | ;; For which attributes can we use a fixed width of the output field? | 85 | ;; For which attributes can we use a fixed width of the output field? |
| 85 | ;; A fixed width speeds up formatting, yet it can make | 86 | ;; A fixed width speeds up formatting, yet it can make |
| @@ -96,45 +97,45 @@ the external command (usually \"kill\")." | |||
| 96 | (defcustom proced-grammar-alist | 97 | (defcustom proced-grammar-alist |
| 97 | '( ;; attributes defined in `process-attributes' | 98 | '( ;; attributes defined in `process-attributes' |
| 98 | (euid "EUID" "%d" right proced-< nil (euid pid) (nil t nil)) | 99 | (euid "EUID" "%d" right proced-< nil (euid pid) (nil t nil)) |
| 99 | (user "USER" nil left proced-string-lessp nil (user pid) (nil t nil)) | 100 | (user "User" nil left proced-string-lessp nil (user pid) (nil t nil)) |
| 100 | (egid "EGID" "%d" right proced-< nil (egid euid pid) (nil t nil)) | 101 | (egid "EGID" "%d" right proced-< nil (egid euid pid) (nil t nil)) |
| 101 | (group "GROUP" nil left proced-string-lessp nil (group user pid) (nil t nil)) | 102 | (group "Group" nil left proced-string-lessp nil (group user pid) (nil t nil)) |
| 102 | (comm "COMMAND" nil left proced-string-lessp nil (comm pid) (nil t nil)) | 103 | (comm "Command" nil left proced-string-lessp nil (comm pid) (nil t nil)) |
| 103 | (state "STAT" nil left proced-string-lessp nil (state pid) (nil t nil)) | 104 | (state "Stat" nil left proced-string-lessp nil (state pid) (nil t nil)) |
| 104 | (ppid "PPID" "%d" right proced-< nil (ppid pid) | 105 | (ppid "PPID" "%d" right proced-< nil (ppid pid) |
| 105 | ((lambda (ppid) (proced-filter-parents proced-process-alist ppid)) | 106 | ((lambda (ppid) (proced-filter-parents proced-process-alist ppid)) |
| 106 | "refine to process parents")) | 107 | "refine to process parents")) |
| 107 | (pgrp "PGRP" "%d" right proced-< nil (pgrp euid pid) (nil t nil)) | 108 | (pgrp "PGrp" "%d" right proced-< nil (pgrp euid pid) (nil t nil)) |
| 108 | (sess "SESS" "%d" right proced-< nil (sess pid) (nil t nil)) | 109 | (sess "Sess" "%d" right proced-< nil (sess pid) (nil t nil)) |
| 109 | (ttname "TTY" proced-format-ttname left proced-string-lessp nil (ttname pid) (nil t nil)) | 110 | (ttname "TTY" proced-format-ttname left proced-string-lessp nil (ttname pid) (nil t nil)) |
| 110 | (tpgid "TPGID" "%d" right proced-< nil (tpgid pid) (nil t nil)) | 111 | (tpgid "TPGID" "%d" right proced-< nil (tpgid pid) (nil t nil)) |
| 111 | (minflt "MINFLT" "%d" right proced-< nil (minflt pid) (nil t t)) | 112 | (minflt "MinFlt" "%d" right proced-< nil (minflt pid) (nil t t)) |
| 112 | (majflt "MAJFLT" "%d" right proced-< nil (majflt pid) (nil t t)) | 113 | (majflt "MajFlt" "%d" right proced-< nil (majflt pid) (nil t t)) |
| 113 | (cminflt "CMINFLT" "%d" right proced-< nil (cminflt pid) (nil t t)) | 114 | (cminflt "CMinFlt" "%d" right proced-< nil (cminflt pid) (nil t t)) |
| 114 | (cmajflt "CMAJFLT" "%d" right proced-< nil (cmajflt pid) (nil t t)) | 115 | (cmajflt "CMajFlt" "%d" right proced-< nil (cmajflt pid) (nil t t)) |
| 115 | (utime "UTIME" proced-format-time right proced-time-lessp t (utime pid) (nil t t)) | 116 | (utime "UTime" proced-format-time right proced-time-lessp t (utime pid) (nil t t)) |
| 116 | (stime "STIME" proced-format-time right proced-time-lessp t (stime pid) (nil t t)) | 117 | (stime "STime" proced-format-time right proced-time-lessp t (stime pid) (nil t t)) |
| 117 | (time "TIME" proced-format-time right proced-time-lessp t (time pid) (nil t t)) | 118 | (time "Time" proced-format-time right proced-time-lessp t (time pid) (nil t t)) |
| 118 | (cutime "CUTIME" proced-format-time right proced-time-lessp t (cutime pid) (nil t t)) | 119 | (cutime "CUTime" proced-format-time right proced-time-lessp t (cutime pid) (nil t t)) |
| 119 | (cstime "CSTIME" proced-format-time right proced-time-lessp t (cstime pid) (nil t t)) | 120 | (cstime "CSTime" proced-format-time right proced-time-lessp t (cstime pid) (nil t t)) |
| 120 | (ctime "CTIME" proced-format-time right proced-time-lessp t (ctime pid) (nil t t)) | 121 | (ctime "CTime" proced-format-time right proced-time-lessp t (ctime pid) (nil t t)) |
| 121 | (pri "PR" "%d" right proced-< t (pri pid) (nil t t)) | 122 | (pri "Pr" "%d" right proced-< t (pri pid) (nil t t)) |
| 122 | (nice "NI" "%3d" 3 proced-< t (nice pid) (t t nil)) | 123 | (nice "Ni" "%3d" 3 proced-< t (nice pid) (t t nil)) |
| 123 | (thcount "THCOUNT" "%d" right proced-< t (thcount pid) (nil t t)) | 124 | (thcount "THCount" "%d" right proced-< t (thcount pid) (nil t t)) |
| 124 | (start "START" proced-format-start 6 proced-time-lessp nil (start pid) (t t nil)) | 125 | (start "Start" proced-format-start 6 proced-time-lessp nil (start pid) (t t nil)) |
| 125 | (vsize "VSIZE" "%d" right proced-< t (vsize pid) (nil t t)) | 126 | (vsize "VSize" "%d" right proced-< t (vsize pid) (nil t t)) |
| 126 | (rss "RSS" "%d" right proced-< t (rss pid) (nil t t)) | 127 | (rss "RSS" "%d" right proced-< t (rss pid) (nil t t)) |
| 127 | (etime "ETIME" proced-format-time right proced-time-lessp t (etime pid) (nil t t)) | 128 | (etime "ETime" proced-format-time right proced-time-lessp t (etime pid) (nil t t)) |
| 128 | (pcpu "%CPU" "%.1f" right proced-< t (pcpu pid) (nil t t)) | 129 | (pcpu "%CPU" "%.1f" right proced-< t (pcpu pid) (nil t t)) |
| 129 | (pmem "%MEM" "%.1f" right proced-< t (pmem pid) (nil t t)) | 130 | (pmem "%Mem" "%.1f" right proced-< t (pmem pid) (nil t t)) |
| 130 | (args "ARGS" proced-format-args left proced-string-lessp nil (args pid) (nil t nil)) | 131 | (args "Args" proced-format-args left proced-string-lessp nil (args pid) (nil t nil)) |
| 131 | ;; | 132 | ;; |
| 132 | ;; attributes defined by proced (see `proced-process-attributes') | 133 | ;; attributes defined by proced (see `proced-process-attributes') |
| 133 | (pid "PID" "%d" right proced-< nil (pid) | 134 | (pid "PID" "%d" right proced-< nil (pid) |
| 134 | ((lambda (ppid) (proced-filter-children proced-process-alist ppid)) | 135 | ((lambda (ppid) (proced-filter-children proced-process-alist ppid)) |
| 135 | "refine to process children")) | 136 | "refine to process children")) |
| 136 | ;; process tree | 137 | ;; process tree |
| 137 | (tree "TREE" proced-format-tree left nil nil nil nil)) | 138 | (tree "Tree" proced-format-tree left nil nil nil nil)) |
| 138 | "Alist of rules for handling Proced attributes. | 139 | "Alist of rules for handling Proced attributes. |
| 139 | 140 | ||
| 140 | Each element has the form | 141 | Each element has the form |
| @@ -1709,16 +1710,19 @@ After sending the signal, this command runs the normal hook | |||
| 1709 | (line-end-position)))))) | 1710 | (line-end-position)))))) |
| 1710 | (unless signal | 1711 | (unless signal |
| 1711 | ;; Display marked processes (code taken from `dired-mark-pop-up'). | 1712 | ;; Display marked processes (code taken from `dired-mark-pop-up'). |
| 1712 | (let ((bufname " *Marked Processes*") | 1713 | (let ((bufname "*Marked Processes*") |
| 1713 | (header-line (substring-no-properties proced-header-line))) | 1714 | (header-line (substring-no-properties proced-header-line))) |
| 1714 | (with-current-buffer (get-buffer-create bufname) | 1715 | (with-current-buffer (get-buffer-create bufname) |
| 1715 | (setq truncate-lines t | 1716 | (setq truncate-lines t |
| 1716 | proced-header-line header-line ; inherit header line | 1717 | proced-header-line header-line ; inherit header line |
| 1717 | header-line-format '(:eval (proced-header-line))) | 1718 | header-line-format '(:eval (proced-header-line))) |
| 1718 | (add-hook 'post-command-hook 'force-mode-line-update nil t) | 1719 | (add-hook 'post-command-hook 'force-mode-line-update nil t) |
| 1719 | (erase-buffer) | 1720 | (let ((inhibit-read-only t)) |
| 1720 | (dolist (process process-alist) | 1721 | (erase-buffer) |
| 1721 | (insert " " (cdr process) "\n")) | 1722 | (buffer-disable-undo) |
| 1723 | (setq buffer-read-only t) | ||
| 1724 | (dolist (process process-alist) | ||
| 1725 | (insert " " (cdr process) "\n"))) | ||
| 1722 | (save-window-excursion | 1726 | (save-window-excursion |
| 1723 | ;; Analogous to `dired-pop-to-buffer' | 1727 | ;; Analogous to `dired-pop-to-buffer' |
| 1724 | ;; Don't split window horizontally. (Bug#1806) | 1728 | ;; Don't split window horizontally. (Bug#1806) |
| @@ -1729,15 +1733,13 @@ After sending the signal, this command runs the normal hook | |||
| 1729 | (pnum (if (= 1 (length process-alist)) | 1733 | (pnum (if (= 1 (length process-alist)) |
| 1730 | "1 process" | 1734 | "1 process" |
| 1731 | (format "%d processes" (length process-alist)))) | 1735 | (format "%d processes" (length process-alist)))) |
| 1732 | ;; The following is an ugly hack. Is there a better way | 1736 | (completion-annotate-function |
| 1733 | ;; to help people like me to remember the signals and | 1737 | (lambda (s) (cdr (assoc s proced-signal-list))))) |
| 1734 | ;; their meanings? | 1738 | (setq signal |
| 1735 | (tmp (completing-read (concat "Send signal [" pnum | 1739 | (completing-read (concat "Send signal [" pnum |
| 1736 | "] (default TERM): ") | 1740 | "] (default TERM): ") |
| 1737 | proced-signal-list | 1741 | proced-signal-list |
| 1738 | nil nil nil nil "TERM"))) | 1742 | nil nil nil nil "TERM"))))))) |
| 1739 | (setq signal (if (string-match "^\\(\\S-+\\)\\s-" tmp) | ||
| 1740 | (match-string 1 tmp) tmp))))))) | ||
| 1741 | ;; send signal | 1743 | ;; send signal |
| 1742 | (let ((count 0) | 1744 | (let ((count 0) |
| 1743 | failures) | 1745 | failures) |