summaryrefslogtreecommitdiff
path: root/grid-engine-mode.el
diff options
context:
space:
mode:
Diffstat (limited to 'grid-engine-mode.el')
-rw-r--r--grid-engine-mode.el39
1 files changed, 27 insertions, 12 deletions
diff --git a/grid-engine-mode.el b/grid-engine-mode.el
index 988d4c5..ed198bb 100644
--- a/grid-engine-mode.el
+++ b/grid-engine-mode.el
@@ -65,12 +65,20 @@
(defun grid-engine-list-jobs ()
"List all jobs for the specified user in a new buffer."
- (setq row-pattern "%-10s %-10s %-15s %-10s\n")
- (setq header (format (concat row-pattern " \n")
- "Job-ID"
- "Priority"
- "User"
- "State"))
+ (setq columns '((job-id . ("Job-ID" "%-10s"))
+ (priority . ("Priority" "%-10s"))
+ (name . ("Job name" "%-10s"))
+ (owner . ("User" "%-15s"))
+ (state . ("State" "%-15s"))
+ (time . ("Time" "%-25s"))
+ (queue . ("Queue" "%-25s"))
+ (slots . ("Slots" "%-10s"))))
+ (setq column-order '(job-id time priority owner state))
+ (setq row-fmt (concat (mapconcat (lambda (key)
+ (caddr (assoc key columns)))
+ column-order " ")
+ "\n"))
+
(defun field-as-text (field obj &optional format-string)
(let* ((value (cdr (assoc field obj)))
(format-string (if format-string format-string
@@ -80,11 +88,10 @@
text))
(defun format-job-record (job)
- (let ((text (format row-pattern
- (field-as-text 'job-id job)
- (field-as-text 'priority job)
- (field-as-text 'owner job)
- (field-as-text 'state job))))
+ (let* ((args (cons row-fmt (mapcar (lambda (key)
+ (field-as-text key job))
+ column-order)))
+ (text (apply 'format args)))
(put-text-property 0 (length text) 'grid-engine-job job text)
text))
@@ -116,7 +123,15 @@
(jobs (mapcar 'mkjob-alist (cddr (caddr tree)))))
(set-buffer (get-buffer-create title))
(erase-buffer)
- (insert header)
+ ;; insert header
+ (insert (apply 'format
+ (cons row-fmt
+ (mapcar (lambda (key)
+ (cadr (assoc key columns)))
+ column-order))))
+ ;; insert separator
+ (insert " \n")
+ ;; insert each row
(mapcar (lambda (job)
(insert (format-job-record job)))
jobs))