From 86e39f1ee3aa7222c81c0bf6d37195e56d091221 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Fri, 24 Oct 2014 13:18:09 +0200 Subject: store job alist and fields in text properties --- grid-engine-mode.el | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/grid-engine-mode.el b/grid-engine-mode.el index 73c9c9d..b91c829 100644 --- a/grid-engine-mode.el +++ b/grid-engine-mode.el @@ -67,12 +67,22 @@ "Priority" "User" "State")) + (defun field-as-text (field obj &optional format-string) + (let* ((value (cdr (assoc field obj))) + (format-string (if format-string format-string + "%s")) + (text (format format-string value))) + (put-text-property 0 (length text) 'field value text) + text)) + (defun format-job-record (job) - (format row-pattern - (cdr (assoc 'job-id job)) - (cdr (assoc 'priority job)) - (cdr (assoc 'owner job)) - (cdr (assoc 'state 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)))) + (put-text-property 0 (length text) 'grid-engine-job job text) + text)) (defun mkjob-alist (subtree) "Convert a parsed XML subtree for a job entry to an alist." -- cgit v1.2.3