diff options
| author | Roland Winkler | 2008-05-21 08:00:05 +0000 |
|---|---|---|
| committer | Roland Winkler | 2008-05-21 08:00:05 +0000 |
| commit | b9df596973bb17c9e491090aa85dc479bc93662f (patch) | |
| tree | 4dff8aa4e285b0cb1a946c415a70d3c98b535c2f | |
| parent | 6aac1c03b854dcb0cd929ea591815d8f0a38f1b2 (diff) | |
| download | emacs-b9df596973bb17c9e491090aa85dc479bc93662f.tar.gz emacs-b9df596973bb17c9e491090aa85dc479bc93662f.zip | |
(proced-header-line): New variable and new function.
(proced-mode): Set header-line-format.
(proced-update): Set proced-header-line.
(proced-send-signal): Use proced-header-line.
| -rw-r--r-- | lisp/proced.el | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/lisp/proced.el b/lisp/proced.el index 7ab719114e1..8496b837f81 100644 --- a/lisp/proced.el +++ b/lisp/proced.el | |||
| @@ -263,6 +263,10 @@ Important: the match ends just after the marker.") | |||
| 263 | "(n)ext, (p)revious, (m)ark, (u)nmark, (k)ill, (q)uit (type ? for more help)" | 263 | "(n)ext, (p)revious, (m)ark, (u)nmark, (k)ill, (q)uit (type ? for more help)" |
| 264 | "Help string for proced.") | 264 | "Help string for proced.") |
| 265 | 265 | ||
| 266 | (defvar proced-header-line nil | ||
| 267 | "Headers in Proced buffer as a string.") | ||
| 268 | (make-variable-buffer-local 'proced-header-line) | ||
| 269 | |||
| 266 | (defvar proced-header-alist nil | 270 | (defvar proced-header-alist nil |
| 267 | "Alist of headers in Proced buffer. | 271 | "Alist of headers in Proced buffer. |
| 268 | Each element is of the form (NAME START END JUSTIFY). | 272 | Each element is of the form (NAME START END JUSTIFY). |
| @@ -310,7 +314,9 @@ Type \\[proced-send-signal] to send signals to marked processes. | |||
| 310 | (abbrev-mode 0) | 314 | (abbrev-mode 0) |
| 311 | (auto-fill-mode 0) | 315 | (auto-fill-mode 0) |
| 312 | (setq buffer-read-only t | 316 | (setq buffer-read-only t |
| 313 | truncate-lines t) | 317 | truncate-lines t |
| 318 | header-line-format '(:eval (proced-header-line))) | ||
| 319 | (add-hook 'post-command-hook 'force-mode-line-update nil t) | ||
| 314 | (set (make-local-variable 'revert-buffer-function) 'proced-revert) | 320 | (set (make-local-variable 'revert-buffer-function) 'proced-revert) |
| 315 | (set (make-local-variable 'font-lock-defaults) | 321 | (set (make-local-variable 'font-lock-defaults) |
| 316 | '(proced-font-lock-keywords t nil nil beginning-of-line))) | 322 | '(proced-font-lock-keywords t nil nil beginning-of-line))) |
| @@ -475,6 +481,16 @@ Returns count of hidden lines." | |||
| 475 | "Return a single space string of WIDTH times the normal character width." | 481 | "Return a single space string of WIDTH times the normal character width." |
| 476 | (propertize " " 'display (list 'space :width width))) | 482 | (propertize " " 'display (list 'space :width width))) |
| 477 | 483 | ||
| 484 | ;; header line: code inspired by `ruler-mode-ruler' | ||
| 485 | (defun proced-header-line () | ||
| 486 | "Return header line for Proced buffer." | ||
| 487 | (list "" (if (eq 'left (car (window-current-scroll-bars))) | ||
| 488 | (proced-header-space 'scroll-bar)) | ||
| 489 | (proced-header-space 'left-fringe) | ||
| 490 | (proced-header-space 'left-margin) | ||
| 491 | (replace-regexp-in-string | ||
| 492 | "%" "%%" (substring proced-header-line (window-hscroll))))) | ||
| 493 | |||
| 478 | (defun proced-update (&optional quiet) | 494 | (defun proced-update (&optional quiet) |
| 479 | "Update the `proced' process information. Preserves point and marks." | 495 | "Update the `proced' process information. Preserves point and marks." |
| 480 | ;; This is the main function that generates and updates the process listing. | 496 | ;; This is the main function that generates and updates the process listing. |
| @@ -508,14 +524,7 @@ Returns count of hidden lines." | |||
| 508 | (delete-region (match-beginning 0) (match-end 0))) | 524 | (delete-region (match-beginning 0) (match-end 0))) |
| 509 | (goto-char (point-min)) | 525 | (goto-char (point-min)) |
| 510 | (let ((lep (line-end-position))) | 526 | (let ((lep (line-end-position))) |
| 511 | ;; header line: code inspired by `ruler-mode-ruler' | 527 | (setq proced-header-line (buffer-substring-no-properties (point) lep)) |
| 512 | (setq header-line-format | ||
| 513 | (list "" (if (eq 'left (car (window-current-scroll-bars))) | ||
| 514 | (proced-header-space 'scroll-bar)) | ||
| 515 | (proced-header-space 'left-fringe) | ||
| 516 | (proced-header-space 'left-margin) | ||
| 517 | (replace-regexp-in-string | ||
| 518 | "%" "%%" (buffer-substring-no-properties (point) lep)))) | ||
| 519 | (setq proced-header-alist nil) | 528 | (setq proced-header-alist nil) |
| 520 | ;; FIXME: handle left/right justification properly | 529 | ;; FIXME: handle left/right justification properly |
| 521 | (while (re-search-forward "\\([^ \t\n]+\\)[ \t]*\\($\\)?" lep t) | 530 | (while (re-search-forward "\\([^ \t\n]+\\)[ \t]*\\($\\)?" lep t) |
| @@ -608,10 +617,12 @@ If SIGNAL is nil display marked processes and query interactively for SIGNAL." | |||
| 608 | (unless signal | 617 | (unless signal |
| 609 | ;; Display marked processes (code taken from `dired-mark-pop-up'). | 618 | ;; Display marked processes (code taken from `dired-mark-pop-up'). |
| 610 | (let ((bufname " *Marked Processes*") | 619 | (let ((bufname " *Marked Processes*") |
| 611 | (header header-line-format)) ; reuse | 620 | (header proced-header-line)) ; inherit header line |
| 612 | (with-current-buffer (get-buffer-create bufname) | 621 | (with-current-buffer (get-buffer-create bufname) |
| 613 | (setq truncate-lines t | 622 | (setq truncate-lines t |
| 614 | header-line-format header) | 623 | proced-header-line header |
| 624 | header-line-format '(:eval (proced-header-line))) | ||
| 625 | (add-hook 'post-command-hook 'force-mode-line-update nil t) | ||
| 615 | (erase-buffer) | 626 | (erase-buffer) |
| 616 | (dolist (process process-list) | 627 | (dolist (process process-list) |
| 617 | (insert " " (cdr process) "\n")) | 628 | (insert " " (cdr process) "\n")) |