emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/rt-liberation bcbf368 35/68: * rt-liberation-viewer.el:


From: Yoni Rabkin
Subject: [elpa] externals/rt-liberation bcbf368 35/68: * rt-liberation-viewer.el: content parsing
Date: Wed, 16 Dec 2020 12:11:11 -0500 (EST)

branch: externals/rt-liberation
commit bcbf368acd9156850334bc6085990a17c7065051
Author: Yoni Rabkin <yoni@rabkins.net>
Commit: Yoni Rabkin <yoni@rabkins.net>

    * rt-liberation-viewer.el: content parsing
    
    The darn leading spaces are still there.
---
 rt-liberation-viewer.el | 61 +++++++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 15 deletions(-)

diff --git a/rt-liberation-viewer.el b/rt-liberation-viewer.el
index e1d499b..d48b9da 100644
--- a/rt-liberation-viewer.el
+++ b/rt-liberation-viewer.el
@@ -59,25 +59,55 @@
                                                         (car section-list)
                                                         (cadr 
section-list))))))))
 
+;; According to:
+;; "https://rt-wiki.bestpractical.com/wiki/REST#Ticket_History_Entry";
+;; id: <history-id>
+;; Ticket: <ticket-id>
+;; TimeTaken: <...>
+;; Type: <...>
+;; Field: <...>
+;; OldValue: <...>
+;; NewValue: <...>
+;; Data: <...>
+;; Description: <...>
+
+;; Content: <lin1-0>
+;;          <line-1>
+;;          ...
+;;          <line-n>
+
+;; Creator: <...>
+;; Created: <...>
+;; Attachments: <...>
 (defun rt-liber-viewer-parse-section (start end)
   (goto-char start)
-  (when (not (re-search-forward rt-liber-viewer-section-header-regexp
-                               end t))
+  (when (not (re-search-forward
+             rt-liber-viewer-section-header-regexp
+             end t))
     (error "invalid section"))
   (forward-line 2)
   (let (section-field-alist
-       section-field-end)
-    (save-excursion
-      (setq section-field-end
-           (re-search-forward "\n\n" end nil)))
-    (while (not (looking-at "^\n"))
-      (when (looking-at rt-liber-viewer-section-field-regexp)
-       (setq section-field-alist
-             (append section-field-alist
-                     `((,(match-string-no-properties 1) .
-                        ,(match-string-no-properties 2))))))
-      (forward-line))
-    section-field-alist))
+       (rt-field-list
+        '(id Ticket TimeTaken Type Field
+             OldValue NewValue Data Description
+             Creator Created)))
+    ;; definitely error out if any of this doesn't work
+    (setq section-field-alist
+         (mapcar
+          (lambda (field-symbol)
+            (re-search-forward (format "^%s:" (symbol-name field-symbol)) end 
nil)
+            (cons field-symbol (buffer-substring (1+ (point)) (point-at-eol))))
+          rt-field-list))
+    ;; content
+    (goto-char start)
+    (let ((content-start (re-search-forward "^Content: " end nil))
+         (content-end (progn
+                        (re-search-forward "^Creator: " end nil)
+                        (point-at-bol))))
+      (append section-field-alist
+             `(,(cons 'Content
+                      (buffer-substring content-start
+                                        content-end)))))))
 
 ;; According to:
 ;; "https://rt-wiki.bestpractical.com/wiki/REST#Ticket_History"; is of
@@ -108,7 +138,8 @@
               (rt-liber-viewer-parse-section
                (car section-points)
                (cdr section-points)))
-            section-point-list)))))
+            section-point-list))
+      section-list)))
 
 (defun rt-liber-display-ticket-history (ticket-alist &optional assoc-browser)
   "Display history for ticket.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]