diff options
| author | Roland Winkler | 2008-12-14 17:31:34 +0000 |
|---|---|---|
| committer | Roland Winkler | 2008-12-14 17:31:34 +0000 |
| commit | 413e65fe7ee7c466434680c8e1503d3ac77516cd (patch) | |
| tree | cbe2a86b89fa03ab8e6c8761989b15290313bd5f | |
| parent | 2f298da2f235d8bfb8ba1ecfaf3bfbc878c93b2a (diff) | |
| download | emacs-413e65fe7ee7c466434680c8e1503d3ac77516cd.tar.gz emacs-413e65fe7ee7c466434680c8e1503d3ac77516cd.zip | |
(proced-auto-update-interval): Renamed from proced-timer-interval.
(proced-auto-update-flag): Renamed from proced-timer-flag.
(proced-auto-update-timer): Renamed from proced-timer.
(proced-toggle-auto-update): Renamed from proced-toggle-timer-flag.
(proced-available): Initialize appropriately.
| -rw-r--r-- | lisp/proced.el | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/lisp/proced.el b/lisp/proced.el index 85980c8e311..5dd0b7a6625 100644 --- a/lisp/proced.el +++ b/lisp/proced.el | |||
| @@ -33,6 +33,19 @@ | |||
| 33 | ;; | 33 | ;; |
| 34 | ;; Wishlist | 34 | ;; Wishlist |
| 35 | ;; - tree view like pstree(1) | 35 | ;; - tree view like pstree(1) |
| 36 | ;; | ||
| 37 | ;; Thoughts and Ideas | ||
| 38 | ;; - Currently, `system-process-attributes' returns the list of | ||
| 39 | ;; command-line arguments of a process as one concatenated string. | ||
| 40 | ;; This format is compatible with `shell-command'. Also, under | ||
| 41 | ;; MS-Windows, the command-line arguments are actually stored as a | ||
| 42 | ;; single string, so that it is impossible to reverse-engineer it back | ||
| 43 | ;; into separate arguments. Alternatively, `system-process-attributes' | ||
| 44 | ;; could (try to) return a list of strings that correspond to individual | ||
| 45 | ;; command-line arguments. Then one could feed such a list of | ||
| 46 | ;; command-line arguments into `call-process' or `start-process'. | ||
| 47 | ;; Are there real-world applications when such a feature would be useful? | ||
| 48 | ;; What about something like `proced-restart-pid'? | ||
| 36 | 49 | ||
| 37 | ;;; Code: | 50 | ;;; Code: |
| 38 | 51 | ||
| @@ -291,17 +304,17 @@ of `proced-grammar-alist'." | |||
| 291 | :type '(choice (const :tag "none" nil) | 304 | :type '(choice (const :tag "none" nil) |
| 292 | (symbol :tag "key"))) | 305 | (symbol :tag "key"))) |
| 293 | 306 | ||
| 294 | (defcustom proced-timer-interval 5 | 307 | (defcustom proced-auto-update-interval 5 |
| 295 | "Time interval in seconds for auto updating Proced buffers." | 308 | "Time interval in seconds for auto updating Proced buffers." |
| 296 | :group 'proced | 309 | :group 'proced |
| 297 | :type 'integer) | 310 | :type 'integer) |
| 298 | 311 | ||
| 299 | (defcustom proced-timer-flag nil | 312 | (defcustom proced-auto-update-flag nil |
| 300 | "Non-nil for auto update of a Proced buffer. | 313 | "Non-nil for auto update of a Proced buffer. |
| 301 | Can be changed interactively via `proced-toggle-timer-flag'." | 314 | Can be changed interactively via `proced-toggle-auto-update'." |
| 302 | :group 'proced | 315 | :group 'proced |
| 303 | :type 'boolean) | 316 | :type 'boolean) |
| 304 | (make-variable-buffer-local 'proced-timer-flag) | 317 | (make-variable-buffer-local 'proced-auto-update-flag) |
| 305 | 318 | ||
| 306 | ;; Internal variables | 319 | ;; Internal variables |
| 307 | 320 | ||
| @@ -350,8 +363,8 @@ Important: the match ends just after the marker.") | |||
| 350 | (defvar proced-process-tree nil | 363 | (defvar proced-process-tree nil |
| 351 | "Process tree of listing (internal variable).") | 364 | "Process tree of listing (internal variable).") |
| 352 | 365 | ||
| 353 | (defvar proced-timer nil | 366 | (defvar proced-auto-update-timer nil |
| 354 | "Stores if Proced timer is already installed.") | 367 | "Stores if Proced auto update timer is already installed.") |
| 355 | 368 | ||
| 356 | (defvar proced-log-buffer "*Proced log*" | 369 | (defvar proced-log-buffer "*Proced log*" |
| 357 | "Name of Proced Log buffer.") | 370 | "Name of Proced Log buffer.") |
| @@ -481,9 +494,9 @@ Important: the match ends just after the marker.") | |||
| 481 | "--" | 494 | "--" |
| 482 | ["Revert" revert-buffer | 495 | ["Revert" revert-buffer |
| 483 | :help "Revert Process Listing"] | 496 | :help "Revert Process Listing"] |
| 484 | ["Auto Update" proced-toggle-timer-flag | 497 | ["Auto Update" proced-toggle-auto-update |
| 485 | :style radio | 498 | :style radio |
| 486 | :selected (eval proced-timer-flag) | 499 | :selected (eval proced-auto-update-flag) |
| 487 | :help "Auto Update of Proced Buffer"] | 500 | :help "Auto Update of Proced Buffer"] |
| 488 | ["Send signal" proced-send-signal | 501 | ["Send signal" proced-send-signal |
| 489 | :help "Send Signal to Marked Processes"])) | 502 | :help "Send Signal to Marked Processes"])) |
| @@ -570,16 +583,17 @@ are defined in `proced-grammar-alist'. | |||
| 570 | (set (make-local-variable 'revert-buffer-function) 'proced-revert) | 583 | (set (make-local-variable 'revert-buffer-function) 'proced-revert) |
| 571 | (set (make-local-variable 'font-lock-defaults) | 584 | (set (make-local-variable 'font-lock-defaults) |
| 572 | '(proced-font-lock-keywords t nil nil beginning-of-line)) | 585 | '(proced-font-lock-keywords t nil nil beginning-of-line)) |
| 573 | (if (and (not proced-timer) proced-timer-interval) | 586 | (if (and (not proced-auto-update-timer) proced-auto-update-interval) |
| 574 | (setq proced-timer | 587 | (setq proced-auto-update-timer |
| 575 | (run-at-time t proced-timer-interval 'proced-timer)))) | 588 | (run-at-time t proced-auto-update-interval |
| 576 | 589 | 'proced-auto-update-timer)))) | |
| 577 | (defvar proced-available nil | ||
| 578 | "Non-nil means Proced is known to work on this system.") | ||
| 579 | 590 | ||
| 580 | ;; Proced mode is suitable only for specially formatted data. | 591 | ;; Proced mode is suitable only for specially formatted data. |
| 581 | (put 'proced-mode 'mode-class 'special) | 592 | (put 'proced-mode 'mode-class 'special) |
| 582 | 593 | ||
| 594 | (defvar proced-available (not (null (list-system-processes))) | ||
| 595 | "Non-nil means Proced is known to work on this system.") | ||
| 596 | |||
| 583 | ;;;###autoload | 597 | ;;;###autoload |
| 584 | (defun proced (&optional arg) | 598 | (defun proced (&optional arg) |
| 585 | "Generate a listing of UNIX system processes. | 599 | "Generate a listing of UNIX system processes. |
| @@ -588,9 +602,8 @@ information will be displayed but not selected. | |||
| 588 | 602 | ||
| 589 | See `proced-mode' for a description of features available in Proced buffers." | 603 | See `proced-mode' for a description of features available in Proced buffers." |
| 590 | (interactive "P") | 604 | (interactive "P") |
| 591 | (or proced-available | 605 | (unless proced-available |
| 592 | (setq proced-available (not (null (list-system-processes)))) | 606 | (error "Proced is not available on this system")) |
| 593 | (error "Proced is not available on this system")) | ||
| 594 | (let ((buffer (get-buffer-create "*Proced*")) new) | 607 | (let ((buffer (get-buffer-create "*Proced*")) new) |
| 595 | (set-buffer buffer) | 608 | (set-buffer buffer) |
| 596 | (setq new (zerop (buffer-size))) | 609 | (setq new (zerop (buffer-size))) |
| @@ -604,25 +617,26 @@ See `proced-mode' for a description of features available in Proced buffers." | |||
| 604 | (substitute-command-keys | 617 | (substitute-command-keys |
| 605 | "Type \\<proced-mode-map>\\[quit-window] to quit, \\[proced-help] for help"))))) | 618 | "Type \\<proced-mode-map>\\[quit-window] to quit, \\[proced-help] for help"))))) |
| 606 | 619 | ||
| 607 | (defun proced-timer () | 620 | (defun proced-auto-update-timer () |
| 608 | "Auto-update Proced buffers using `run-at-time'." | 621 | "Auto-update Proced buffers using `run-at-time'." |
| 609 | (dolist (buf (buffer-list)) | 622 | (dolist (buf (buffer-list)) |
| 610 | (with-current-buffer buf | 623 | (with-current-buffer buf |
| 611 | (if (and (eq major-mode 'proced-mode) | 624 | (if (and (eq major-mode 'proced-mode) |
| 612 | proced-timer-flag) | 625 | proced-auto-update-flag) |
| 613 | (proced-update t t))))) | 626 | (proced-update t t))))) |
| 614 | 627 | ||
| 615 | (defun proced-toggle-timer-flag (arg) | 628 | (defun proced-toggle-auto-update (arg) |
| 616 | "Change whether this Proced buffer is updated automatically. | 629 | "Change whether this Proced buffer is updated automatically. |
| 617 | With prefix ARG, update this buffer automatically if ARG is positive, | 630 | With prefix ARG, update this buffer automatically if ARG is positive, |
| 618 | otherwise do not update. Sets the variable `proced-timer-flag'. | 631 | otherwise do not update. Sets the variable `proced-auto-update-flag'. |
| 619 | The time interval for updates is specified via `proced-timer-interval'." | 632 | The time interval for updates is specified via `proced-auto-update-interval'." |
| 620 | (interactive (list (or current-prefix-arg 'toggle))) | 633 | (interactive (list (or current-prefix-arg 'toggle))) |
| 621 | (setq proced-timer-flag | 634 | (setq proced-auto-update-flag |
| 622 | (cond ((eq arg 'toggle) (not proced-timer-flag)) | 635 | (cond ((eq arg 'toggle) (not proced-auto-update-flag)) |
| 623 | (arg (> (prefix-numeric-value arg) 0)) | 636 | (arg (> (prefix-numeric-value arg) 0)) |
| 624 | (t (not proced-timer-flag)))) | 637 | (t (not proced-auto-update-flag)))) |
| 625 | (message "`proced-timer-flag' set to %s" proced-timer-flag)) | 638 | (message "Proced auto update %s" |
| 639 | (if proced-auto-update-flag "enabled" "disabled"))) | ||
| 626 | 640 | ||
| 627 | (defun proced-mark (&optional count) | 641 | (defun proced-mark (&optional count) |
| 628 | "Mark the current (or next COUNT) processes." | 642 | "Mark the current (or next COUNT) processes." |