summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--grid-engine-mode.el68
1 files changed, 31 insertions, 37 deletions
diff --git a/grid-engine-mode.el b/grid-engine-mode.el
index a023f30..6de65c1 100644
--- a/grid-engine-mode.el
+++ b/grid-engine-mode.el
@@ -21,8 +21,6 @@
"The grid engine user. Defaults to the logged in user's name.")
(defun grid-engine-setup ()
- (if grid-engine-map
- nil
(setq grid-engine-map (make-keymap))
;; disable all key bindings
(suppress-keymap grid-engine-map)
@@ -38,7 +36,26 @@
(error "[Grid Engine] point is not on a field of a job record"))
(grid-engine-job-details field job arg))))
(define-key grid-engine-map (kbd "g")
- (lambda () (interactive) (grid-engine-list-jobs)))))
+ (lambda () (interactive) (grid-engine-list-jobs)))
+
+ (grid-engine-update-list-format)
+ (tabulated-list-init-header))
+
+
+(setq column-order '(job-id time priority owner state))
+(defun grid-engine-update-list-format ()
+ (setq columns '((job-id . ("Job-ID" 10 nil))
+ (priority . ("Priority" 10 nil))
+ (name . ("Job name" 10 nil))
+ (owner . ("User" 15 nil))
+ (state . ("State" 15 nil))
+ (time . ("Time" 25 nil))
+ (queue . ("Queue" 25 nil))
+ (slots . ("Slots" 10 nil))))
+ (setq tabulated-list-format
+ (vconcat (mapcar (lambda (key)
+ (cdr (assoc key columns)))
+ column-order))))
(defun grid-engine--raise-buffer (&optional buffer)
(when buffer
@@ -73,23 +90,8 @@
(grid-engine--cmd-to-buffer cmd)
(libxml-parse-xml-region 1 (buffer-size))))
-
(defun grid-engine-list-jobs ()
"List all jobs for the specified user in a new buffer."
- (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
@@ -97,12 +99,11 @@
(text (format format-string value)))
(propertize text 'field value)))
- (defun format-job-record (job)
- (let* ((args (cons row-fmt (mapcar (lambda (key)
- (field-as-text key job))
- column-order)))
- (text (apply 'format args)))
- (propertize text 'grid-engine-job job)))
+ (defun job-to-row (job)
+ (let ((contents (vconcat (mapcar (lambda (key)
+ (field-as-text key job))
+ column-order))))
+ (list job contents)))
(defun mkjob-alist (subtree)
"Convert a parsed XML subtree for a job entry to an alist."
@@ -131,20 +132,13 @@
(let* ((tree (grid-engine--cmd-to-xmltree cmd))
(jobs (mapcar 'mkjob-alist (cddr (caddr tree)))))
(set-buffer (get-buffer-create title))
- (erase-buffer)
- ;; 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))
+ (setq tabulated-list-entries
+ (mapcar (lambda (job)
+ (job-to-row job))
+ jobs)))
(grid-engine--raise-buffer)
+ ;; update list
+ (tabulated-list-print)
(message nil)))
(defun grid-engine-job-details (field job &optional new-buffer)