1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00
emacs/lisp/proced.el

2331 lines
97 KiB
EmacsLisp
Raw Normal View History

;;; proced.el --- operate on system processes like dired -*- lexical-binding:t -*-
2008-03-26 02:15:28 +00:00
2024-01-02 01:47:10 +00:00
;; Copyright (C) 2008-2024 Free Software Foundation, Inc.
2008-03-26 02:29:43 +00:00
;; Author: Roland Winkler <winkler@gnu.org>
2008-03-26 02:15:28 +00:00
;; Keywords: Processes, Unix
2008-03-26 02:29:43 +00:00
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
2008-03-26 02:29:43 +00:00
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
2008-03-26 02:15:28 +00:00
2008-03-26 02:29:43 +00:00
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
2008-03-26 02:15:28 +00:00
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
2008-03-26 02:15:28 +00:00
;;; Commentary:
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Proced makes an Emacs buffer containing a listing of the current
;; system processes. You can use the normal Emacs commands to move around
;; in this buffer, and special Proced commands to operate on the processes
;; listed. See `proced-mode' for getting started.
2008-03-26 02:15:28 +00:00
;;
;; To do:
;; - Interactive temporary customizability of flags in `proced-grammar-alist'
;;
;; Thoughts and Ideas
;; - Currently, `process-attributes' returns the list of
;; command-line arguments of a process as one concatenated string.
;; This format is compatible with `shell-command'. Also, under
;; MS-Windows, the command-line arguments are actually stored as a
;; single string, so that it is impossible to reverse-engineer it back
;; into separate arguments. Alternatively, `process-attributes'
;; could (try to) return a list of strings that correspond to individual
;; command-line arguments. Then one could feed such a list of
;; command-line arguments into `call-process' or `start-process'.
;; Are there real-world applications when such a feature would be useful?
;; What about something like `proced-restart-pid'?
2008-03-26 02:15:28 +00:00
;;; Code:
(defgroup proced nil
"Proced mode."
:group 'processes
:group 'unix
:prefix "proced-")
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(defcustom proced-show-remote-processes nil
"Whether processes of the remote host shall be shown.
This happens only when `default-directory' is remote."
:version "29.1"
:type 'boolean)
(defcustom proced-signal-function #'signal-process
"Name of signal function.
It can be an elisp function (usually `signal-process') or a string specifying
the external command (usually \"kill\")."
:type '(choice (function :tag "function")
(string :tag "command")))
(make-obsolete-variable 'proced-signal-function "no longer used." "29.1")
(defcustom proced-renice-command "renice"
"Name of renice command."
Add missing :version tags * profiler.el (profiler): Add missing group :version tag. * avoid.el (mouse-avoidance-banish-position): * proced.el (proced-renice-command): * calc/calc.el (calc-ensure-consistent-units): * calendar/icalendar.el (icalendar-import-format-uid): * net/tramp.el (tramp-save-ad-hoc-proxies): * progmodes/bug-reference.el (bug-reference-bug-regexp): * progmodes/flymake.el (flymake-error-bitmap) (flymake-warning-bitmap, flymake-fringe-indicator-position): * progmodes/sh-script.el (sh-indent-after-continuation): * progmodes/verilog-mode.el (verilog-auto-template-warn-unused) (verilog-before-save-font-hook, verilog-after-save-font-hook): * progmodes/vhdl-mode.el (vhdl-makefile-default-targets) (vhdl-array-index-record-field-in-sensitivity-list) (vhdl-indent-comment-like-next-code-line): * textmodes/reftex-vars.el (reftex-ref-style-alist) (reftex-ref-macro-prompt, reftex-ref-style-default-list) (reftex-cite-key-separator, reftex-create-bibtex-header) (reftex-create-bibtex-footer): * textmodes/rst.el (rst-new-adornment-down, rst-indent-field) (rst-indent-literal-normal, rst-indent-literal-minimized) (rst-indent-comment): Add missing custom :version tags. * cedet/semantic/complete.el (semantic-displayor-tooltip-mode) (semantic-displayor-tooltip-initial-max-tags) (semantic-displayor-tooltip-max-tags): Add missing custom :version tags. * cedet/ede/linux.el (project-linux): Add missing group :version tag. * cedet/semantic/complete.el (semantic-displayor-tooltip-max-tags): Doc fix. * erc/erc.el (erc-lurker): * erc/erc-desktop-notifications.el (erc-notifications): Add missing group :version tags. * gnus/gnus-notifications.el (gnus-notifications): Add missing group :version tag. * gnus/gnus-msg.el (gnus-gcc-pre-body-encode-hook) (gnus-gcc-post-body-encode-hook): * gnus/gnus-sync.el (gnus-sync-lesync-name) (gnus-sync-lesync-install-topics): Add missing custom :version tags.
2012-10-06 20:30:26 +00:00
:version "24.3"
:type '(string :tag "command"))
2008-03-26 02:15:28 +00:00
(defcustom proced-signal-list
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
'( ;; signals supported on all POSIX compliant systems
("HUP" . " (1. Hangup)")
("INT" . " (2. Terminal interrupt)")
("QUIT" . " (3. Terminal quit)")
("ABRT" . " (6. Process abort)")
("KILL" . " (9. Kill - cannot be caught or ignored)")
("ALRM" . " (14. Alarm Clock)")
("TERM" . " (15. Termination)")
;; signals supported on systems conforming to POSIX 1003.1-2001
;; according to (info "(coreutils) Signal specifications")
("BUS" . " (Access to an undefined portion of a memory object)")
("CHLD" . " (Child process terminated, stopped, or continued)")
("CONT" . " (Continue executing, if stopped)")
("FPE" . " (Erroneous arithmetic operation)")
("ILL" . " (Illegal Instruction)")
("PIPE" . " (Write on a pipe with no one to read it)")
("SEGV" . " (Invalid memory reference)")
("STOP" . " (Stop executing / pause - cannot be caught or ignored)")
("TSTP" . " (Terminal stop / pause)")
("TTIN" . " (Background process attempting read)")
("TTOU" . " (Background process attempting write)")
("URG" . " (High bandwidth data is available at a socket)")
("USR1" . " (User-defined signal 1)")
("USR2" . " (User-defined signal 2)"))
2008-03-26 02:15:28 +00:00
"List of signals, used for minibuffer completion."
:type '(repeat (cons (string :tag "signal name")
(string :tag "description"))))
2008-03-26 02:15:28 +00:00
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; For which attributes can we use a fixed width of the output field?
;; A fixed width speeds up formatting, yet it can make
;; `proced-grammar-alist' system-dependent.
;; (If proced runs like top(1) we want it to be fast.)
;;
;; If it is impossible / unlikely that an attribute has the same value
;; for two processes, then sorting can be based on one ordinary (fast)
;; predicate like `<'. Otherwise, a list of proced predicates can be used
;; to refine the sort.
;;
;; It would be neat if one could temporarily override the following
;; predefined rules.
(defcustom proced-grammar-alist
'( ;; attributes defined in `process-attributes'
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(euid "EUID" "%d" right proced-< nil (euid pid) (nil t nil))
(user "User" proced-format-user left proced-string-lessp nil
(user pid) (nil t nil))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(egid "EGID" "%d" right proced-< nil (egid euid pid) (nil t nil))
(group "Group" nil left proced-string-lessp nil (group user pid)
(nil t nil))
(comm "Command" nil left proced-string-lessp nil (comm pid) (nil t nil))
(state "Stat" proced-format-state left proced-string-lessp nil
(state pid) (nil t nil))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(ppid "PPID" proced-format-ppid right proced-< nil (ppid pid)
((lambda (ppid)
(proced-filter-parents proced-process-alist ppid))
"refine to process parents"))
(pgrp "PGrp" proced-format-pgrp right proced-< nil (pgrp euid pid)
(nil t nil))
(sess "Sess" proced-format-sess right proced-< nil (sess pid)
(nil t nil))
(ttname "TTY" proced-format-ttname left proced-string-lessp nil
(ttname pid) (nil t nil))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(tpgid "TPGID" "%d" right proced-< nil (tpgid pid) (nil t nil))
(minflt "MinFlt" "%d" right proced-< nil (minflt pid) (nil t t))
(majflt "MajFlt" "%d" right proced-< nil (majflt pid) (nil t t))
(cminflt "CMinFlt" "%d" right proced-< nil (cminflt pid) (nil t t))
(cmajflt "CMajFlt" "%d" right proced-< nil (cmajflt pid) (nil t t))
(utime "UTime" proced-format-time right proced-time-lessp t (utime pid)
(nil t t))
(stime "STime" proced-format-time right proced-time-lessp t (stime pid)
(nil t t))
(time "Time" proced-format-time right proced-time-lessp t (time pid)
(nil t t))
(cutime "CUTime" proced-format-time right proced-time-lessp t (cutime pid)
(nil t t))
(cstime "CSTime" proced-format-time right proced-time-lessp t (cstime pid)
(nil t t))
(ctime "CTime" proced-format-time right proced-time-lessp t (ctime pid)
(nil t t))
(pri "Pr" "%d" right proced-< t (pri pid) (nil t t))
(nice "Ni" "%3d" 3 proced-< t (nice pid) (t t nil))
(thcount "THCount" "%d" right proced-< t (thcount pid) (nil t t))
(start "Start" proced-format-start left proced-time-lessp nil (start pid)
(t t nil))
(vsize "VSize" proced-format-memory right proced-< t (vsize pid)
(nil t t))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(rss "RSS" proced-format-rss right proced-< t (rss pid) (nil t t))
(etime "ETime" proced-format-time right proced-time-lessp t (etime pid)
(nil t t))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(pcpu "%CPU" proced-format-cpu right proced-< t (pcpu pid) (nil t t))
(pmem "%Mem" proced-format-mem right proced-< t (pmem pid) (nil t t))
(args "Args" proced-format-args left proced-string-lessp nil
(args pid) (nil t nil))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;;
;; attributes defined by proced (see `proced-process-attributes')
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(pid "PID" proced-format-pid right proced-< nil (pid)
((lambda (ppid) (proced-filter-children proced-process-alist ppid))
"refine to process children"))
;; process tree
(tree "Tree" proced-format-tree left nil nil nil nil))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Alist of rules for handling Proced attributes.
Each element has the form
(KEY NAME FORMAT JUSTIFY PREDICATE REVERSE SORT-SCHEME REFINER).
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
Symbol KEY is the car of a process attribute.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
String NAME appears in the header line.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
FORMAT specifies the format for displaying the attribute values. It can
be a string passed to `format'. It can be a function called with one
argument, the value of the attribute. The value nil means take as is.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
If JUSTIFY is an integer, its modulus gives the width of the attribute
values formatted with FORMAT. If JUSTIFY is positive, NAME appears
right-justified, otherwise it appears left-justified. If JUSTIFY is `left'
or `right', the field width is calculated from all field values in the listing.
If JUSTIFY is `left', the field values are formatted left-justified and
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
right-justified otherwise.
PREDICATE is the predicate for sorting and filtering the process listing
based on attribute KEY. PREDICATE takes two arguments P1 and P2,
the corresponding attribute values of two processes. PREDICATE should
return `equal' if P1 has same rank like P2. Any other non-nil value says
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
that P1 is \"less than\" P2, or nil if not.
If PREDICATE is nil the attribute cannot be sorted.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
PREDICATE defines an ascending sort order. REVERSE is non-nil if the sort
order is descending.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
SORT-SCHEME is a list (KEY1 KEY2 ...) defining a hierarchy of rules
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
for sorting the process listing. KEY1, KEY2, ... are KEYs appearing as cars
of `proced-grammar-alist'. First the PREDICATE of KEY1 is evaluated.
If it yields non-equal, it defines the sort order for the corresponding
processes. If it evaluates to `equal' the PREDICATE of KEY2 is evaluated, etc.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
REFINER can be a list of flags (LESS-B EQUAL-B LARGER-B) used by the command
`proced-refine' (see there) to refine the listing based on attribute KEY.
This command compares the value of attribute KEY of every process with
the value of attribute KEY of the process at the position of point
using PREDICATE.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
If PREDICATE yields non-nil, the process is accepted if LESS-B is non-nil.
If PREDICATE yields `equal', the process is accepted if EQUAL-B is non-nil.
If PREDICATE yields nil, the process is accepted if LARGER-B is non-nil.
REFINER can also be a list (FUNCTION HELP-ECHO).
FUNCTION is called with one argument, the PID of the process at the position
of point. The function must return a list of PIDs that is used for the refined
listing. HELP-ECHO is a string that is shown when mouse is over this field.
If REFINER is nil no refinement is done."
:type '(repeat (list :tag "Attribute"
(symbol :tag "Key")
(string :tag "Header")
(choice :tag "Format"
(const :tag "None" nil)
(string :tag "Format String")
(function :tag "Formatting Function"))
(choice :tag "Justification"
(const :tag "left" left)
(const :tag "right" right)
(integer :tag "width"))
(choice :tag "Predicate"
(const :tag "None" nil)
(function :tag "Function"))
(boolean :tag "Descending Sort Order")
(repeat :tag "Sort Scheme" (symbol :tag "Key"))
(choice :tag "Refiner"
(const :tag "None" nil)
(list (function :tag "Refinement Function")
(string :tag "Help echo"))
(list :tag "Refine Flags"
(boolean :tag "Less")
(boolean :tag "Equal")
(boolean :tag "Larger"))))))
(defcustom proced-custom-attributes nil
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"List of functions defining custom attributes.
This variable extends the functionality of `proced-process-attributes'.
Each function is called with one argument, the list of attributes
of a system process. It returns a cons cell of the form (KEY . VALUE)
like `process-attributes'. This cons cell is appended to the list
returned by `proced-process-attributes'.
If the function returns nil, the value is ignored."
:type '(repeat (function :tag "Attribute")))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Formatting and sorting rules are defined "per attribute". If formatting
;; and / or sorting should use more than one attribute, it appears more
;; transparent to define a new derived attribute, so that formatting and
;; sorting can use them consistently. (Are there exceptions to this rule?
;; Would it be advantageous to have yet more general methods available?)
;; Sorting can also be based on attributes that are invisible in the listing.
(defcustom proced-format-alist
'((short user pid tree pcpu pmem start time (args comm))
(medium user pid tree pcpu pmem vsize rss ttname state start time (args comm))
(long user euid group pid tree pri nice pcpu pmem vsize rss ttname state
start time (args comm))
(verbose user euid group egid pid ppid tree pgrp sess pri nice pcpu pmem
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
state thcount vsize rss ttname tpgid minflt majflt cminflt cmajflt
start time utime stime ctime cutime cstime etime (args comm)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Alist of formats of listing.
The car of each element is a symbol, the name of the format.
The cdr is a list of attribute keys appearing in `proced-grammar-alist'.
An element of this list may also be a list of attribute keys that specifies
alternatives. If the first attribute is absent for a process, use the second
one, etc."
:type '(alist :key-type (symbol :tag "Format Name")
:value-type (repeat :tag "Keys"
(choice (symbol :tag "")
(repeat :tag "Alternative Keys"
(symbol :tag ""))))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defcustom proced-format 'short
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Current format of Proced listing.
It can be the car of an element of `proced-format-alist'.
It can also be a list of keys appearing in `proced-grammar-alist'."
:type '(choice (symbol :tag "Format Name")
(repeat :tag "Keys" (symbol :tag ""))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(make-variable-buffer-local 'proced-format)
;; FIXME: is there a better name for filter `user' that does not coincide
;; with an attribute key?
(defcustom proced-filter-alist
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
`((user (user . proced-user-name))
(user-running (user . proced-user-name)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(state . "\\`[Rr]\\'"))
(all)
(all-running (state . "\\`[Rr]\\'"))
(emacs (fun-all . (lambda (list)
(proced-filter-children list ,(emacs-pid))))))
"Alist of process filters.
The car of each element is a symbol, the name of the filter.
The cdr is a list of elementary filters that are applied to every process.
A process is displayed if it passes all elementary filters of a selected
filter.
An elementary filter can be one of the following:
\(KEY . REGEXP) If value of attribute KEY matches REGEXP,
accept this process.
\(KEY . FUN) Apply function FUN to attribute KEY. Accept this process,
if FUN returns non-nil.
\(function . FUN) For each process, apply function FUN to list of attributes
of each. Accept the process if FUN returns non-nil.
\(fun-all . FUN) Apply function FUN to entire process list.
FUN must return the filtered list."
:type '(repeat (cons :tag "Filter"
(symbol :tag "Filter Name")
(repeat :tag "Filters"
(choice (cons :tag "Key . Regexp" (symbol :tag "Key") regexp)
(cons :tag "Key . Function" (symbol :tag "Key") function)
(cons :tag "Function" (const :tag "Key: function" function) function)
(cons :tag "Fun-all" (const :tag "Key: fun-all" fun-all) function))))))
(defcustom proced-filter 'user
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Current filter of proced listing.
It can be the car of an element of `proced-filter-alist'.
It can also be a list of elementary filters as in the cdrs of the elements
of `proced-filter-alist'."
:type '(choice (symbol :tag "Filter Name")
(repeat :tag "Filters"
(choice (cons :tag "Key . Regexp" (symbol :tag "Key") regexp)
(cons :tag "Key . Function" (symbol :tag "Key") function)
(cons :tag "Function" (const :tag "Key: function" function) function)
(cons :tag "Fun-all" (const :tag "Key: fun-all" fun-all) function)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(make-variable-buffer-local 'proced-filter)
(defcustom proced-sort 'pcpu
"Current sort scheme for proced listing.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
It must be the KEY of an element of `proced-grammar-alist'.
It can also be a list of KEYs as in the SORT-SCHEMEs of the elements
of `proced-grammar-alist'."
:type '(choice (symbol :tag "Sort Scheme")
(repeat :tag "Key List" (symbol :tag "Key"))))
(make-variable-buffer-local 'proced-sort)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defcustom proced-descend t
"Non-nil if proced listing is sorted in descending order."
:type '(boolean :tag "Descending Sort Order"))
(make-variable-buffer-local 'proced-descend)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defcustom proced-goal-attribute 'args
"If non-nil, key of the attribute that defines the `goal-column'."
:type '(choice (const :tag "none" nil)
(symbol :tag "key")))
(defcustom proced-auto-update-interval 5
"Time interval in seconds for auto updating Proced buffers."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
:type 'integer)
(defcustom proced-auto-update-flag nil
"Non-nil means auto update proced buffers.
Special value `visible' means only update proced buffers that are currently
displayed in a window. Can be changed interactively via
`proced-toggle-auto-update'."
:type '(radio (const :tag "Don't auto update" nil)
(const :tag "Only update visible proced buffers" visible)
(const :tag "Update all proced buffers" t)))
(make-variable-buffer-local 'proced-auto-update-flag)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defcustom proced-tree-flag nil
"Non-nil for display of Proced buffer as process tree."
:type 'boolean)
(make-variable-buffer-local 'proced-tree-flag)
(defcustom proced-post-display-hook nil
"Normal hook run after displaying or updating a Proced buffer.
May be used to adapt the window size via `fit-window-to-buffer'."
:type 'hook
:options '(fit-window-to-buffer))
(defcustom proced-after-send-signal-hook nil
"Normal hook run after sending a signal to processes by `proced-send-signal'.
May be used to revert the process listing."
:type 'hook
:options '(proced-revert))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(defcustom proced-enable-color-flag nil
"Non-nil means Proced should display some process attributes with color."
:type 'boolean
:version "29.1")
(defcustom proced-low-memory-usage-threshold 0.1
"The upper bound for low relative memory usage display in Proced.
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
When `proced-enable-color-flag' is non-nil, RSS values denoting a
proportion of memory, relative to total memory, that is lower
than this value will be displayed using the `proced-memory-low-usage' face."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:type 'float
:version "29.1")
(defcustom proced-medium-memory-usage-threshold 0.5
"The upper bound for medium relative memory usage display in Proced.
When `proced-enable-color-flag' is non-nil, RSS values denoting a
proportion of memory, relative to total memory, that is less than
this value, but greater than `proced-low-memory-usage-threshold',
will be displayed using the `proced-memory-medium-usage' face.
RSS values denoting a greater proportion than this value will be
displayed using the `proced-memory-high-usage' face."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:type 'float
:version "29.1")
;; Internal variables
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(defvar proced-available t;(not (null (list-system-processes)))
"Non-nil means Proced is known to work on this system.")
(defvar-local proced-process-alist nil
"Alist of processes displayed by Proced.
The car of each element is the PID, and the cdr is a list of
cons pairs, see `proced-process-attributes'.")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defvar proced-sort-internal nil
"Sort scheme for listing (internal format).
It is a list of lists (KEY PREDICATE REVERSE).")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
2008-03-26 02:15:28 +00:00
(defvar proced-marker-char ?* ; the answer is 42
"In Proced, the current mark character.")
2008-03-26 02:15:28 +00:00
;; Faces and font-lock code taken from dired,
;; but face variables are deprecated for new code.
2008-03-26 02:15:28 +00:00
(defgroup proced-faces nil
"Faces used by Proced."
:group 'proced
:group 'faces)
(defface proced-mark
'((t (:inherit font-lock-constant-face)))
"Face used for Proced marks.")
2008-03-26 02:15:28 +00:00
(defface proced-marked
'((t (:inherit error)))
"Face used for marked processes.")
2008-03-26 02:15:28 +00:00
(defface proced-sort-header
'((t (:inherit font-lock-keyword-face)))
"Face used for header of attribute used for sorting.")
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(defface proced-run-status-code
'((t (:foreground "green")))
"Face used in Proced buffers for running or runnable status code character \"R\"."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:version "29.1")
(defface proced-interruptible-sleep-status-code
'((((class color) (min-colors 88)) (:foreground "DimGrey"))
(t (:italic t)))
"Face used in Proced buffers for interruptible sleep status code character \"S\"."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:version "29.1")
(defface proced-uninterruptible-sleep-status-code
'((((class color)) (:foreground "red"))
(t (:bold t)))
"Face used in Proced buffers for uninterruptible sleep status code character \"D\"."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:version "29.1")
(defface proced-executable
'((((class color) (min-colors 88) (background dark)) (:foreground "DeepSkyBlue"))
(((class color) (background dark)) (:foreground "cyan"))
(((class color) (background light)) (:foreground "blue"))
(t (:bold t)))
"Face used in Proced buffers for executable names.
The first word in the process arguments attribute is assumed to
be the executable that runs in the process."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
:version "29.1")
(defface proced-memory-high-usage
'((((class color) (min-colors 88) (background dark)) (:foreground "orange"))
(((class color) (min-colors 88) (background light)) (:foreground "OrangeRed"))
(((class color)) (:foreground "red"))
(t (:underline t)))
"Face used in Proced buffers for high memory usage."
:version "29.1")
(defface proced-memory-medium-usage
'((((class color) (min-colors 88) (background dark)) (:foreground "yellow3"))
(((class color) (min-colors 88) (background light)) (:foreground "orange"))
(((class color)) (:foreground "yellow")))
"Face used in Proced buffers for medium memory usage."
:version "29.1")
(defface proced-memory-low-usage
'((((class color) (min-colors 88) (background dark)) (:foreground "#8bcd50"))
(((class color)) (:foreground "green")))
"Face used in Proced buffers for low memory usage."
:version "29.1")
(defface proced-emacs-pid
'((((class color) (min-colors 88)) (:foreground "purple"))
(((class color)) (:foreground "magenta")))
"Face used in Proced buffers for the process ID of the current Emacs process."
:version "29.1")
(defface proced-pid
'((((class color) (min-colors 88)) (:foreground "#5085ef"))
(((class color)) (:foreground "blue")))
"Face used in Proced buffers for process IDs."
:version "29.1")
(defface proced-session-leader-pid
'((((class color) (min-colors 88)) (:foreground "#5085ef" :underline t))
(((class color)) (:foreground "blue" :underline t))
(t (:underline t)))
"Face used in Proced buffers for process IDs which are session leaders."
:version "29.1")
(defface proced-ppid
'((((class color) (min-colors 88)) (:foreground "#5085bf"))
(((class color)) (:foreground "blue")))
"Face used in Proced buffers for parent process IDs."
:version "29.1")
(defface proced-pgrp
'((((class color) (min-colors 88)) (:foreground "#4785bf"))
(((class color)) (:foreground "blue")))
"Face used in Proced buffers for process group IDs."
:version "29.1")
(defface proced-sess
'((((class color) (min-colors 88)) (:foreground "#41729f"))
(((class color)) (:foreground "MidnightBlue")))
"Face used in Proced buffers for process session IDs."
:version "29.1")
(defface proced-cpu
'((((class color) (min-colors 88)) (:foreground "#6d5cc3" :bold t))
(t (:bold t)))
"Face used in Proced buffers for process CPU utilization."
:version "29.1")
(defface proced-mem
'((((class color) (min-colors 88))
(:foreground "#6d5cc3")))
"Face used in Proced buffers for process memory utilization."
:version "29.1")
(defface proced-user
'((t (:bold t)))
"Face used in Proced buffers for the user owning the process."
:version "29.1")
(defface proced-time-colon
'((((class color) (min-colors 88)) (:foreground "DarkMagenta"))
(t (:bold t)))
"Face used in Proced buffers for the colon in time strings."
:version "29.1")
2008-03-26 02:15:28 +00:00
(defvar proced-re-mark "^[^ \n]"
"Regexp matching a marked line.
Important: the match ends just after the marker.")
(defvar-local proced-header-line nil
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Headers in Proced buffer as a string.")
(defvar proced-temp-alist nil
"Temporary alist (internal variable).")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defvar proced-process-tree nil
"Proced process tree (internal variable).")
(defvar proced-tree-depth nil
"Internal variable for depth of Proced process tree.")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defvar proced-auto-update-timer nil
"Stores if Proced auto update timer is already installed.")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defvar proced-log-buffer "*Proced log*"
"Name of Proced Log buffer.")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defconst proced-help-string
(concat "\\<proced-mode-map> "
"\\[next-line] next, "
"\\[previous-line] previous, "
"\\[proced-mark] mark, "
"\\[proced-unmark] unmark, "
"\\[proced-send-signal] kill, "
"\\[quit-window] quit "
"(type \\[proced-help] for more help)")
"Help string for Proced.")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defconst proced-header-help-echo
"mouse-1, mouse-2: sort by attribute %s%s (%s)"
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Help string shown when mouse is over a sortable header.")
(defconst proced-field-help-echo
"mouse-2, RET: refine by attribute %s %s"
"Help string shown when mouse is over a refinable field.")
2008-03-26 02:15:28 +00:00
(defvar proced-font-lock-keywords
`(;; (Any) proced marks.
(,proced-re-mark . 'proced-mark)
;; Processes marked with `proced-marker-char'
;; Should we make sure that only certain attributes are font-locked?
(,(concat "^[" (char-to-string proced-marker-char) "]")
".+" (proced-move-to-goal-column) nil (0 'proced-marked))))
2008-03-26 02:15:28 +00:00
(defvar-keymap proced-mode-map
:doc "Keymap for Proced commands."
;; moving
"SPC" #'next-line
"n" #'next-line
"p" #'previous-line
"C-n" #'next-line
"C-p" #'previous-line
"S-SPC" #'previous-line
"<down>" #'next-line
"<up>" #'previous-line
;; marking
"d" #'proced-mark ; Dired compatibility ("delete")
"m" #'proced-mark
"u" #'proced-unmark
"DEL" #'proced-unmark-backward
"M" #'proced-mark-all
"U" #'proced-unmark-all
"t" #'proced-toggle-marks
"C" #'proced-mark-children
"P" #'proced-mark-parents
;; filtering
"f" #'proced-filter-interactive
"<mouse-2>" #'proced-refine
"RET" #'proced-refine
;; sorting
"s c" #'proced-sort-pcpu
"s m" #'proced-sort-pmem
"s p" #'proced-sort-pid
"s s" #'proced-sort-start
"s S" #'proced-sort-interactive
"s t" #'proced-sort-time
"s u" #'proced-sort-user
;; similar to `Buffer-menu-sort-by-column'
"<header-line> <mouse-1>" #'proced-sort-header
"<header-line> <mouse-2>" #'proced-sort-header
"T" #'proced-toggle-tree
;; formatting
"F" #'proced-format-interactive
;; operate
"o" #'proced-omit-processes
"x" #'proced-send-signal ; Dired compatibility
"k" #'proced-send-signal ; kill processes
"r" #'proced-renice ; renice processes
;; misc
"h" #'describe-mode
"?" #'proced-help
"<remap> <undo>" #'proced-undo
"<remap> <advertised-undo>" #'proced-undo
;; Additional keybindings are inherited from `special-mode-map'
)
(put 'proced-mark :advertised-binding "m")
2008-03-26 02:15:28 +00:00
(defvar-local proced-refinements nil
"Information about the current buffer refinements.
It should be a list of elements of the form (REFINER PID KEY GRAMMAR), where
REFINER and GRAMMAR are as described in `proced-grammar-alist', PID is the
process ID of the process used to create the refinement, and KEY the attribute
of the process. A value of nil indicates that there are no active refinements.")
(easy-menu-define proced-menu proced-mode-map
"Proced Menu."
`("Proced"
["Mark" proced-mark
:help "Mark Current Process"]
["Unmark" proced-unmark
:help "Unmark Current Process"]
["Mark All" proced-mark-all
:help "Mark All Processes"]
["Unmark All" proced-unmark-all
:help "Unmark All Process"]
["Toggle Marks" proced-toggle-marks
:help "Marked Processes Become Unmarked, and Vice Versa"]
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
["Mark Children" proced-mark-children
:help "Mark Current Process and its Children"]
["Mark Parents" proced-mark-parents
:help "Mark Current Process and its Parents"]
"--"
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
("Filters"
:help "Select Filter for Process Listing"
,@(mapcar (lambda (el)
(let ((filter (car el)))
`[,(symbol-name filter)
(proced-filter-interactive ',filter)
:style radio
:selected (eq proced-filter ',filter)]))
proced-filter-alist))
("Sorting"
:help "Select Sort Scheme"
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
["Sort..." proced-sort-interactive
:help "Sort Process List"]
"--"
["Sort by %CPU" proced-sort-pcpu]
["Sort by %MEM" proced-sort-pmem]
["Sort by PID" proced-sort-pid]
["Sort by START" proced-sort-start]
["Sort by TIME" proced-sort-time]
["Sort by USER" proced-sort-user])
("Formats"
:help "Select Format for Process Listing"
,@(mapcar (lambda (el)
(let ((format (car el)))
`[,(symbol-name format)
(proced-format-interactive ',format)
:style radio
:selected (eq proced-format ',format)]))
proced-format-alist))
["Tree Display" proced-toggle-tree
:style toggle
:selected (eval proced-tree-flag)
:help "Display Proced Buffer as Process Tree"]
"--"
["Omit Marked Processes" proced-omit-processes
:help "Omit Marked Processes in Process Listing."]
2008-03-26 02:15:28 +00:00
"--"
["Revert" revert-buffer
:help "Revert Process Listing"]
["Auto Update" proced-toggle-auto-update
:style toggle
:selected (eval proced-auto-update-flag)
:help "Auto Update of Proced Buffer"]
"--"
["Send signal" proced-send-signal
:help "Send Signal to Marked Processes"]
["Renice" proced-renice
:help "Renice Marked Processes"]))
;; helper functions
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(defun proced-user-name (user)
"Check the `user' attribute with user name `proced' is running for."
(string-equal user (if (file-remote-p default-directory)
(file-remote-p default-directory 'user)
(user-real-login-name))))
(defun proced-marker-regexp ()
"Return regexp matching `proced-marker-char'."
;; `proced-marker-char' must appear in column zero
(concat "^" (regexp-quote (char-to-string proced-marker-char))))
(defun proced-success-message (action count)
"Display success message for ACTION performed for COUNT processes."
(message "%s %s process%s" action count (if (= 1 count) "" "es")))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Unlike dired, we do not define our own commands for vertical motion.
;; If `goal-column' is set, `next-line' and `previous-line' are fancy
;; commands to satisfy our modest needs. If `proced-goal-attribute'
;; and/or `goal-column' are not set, `next-line' and `previous-line'
;; are really what we need to preserve the column of point.
;; We use `proced-move-to-goal-column' for "non-interactive" cases only
;; to get a well-defined position of point.
(defun proced-move-to-goal-column ()
"Move to `goal-column' if non-nil. Return position of point."
(beginning-of-line)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(unless (eobp)
(if goal-column
(forward-char goal-column)
(forward-char 2)))
(point))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-header-line ()
"Return header line for Proced buffer."
(let ((base (line-number-display-width 'columns))
(hl (if (<= (window-hscroll) (length proced-header-line))
(substring proced-header-line (window-hscroll)))))
(when hl
;; From buff-menu.el: Turn whitespace chars in the header into
;; stretch specs so they work regardless of the header-line face.
(let ((pos 0))
(while (string-match "[ \t\n]+" hl pos)
(setq pos (match-end 0))
(put-text-property (match-beginning 0) pos 'display
`(space :align-to (,(+ pos base) . width))
hl)))
(setq hl (replace-regexp-in-string ;; preserve text properties
"\\(%\\)" "\\1\\1"
hl)))
(list (propertize " " 'display `(space :align-to (,base . width)))
hl)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-pid-at-point ()
"Return pid of system process at point.
Return nil if point is not on a process line."
(save-excursion
(beginning-of-line)
(if (looking-at "^. .")
(get-text-property (match-end 0) 'proced-pid))))
(defun proced--position-info (pos)
"Return information of the process at POS.
The returned information will have the form `(PID KEY COLUMN)' where
PID is the process ID of the process at point, KEY is the value of the
proced-key text property at point, and COLUMN is the column for which the
current value of the proced-key text property starts, or 0 if KEY is nil."
;; If point is on a field, we try to return point to that field.
;; Otherwise we try to return to the same column
(save-excursion
(goto-char pos)
(let ((pid (proced-pid-at-point))
(key (get-text-property (point) 'proced-key)))
(list pid key ; can both be nil
(if key
(if (get-text-property (1- (point)) 'proced-key)
(- (point) (previous-single-property-change
(point) 'proced-key))
0)
(current-column))))))
(defun proced--determine-pos (key column)
"Return position of point in the current line using KEY and COLUMN.
Attempt to find the first position on the current line where the
text property proced-key is equal to KEY. If this is not possible, return
the position of point of column COLUMN on the current line."
(save-excursion
(let (new-pos)
(if key
(let ((limit (line-end-position)) pos)
(while (and (not new-pos)
(setq pos (next-property-change (point) nil limit)))
(goto-char pos)
(when (eq key (get-text-property (point) 'proced-key))
(forward-char (min column (- (next-property-change (point))
(point))))
(setq new-pos (point))))
(unless new-pos
;; we found the process, but the field of point
;; is not listed anymore
(setq new-pos (proced-move-to-goal-column))))
(setq new-pos (min (+ (line-beginning-position) column)
(line-end-position))))
new-pos)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; proced mode
(define-derived-mode proced-mode special-mode "Proced"
2009-09-06 20:09:01 +00:00
"Mode for displaying system processes and sending signals to them.
Type \\[proced] to start a Proced session. In a Proced buffer
type \\<proced-mode-map>\\[proced-mark] to mark a process for later commands.
Type \\[proced-send-signal] to send signals to marked processes.
Type \\[proced-renice] to renice marked processes.
The initial content of a listing is defined by the variable
`proced-filter' and the variable `proced-format'.
The variable `proced-filter' specifies which system processes are
displayed.
The variable `proced-format' specifies which attributes are
displayed for each process.
Type \\[proced-filter-interactive] and \\[proced-format-interactive] to \
change the values of `proced-filter' and
`proced-format'. The current value of the variable
`proced-filter' is indicated in the mode line.
The sort order of Proced listings is defined by the variable `proced-sort'.
Type \\[proced-sort-interactive] or click on a header in the header \
line to change the sort scheme.
The current sort scheme is indicated in the mode line, using
\"+\" or \"-\" for ascending or descending sort order.
Type \\[proced-toggle-tree] to toggle whether the listing is displayed as process tree.
Type \\[proced-toggle-auto-update] to automatically update the
process list. The time interval for updates can be configured
via `proced-auto-update-interval'.
An existing Proced listing can be refined by typing \\[proced-refine].
Refining an existing listing does not update the variable `proced-filter'.
The attribute-specific rules for formatting, filtering, sorting,
and refining are defined in `proced-grammar-alist'.
After displaying or updating a Proced buffer, Proced runs the
normal hook `proced-post-display-hook'.
\\{proced-mode-map}"
:interactive nil
(abbrev-mode 0)
(auto-fill-mode 0)
(setq buffer-read-only t
truncate-lines t
header-line-format '(:eval (proced-header-line)))
(add-hook 'post-command-hook #'force-mode-line-update nil t) ;; FIXME: Why?
Prefer setq-local in most files * lisp/apropos.el (apropos-print): * lisp/buff-menu.el (Buffer-menu-mode): * lisp/calc/calc.el (calc-trail-buffer): * lisp/chistory.el (command-history-mode): * lisp/dabbrev.el: * lisp/dframe.el (dframe-frame-mode): * lisp/doc-view.el (doc-view-presentation-mode): * lisp/ebuff-menu.el (electric-buffer-menu-mode) (electric-buffer-update-highlight): * lisp/edmacro.el (edit-kbd-macro): * lisp/face-remap.el (buffer-face-set, buffer-face-toggle): * lisp/files.el: (find-file-noselect-1, hack-local-variables-confirm) (set-visited-file-name, revert-buffer--default): * lisp/filesets.el (filesets-spawn-external-viewer): * lisp/find-dired.el (find-dired): * lisp/find-lisp.el (find-lisp-find-dired-internal): * lisp/finder.el (finder-mode): * lisp/font-core.el (font-lock-default-function): * lisp/format.el (format-annotate-function): * lisp/help-fns.el (describe-variable): * lisp/help-mode.el (help-mode): * lisp/icomplete.el (icomplete-minibuffer-setup) (icomplete--in-region-setup): * lisp/ido.el (ido-completion-help, ido-tidy): * lisp/international/robin.el (robin-activate): * lisp/leim/quail/hangul.el (hangul-input-method-activate): * lisp/leim/quail/uni-input.el (ucs-input-activate): * lisp/man.el (Man-mode): * lisp/master.el (master-set-slave): * lisp/minibuffer.el (minibuffer-completion-help) (read-file-name-default): * lisp/outline.el (outline-minor-mode): * lisp/pcomplete.el (pcomplete-comint-setup): * lisp/proced.el (proced-mode): * lisp/recentf.el (recentf-edit-list, recentf-open-files-items): * lisp/replace.el (occur-1): * lisp/reveal.el (reveal-mode): * lisp/ruler-mode.el (ruler--save-header-line-format): * lisp/scroll-lock.el (scroll-lock-mode): * lisp/startup.el (normal-top-level, normal-splash-screen): * lisp/strokes.el (strokes-list-strokes): * lisp/thumbs.el (thumbs-insert-image, thumbs-show-thumbs-list): * lisp/tree-widget.el (tree-widget-set-theme): * lisp/window.el (read-buffer-to-switch): * lisp/xwidget.el (xwidget-webkit-begin-edit-textarea): Prefer setq-local.
2020-12-09 08:44:38 +00:00
(setq-local revert-buffer-function #'proced-revert)
(setq-local font-lock-defaults
'(proced-font-lock-keywords t nil nil beginning-of-line))
(setq-local switch-to-buffer-preserve-window-point nil)
;; So that the heading scales together with the body of the table.
(setq-local text-scale-remap-header-line t)
(if (and (not proced-auto-update-timer) proced-auto-update-interval)
(setq proced-auto-update-timer
(run-at-time t proced-auto-update-interval
'proced-auto-update-timer))))
;;;###autoload
(defun proced (&optional arg)
"Generate a listing of UNIX system processes.
\\<proced-mode-map>
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
If invoked with optional non-negative ARG, do not select the
window displaying the process information.
If `proced-show-remote-processes' is non-nil or the command is
invoked with a negative ARG `\\[universal-argument] \\[negative-argument]', \
and `default-directory'
points to a remote host, the system processes of that host are shown.
2008-03-26 02:15:28 +00:00
This function runs the normal hook `proced-post-display-hook'.
See `proced-mode' for a description of features available in
Proced buffers."
2008-03-26 02:15:28 +00:00
(interactive "P")
(unless proced-available
(error "Proced is not available on this system"))
(let ((buffer (get-buffer-create "*Proced*")) new)
(set-buffer buffer)
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(when (and (file-remote-p default-directory)
(not
(or proced-show-remote-processes
(eq arg '-))))
(setq default-directory temporary-file-directory))
2008-03-26 02:15:28 +00:00
(setq new (zerop (buffer-size)))
(when new
(proced-mode)
;; `proced-update' runs `proced-post-display-hook' only if the
;; Proced buffer has been selected. Yet the following call of
;; `proced-update' is for an empty Proced buffer that has not
;; yet been selected. Therefore we need to call
;; `proced-post-display-hook' below.
(proced-update t))
2008-03-26 02:15:28 +00:00
(if arg
(progn
(display-buffer buffer)
(with-current-buffer buffer
(proced-update t)))
(pop-to-buffer buffer)
(proced-update t)
(message
(substitute-command-keys
"Type \\<proced-mode-map>\\[quit-window] to quit, \\[proced-help] for help")))))
2008-03-26 02:15:28 +00:00
(defun proced-auto-update-timer ()
"Auto-update Proced buffers using `run-at-time'.
If there are no proced buffers, cancel the timer."
(if-let (buffers (match-buffers '(derived-mode . proced-mode)))
(dolist (buf buffers)
(when-let ((flag (buffer-local-value 'proced-auto-update-flag buf))
((or (not (eq flag 'visible))
(get-buffer-window buf 'visible))))
(with-current-buffer buf
(proced-update t t))))
(cancel-timer proced-auto-update-timer)
(setq proced-auto-update-timer nil)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-toggle-auto-update (arg)
"Change whether this Proced buffer is updated automatically.
With prefix ARG, update this buffer automatically if ARG is positive,
update the buffer only when the buffer is displayed in a window if ARG is 0,
otherwise do not update. Sets the variable `proced-auto-update-flag' by
cycling between nil, `visible' and t. The time interval for updates is
specified via `proced-auto-update-interval'."
(interactive (list (or current-prefix-arg 'toggle)) proced-mode)
(setq proced-auto-update-flag
(cond ((eq arg 'toggle)
(cond ((not proced-auto-update-flag) 'visible)
((eq proced-auto-update-flag 'visible) t)
(t nil)))
(arg
(setq arg (prefix-numeric-value arg))
(message "%s" arg)
(cond ((> arg 0) t)
((eq arg 0) 'visible)
(t nil)))
(t (not proced-auto-update-flag))))
(message "Proced auto update %s"
(cond ((eq proced-auto-update-flag 'visible) "enabled (only when buffer is visible)")
(proced-auto-update-flag "enabled (unconditionally)")
(t "disabled"))))
;;; Mark
2008-03-26 02:15:28 +00:00
(defun proced-mark (&optional count)
"Mark the current (or next COUNT) processes."
(interactive "p" proced-mode)
2008-03-26 02:15:28 +00:00
(proced-do-mark t count))
(defun proced-unmark (&optional count)
"Unmark the current (or next COUNT) processes."
(interactive "p" proced-mode)
2008-03-26 02:15:28 +00:00
(proced-do-mark nil count))
(defun proced-unmark-backward (&optional count)
"Unmark the previous (or COUNT previous) processes."
;; Analogous to `dired-unmark-backward',
;; but `ibuffer-unmark-backward' behaves different.
(interactive "p" proced-mode)
(proced-do-mark nil (- (or count 1))))
2008-03-26 02:15:28 +00:00
(defun proced-do-mark (mark &optional count)
"Mark the current (or next COUNT) processes using MARK."
2008-03-26 02:15:28 +00:00
(or count (setq count 1))
(let ((backward (< count 0))
2008-03-26 02:15:28 +00:00
buffer-read-only)
(setq count (1+ (if (<= 0 count) count
(min (1- (line-number-at-pos)) (abs count)))))
(beginning-of-line)
(while (not (or (zerop (setq count (1- count))) (eobp)))
(proced-insert-mark mark backward))
(proced-move-to-goal-column)))
2008-03-26 02:15:28 +00:00
(defun proced-toggle-marks ()
"Toggle marks: marked processes become unmarked, and vice versa."
(interactive nil proced-mode)
(let ((mark-re (proced-marker-regexp))
buffer-read-only)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(cond ((looking-at mark-re)
(proced-insert-mark nil))
((= (following-char) ?\s)
(proced-insert-mark t))
(t
(forward-line 1)))))))
(defun proced-insert-mark (mark &optional backward)
"If MARK is non-nil, insert `proced-marker-char'.
If BACKWARD is non-nil, move one line backwards before inserting the mark.
Otherwise move one line forward after inserting the mark."
(if backward (forward-line -1))
(insert (if mark proced-marker-char ?\s))
(delete-char 1)
(unless backward (forward-line)))
2008-03-26 02:15:28 +00:00
(defun proced-mark-all ()
"Mark all processes.
If `transient-mark-mode' is turned on and the region is active,
mark the region."
(interactive nil proced-mode)
2008-03-26 02:15:28 +00:00
(proced-do-mark-all t))
(defun proced-unmark-all ()
"Unmark all processes.
If `transient-mark-mode' is turned on and the region is active,
unmark the region."
(interactive nil proced-mode)
2008-03-26 02:15:28 +00:00
(proced-do-mark-all nil))
(defun proced-do-mark-all (mark)
"Mark all processes using MARK.
If `transient-mark-mode' is turned on and the region is active,
mark the region."
(let* ((count 0)
(proced-marker-char (if mark proced-marker-char ?\s))
(marker-re (proced-marker-regexp))
end buffer-read-only)
(save-excursion
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(if (use-region-p)
;; Operate even on those lines that are only partially a part
;; of region. This appears most consistent with
;; `proced-move-to-goal-column'.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(progn (setq end (save-excursion
(goto-char (region-end))
(unless (looking-at "^") (forward-line))
(point)))
(goto-char (region-beginning))
(unless (looking-at "^") (beginning-of-line)))
(goto-char (point-min))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(setq end (point-max)))
(while (< (point) end)
(unless (looking-at marker-re)
(setq count (1+ count))
(insert proced-marker-char)
(delete-char 1))
(forward-line))
(proced-success-message (if mark "Marked" "Unmarked") count))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-mark-children (ppid &optional omit-ppid)
"Mark child processes of process PPID.
Also mark process PPID unless prefix OMIT-PPID is non-nil."
(interactive (list (proced-pid-at-point) current-prefix-arg) proced-mode)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(proced-mark-process-alist
(proced-filter-children proced-process-alist ppid omit-ppid)))
(defun proced-mark-parents (cpid &optional omit-cpid)
"Mark parent processes of process CPID.
Also mark CPID unless prefix OMIT-CPID is non-nil."
(interactive (list (proced-pid-at-point) current-prefix-arg) proced-mode)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(proced-mark-process-alist
(proced-filter-parents proced-process-alist cpid omit-cpid)))
(defun proced-mark-process-alist (process-alist &optional quiet)
"Mark processes in PROCESS-ALIST.
If QUIET is non-nil suppress status message."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((count 0))
(if process-alist
(let (buffer-read-only)
(save-excursion
(goto-char (point-min))
(while (not (eobp))
(when (assq (proced-pid-at-point) process-alist)
(insert proced-marker-char)
(delete-char 1)
(setq count (1+ count)))
(forward-line)))))
(unless quiet
(proced-success-message "Marked" count))))
;; Mostly analog of `dired-do-kill-lines'.
;; However, for negative args the target lines of `dired-do-kill-lines'
;; include the current line, whereas `dired-mark' for negative args operates
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; on the preceding lines. Here we are consistent with `dired-mark'.
(defun proced-omit-processes (&optional arg quiet)
"Omit marked processes.
With prefix ARG, omit that many lines starting with the current line.
\(A negative argument omits backward.)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
If `transient-mark-mode' is turned on and the region is active,
omit the processes in region.
If QUIET is non-nil suppress status message.
Returns count of omitted lines."
(interactive "P" proced-mode)
(let ((mark-re (proced-marker-regexp))
(count 0)
buffer-read-only)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(cond ((use-region-p) ;; Omit active region
(let ((lines (count-lines (region-beginning) (region-end))))
(save-excursion
(goto-char (region-beginning))
(while (< count lines)
(proced-omit-process)
(setq count (1+ count))))))
((not arg) ;; Omit marked lines
(save-excursion
(goto-char (point-min))
(while (and (not (eobp))
(re-search-forward mark-re nil t))
(proced-omit-process)
(setq count (1+ count)))))
((< 0 arg) ;; Omit forward
(while (and (not (eobp)) (< count arg))
(proced-omit-process)
(setq count (1+ count))))
((< arg 0) ;; Omit backward
(while (and (not (bobp)) (< count (- arg)))
(forward-line -1)
(proced-omit-process)
(setq count (1+ count)))))
(unless (zerop count) (proced-move-to-goal-column))
(unless quiet (proced-success-message "Omitted" count))
count))
2008-03-26 02:15:28 +00:00
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-omit-process ()
"Omit process from listing point is on.
Update `proced-process-alist' accordingly."
(setq proced-process-alist
(assq-delete-all (proced-pid-at-point) proced-process-alist))
(delete-region (line-beginning-position)
(save-excursion (forward-line) (point))))
;;; Filtering
(defun proced-filter (process-alist filter-list)
"Apply FILTER-LIST to PROCESS-ALIST.
Return the filtered process list."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(if (symbolp filter-list)
(setq filter-list (cdr (assq filter-list proced-filter-alist))))
(dolist (filter filter-list)
(let (new-alist)
(cond ( ;; apply function to entire process list
(eq (car filter) 'fun-all)
(setq new-alist (funcall (cdr filter) process-alist)))
( ;; apply predicate to each list of attributes
(eq (car filter) 'function)
(dolist (process process-alist)
(if (funcall (car filter) (cdr process))
(push process new-alist))))
(t ;; apply predicate to specified attribute
(let* ((cdrfilter (cdr filter))
(fun (if (stringp cdrfilter)
(lambda (val)
(string-match cdrfilter val))
cdrfilter))
value)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(dolist (process process-alist)
(setq value (cdr (assq (car filter) (cdr process))))
(if (and value (funcall fun value))
(push process new-alist))))))
(setq process-alist new-alist)))
process-alist)
(defun proced-filter-interactive (scheme)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Filter Proced buffer using SCHEME.
When called interactively, an empty string means nil, i.e., no filtering.
Set variable `proced-filter' to SCHEME. Revert listing."
2008-03-26 02:15:28 +00:00
(interactive
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((scheme (completing-read "Filter: "
proced-filter-alist nil t)))
(list (if (string= "" scheme) nil (intern scheme))))
proced-mode)
;; only update if necessary
(unless (eq proced-filter scheme)
(setq proced-filter scheme)
(proced-update t)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-filter-parents (process-alist pid &optional omit-pid)
"For PROCESS-ALIST return list of parent processes of PID.
This list includes PID unless OMIT-PID is non-nil."
(let ((parent-list (unless omit-pid (list (assq pid process-alist))))
(process (assq pid process-alist))
ppid)
(while (and (setq ppid (cdr (assq 'ppid (cdr process))))
;; Ignore a PPID that equals PID.
(/= ppid pid)
;; Accept only PPIDs that correspond to members in PROCESS-ALIST.
(setq process (assq ppid process-alist)))
(setq pid ppid)
(push process parent-list))
parent-list))
(defun proced-filter-children (process-alist ppid &optional omit-ppid)
"For PROCESS-ALIST return list of child processes of PPID.
This list includes PPID unless OMIT-PPID is non-nil."
(let ((proced-temp-alist (proced-children-alist process-alist))
new-alist)
(dolist (pid (proced-children-pids ppid))
(push (assq pid process-alist) new-alist))
(if omit-ppid
(assq-delete-all ppid new-alist)
new-alist)))
;;; Process tree
(defun proced-children-alist (process-alist)
"Return children alist for PROCESS-ALIST.
The children alist has elements (PPID PID1 PID2 ...).
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
PPID is a parent PID. PID1, PID2, ... are the child processes of PPID.
The children alist inherits the sorting order of PROCESS-ALIST.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
The list of children does not include grandchildren."
;; The PPIDs inherit the sorting order of PROCESS-ALIST.
(let ((process-tree (mapcar (lambda (a) (list (car a))) process-alist))
ppid)
(dolist (process process-alist)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(setq ppid (cdr (assq 'ppid (cdr process))))
(if (and ppid
;; Ignore a PPID that equals PID.
(/= ppid (car process))
;; Accept only PPIDs that correspond to members in PROCESS-ALIST.
(assq ppid process-alist))
(let ((temp-alist process-tree) elt)
(while (setq elt (pop temp-alist))
(when (eq ppid (car elt))
(setq temp-alist nil)
(setcdr elt (cons (car process) (cdr elt))))))))
;; The child processes inherit the sorting order of PROCESS-ALIST.
(setq process-tree
(mapcar (lambda (a) (cons (car a) (nreverse (cdr a))))
process-tree))))
(defun proced-children-pids (ppid)
"Return list of children PIDs of PPID (including PPID)."
(let ((cpids (cdr (assq ppid proced-temp-alist))))
(if cpids
(cons ppid (apply #'append (mapcar #'proced-children-pids cpids)))
(list ppid))))
(defun proced-process-tree (process-alist)
"Return process tree for PROCESS-ALIST.
It is an alist of alists where the car of each alist is a parent process
and the cdr is a list of child processes according to the ppid attribute
of these processes.
The process tree inherits the sorting order of PROCESS-ALIST."
(let ((proced-temp-alist (proced-children-alist process-alist))
pid-alist proced-process-tree)
(while (setq pid-alist (pop proced-temp-alist))
(push (proced-process-tree-internal pid-alist) proced-process-tree))
(nreverse proced-process-tree)))
(defun proced-process-tree-internal (pid-alist)
"Helper function for `proced-process-tree'."
(let ((cpid-list (cdr pid-alist)) cpid-alist cpid)
(while (setq cpid (car cpid-list))
(if (setq cpid-alist (assq cpid proced-temp-alist))
;; Unprocessed part of process tree that needs to be
;; analyzed recursively.
(progn
(setq proced-temp-alist
(assq-delete-all cpid proced-temp-alist))
(setcar cpid-list (proced-process-tree-internal cpid-alist)))
;; We already processed this subtree and take it "as is".
(setcar cpid-list (assq cpid proced-process-tree))
(setq proced-process-tree
(assq-delete-all cpid proced-process-tree)))
(pop cpid-list)))
pid-alist)
(defun proced-toggle-tree (arg)
"Toggle the display of the process listing as process tree.
With prefix ARG, display as process tree if ARG is positive, otherwise
do not display as process tree. Sets the variable `proced-tree-flag'.
The process tree is generated from the selected processes in the
Proced buffer (that is, the processes in `proced-process-alist').
All processes that do not have a parent process in this list
according to their ppid attribute become the root of a process tree.
Each parent process is followed by its child processes.
The process tree inherits the chosen sorting order of the process listing,
that is, child processes of the same parent process are sorted using
the selected sorting order."
(interactive (list (or current-prefix-arg 'toggle)) proced-mode)
(setq proced-tree-flag
(cond ((eq arg 'toggle) (not proced-tree-flag))
(arg (> (prefix-numeric-value arg) 0))
(t (not proced-tree-flag))))
(proced-update)
(message "Proced process tree display %s"
(if proced-tree-flag "enabled" "disabled")))
(defun proced-tree (process-alist)
"Rearrange PROCESS-ALIST as process tree.
If `proced-tree-flag' is non-nil, rearrange PROCESS-ALIST such that
every processes is followed by its child processes. Each process
gets a tree attribute that specifies the depth of the process in the tree.
A root process is a process with no parent within PROCESS-ALIST according
to its value of the ppid attribute. It has depth 0.
If `proced-tree-flag' is nil, remove the tree attribute.
Return the rearranged process list."
(if proced-tree-flag
;; add tree attribute
(let ((process-tree (proced-process-tree process-alist))
(proced-tree-depth 0)
(proced-temp-alist process-alist)
proced-process-tree pt)
(while (setq pt (pop process-tree))
(proced-tree-insert pt))
(nreverse proced-process-tree))
;; remove tree attribute
(let ((process-alist process-alist))
(while process-alist
(setcar process-alist
(assq-delete-all 'tree (car process-alist)))
(pop process-alist)))
process-alist))
(defun proced-tree-insert (process-tree)
"Helper function for `proced-tree'."
(let ((pprocess (assq (car process-tree) proced-temp-alist)))
(push (append (list (car pprocess))
(list (cons 'tree proced-tree-depth))
(cdr pprocess))
proced-process-tree)
(if (cdr process-tree)
(let ((proced-tree-depth (1+ proced-tree-depth)))
(mapc #'proced-tree-insert (cdr process-tree))))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Refining
;; Filters are used to select the processes in a new listing.
;; Refiners are used to narrow down further (interactively) the processes
;; in an existing listing.
(defun proced-refine (&optional event)
"Refine Proced listing by comparing with the attribute value at point.
Optional EVENT is the location of the Proced field.
Refinement is controlled by the REFINER defined for each attribute ATTR
in `proced-grammar-alist'.
If REFINER is a list of flags and point is on a process's value of ATTR,
this command compares the value of ATTR of every process with the value
of ATTR of the process at the position of point.
The predicate for the comparison of two ATTR values is defined
in `proced-grammar-alist'. For each return value of the predicate
a refine flag is defined in `proced-grammar-alist'. One can select
processes for which the value of ATTR is \"less than\", \"equal\",
and / or \"larger\" than ATTR of the process point is on. A process
is included in the new listing if the refine flag for the corresponding
return value of the predicate is non-nil.
The help-echo string for `proced-refine' uses \"+\" or \"-\" to indicate
the current values of these refine flags.
If REFINER is a cons pair (FUNCTION . HELP-ECHO), FUNCTION is called
with one argument, the PID of the process at the position of point.
The function must return a list of PIDs that is used for the refined
listing. HELP-ECHO is a string that is shown when mouse is over this field.
This command refines an already existing process listing generated initially
based on the value of the variable `proced-filter'. It does not change
this variable. It does not revert the listing. If you frequently need
a certain refinement, consider defining a new filter in `proced-filter-alist'."
(interactive (list last-input-event) proced-mode)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(if event (posn-set-point (event-end event)))
(let ((key (get-text-property (point) 'proced-key))
(pid (get-text-property (point) 'proced-pid)))
(if (and key pid)
(let* ((grammar (assq key proced-grammar-alist))
(refiner (nth 7 grammar)))
(when refiner
(add-to-list 'proced-refinements (list refiner pid key grammar) t)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(proced-update)))
(message "No refiner defined here."))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Proced predicates for sorting and filtering are based on a three-valued
;; logic:
;; Predicates take two arguments P1 and P2, the corresponding attribute
;; values of two processes. Predicates should return 'equal if P1 has
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; same rank like P2. Any other non-nil value says that P1 is "less than" P2,
;; or nil if not.
(defun proced-< (num1 num2)
"Return t if NUM1 less than NUM2.
Return `equal' if NUM1 equals NUM2. Return nil if NUM1 greater than NUM2."
(if (= num1 num2)
'equal
(< num1 num2)))
(defun proced-string-lessp (s1 s2)
"Return t if string S1 is less than S2 in lexicographic order.
Return `equal' if S1 and S2 have identical contents.
Return nil otherwise."
(if (string= s1 s2)
'equal
(string-lessp s1 s2)))
(defun proced-time-lessp (t1 t2)
"Return t if time value T1 is less than time value T2.
Return `equal' if T1 equals T2. Return nil otherwise."
Improve time stamp handling, and be more consistent about it. This implements a suggestion made in: http://lists.gnu.org/archive/html/emacs-devel/2014-10/msg00587.html Among other things, this means timer.el no longer needs to autoload the time-date module. * doc/lispref/os.texi (Time of Day, Time Conversion, Time Parsing) (Processor Run Time, Time Calculations): Document the new behavior, plus be clearer about the old behavior. (Idle Timers): Take advantage of new functionality. * etc/NEWS: Document the changes. * lisp/allout-widgets.el (allout-elapsed-time-seconds): Doc fix. * lisp/arc-mode.el (archive-ar-summarize): * lisp/calendar/time-date.el (seconds-to-time, days-to-time, time-since): * lisp/emacs-lisp/timer.el (timer-relative-time, timer-event-handler) (run-at-time, with-timeout-suspend, with-timeout-unsuspend): * lisp/net/tramp.el (tramp-time-less-p, tramp-time-subtract): * lisp/proced.el (proced-time-lessp): * lisp/timezone.el (timezone-time-from-absolute): * lisp/type-break.el (type-break-schedule, type-break-time-sum): Simplify by using new functionality. * lisp/calendar/cal-dst.el (calendar-next-time-zone-transition): Do not return time values in obsolete and undocumented (HI . LO) format; use (HI LO) instead. * lisp/calendar/time-date.el (with-decoded-time-value): Treat 'nil' as current time. This is mostly for XEmacs. (encode-time-value, with-decoded-time-value): Obsolete. (time-add, time-subtract, time-less-p): Use no-op autoloads, for XEmacs. Define only if XEmacs, as they're now C builtins in Emacs. * lisp/ldefs-boot.el: Update to match new time-date.el * lisp/proced.el: Do not require time-date. * src/editfns.c (invalid_time): New function. Use it instead of 'error ("Invalid time specification")'. (time_add, time_subtract, time_arith, Ftime_add, Ftime_less_p) (decode_float_time, lisp_to_timespec, lisp_time_struct): New functions. (make_time_tail, make_time): Remove. All uses changed to use new functions or plain list4i. (disassemble_lisp_time): Return effective length if successful. Check that LOW is an integer, if it's combined with other components. (decode_time_components): Decode into struct lisp_time, not struct timespec, so that we can support a wide set of times regardless of whether time_t is signed. Decode plain numbers as seconds since the Epoch, and nil as the current time. (lisp_time_argument, lisp_seconds_argument, Ffloat_time): Reimplement in terms of new functions. (Fencode_time): Just use list2i. (syms_of_editfns): Add time-add, time-subtract, time-less-p. * src/keyboard.c (decode_timer): Don't allow the new formats (floating point or nil) in timers. * src/systime.h (LO_TIME_BITS): New constant. Use it everywhere in place of the magic number '16'. (struct lisp_time): New type. (decode_time_components): Use it. (lisp_to_timespec): New decl.
2014-11-17 04:38:15 +00:00
(or (time-less-p t1 t2)
(if (not (time-less-p t2 t1)) 'equal)))
2008-03-26 02:15:28 +00:00
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;;; Sorting
(define-obsolete-function-alias 'proced-xor #'xor "27.1")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-p (p1 p2)
"Predicate for sorting processes P1 and P2."
(if (not (cdr proced-sort-internal))
;; only one predicate: fast scheme
(let* ((sorter (car proced-sort-internal))
(k1 (cdr (assq (car sorter) (cdr p1))))
(k2 (cdr (assq (car sorter) (cdr p2)))))
;; if the attributes are undefined, we should really abort sorting
(if (and k1 k2)
(xor (funcall (nth 1 sorter) k1 k2)
(nth 2 sorter))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((sort-list proced-sort-internal) sorter predicate k1 k2)
(catch 'done
(while (setq sorter (pop sort-list))
(setq k1 (cdr (assq (car sorter) (cdr p1)))
k2 (cdr (assq (car sorter) (cdr p2)))
predicate
(if (and k1 k2)
(funcall (nth 1 sorter) k1 k2)))
(if (not (eq predicate 'equal))
(throw 'done (xor predicate (nth 2 sorter)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(eq t predicate)))))
(defun proced-sort (process-alist sorter descend)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Sort PROCESS-ALIST using scheme SORTER.
SORTER is a scheme like `proced-sort'.
DESCEND is non-nil if the first element of SORTER is sorted
in descending order.
Return the sorted process list."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; translate SORTER into a list of lists (KEY PREDICATE REVERSE)
(setq proced-sort-internal
(mapcar (lambda (arg)
(let ((grammar (assq arg proced-grammar-alist)))
(unless (nth 4 grammar)
(error "Attribute %s not sortable" (car grammar)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(list arg (nth 4 grammar) (nth 5 grammar))))
(cond ((listp sorter) sorter)
((and (symbolp sorter)
(nth 6 (assq sorter proced-grammar-alist))))
((symbolp sorter) (list sorter))
(t (error "Sorter undefined %s" sorter)))))
(if proced-sort-internal
(progn
;; splice DESCEND into the list
(setcar proced-sort-internal
(list (caar proced-sort-internal)
(nth 1 (car proced-sort-internal)) descend))
(sort process-alist 'proced-sort-p))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
process-alist))
(defun proced-sort-interactive (scheme &optional arg)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Sort Proced buffer using SCHEME.
When called interactively, an empty string means nil, i.e., no sorting.
Prefix ARG controls sort order:
- If prefix ARG is positive (negative), sort in ascending (descending) order.
- If ARG is nil or `no-arg' and SCHEME is equal to the previous sorting scheme,
reverse the sorting order.
- If ARG is nil or `no-arg' and SCHEME differs from the previous sorting scheme,
adopt the sorting order defined for SCHEME in `proced-grammar-alist'.
Set variable `proced-sort' to SCHEME. The current sort scheme is displayed
in the mode line, using \"+\" or \"-\" for ascending or descending order."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(interactive
(let* (choices
(scheme (completing-read "Sort attribute: "
(dolist (grammar proced-grammar-alist choices)
(if (nth 4 grammar)
(push (list (car grammar)) choices)))
nil t)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(list (if (string= "" scheme) nil (intern scheme))
;; like 'toggle in `define-derived-mode'
(or current-prefix-arg 'no-arg)))
proced-mode)
(setq proced-descend
;; If `proced-sort-interactive' is called repeatedly for the same
;; sort key, the sort order is reversed.
(cond ((and (eq arg 'no-arg) (equal proced-sort scheme))
(not proced-descend))
((eq arg 'no-arg)
(nth 5 (assq (if (consp scheme) (car scheme) scheme)
proced-grammar-alist)))
(arg (< (prefix-numeric-value arg) 0))
((equal proced-sort scheme)
(not proced-descend))
(t (nth 5 (assq (if (consp scheme) (car scheme) scheme)
proced-grammar-alist))))
proced-sort scheme)
(proced-update))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-pcpu (&optional arg)
"Sort Proced buffer by percentage CPU time (%CPU).
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'pcpu arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-pmem (&optional arg)
"Sort Proced buffer by percentage memory usage (%MEM).
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'pmem arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-pid (&optional arg)
"Sort Proced buffer by PID.
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'pid arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-start (&optional arg)
"Sort Proced buffer by time the command started (START).
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'start arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-time (&optional arg)
"Sort Proced buffer by CPU time (TIME).
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'time arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-user (&optional arg)
"Sort Proced buffer by USER.
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list (or current-prefix-arg 'no-arg)) proced-mode)
(proced-sort-interactive 'user arg))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-sort-header (event &optional arg)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Sort Proced listing based on an attribute.
EVENT is a mouse event with starting position in the header line.
It is converted to the corresponding attribute key.
This command updates the variable `proced-sort'.
Prefix ARG controls sort order, see `proced-sort-interactive'."
(interactive (list last-input-event (or last-prefix-arg 'no-arg)) proced-mode)
(let* ((start (event-start event))
(obj (posn-object start))
col key)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(save-selected-window
(select-window (posn-window start))
(setq col (+ (if obj (cdr obj) (posn-point start))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(window-hscroll)))
(when (and (<= 0 col) (< col (length proced-header-line)))
(setq key (get-text-property col 'proced-key proced-header-line))
(if key
(proced-sort-interactive key arg)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(message "No sorter defined here."))))))
2011-12-12 05:32:49 +00:00
;;; Formatting
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-format-time (time)
"Format time interval TIME."
New function time-convert This replaces the awkward reuse of encode-time to both convert calendrical timestamps to Lisp timestamps, and to convert Lisp timestamps to other forms. Now, encode-time does just the former and the new function does just the latter. The new function builds on a suggestion by Lars Ingebrigtsen in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00801.html and refined by Stefan Monnier in: https://lists.gnu.org/r/emacs-devel/2019-07/msg00803.html * doc/lispref/os.texi (Time of Day, Time Conversion): * doc/misc/emacs-mime.texi (time-date): * etc/NEWS: Update documentation. * lisp/calendar/cal-dst.el (calendar-next-time-zone-transition): * lisp/calendar/time-date.el (seconds-to-time, days-to-time): * lisp/calendar/timeclock.el (timeclock-seconds-to-time): * lisp/cedet/ede/detect.el (ede-detect-qtest): * lisp/completion.el (cmpl-hours-since-origin): * lisp/ecomplete.el (ecomplete-add-item): * lisp/emacs-lisp/cl-extra.el (cl--random-time): * lisp/emacs-lisp/timer.el (timer--time-setter) (timer-next-integral-multiple-of-time): * lisp/find-lisp.el (find-lisp-format-time): * lisp/gnus/gnus-diary.el (gnus-user-format-function-d): * lisp/gnus/gnus-group.el (gnus-group-set-timestamp): * lisp/gnus/gnus-icalendar.el (gnus-icalendar-show-org-agenda): * lisp/gnus/nnrss.el (nnrss-normalize-date): * lisp/gnus/nnspool.el (nnspool-request-newgroups): * lisp/net/ntlm.el (ntlm-compute-timestamp): * lisp/net/pop3.el (pop3-uidl-dele): * lisp/obsolete/vc-arch.el (vc-arch-add-tagline): * lisp/org/org-clock.el (org-clock-get-clocked-time) (org-clock-resolve, org-resolve-clocks, org-clock-in) (org-clock-out, org-clock-sum): * lisp/org/org-id.el (org-id-uuid, org-id-time-to-b36): * lisp/org/ox-publish.el (org-publish-cache-ctime-of-src): * lisp/proced.el (proced-format-time): * lisp/progmodes/cc-cmds.el (c-progress-init) (c-progress-update): * lisp/progmodes/cperl-mode.el (cperl-time-fontification): * lisp/progmodes/flymake.el (flymake--schedule-timer-maybe): * lisp/progmodes/vhdl-mode.el (vhdl-update-progress-info) (vhdl-fix-case-region-1): * lisp/tar-mode.el (tar-octal-time): * lisp/time.el (emacs-uptime): * lisp/url/url-auth.el (url-digest-auth-make-cnonce): * lisp/url/url-util.el (url-lazy-message): * lisp/vc/vc-cvs.el (vc-cvs-parse-entry): * lisp/vc/vc-hg.el (vc-hg-state-fast): * lisp/xt-mouse.el (xterm-mouse-event): * test/lisp/emacs-lisp/timer-tests.el: (timer-next-integral-multiple-of-time-2): Use time-convert, not encode-time. * lisp/calendar/icalendar.el (icalendar--decode-isodatetime): Don’t use now-removed FORM argument for encode-time. It wasn’t crucial anyway. * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Add time-convert. * lisp/emacs-lisp/elint.el (elint-unknown-builtin-args): Update encode-time signature to match current arg set. * lisp/emacs-lisp/timer.el (timer-next-integral-multiple-of-time): Use timer-convert with t rather than doing it by hand. * src/timefns.c (time_hz_ticks, time_form_stamp, lisp_time_form_stamp): Remove; no longer needed. (decode_lisp_time): Rturn the form instead of having a *PFORM arg. All uses changed. (time_arith): Just return TICKS if HZ is 1. (Fencode_time): Remove argument FORM. All callers changed. Do not attempt to encode time values; just encode decoded (calendrical) times. Unless CURRENT_TIME_LIST, just return VALUE since HZ is 1. (Ftime_convert): New function, which does the time value conversion that bleeding-edge encode-time formerly did. Return TIME if it is easy to see that it is already of the correct form. (Fcurrent_time): Mention in doc that the form is planned to change. * test/src/timefns-tests.el (decode-then-encode-time): Don’t use (encode-time nil).
2019-08-06 00:38:52 +00:00
(let* ((ftime (time-convert time 'integer))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(days (truncate ftime 86400))
(ftime (mod ftime 86400))
(hours (truncate ftime 3600))
(ftime (mod ftime 3600))
(minutes (truncate ftime 60))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(seconds (mod ftime 60))
(colon (if proced-enable-color-flag
(propertize ":" 'font-lock-face 'proced-time-colon)
":")))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(cond ((< 0 days)
(format "%d-%02d%s%02d%s%02d" days hours colon minutes colon seconds))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
((< 0 hours)
(format "%02d%s%02d%s%02d" hours colon minutes colon seconds))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(t
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(format "%02d%s%02d" minutes colon seconds)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-format-start (start)
"Format time START."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((d-start (decode-time start))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(d-current (decode-time))
(colon (if proced-enable-color-flag
(propertize ":" 'font-lock-face 'proced-time-colon)
":")))
(cond (;; process started in previous years
(< (decoded-time-year d-start) (decoded-time-year d-current))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(format-time-string " %Y" start))
;; process started today
((and (= (decoded-time-day d-start) (decoded-time-day d-current))
(= (decoded-time-month d-start) (decoded-time-month d-current)))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(string-replace ":" colon (format-time-string " %H:%M" start)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(t ;; process started this year
(format-time-string "%b %e" start)))))
(defun proced-format-ttname (ttname)
"Format attribute TTNAME, omitting path \"/dev/\"."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Does this work for all systems?
(substring ttname (if (string-match "\\`/dev/" ttname)
(match-end 0) 0)))
(defun proced-format-tree (tree)
"Format attribute TREE."
(concat (make-string tree ?\s) (number-to-string tree)))
;; Proced assumes that every process occupies only one line in the listing.
(defun proced-format-args (args)
"Format attribute ARGS.
Replace newline characters by \"^J\" (two characters)."
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(string-replace "\n" "^J"
(pcase-let* ((`(,exe . ,rest) (split-string args))
(exe-prop (if proced-enable-color-flag
(propertize exe 'font-lock-face 'proced-executable)
exe)))
(mapconcat #'identity (cons exe-prop rest) " "))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-format-memory (kilobytes)
"Format KILOBYTES in a human readable format."
(funcall byte-count-to-string-function (* 1024 kilobytes)))
Add colors to Proced (bug#59407) Add a new custom variable proced-enable-color-flag which when set to a non-nil value (defaults to nil), will prompt some format functions to furnish their respective process attributes with colors and effects in order to make them easier to distinguish and highlight possible issues (e.g. high memory usage), in a manner similar to htop. In particular, the current Emacs process id is highlighted purple in both the process id and parent process id columns, session leaders have their process ids underlined, larger memory sizes for rss are highlighted in darker shades of orange, and the first word in the args property (the executable) is highlighted in blue. * lisp/proced.el (proced-grammar-alist): Update to use the new format functions. (proced-low-memory-usage-threshold): New custom variable to determine whether a value represents 'low' memory usage, used only in proced-format-memory for coloring. (proced-medium-memory-usage-threshold): New custom variable to determine whether a value represents 'medium' memory usage, used only in proced-format-memory for coloring. (proced-enable-color-flag): New custom variable to toggle coloring. (proced-run-status-code, proced-interruptible-sleep-status-code) (proced-uninterruptible-sleep-status-code, proced-executable) (proced-executable, proced-memory-gb, proced-memory-mb) (proced-memory-default, proced-pid, proced-ppid, proced-pgrp) (proced-sess, proced-cpu, proced-mem, proced-user, proced-time-colon): New faces. (proced-format-time): Edit function to color colons using proced-time-colon. (proced-format-args): Edit function to color executables using proced-executable. (proced-format-state): New function to color states. (proced-format-pid): New function to color process ids. (proced-format-ppid): New function to color parent process ids. (proced-format-pgrp): New function to color process group ids. (proced-format-sess): New function to color process session leader ids. (proced-format-cpu): New function to color cpu utilization. (proced-format-mem): New function to color memory utilization. (proced-format-user): New function to color the user a process belongs to.
2022-11-16 14:32:44 +00:00
(defun proced-format-rss (kilobytes)
"Format RSS KILOBYTES in a human readable format."
(let ((formatted (proced-format-memory kilobytes)))
(if-let* ((proced-enable-color-flag)
(total (car (memory-info)))
(proportion (/ (float kilobytes) total)))
(cond ((< proportion proced-low-memory-usage-threshold)
(propertize formatted 'font-lock-face 'proced-memory-low-usage))
((< proportion proced-medium-memory-usage-threshold)
(propertize formatted 'font-lock-face 'proced-memory-medium-usage))
(t (propertize formatted 'font-lock-face 'proced-memory-high-usage)))
formatted)))
(defun proced-format-state (state)
"Format STATE."
(cond ((and proced-enable-color-flag (string= state "R"))
(propertize state 'font-lock-face 'proced-run-status-code))
((and proced-enable-color-flag (string= state "S"))
(propertize state 'font-lock-face 'proced-interruptible-sleep-status-code))
((and proced-enable-color-flag (string= state "D"))
(propertize state 'font-lock-face 'proced-uninterruptible-sleep-status-code))
(t state)))
(defun proced-format-pid (pid)
"Format PID."
(let ((proc-info (process-attributes pid))
(pid-s (number-to-string pid)))
(cond ((and proced-enable-color-flag
(not (file-remote-p default-directory))
(equal pid (emacs-pid)))
(propertize pid-s 'font-lock-face 'proced-emacs-pid))
((and proced-enable-color-flag (equal pid (alist-get 'sess proc-info)))
(propertize pid-s 'font-lock-face 'proced-session-leader-pid))
(proced-enable-color-flag
(propertize pid-s 'font-lock-face 'proced-pid))
(t pid-s))))
(defun proced-format-ppid (ppid)
"Format PPID."
(let ((ppid-s (number-to-string ppid)))
(cond ((and proced-enable-color-flag
(not (file-remote-p default-directory))
(= ppid (emacs-pid)))
(propertize ppid-s 'font-lock-face 'proced-emacs-pid))
(proced-enable-color-flag
(propertize ppid-s 'font-lock-face 'proced-ppid))
(t ppid-s))))
(defun proced-format-pgrp (pgrp)
"Format PGRP."
(if proced-enable-color-flag
(propertize (number-to-string pgrp) 'font-lock-face 'proced-pgrp)
(number-to-string pgrp)))
(defun proced-format-sess (sess)
"Format SESS."
(if proced-enable-color-flag
(propertize (number-to-string sess) 'font-lock-face 'proced-sess)
(number-to-string sess)))
(defun proced-format-cpu (cpu)
"Format CPU."
(let ((formatted (format "%.1f" cpu)))
(if proced-enable-color-flag
(propertize formatted 'font-lock-face 'proced-cpu)
formatted)))
(defun proced-format-mem (mem)
"Format MEM."
(let ((formatted (format "%.1f" mem)))
(if proced-enable-color-flag
(propertize formatted 'font-lock-face 'proced-mem)
formatted)))
(defun proced-format-user (user)
"Format USER."
(if proced-enable-color-flag
(propertize user 'font-lock-face 'proced-user)
user))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-format (process-alist format)
"Display PROCESS-ALIST using FORMAT."
(if (symbolp format)
(setq format (cdr (assq format proced-format-alist))))
;; Not all systems give us all attributes. We take `emacs-pid' as a
;; representative process PID. If FORMAT contains a list of alternative
;; attributes, we take the first attribute that is non-nil for `emacs-pid'.
;; If none of the alternatives is non-nil, the attribute is ignored
;; in the listing.
(let ((standard-attributes
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(car (proced-process-attributes (list-system-processes))))
new-format fmi)
(if (and proced-tree-flag
(assq 'ppid standard-attributes))
(push (cons 'tree 0) standard-attributes))
(dolist (fmt format)
(if (symbolp fmt)
(if (assq fmt standard-attributes)
(push fmt new-format))
(while (setq fmi (pop fmt))
(when (assq fmi standard-attributes)
(push fmi new-format)
(setq fmt nil)))))
(setq format (nreverse new-format)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(insert (make-string (length process-alist) ?\n))
(let ((whitespace " ") (unknown "?")
(sort-key (if (consp proced-sort) (car proced-sort) proced-sort))
header-list grammar)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; Loop over all attributes
(while (setq grammar (assq (pop format) proced-grammar-alist))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let* ((key (car grammar))
(nth2grm (nth 2 grammar))
(fun (cond ((stringp nth2grm)
(lambda (arg) (format nth2grm arg)))
((not nth2grm) #'identity)
(t nth2grm)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(whitespace (if format whitespace ""))
;; Text properties:
;; We use the text property `proced-key' to store in each
;; field the corresponding key.
;; Of course, the sort predicate appearing in help-echo
;; is only part of the story. But it gives the main idea.
(hprops
(if (nth 4 grammar)
(let ((descend (if (eq key sort-key) proced-descend (nth 5 grammar))))
`(proced-key ,key mouse-face header-line-highlight
help-echo ,(format proced-header-help-echo
(if descend "-" "+")
(nth 1 grammar)
(if descend "descending" "ascending"))))))
(refiner (nth 7 grammar))
(fprops
(cond ((functionp (car refiner))
`(proced-key ,key mouse-face highlight
help-echo ,(format "mouse-2, RET: %s"
(nth 1 refiner))))
((consp refiner)
`(proced-key ,key mouse-face highlight
help-echo ,(format "mouse-2, RET: refine by attribute %s %s"
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(nth 1 grammar)
(mapconcat (lambda (s)
(if s "+" "-"))
refiner ""))))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
value)
;; highlight the header of the sort column
(if (eq key sort-key)
(setq hprops (append '(face proced-sort-header) hprops)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(goto-char (point-min))
(cond ( ;; fixed width of output field
(numberp (nth 3 grammar))
(dolist (process process-alist)
(end-of-line)
(setq value (cdr (assq key (cdr process))))
(insert (if value
(apply #'propertize (funcall fun value) fprops)
(format (concat "%" (number-to-string (nth 3 grammar)) "s")
unknown))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
whitespace)
(forward-line))
(push (format (concat "%" (number-to-string (nth 3 grammar)) "s")
(apply #'propertize (nth 1 grammar) hprops))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
header-list))
( ;; last field left-justified
(and (not format) (eq 'left (nth 3 grammar)))
(dolist (process process-alist)
(end-of-line)
(setq value (cdr (assq key (cdr process))))
(insert (if value (apply #'propertize (funcall fun value) fprops)
unknown))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(forward-line))
(push (apply #'propertize (nth 1 grammar) hprops) header-list))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(t ;; calculated field width
(let ((width (length (nth 1 grammar)))
field-list value)
(dolist (process process-alist)
(setq value (cdr (assq key (cdr process))))
(if value
(setq value (apply #'propertize (funcall fun value) fprops)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
width (max width (length value))
field-list (cons value field-list))
(push unknown field-list)
(setq width (max width (length unknown)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((afmt (concat "%" (if (eq 'left (nth 3 grammar)) "-" "")
(number-to-string width) "s")))
(push (format afmt (apply #'propertize (nth 1 grammar) hprops))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
header-list)
(dolist (value (nreverse field-list))
(end-of-line)
(insert (format afmt value) whitespace)
(forward-line))))))))
;; final cleanup
(goto-char (point-min))
(dolist (process process-alist)
;; We use the text property `proced-pid' to store in each line
;; the corresponding pid
(put-text-property (point) (line-end-position) 'proced-pid (car process))
(forward-line))
;; Set header line
(setq proced-header-line
(mapconcat #'identity (nreverse header-list) whitespace))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(if (string-match "[ \t]+$" proced-header-line)
(setq proced-header-line (substring proced-header-line 0
(match-beginning 0))))
;; (delete-trailing-whitespace)
(goto-char (point-min))
(while (re-search-forward "[ \t\r]+$" nil t)
(delete-region (match-beginning 0) (match-end 0)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-format-interactive (scheme &optional revert)
"Format Proced buffer using SCHEME.
When called interactively, an empty string means nil, i.e., no formatting.
Set variable `proced-format' to SCHEME.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
With prefix REVERT non-nil revert listing."
(interactive
(let ((scheme (completing-read "Format: "
proced-format-alist nil t)))
(list (if (string= "" scheme) nil (intern scheme))
current-prefix-arg))
proced-mode)
;; only update if necessary
(when (or (not (eq proced-format scheme)) revert)
(setq proced-format scheme)
(proced-update revert)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; generate listing
(defun proced-process-attributes (&optional pid-list)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
"Return alist of attributes for each system process.
This alist can be customized via `proced-custom-attributes'.
Optional arg PID-LIST is a list of PIDs of system process that are analyzed.
If no attributes are known for a process (possibly because it already died)
the process is ignored."
;; Should we make it customizable whether processes with empty attribute
;; lists are ignored? When would such processes be of interest?
(let (process-alist attributes attr)
(dolist (pid (or pid-list (list-system-processes)) process-alist)
(when (setq attributes (process-attributes pid))
(setq attributes (cons (cons 'pid pid) attributes))
(dolist (fun proced-custom-attributes)
(if (setq attr (funcall fun attributes))
(push attr attributes)))
(push (cons pid attributes) process-alist)))))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(defun proced-update (&optional revert quiet)
"Update the Proced process information. Preserves point and marks.
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
With prefix REVERT non-nil, revert listing.
Suppress status information if QUIET is nil.
After updating a displayed Proced buffer run the normal hook
`proced-post-display-hook'."
;; This is the main function that generates and updates the process listing.
(interactive "P" proced-mode)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(setq revert (or revert (not proced-process-alist)))
(or quiet (message (if revert "Updating process information..."
"Updating process display...")))
(if revert ;; evaluate all processes
(setq proced-process-alist (proced-process-attributes)))
;; filtering
(setq proced-process-alist (proced-filter proced-process-alist proced-filter))
;; refinements
(pcase-dolist (`(,refiner ,pid ,key ,grammar) proced-refinements)
;; It's possible the process has exited since the refinement was made
(when (assq pid proced-process-alist)
(cond ((functionp (car refiner))
(setq proced-process-alist (funcall (car refiner) pid)))
((consp refiner)
(let ((predicate (nth 4 grammar))
(ref (cdr (assq key (cdr (assq pid proced-process-alist)))))
val new-alist)
(dolist (process proced-process-alist)
(setq val (funcall predicate (cdr (assq key (cdr process))) ref))
(when (cond ((not val) (nth 2 refiner))
((eq val 'equal) (nth 1 refiner))
(val (car refiner)))
(push process new-alist)))
(setq proced-process-alist new-alist))))))
;; sorting
(setq proced-process-alist
(proced-sort proced-process-alist proced-sort proced-descend))
;; display as process tree?
(setq proced-process-alist
(proced-tree proced-process-alist))
;; It is useless to keep undo information if we revert, filter, or
;; refine the listing so that `proced-process-alist' has changed.
;; We could keep the undo information if we only re-sort the buffer.
;; Would that be useful? Re-re-sorting is easy, too.
(if (consp buffer-undo-list)
(setq buffer-undo-list nil))
(let ((buffer-undo-list t)
(window-pos-infos
(mapcar (lambda (w) `(,w . ,(proced--position-info (window-point w))))
(get-buffer-window-list (current-buffer) nil t)))
(old-pos (proced--position-info (point)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
buffer-read-only mp-list)
2008-03-26 02:15:28 +00:00
;; remember marked processes (whatever the mark was)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(goto-char (point-min))
(while (re-search-forward "^\\(\\S-\\)" nil t)
(push (cons (save-match-data (proced-pid-at-point))
(match-string-no-properties 1)) mp-list))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; generate listing
2008-03-26 02:15:28 +00:00
(erase-buffer)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(proced-format proced-process-alist proced-format)
2008-03-26 02:15:28 +00:00
(goto-char (point-min))
(while (not (eobp))
(insert " ")
(forward-line))
(setq proced-header-line (concat " " proced-header-line))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(if revert (set-buffer-modified-p nil))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; set `goal-column'
(let ((grammar (assq proced-goal-attribute proced-grammar-alist)))
(setq goal-column ;; set to nil if no match
(if (and grammar
(not (zerop (buffer-size)))
(string-match (regexp-quote (nth 1 grammar))
proced-header-line))
(if (nth 3 grammar)
(match-beginning 0)
(match-end 0)))))
;; Restore process marks and buffer position (if possible).
;; Sometimes this puts point in the middle of the proced buffer
;; where it is not interesting. Is there a better / more flexible solution?
(goto-char (point-min))
(let (pid mark new-pos win-points)
(if (or mp-list (car old-pos))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(while (not (eobp))
(setq pid (proced-pid-at-point))
(when (setq mark (assq pid mp-list))
(insert (cdr mark))
(delete-char 1)
(beginning-of-line))
(when (eq (car old-pos) pid)
(setq new-pos (proced--determine-pos (nth 1 old-pos)
(nth 2 old-pos))))
(mapc (lambda (w-pos)
(when (eq (cadr w-pos) pid)
(push `(,(car w-pos) . ,(proced--determine-pos
(nth 1 (cdr w-pos))
(nth 2 (cdr w-pos))))
win-points)))
window-pos-infos)
(forward-line)))
(let ((fallback (save-excursion (goto-char (point-min))
(proced-move-to-goal-column)
(point))))
(goto-char (or new-pos fallback))
;; Update window points
(mapc (lambda (w-pos)
(set-window-point (car w-pos)
(alist-get (car w-pos) win-points fallback)))
window-pos-infos)))
Remove incorrect uses of "modeline". * ansi-color.el (ansi-color-faces-vector): Change default faces. * cus-edit.el (mode-line): * dframe.el (dframe-mouse-hscroll): * emacs-lisp/re-builder.el: * emacs-lisp/easy-mmode.el (define-minor-mode): * frame.el (set-frame-name): * help.el (lookup-minor-mode-from-indicator): * net/rcirc.el (rcirc-activity-string, rcirc-short-buffer-name): * progmodes/cc-cmds.el (c-toggle-auto-newline) (c-toggle-hungry-state): * progmodes/antlr-mode.el (antlr-language-alist): * progmodes/idlw-shell.el (idlwave-shell-electric-stop-line-face): * progmodes/vhdl-mode.el (vhdl-mode): * progmodes/which-func.el (which-func, which-func-cleanup-function): * term/ns-win.el (ns-face-at-pos): * term/sup-mouse.el (sup-mouse-report): * textmodes/flyspell.el (flyspell-mode-line-string): * textmodes/ispell.el (ispell-highlight-face): * textmodes/reftex-global.el: * vc/vc-arch.el (vc-arch-mode-line-string): * vc/vc-cvs.el (vc-cvs-mode-line-string): * vc/vc-git.el (vc-git-mode-line-string): * vc/vc-hooks.el (vc-display-status) (vc-default-mode-line-string): * vc/vc-mtn.el (vc-mtn-mode-line-string): Doc fixes. * dired.el (dired-sort-set-mode-line): Rename from dired-sort-set-modeline. All callers changed. * foldout.el (foldout-mode-line-string): Rename from foldout-modeline-string. All callers changed. (foldout-update-mode-line): Rename from foldout-update-modeline. * strokes.el (strokes-lighter): Rename from strokes-modeline-string. * subr.el (redraw-modeline): Make into obsolete alias. * calendar/timeclock.el (timeclock-mode-line-display): Rename from timeclock-modeline-display. Make old name an alias. (timeclock-update-mode-line): Likewise. All callers changed. (timeclock-mode-line-display): No need to check before using add-hook. (timeclock-relative, timeclock-day-over-hook) (timeclock-use-elapsed, timeclock-mode-string) (timeclock-mode-line-display): Doc fix, "modeline" -> "mode line". * emulation/crisp.el (crisp-mode-mode-line-string): Rename from crisp-mode-modeline-string. * erc-track.el (erc-track, erc-track-faces-priority-list) (erc-track-faces-normal-list, erc-track-find-face) (erc-track-modified-channels): Fix modeline -> mode line in docs. * eshell/esh-mode.el (eshell-status-in-mode-line): Rename from eshell-status-in-modeline. * org-clock.el (org-clock-string-limit) (org-clock-modeline-total, org-clock-task-overrun-text) (org-clock-mode-line-entry): Doc fix, "modeline" -> "mode line". * play/solitaire.el (solitaire-build-mode-line): Rename from solitaire-build-modeline. All callers changed. * play/zone.el (zone-hiding-mode-line): Rename from zone-hiding-modeline. All callers changed. (zone): Remove unusued `modeline-hidden-level' property. * progmodes/xscheme.el (xscheme-mode-line-initialize): Rename from xscheme-modeline-initialize. All callers changed. * textmodes/sgml-mode.el (html-face-tag-alist) (html-tag-face-alist): Use mode-line face instead of obsolete alias modeline. Fixes: debbugs:10329
2012-06-02 10:56:09 +00:00
;; update mode line
;; Does the long `mode-name' clutter the mode line? It would be nice
;; to have some other location for displaying the values of the various
;; flags that affect the behavior of proced (flags one might want
;; to change on the fly). Where??
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(setq mode-name
(concat "Proced"
(if proced-filter
(concat ": " (symbol-name proced-filter))
"")
(if proced-sort
(let* ((key (if (consp proced-sort) (car proced-sort)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
proced-sort))
(grammar (assq key proced-grammar-alist)))
(concat " by " (if proced-descend "-" "+")
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(nth 1 grammar)))
"")))
(force-mode-line-update)
;; run `proced-post-display-hook' only for a displayed buffer.
(if (get-buffer-window) (run-hooks 'proced-post-display-hook))
;; done
2008-03-26 02:15:28 +00:00
(or quiet (input-pending-p)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(message (if revert "Updating process information...done."
"Updating process display...done.")))))
2008-03-26 02:15:28 +00:00
2011-04-19 13:44:55 +00:00
(defun proced-revert (&rest _args)
"Reevaluate the process listing based on the currently running processes.
Preserves point and marks, but not refinements (see `proced-refine' for
information on refinements)."
(setq proced-refinements nil)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(proced-update t))
2008-03-26 02:15:28 +00:00
(defun proced-marked-processes ()
"Return marked processes as alist of PIDs.
If no process is marked return alist with the PID of the process point is on.
The cdrs of the alist are the text strings displayed by Proced for these
processes. They are used for error messages."
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let ((regexp (proced-marker-regexp))
process-alist)
2008-03-26 02:15:28 +00:00
;; collect marked processes
(save-excursion
(goto-char (point-min))
(while (re-search-forward regexp nil t)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(push (cons (proced-pid-at-point)
;; How much info should we collect here?
(buffer-substring-no-properties
(+ 2 (line-beginning-position))
(line-end-position)))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
process-alist)))
(if process-alist
(nreverse process-alist)
;; take current process
(let ((pid (proced-pid-at-point)))
(if pid
(list (cons pid
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(buffer-substring-no-properties
(+ 2 (line-beginning-position))
(line-end-position)))))))))
(defmacro proced-with-processes-buffer (process-alist &rest body)
"Execute the forms in BODY in a temporary buffer displaying PROCESS-ALIST.
PROCESS-ALIST is an alist of process PIDs as in `proced-process-alist'.
The value returned is the value of the last form in BODY."
(declare (indent 1) (debug t))
;; Use leading space in buffer name to make this buffer ephemeral
`(let ((bufname " *Marked Processes*")
(header-line (substring-no-properties proced-header-line)))
(with-current-buffer (get-buffer-create bufname)
(setq truncate-lines t
proced-header-line header-line ; inherit header line
header-line-format '(:eval (proced-header-line)))
(add-hook 'post-command-hook #'force-mode-line-update nil t) ;FIXME: Why?
(let ((inhibit-read-only t))
(erase-buffer)
(buffer-disable-undo)
(setq buffer-read-only t)
(dolist (process ,process-alist)
(insert " " (cdr process) "\n"))
(delete-char -1)
(goto-char (point-min)))
(save-window-excursion
;; Analogous to `dired-pop-to-buffer'
;; Don't split window horizontally. (Bug#1806)
Delete many items obsolete since 24.3 * lisp/allout.el (allout-exposure-change-hook) (allout-structure-added-hook, allout-structure-deleted-hook) (allout-structure-shifted-hook): * lisp/arc-mode.el (archive-extract-hooks): * lisp/buff-menu.el (Buffer-menu-buffer+size-width): * lisp/calendar/timeclock.el (timeclock-modeline-display) (timeclock-modeline-display, timeclock-update-modeline): * lisp/cedet/semantic/db-el.el (semanticdb-elisp-sym-function-arglist): * lisp/cedet/semantic/db-file.el (semanticdb-save-database-hooks): * lisp/cedet/semantic/edit.el (semantic-change-hooks) (semantic-edits-new-change-hooks) (semantic-edits-delete-change-hooks) (semantic-edits-reparse-change-hooks): * lisp/cedet/semantic/lex.el (semantic-lex-reset-hooks): * lisp/comint.el (comint--unquote&expand-filename) (comint-unquote-filename): * lisp/custom.el (user-variable-p): * lisp/dired.el (dired-shrink-to-fit, dired-pop-to-buffer) (dired-sort-set-modeline): * lisp/ebuff-menu.el (Electric-buffer-menu-mode): * lisp/emacs-lisp/byte-run.el (macro-declaration-function): * lisp/emacs-lisp/checkdoc.el (custom-print-functions) (checkdoc-comment-style-hooks): * lisp/emacs-lisp/cl-lib.el (custom-print-functions): * lisp/emacs-lisp/edebug.el (gud-inhibit-global-bindings): * lisp/erc/erc-dcc.el (erc-dcc-chat-filter-hook): * lisp/eshell/esh-mode.el (eshell-status-in-modeline): * lisp/eshell/eshell.el (eshell-add-to-window-buffer-names) (eshell-remove-from-window-buffer-names): * lisp/faces.el (set-face-underline-p, font-list-limit): * lisp/files.el (automount-dir-prefix, toggle-read-only): * lisp/filesets.el (filesets-cache-fill-content-hooks): * lisp/frame.el (automatic-hscrolling): * lisp/generic-x.el (javascript-generic-mode) (javascript-generic-mode-hook): * lisp/gnus/gnus-start.el (gnus-subscribe-newsgroup-hooks): * lisp/gnus/nndiary.el (nndiary-request-create-group-hooks) (nndiary-request-update-info-hooks) (nndiary-request-accept-article-hooks): * lisp/htmlfontify.el (hfy-post-html-hooks): * lisp/international/mule-cmds.el (inactivate-current-input-method-function) (inactivate-input-method, input-method-inactivate-hook) (ucs-insert): * lisp/international/quail.el (quail-inactivate) (quail-inactivate-hook): * lisp/international/robin.el (robin-inactivate) (robin-inactivate-hook): * lisp/leim/quail/hangul.el (hangul-input-method-inactivate): * lisp/leim/quail/uni-input.el (ucs-input-inactivate): * lisp/mail/emacsbug.el (report-emacs-bug-info): * lisp/mh-e/mh-e.el (mh-kill-folder-suppress-prompt-hooks): * lisp/mpc.el (mpc-string-prefix-p): * lisp/net/rcirc.el (rcirc-print-hooks, rcirc-sentinel-hooks) (rcirc-receive-message-hooks, rcirc-activity-hooks): * lisp/obsolete/crisp.el (crisp-mode-modeline-string): * lisp/pcomplete.el (pcomplete-arg-quote-list) (pcomplete-quote-argument): * lisp/progmodes/cc-mode.el (c-prepare-bug-report-hooks): * lisp/progmodes/python.el (python-info-ppss-context) (python-info-ppss-context-type) (python-info-ppss-comment-or-string-p, python-indent) (python-guess-indent, python-buffer, python-preoutput-result) (python-proc, python-send-receive, python-send-string) (python-use-skeletons): * lisp/progmodes/sh-script.el (sh-maybe-here-document): * lisp/replace.el (query-replace-interactive): * lisp/strokes.el (strokes-modeline-string): * lisp/subr.el (redraw-modeline): * lisp/term.el (term-default-fg-color, term-default-bg-color): * lisp/textmodes/tex-mode.el (latex-string-prefix-p) (tex-string-prefix-p): * lisp/url/url-parse.el (url-recreate-url-attributes): * lisp/vc/add-log.el (change-log-acknowledgement): * lisp/vc/ediff-wind.el (ediff-choose-window-setup-function-automatically): * lisp/vc/pcvs-util.el (cvs-string-prefix-p): * lisp/vc/vc.el (vc-string-prefix-p): * lisp/window.el (display-buffer-function): * lisp/winner.el (winner-mode-leave-hook): Remove many functions and variables obsolete since 24.3. * lisp/buff-menu.el (list-buffers--refresh): * lisp/dired.el (dired-mode-map): * lisp/files.el (abbreviate-file-name): * lisp/generic-x.el (generic-default-modes): * lisp/mh-e/mh-funcs.el (mh-kill-folder): * lisp/progmodes/hideif.el (hide-ifdef-mode-submap): * lisp/replace.el (query-replace-read-from): * lisp/term.el (term): * lisp/window.el (display-buffer): Don't use above deleted functions and variables. * src/marker.c (Fbuffer_has_markers_at): Delete DEFUN obsolete since 24.3. (syms_of_marker) <Sbuffer_has_markers_at>: Delete defsubr. * lisp/subr.el (buffer-has-markers-at): Remove obsoletion of above deleted DEFUN. * etc/TODO: Doc fix; don't mention above deleted function. * admin/cus-test.el (cus-test-get-options): * lisp/pcomplete.el: Doc fixes; don't mention removed items. ; * etc/NEWS: List removed items.
2022-07-10 11:27:36 +00:00
;; FIXME: `dired-pop-to-buffer' was removed and replaced with
;; `dired-mark-pop-up'. Should we just use
;; `pop-to-buffer' here also?
(display-buffer (current-buffer)
'(display-buffer-in-direction
(direction . bottom)
(window-height . fit-window-to-buffer)))
,@body))))
(defun proced-send-signal (&optional signal process-alist)
"Send a SIGNAL to processes in PROCESS-ALIST.
PROCESS-ALIST is an alist as returned by `proced-marked-processes'.
Interactively, PROCESS-ALIST contains the marked processes.
If no process is marked, it contains the process point is on,
SIGNAL may be a string (HUP, INT, TERM, etc.) or a number.
After sending SIGNAL to all processes in PROCESS-ALIST, this command
runs the normal hook `proced-after-send-signal-hook'.
For backward compatibility SIGNAL and PROCESS-ALIST may be nil.
Then PROCESS-ALIST contains the marked processes or the process point is on
and SIGNAL is queried interactively. This noninteractive usage is still
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
supported but discouraged. It will be removed in a future version of Emacs."
(interactive
(let* ((process-alist (proced-marked-processes))
(pnum (if (= 1 (length process-alist))
"1 process"
(format "%d processes" (length process-alist))))
(completion-ignore-case t)
(completion-extra-properties
`(:annotation-function
,(lambda (s) (cdr (assoc s proced-signal-list))))))
(proced-with-processes-buffer process-alist
Use format-prompt for many more prompts * lisp/bookmark.el (bookmark-completing-read): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-store.el (calc-permanent-variable): * lisp/calc/calc-units.el (calc-convert-units) (calc-convert-exact-units, calc-convert-temperature): * lisp/cedet/semantic/complete.el (semantic-complete-read-tag-engine): * lisp/cus-edit.el (customize-read-group): * lisp/dired-aux.el (dired-do-chxxx): * lisp/dired-x.el (dired-mark-unmarked-files): * lisp/emacs-lisp/debug.el (cancel-debug-on-entry) (cancel-debug-on-variable-change): * lisp/emacs-lisp/edebug.el (edebug-cancel-on-entry) (edebug-remove-instrumentation): * lisp/epa.el (epa-read-file-name, epa-export-keys): * lisp/faces.el (read-face-name): * lisp/format.el (format-decode-buffer, format-decode-region): * lisp/gnus/gnus-art.el (gnus-read-save-file-name): * lisp/gnus/gnus-util.el (gnus-completing-read): * lisp/gnus/message.el (message-check-news-header-syntax): * lisp/info.el (Info-follow-reference): * lisp/international/mule-diag.el (describe-font) (describe-fontset): * lisp/international/quail.el (quail-show-keyboard-layout): * lisp/language/cyril-util.el (standard-display-cyrillic-translit): * lisp/mail/rmailkwd.el (rmail-read-label): * lisp/mail/rmailmm.el (rmail-mime-save): * lisp/mail/rmailout.el (rmail-output-read-file-name): * lisp/man.el (Man-goto-section, Man-follow-manual-reference): * lisp/menu-bar.el (emacs-index--prompt): * lisp/net/ange-ftp.el (ange-ftp-get-passwd): * lisp/proced.el (proced-send-signal): * lisp/progmodes/cpp.el (cpp-choose-face): * lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation): * lisp/progmodes/etags.el (visit-tags-table) (visit-tags-table-buffer): * lisp/progmodes/grep.el (grep-read-files): * lisp/progmodes/hideif.el (hide-ifdef-define): * lisp/progmodes/pascal.el (pascal-goto-defun): * lisp/progmodes/prolog.el (prolog-read-predicate): * lisp/progmodes/sql.el (sql-get-login-ext): * lisp/ses.el (ses-define-local-printer): * lisp/textmodes/artist.el (artist-figlet-choose-font): * lisp/textmodes/tex-mode.el (tex-compile): * lisp/vc/diff.el (diff): * lisp/vc/ediff-ptch.el (ediff-prompt-for-patch-file): * lisp/vc/ediff-util.el (ediff-read-file-name): * lisp/vc/pcvs.el (cvs-mode-mark-on-state): * lisp/vc/vc.el (vc-diff-build-argument-list-internal) (vc-revision-other-window, vc-retrieve-tag): * lisp/wid-edit.el: Prefer format-prompt unconditionally. * lisp/org/org-capture.el (org-capture-fill-template): * lisp/org/org-refile.el (org-refile-get-location): * lisp/progmodes/python.el (python-eldoc-at-point): * lisp/progmodes/verilog-mode.el (verilog-surelint-off) (verilog-goto-defun): * lisp/progmodes/xref.el (xref--read-identifier): Prefer format-prompt when it is fboundp.
2021-10-05 01:34:08 +00:00
(list (completing-read (format-prompt "Send signal [%s]"
"TERM" pnum)
proced-signal-list
nil nil nil nil "TERM")
process-alist)))
proced-mode)
(unless (and signal process-alist)
2012-10-05 05:57:24 +00:00
;; Discouraged usage (supported for backward compatibility):
;; The new calling sequence separates more cleanly between the parts
;; of the code required for interactive and noninteractive calls so that
;; the command can be used more flexibly in noninteractive ways, too.
(unless (get 'proced-send-signal 'proced-outdated)
(put 'proced-send-signal 'proced-outdated t)
(message "Outdated usage of `proced-send-signal'")
(sit-for 2))
(setq process-alist (proced-marked-processes))
(unless signal
(let ((pnum (if (= 1 (length process-alist))
"1 process"
(format "%d processes" (length process-alist))))
(completion-ignore-case t)
(completion-extra-properties
`(:annotation-function
,(lambda (s) (cdr (assoc s proced-signal-list))))))
(proced-with-processes-buffer process-alist
Use format-prompt for many more prompts * lisp/bookmark.el (bookmark-completing-read): * lisp/calc/calc-prog.el (calc-user-define-formula): * lisp/calc/calc-store.el (calc-permanent-variable): * lisp/calc/calc-units.el (calc-convert-units) (calc-convert-exact-units, calc-convert-temperature): * lisp/cedet/semantic/complete.el (semantic-complete-read-tag-engine): * lisp/cus-edit.el (customize-read-group): * lisp/dired-aux.el (dired-do-chxxx): * lisp/dired-x.el (dired-mark-unmarked-files): * lisp/emacs-lisp/debug.el (cancel-debug-on-entry) (cancel-debug-on-variable-change): * lisp/emacs-lisp/edebug.el (edebug-cancel-on-entry) (edebug-remove-instrumentation): * lisp/epa.el (epa-read-file-name, epa-export-keys): * lisp/faces.el (read-face-name): * lisp/format.el (format-decode-buffer, format-decode-region): * lisp/gnus/gnus-art.el (gnus-read-save-file-name): * lisp/gnus/gnus-util.el (gnus-completing-read): * lisp/gnus/message.el (message-check-news-header-syntax): * lisp/info.el (Info-follow-reference): * lisp/international/mule-diag.el (describe-font) (describe-fontset): * lisp/international/quail.el (quail-show-keyboard-layout): * lisp/language/cyril-util.el (standard-display-cyrillic-translit): * lisp/mail/rmailkwd.el (rmail-read-label): * lisp/mail/rmailmm.el (rmail-mime-save): * lisp/mail/rmailout.el (rmail-output-read-file-name): * lisp/man.el (Man-goto-section, Man-follow-manual-reference): * lisp/menu-bar.el (emacs-index--prompt): * lisp/net/ange-ftp.el (ange-ftp-get-passwd): * lisp/proced.el (proced-send-signal): * lisp/progmodes/cpp.el (cpp-choose-face): * lisp/progmodes/ebrowse.el (ebrowse-set-tree-indentation): * lisp/progmodes/etags.el (visit-tags-table) (visit-tags-table-buffer): * lisp/progmodes/grep.el (grep-read-files): * lisp/progmodes/hideif.el (hide-ifdef-define): * lisp/progmodes/pascal.el (pascal-goto-defun): * lisp/progmodes/prolog.el (prolog-read-predicate): * lisp/progmodes/sql.el (sql-get-login-ext): * lisp/ses.el (ses-define-local-printer): * lisp/textmodes/artist.el (artist-figlet-choose-font): * lisp/textmodes/tex-mode.el (tex-compile): * lisp/vc/diff.el (diff): * lisp/vc/ediff-ptch.el (ediff-prompt-for-patch-file): * lisp/vc/ediff-util.el (ediff-read-file-name): * lisp/vc/pcvs.el (cvs-mode-mark-on-state): * lisp/vc/vc.el (vc-diff-build-argument-list-internal) (vc-revision-other-window, vc-retrieve-tag): * lisp/wid-edit.el: Prefer format-prompt unconditionally. * lisp/org/org-capture.el (org-capture-fill-template): * lisp/org/org-refile.el (org-refile-get-location): * lisp/progmodes/python.el (python-eldoc-at-point): * lisp/progmodes/verilog-mode.el (verilog-surelint-off) (verilog-goto-defun): * lisp/progmodes/xref.el (xref--read-identifier): Prefer format-prompt when it is fboundp.
2021-10-05 01:34:08 +00:00
(setq signal (completing-read (format-prompt "Send signal [%s]"
"TERM" pnum)
proced-signal-list
nil nil nil nil "TERM"))))))
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(let (failures)
;; Why not always use `signal-process'? See
;; https://lists.gnu.org/r/emacs-devel/2008-03/msg02955.html
(if (functionp proced-signal-function)
;; use built-in `signal-process'
(let ((signal (if (stringp signal)
(if (string-match "\\`[0-9]+\\'" signal)
(string-to-number signal)
(make-symbol signal))
signal))) ; number
(dolist (process process-alist)
(condition-case err
(unless (zerop (funcall
proced-signal-function (car process) signal
(file-remote-p default-directory)))
(proced-log "%s\n" (cdr process))
(push (cdr process) failures))
(error ; catch errors from failed signals
(proced-log "%s\n" err)
(proced-log "%s\n" (cdr process))
(push (cdr process) failures)))))
;; use external system call
(let ((signal (format "-%s" signal)))
(dolist (process process-alist)
(with-temp-buffer
(condition-case nil
(unless (zerop (process-file
proced-signal-function nil t nil
signal (number-to-string (car process))))
(proced-log (current-buffer))
(proced-log "%s\n" (cdr process))
(push (cdr process) failures))
(error ; catch errors from failed signals
(proced-log (current-buffer))
(proced-log "%s\n" (cdr process))
(push (cdr process) failures)))))))
(if failures
;; Proced error message are not always very precise.
;; Can we issue a useful one-line summary in the
;; message area (using FAILURES) if only one signal failed?
(proced-log-summary
(format "Signal %s" signal)
(format "%d of %d signal%s failed"
(length failures) (length process-alist)
(if (= 1 (length process-alist)) "" "s")))
(proced-success-message "Sent signal to" (length process-alist))))
;; final clean-up
(run-hooks 'proced-after-send-signal-hook))
(defun proced-renice (priority process-alist)
"Renice the processes in PROCESS-ALIST to PRIORITY.
PROCESS-ALIST is an alist as returned by `proced-marked-processes'.
Interactively, PROCESS-ALIST contains the marked processes.
If no process is marked, it contains the process point is on,
After renicing all processes in PROCESS-ALIST, this command runs
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
the normal hook `proced-after-send-signal-hook'."
(interactive
(let ((process-alist (proced-marked-processes)))
(proced-with-processes-buffer process-alist
(list (read-number "New priority: ")
process-alist)))
proced-mode)
(if (numberp priority)
(setq priority (number-to-string priority)))
Handle remote system processes * doc/lispref/files.texi (Magic File Names): Add list-system-processes and process-attributes. * doc/lispref/processes.texi (System Processes): Document changes in list-system-processes and process-attributes. * doc/misc/tramp.texi (Customizing Completion): Use @ftable. (Remote processes): Document changes in list-system-processes and process-attributes. * etc/NEWS: Document changes in proced, list-system-processes and process-attributes. * lisp/proced.el (proced-show-remote-processes): New defcustom. (proced-remote-directory): Remove. (proced-filter-alist): Use it. (proced-user-name): New defun. (proced-available): Set it to t. (proced-mode): Adapt docstring. (proced): Adapt docstring. Acknowledge prefix argument. (proced-format): Change initialization of `standard-attributes'. (proced-send-signal, proced-renice): Adapt docstring. Remove special handling of prefix argument. * lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist): * lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist): * lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist): * lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist): * lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist): * lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist): * lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist): * lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist): * lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist): Add 'list-system-processes' and `process-attributes'. * lisp/net/tramp-integration.el (files-x): Require `files-x'. (tramp-bsd-process-attributes-ps-args) (tramp-bsd-process-attributes-ps-format) (tramp-connection-local-bsd-ps-variables) (tramp-busybox-process-attributes-ps-args) (tramp-busybox-process-attributes-ps-format) (tramp-connection-local-busybox-ps-variables): * lisp/net/tramp-adb.el (tramp-adb-connection-local-default-ps-variables): New defconsts. Add them to connection-local variables. * lisp/net/tramp.el (tramp-file-name-for-operation): Add 'list-system-processes' and `process-attributes'. (tramp-process-attributes-ps-args) (tramp-process-attributes-ps-format): New defconsts. (tramp-ps-time, tramp-get-process-attributes) (tramp-handle-list-system-processes) (tramp-handle-process-attributes): New defuns. * src/process.c (Flist_system_processes, Fprocess_attributes): Support remote system processes. (Qlist_system_processes, Qprocess_attributes): Declare symbols.
2022-04-05 15:08:03 +00:00
(let (failures)
(dolist (process process-alist)
(with-temp-buffer
(condition-case nil
(unless (zerop (process-file
proced-renice-command nil t nil
priority (number-to-string (car process))))
(proced-log (current-buffer))
(proced-log "%s\n" (cdr process))
(push (cdr process) failures))
(error ; catch errors from failed renice
(proced-log (current-buffer))
(proced-log "%s\n" (cdr process))
(push (cdr process) failures)))))
(if failures
(proced-log-summary
(format "Renice %s" priority)
(format "%d of %d renice%s failed"
(length failures) (length process-alist)
(if (= 1 (length process-alist)) "" "s")))
(proced-success-message "Reniced" (length process-alist))))
;; final clean-up
(run-hooks 'proced-after-send-signal-hook))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
;; similar to `dired-why'
(defun proced-why ()
"Pop up a buffer with error log output from Proced.
A group of errors from a single command ends with a formfeed.
Thus, use \\[backward-page] to find the beginning of a group of errors."
(interactive nil proced-mode)
(if (get-buffer proced-log-buffer)
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(save-selected-window
;; move `proced-log-buffer' to the front of the buffer list
(select-window (display-buffer (get-buffer proced-log-buffer)))
(setq truncate-lines t)
(set-buffer-modified-p nil)
(setq buffer-read-only t)
(goto-char (point-max))
(forward-line -1)
(backward-page 1)
(recenter 0))))
;; similar to `dired-log'
(defun proced-log (log &rest args)
"Log a message or the contents of a buffer.
If LOG is a string and there are more args, it is formatted with
those ARGS. Usually the LOG string ends with a \\n.
End each bunch of errors with (proced-log t signal):
this inserts the current time, buffer and signal at the start of the page,
and \\f (formfeed) at the end."
(let ((obuf (current-buffer)))
(with-current-buffer (get-buffer-create proced-log-buffer)
(goto-char (point-max))
Require time-date. (proced-command-alist, proced-command, proced-goal-header-re) (proced-sorting-schemes-alist, proced-sorting-scheme) (proced-header-alist, proced-sorting-schemes-re) (proced-skip-regexp, proced-next-line, proced-previous-line) (proced-listing-type, proced-sorting-scheme-p): Removed. (proced-grammar-alist, proced-custom-attributes) (proced-format-alist, proced-format, proced-filter-alist) (proced-filter, proced-sort, proced-goal-attribute) (proced-timer-interval, proced-timer-flag, proced-timer) (proced-process-alist, proced-sort-internal, proced-process-tree) (proced-header-help-echo, proced-field-help-echo): New variables. (proced-pid-at-point, proced-timer, proced-mark-process-alist) (proced-omit-process, proced-filter, proced-process-tree) (proced-filter-children, proced-children-pids) (proced-filter-parents, proced-<, proced-string-lessp) (proced-time-lessp, proced-xor, proced-sort-p) (proced-format-time, proced-format-start, proced-format-ttname) (proced-format, proced-process-attributes): New functions. (proced-toggle-timer-flag, proced-mark-children) (proced-mark-parents, proced-filter-interactive) (proced-filter-attribute, proced-sort-interactive) (proced-sort-header, proced-format-interactive): New commands. (proced-move-to-goal-column): Use goal-column. (proced-mode): Use proced-timer. (proced-do-mark-all): Display process count. Use use-region-p. Simplify. (proced-omit-processes): Use use-region-p. (proced-sort-pcpu, proced-sort-pmem, proced-sort-pid) (proced-sort-start, proced-sort-time, proced-sort-user): Use proced-sort-interactive. (proced-sort): Make it a function that performs the actual sort. (proced-update): New arg revert. Use proced-process-alist, proced-filter, proced-sort, proced-format, and proced-grammar-alist. Preserve position of point based on fields. Make header line and fields clickable. (proced-send-signal): Use proced-pid-at-point and proced-process-alist. (proced-why): Use save-selected-window. (proced-log): Use buffer-read-only.
2008-09-06 23:05:49 +00:00
(let (buffer-read-only)
(cond ((stringp log)
(insert (if args
More-conservative ‘format’ quote restyling Instead of restyling curved quotes for every call to ‘format’, create a new function ‘format-message’ that does the restyling, and using the new function instead of ‘format’ only in contexts where this seems appropriate. Problem reported by Dmitry Gutov and Andreas Schwab in: http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00826.html http://lists.gnu.org/archive/html/emacs-devel/2015-08/msg00827.html * doc/lispref/commands.texi (Using Interactive): * doc/lispref/control.texi (Signaling Errors, Signaling Errors): * doc/lispref/display.texi (Displaying Messages, Progress): * doc/lispref/elisp.texi: * doc/lispref/help.texi (Keys in Documentation): * doc/lispref/minibuf.texi (Minibuffer Misc): * doc/lispref/strings.texi (Formatting Strings): * etc/NEWS: Document the changes. * lisp/abbrev.el (expand-region-abbrevs): * lisp/apropos.el (apropos-library): * lisp/calc/calc-ext.el (calc-record-message) (calc-user-function-list): * lisp/calc/calc-help.el (calc-describe-key, calc-full-help): * lisp/calc/calc-lang.el (math-read-big-balance): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-units.el (math-build-units-table-buffer): * lisp/calc/calc-yank.el (calc-edit-mode): * lisp/calendar/icalendar.el (icalendar-export-region) (icalendar--add-diary-entry): * lisp/cedet/mode-local.el (mode-local-print-binding) (mode-local-describe-bindings-2): * lisp/cedet/semantic/complete.el (semantic-completion-message): * lisp/cedet/semantic/edit.el (semantic-parse-changes-failed): * lisp/cedet/semantic/wisent/comp.el (wisent-log): * lisp/cedet/srecode/insert.el (srecode-insert-show-error-report): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/dframe.el (dframe-message): * lisp/dired-aux.el (dired-query): * lisp/emacs-lisp/byte-opt.el (byte-compile-log-lap-1): * lisp/emacs-lisp/bytecomp.el (byte-compile-log) (byte-compile-log-file, byte-compile-warn, byte-compile-form): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use) (cconv-analyze-form): * lisp/emacs-lisp/check-declare.el (check-declare-warn): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine): * lisp/emacs-lisp/cl-macs.el (cl-symbol-macrolet): * lisp/emacs-lisp/edebug.el (edebug-format): * lisp/emacs-lisp/eieio-core.el (eieio-oref): * lisp/emacs-lisp/eldoc.el (eldoc-minibuffer-message) (eldoc-message): * lisp/emacs-lisp/elint.el (elint-file, elint-log): * lisp/emacs-lisp/find-func.el (find-function-library): * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): * lisp/emacs-lisp/nadvice.el (advice--make-docstring): * lisp/emacs-lisp/package.el (package-compute-transaction) (package-install-button-action, package-delete-button-action) (package-menu--list-to-prompt): * lisp/emacs-lisp/timer.el (timer-event-handler): * lisp/emacs-lisp/warnings.el (lwarn, warn): * lisp/emulation/viper-cmd.el: (viper-toggle-parse-sexp-ignore-comments) (viper-kill-buffer, viper-brac-function): * lisp/emulation/viper-macs.el (viper-record-kbd-macro): * lisp/facemenu.el (facemenu-add-new-face): * lisp/faces.el (face-documentation, read-face-name) (face-read-string, read-face-font, describe-face): * lisp/files.el (find-alternate-file, hack-local-variables) (hack-one-local-variable--obsolete, write-file) (basic-save-buffer, delete-directory): * lisp/format.el (format-write-file, format-find-file) (format-insert-file): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--obsolete) (help-fns--interactive-only, describe-function-1) (describe-variable): * lisp/help.el (describe-mode): * lisp/info-xref.el (info-xref-output): * lisp/info.el (Info-virtual-index-find-node) (Info-virtual-index, info-apropos): * lisp/international/kkc.el (kkc-error): * lisp/international/mule-cmds.el: (select-safe-coding-system-interactively) (select-safe-coding-system, describe-input-method): * lisp/international/mule-conf.el (code-offset): * lisp/international/mule-diag.el (describe-character-set) (list-input-methods-1): * lisp/international/quail.el (quail-error): * lisp/minibuffer.el (minibuffer-message): * lisp/mpc.el (mpc--debug): * lisp/msb.el (msb--choose-menu): * lisp/net/ange-ftp.el (ange-ftp-message): * lisp/net/gnutls.el (gnutls-message-maybe): * lisp/net/newst-backend.el (newsticker--sentinel-work): * lisp/net/newst-treeview.el (newsticker--treeview-load): * lisp/net/nsm.el (nsm-query-user): * lisp/net/rlogin.el (rlogin): * lisp/net/soap-client.el (soap-warning): * lisp/net/tramp.el (tramp-debug-message): * lisp/nxml/nxml-outln.el (nxml-report-outline-error): * lisp/nxml/nxml-parse.el (nxml-parse-error): * lisp/nxml/rng-cmpct.el (rng-c-error): * lisp/nxml/rng-match.el (rng-compile-error): * lisp/nxml/rng-uri.el (rng-uri-error): * lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer): * lisp/org/org-ctags.el: (org-ctags-ask-rebuild-tags-file-then-find-tag): * lisp/proced.el (proced-log): * lisp/progmodes/ebnf2ps.el (ebnf-log): * lisp/progmodes/flymake.el (flymake-log): * lisp/progmodes/vhdl-mode.el (vhdl-warning-when-idle): * lisp/replace.el (occur-1): * lisp/simple.el (execute-extended-command) (undo-outer-limit-truncate, define-alternatives): * lisp/startup.el (command-line): * lisp/subr.el (error, user-error, add-to-list): * lisp/tutorial.el (tutorial--describe-nonstandard-key) (tutorial--find-changed-keys): * src/callint.c (Fcall_interactively): * src/editfns.c (Fmessage, Fmessage_box): Restyle the quotes of format strings intended for use as a diagnostic, when restyling seems appropriate. * lisp/subr.el (format-message): New function. * src/doc.c (Finternal__text_restyle): New function. (syms_of_doc): Define it.
2015-08-24 05:38:02 +00:00
(apply #'format-message log args)
log)))
((bufferp log)
(insert-buffer-substring log))
((eq t log)
(backward-page 1)
(unless (bolp)
(insert "\n"))
(insert (current-time-string)
Go back to grave quoting in source-code docstrings etc. This reverts almost all my recent changes to use curved quotes in docstrings and/or strings used for error diagnostics. There are a few exceptions, e.g., Bahá’í proper names. * admin/unidata/unidata-gen.el (unidata-gen-table): * lisp/abbrev.el (expand-region-abbrevs): * lisp/align.el (align-region): * lisp/allout.el (allout-mode, allout-solicit-alternate-bullet) (outlineify-sticky): * lisp/apropos.el (apropos-library): * lisp/bookmark.el (bookmark-default-annotation-text): * lisp/button.el (button-category-symbol, button-put) (make-text-button): * lisp/calc/calc-aent.el (math-read-if, math-read-factor): * lisp/calc/calc-embed.el (calc-do-embedded): * lisp/calc/calc-ext.el (calc-user-function-list): * lisp/calc/calc-graph.el (calc-graph-show-dumb): * lisp/calc/calc-help.el (calc-describe-key) (calc-describe-thing, calc-full-help): * lisp/calc/calc-lang.el (calc-c-language) (math-parse-fortran-vector-end, math-parse-tex-sum) (math-parse-eqn-matrix, math-parse-eqn-prime) (calc-yacas-language, calc-maxima-language, calc-giac-language) (math-read-giac-subscr, math-read-math-subscr) (math-read-big-rec, math-read-big-balance): * lisp/calc/calc-misc.el (calc-help, report-calc-bug): * lisp/calc/calc-mode.el (calc-auto-why, calc-save-modes) (calc-auto-recompute): * lisp/calc/calc-prog.el (calc-fix-token-name) (calc-read-parse-table-part, calc-user-define-invocation) (math-do-arg-check): * lisp/calc/calc-store.el (calc-edit-variable): * lisp/calc/calc-units.el (math-build-units-table-buffer): * lisp/calc/calc-vec.el (math-read-brackets): * lisp/calc/calc-yank.el (calc-edit-mode): * lisp/calc/calc.el (calc, calc-do, calc-user-invocation): * lisp/calendar/appt.el (appt-display-message): * lisp/calendar/diary-lib.el (diary-check-diary-file) (diary-mail-entries, diary-from-outlook): * lisp/calendar/icalendar.el (icalendar-export-region) (icalendar--convert-float-to-ical) (icalendar--convert-date-to-ical) (icalendar--convert-ical-to-diary) (icalendar--convert-recurring-to-diary) (icalendar--add-diary-entry): * lisp/calendar/time-date.el (format-seconds): * lisp/calendar/timeclock.el (timeclock-mode-line-display) (timeclock-make-hours-explicit, timeclock-log-data): * lisp/calendar/todo-mode.el (todo-prefix, todo-delete-category) (todo-item-mark, todo-check-format) (todo-insert-item--next-param, todo-edit-item--next-key) (todo-mode): * lisp/cedet/ede/pmake.el (ede-proj-makefile-insert-dist-rules): * lisp/cedet/mode-local.el (describe-mode-local-overload) (mode-local-print-binding, mode-local-describe-bindings-2): * lisp/cedet/semantic/complete.el (semantic-displayor-show-request): * lisp/cedet/srecode/srt-mode.el (srecode-macro-help): * lisp/cus-start.el (standard): * lisp/cus-theme.el (describe-theme-1): * lisp/custom.el (custom-add-dependencies, custom-check-theme) (custom--sort-vars-1, load-theme): * lisp/descr-text.el (describe-text-properties-1, describe-char): * lisp/dired-x.el (dired-do-run-mail): * lisp/dired.el (dired-log): * lisp/emacs-lisp/advice.el (ad-read-advised-function) (ad-read-advice-class, ad-read-advice-name, ad-enable-advice) (ad-disable-advice, ad-remove-advice, ad-set-argument) (ad-set-arguments, ad--defalias-fset, ad-activate) (ad-deactivate): * lisp/emacs-lisp/byte-opt.el (byte-compile-inline-expand) (byte-compile-unfold-lambda, byte-optimize-form-code-walker) (byte-optimize-while, byte-optimize-apply): * lisp/emacs-lisp/byte-run.el (defun, defsubst): * lisp/emacs-lisp/bytecomp.el (byte-compile-lapcode) (byte-compile-log-file, byte-compile-format-warn) (byte-compile-nogroup-warn, byte-compile-arglist-warn) (byte-compile-cl-warn) (byte-compile-warn-about-unresolved-functions) (byte-compile-file, byte-compile--declare-var) (byte-compile-file-form-defmumble, byte-compile-form) (byte-compile-normal-call, byte-compile-check-variable) (byte-compile-variable-ref, byte-compile-variable-set) (byte-compile-subr-wrong-args, byte-compile-setq-default) (byte-compile-negation-optimizer) (byte-compile-condition-case--old) (byte-compile-condition-case--new, byte-compile-save-excursion) (byte-compile-defvar, byte-compile-autoload) (byte-compile-lambda-form) (byte-compile-make-variable-buffer-local, display-call-tree) (batch-byte-compile): * lisp/emacs-lisp/cconv.el (cconv-convert, cconv--analyze-use): * lisp/emacs-lisp/chart.el (chart-space-usage): * lisp/emacs-lisp/check-declare.el (check-declare-scan) (check-declare-warn, check-declare-file) (check-declare-directory): * lisp/emacs-lisp/checkdoc.el (checkdoc-this-string-valid-engine) (checkdoc-message-text-engine): * lisp/emacs-lisp/cl-extra.el (cl-parse-integer) (cl--describe-class): * lisp/emacs-lisp/cl-generic.el (cl-defgeneric) (cl--generic-describe, cl-generic-generalizers): * lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause, cl-tagbody) (cl-symbol-macrolet): * lisp/emacs-lisp/cl.el (cl-unload-function, flet): * lisp/emacs-lisp/copyright.el (copyright) (copyright-update-directory): * lisp/emacs-lisp/edebug.el (edebug-read-list): * lisp/emacs-lisp/eieio-base.el (eieio-persistent-read): * lisp/emacs-lisp/eieio-core.el (eieio--slot-override) (eieio-oref): * lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor): * lisp/emacs-lisp/eieio-speedbar.el: (eieio-speedbar-child-make-tag-lines) (eieio-speedbar-child-description): * lisp/emacs-lisp/eieio.el (defclass, change-class): * lisp/emacs-lisp/elint.el (elint-file, elint-get-top-forms) (elint-init-form, elint-check-defalias-form) (elint-check-let-form): * lisp/emacs-lisp/ert.el (ert-get-test, ert-results-mode-menu) (ert-results-pop-to-backtrace-for-test-at-point) (ert-results-pop-to-messages-for-test-at-point) (ert-results-pop-to-should-forms-for-test-at-point) (ert-describe-test): * lisp/emacs-lisp/find-func.el (find-function-search-for-symbol) (find-function-library): * lisp/emacs-lisp/generator.el (iter-yield): * lisp/emacs-lisp/gv.el (gv-define-simple-setter): * lisp/emacs-lisp/lisp-mnt.el (lm-verify): * lisp/emacs-lisp/macroexp.el (macroexp--obsolete-warning): * lisp/emacs-lisp/map-ynp.el (map-y-or-n-p): * lisp/emacs-lisp/nadvice.el (advice--make-docstring) (advice--make, define-advice): * lisp/emacs-lisp/package-x.el (package-upload-file): * lisp/emacs-lisp/package.el (package-version-join) (package-disabled-p, package-activate-1, package-activate) (package--download-one-archive) (package--download-and-read-archives) (package-compute-transaction, package-install-from-archive) (package-install, package-install-selected-packages) (package-delete, package-autoremove, describe-package-1) (package-install-button-action, package-delete-button-action) (package-menu-hide-package, package-menu--list-to-prompt) (package-menu--perform-transaction) (package-menu--find-and-notify-upgrades): * lisp/emacs-lisp/pcase.el (pcase-exhaustive, pcase--u1): * lisp/emacs-lisp/re-builder.el (reb-enter-subexp-mode): * lisp/emacs-lisp/ring.el (ring-previous, ring-next): * lisp/emacs-lisp/rx.el (rx-check, rx-anything) (rx-check-any-string, rx-check-any, rx-check-not, rx-=) (rx-repeat, rx-check-backref, rx-syntax, rx-check-category) (rx-form): * lisp/emacs-lisp/smie.el (smie-config-save): * lisp/emacs-lisp/subr-x.el (internal--check-binding): * lisp/emacs-lisp/tabulated-list.el (tabulated-list-put-tag): * lisp/emacs-lisp/testcover.el (testcover-1value): * lisp/emacs-lisp/timer.el (timer-event-handler): * lisp/emulation/viper-cmd.el (viper-toggle-parse-sexp-ignore-comments) (viper-toggle-search-style, viper-kill-buffer) (viper-brac-function): * lisp/emulation/viper-macs.el (viper-record-kbd-macro): * lisp/env.el (setenv): * lisp/erc/erc-button.el (erc-nick-popup): * lisp/erc/erc.el (erc-cmd-LOAD, erc-handle-login, english): * lisp/eshell/em-dirs.el (eshell/cd): * lisp/eshell/em-glob.el (eshell-glob-regexp) (eshell-glob-entries): * lisp/eshell/em-pred.el (eshell-parse-modifiers): * lisp/eshell/esh-opt.el (eshell-show-usage): * lisp/facemenu.el (facemenu-add-new-face) (facemenu-add-new-color): * lisp/faces.el (read-face-name, read-face-font, describe-face) (x-resolve-font-name): * lisp/files-x.el (modify-file-local-variable): * lisp/files.el (locate-user-emacs-file, find-alternate-file) (set-auto-mode, hack-one-local-variable--obsolete) (dir-locals-set-directory-class, write-file, basic-save-buffer) (delete-directory, copy-directory, recover-session) (recover-session-finish, insert-directory) (file-modes-char-to-who, file-modes-symbolic-to-number) (move-file-to-trash): * lisp/filesets.el (filesets-add-buffer, filesets-remove-buffer): * lisp/find-cmd.el (find-generic, find-to-string): * lisp/finder.el (finder-commentary): * lisp/font-lock.el (font-lock-fontify-buffer): * lisp/format.el (format-write-file, format-find-file) (format-insert-file): * lisp/frame.el (get-device-terminal, select-frame-by-name): * lisp/fringe.el (fringe--check-style): * lisp/gnus/nnmairix.el (nnmairix-widget-create-query): * lisp/help-fns.el (help-fns--key-bindings) (help-fns--compiler-macro, help-fns--parent-mode) (help-fns--obsolete, help-fns--interactive-only) (describe-function-1, describe-variable): * lisp/help.el (describe-mode) (describe-minor-mode-from-indicator): * lisp/image.el (image-type): * lisp/international/ccl.el (ccl-dump): * lisp/international/fontset.el (x-must-resolve-font-name): * lisp/international/mule-cmds.el (prefer-coding-system) (select-safe-coding-system-interactively) (select-safe-coding-system, activate-input-method) (toggle-input-method, describe-current-input-method) (describe-language-environment): * lisp/international/mule-conf.el (code-offset): * lisp/international/mule-diag.el (describe-character-set) (list-input-methods-1): * lisp/mail/feedmail.el (feedmail-run-the-queue): * lisp/mouse.el (minor-mode-menu-from-indicator): * lisp/mpc.el (mpc-playlist-rename): * lisp/msb.el (msb--choose-menu): * lisp/net/ange-ftp.el (ange-ftp-shell-command): * lisp/net/imap.el (imap-interactive-login): * lisp/net/mairix.el (mairix-widget-create-query): * lisp/net/newst-backend.el (newsticker--sentinel-work): * lisp/net/newst-treeview.el (newsticker--treeview-load): * lisp/net/rlogin.el (rlogin): * lisp/obsolete/iswitchb.el (iswitchb-possible-new-buffer): * lisp/obsolete/otodo-mode.el (todo-more-important-p): * lisp/obsolete/pgg-gpg.el (pgg-gpg-process-region): * lisp/obsolete/pgg-pgp.el (pgg-pgp-process-region): * lisp/obsolete/pgg-pgp5.el (pgg-pgp5-process-region): * lisp/org/ob-core.el (org-babel-goto-named-src-block) (org-babel-goto-named-result): * lisp/org/ob-fortran.el (org-babel-fortran-ensure-main-wrap): * lisp/org/ob-ref.el (org-babel-ref-resolve): * lisp/org/org-agenda.el (org-agenda-prepare): * lisp/org/org-clock.el (org-clock-notify-once-if-expired) (org-clock-resolve): * lisp/org/org-ctags.el (org-ctags-ask-rebuild-tags-file-then-find-tag): * lisp/org/org-feed.el (org-feed-parse-atom-entry): * lisp/org/org-habit.el (org-habit-parse-todo): * lisp/org/org-mouse.el (org-mouse-popup-global-menu) (org-mouse-context-menu): * lisp/org/org-table.el (org-table-edit-formulas): * lisp/org/ox.el (org-export-async-start): * lisp/proced.el (proced-log): * lisp/progmodes/ada-mode.el (ada-get-indent-case) (ada-check-matching-start, ada-goto-matching-start): * lisp/progmodes/ada-prj.el (ada-prj-display-page): * lisp/progmodes/ada-xref.el (ada-find-executable): * lisp/progmodes/ebrowse.el (ebrowse-tags-apropos): * lisp/progmodes/etags.el (etags-tags-apropos-additional): * lisp/progmodes/flymake.el (flymake-parse-err-lines) (flymake-start-syntax-check-process): * lisp/progmodes/python.el (python-shell-get-process-or-error) (python-define-auxiliary-skeleton): * lisp/progmodes/sql.el (sql-comint): * lisp/progmodes/verilog-mode.el (verilog-load-file-at-point): * lisp/progmodes/vhdl-mode.el (vhdl-widget-directory-validate): * lisp/recentf.el (recentf-open-files): * lisp/replace.el (query-replace-read-from) (occur-after-change-function, occur-1): * lisp/scroll-bar.el (scroll-bar-columns): * lisp/server.el (server-get-auth-key): * lisp/simple.el (execute-extended-command) (undo-outer-limit-truncate, list-processes--refresh) (compose-mail, set-variable, choose-completion-string) (define-alternatives): * lisp/startup.el (site-run-file, tty-handle-args, command-line) (command-line-1): * lisp/subr.el (noreturn, define-error, add-to-list) (read-char-choice, version-to-list): * lisp/term/common-win.el (x-handle-xrm-switch) (x-handle-name-switch, x-handle-args): * lisp/term/x-win.el (x-handle-parent-id, x-handle-smid): * lisp/textmodes/reftex-ref.el (reftex-label): * lisp/textmodes/reftex-toc.el (reftex-toc-rename-label): * lisp/textmodes/two-column.el (2C-split): * lisp/tutorial.el (tutorial--describe-nonstandard-key) (tutorial--find-changed-keys): * lisp/type-break.el (type-break-noninteractive-query): * lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes) (wdired-do-perm-changes): * lisp/whitespace.el (whitespace-report-region): Prefer grave quoting in source-code strings used to generate help and diagnostics. * lisp/faces.el (face-documentation): No need to convert quotes, since the result is a docstring. * lisp/info.el (Info-virtual-index-find-node) (Info-virtual-index, info-apropos): Simplify by generating only curved quotes, since info files are typically that ways nowadays anyway. * lisp/international/mule-diag.el (list-input-methods): Don’t assume text quoting style is curved. * lisp/org/org-bibtex.el (org-bibtex-fields): Revert my recent changes, going back to the old quoting style.
2015-09-07 15:41:44 +00:00
(format-message "\tBuffer `%s', signal `%s'\n"
Top-level elisp files respect ‘text-quoting-style’ In top-level elisp files, use format-message in diagnostic formats, so that they follow user preference as per ‘text-quoting-style’ rather than being hard-coded to quote `like this'. * lisp/allout.el (allout-get-configvar-values): * lisp/apropos.el (apropos-symbols-internal): * lisp/dired-aux.el (dired-do-shell-command, dired-create-files) (dired-do-create-files-regexp, dired-create-files-non-directory): * lisp/dired-x.el (dired-do-run-mail): * lisp/dired.el (dired-log, dired-dnd-handle-local-file): * lisp/disp-table.el (standard-display-european): * lisp/find-dired.el (find-dired): * lisp/forms.el (forms-mode): * lisp/ido.el (ido-buffer-internal): * lisp/info.el (Info-index-next): * lisp/outline.el (outline-invent-heading): * lisp/printing.el (pr-ps-outfile-preprint, pr-i-ps-send): * lisp/proced.el (proced-log): * lisp/ps-print.el (ps-print-preprint, ps-get-size): * lisp/recentf.el (recentf-open-files, recentf-save-list): * lisp/savehist.el (savehist-save): * lisp/server.el (server-ensure-safe-dir): * lisp/ses.el (ses-rename-cell): * lisp/simple.el (list-processes--refresh): * lisp/startup.el (command-line): * lisp/strokes.el (strokes-unset-last-stroke) (strokes-execute-stroke): Use format-message so that quotes are restyled. * lisp/cus-edit.el (custom-raised-buttons, customize-browse): Don’t quote ‘raised’. * lisp/descr-text.el (describe-char): * lisp/dirtrack.el (dirtrack-debug-message): * lisp/hexl.el (hexl-insert-multibyte-char): Apply substitute-command-keys to help string. * lisp/wdired.el (wdired-do-renames, wdired-do-symlink-changes) (wdired-do-perm-changes): Let dired-log do the formatting.
2015-08-26 08:30:29 +00:00
(buffer-name obuf) (car args)))
(goto-char (point-max))
(insert "\f\n")))))))
;; similar to `dired-log-summary'
(defun proced-log-summary (signal string)
"State a summary of SIGNAL's failures, in echo area and log buffer.
STRING is an overall summary of the failures."
(message "Signal %s: %s--type ? for details" signal string)
;; Log a summary describing a bunch of errors.
(proced-log (concat "\n" string "\n"))
(proced-log t signal))
2008-03-26 02:15:28 +00:00
(defun proced-help ()
"Provide help for the Proced user."
(interactive nil proced-mode)
(proced-why)
2008-03-26 02:15:28 +00:00
(if (eq last-command 'proced-help)
(describe-mode)
(message (substitute-command-keys proced-help-string))))
2008-03-26 02:15:28 +00:00
(defun proced-undo ()
"Undo in a Proced buffer.
This doesn't recover killed processes, it just undoes changes in the Proced
2008-03-26 02:15:28 +00:00
buffer. You can use it to recover marks."
(interactive nil proced-mode)
2008-03-26 02:15:28 +00:00
(let (buffer-read-only)
(undo))
(message "Change in Proced buffer undone.
2008-03-26 02:15:28 +00:00
Killed processes cannot be recovered by Emacs."))
(provide 'proced)
;;; proced.el ends here