diff options
Diffstat (limited to 'rt-liberation-viewer.el')
-rw-r--r-- | rt-liberation-viewer.el | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/rt-liberation-viewer.el b/rt-liberation-viewer.el index e07186d..10d4799 100644 --- a/rt-liberation-viewer.el +++ b/rt-liberation-viewer.el @@ -25,11 +25,15 @@ ;;; Comments: ;; By the end of 2020 is was clear that a more robust way of viewing ;; tickets was preferable. - +(require 'rt-liberation-rest) +(require 'rt-liberation-browser) ;;; Code: -(require 'rt-liberation) +(defvar rt-liber-jump-to-latest nil + "jump to the latest correspondence when viewing a ticket.") +(defvar rt-liber-content-regexp "^Content:.*$" + "Regular expression for section headers.") (defvar rt-liber-viewer-section-header-regexp "^# [0-9]+/[0-9]+ (id/[0-9]+/total)") @@ -49,31 +53,7 @@ 'font-lock-comment-face))) "Expressions to font-lock for RT ticket viewer.") -(defun rt-liber-display-ticket-history (ticket-alist &optional assoc-browser) - "Display history for ticket. -TICKET-ALIST alist of ticket data. -ASSOC-BROWSER if non-nil should be a ticket browser." - (let* ((ticket-id (rt-liber-ticket-id-only ticket-alist)) - (contents (rt-liber-rest-run-ticket-history-base-query ticket-id)) - (new-ticket-buffer (get-buffer-create - (concat "*RT Ticket #" ticket-id "*")))) - (with-current-buffer new-ticket-buffer - (let ((inhibit-read-only t)) - (erase-buffer) - (insert contents) - (goto-char (point-min)) - (rt-liber-viewer-mode) - (set - (make-local-variable 'rt-liber-ticket-local) - ticket-alist) - (when assoc-browser - (set - (make-local-variable 'rt-liber-assoc-browser) - assoc-browser)) - (set-buffer-modified-p nil) - (setq buffer-read-only t))) - (switch-to-buffer new-ticket-buffer))) ;;; ------------------------------------------------------------------ @@ -239,13 +219,9 @@ ASSOC-BROWSER if non-nil should be a ticket browser." (rt-liber-viewer2-display-history contents) (goto-char (point-min)) (rt-liber-viewer2-mode) - (set - (make-local-variable 'rt-liber-ticket-local) - ticket-alist) + (set (make-local-variable 'rt-liber-ticket-local) ticket-alist) (when assoc-browser - (set - (make-local-variable 'rt-liber-assoc-browser) - assoc-browser)) + (set (make-local-variable 'rt-liber-assoc-browser) assoc-browser)) (set-buffer-modified-p nil) (setq buffer-read-only t))) (switch-to-buffer new-ticket-buffer))) @@ -295,6 +271,39 @@ ASSOC-BROWSER if non-nil should be a ticket browser." ;;; ------------------------------------------------------------------ ;;; viewer mode functions ;;; ------------------------------------------------------------------ +(defun rt-liber-refresh-ticket-history (&optional _ignore-auto _noconfirm) + (interactive) + (if rt-liber-ticket-local + (rt-liber-display-ticket-history rt-liber-ticket-local + rt-liber-assoc-browser) + (error "not viewing a ticket"))) + +(defun rt-liber-display-ticket-history (ticket-alist &optional assoc-browser) + "Display history for ticket. + +TICKET-ALIST alist of ticket data. +ASSOC-BROWSER if non-nil should be a ticket browser." + (let* ((ticket-id (rt-liber-ticket-id-only ticket-alist)) + (contents (rt-liber-rest-run-ticket-history-base-query ticket-id)) + (new-ticket-buffer (get-buffer-create + (concat "*RT Ticket #" ticket-id "*")))) + (with-current-buffer new-ticket-buffer + (let ((inhibit-read-only t)) + (erase-buffer) + (insert contents) + (goto-char (point-min)) + (rt-liber-viewer-mode) + (set + (make-local-variable 'rt-liber-ticket-local) + ticket-alist) + (when assoc-browser + (set + (make-local-variable 'rt-liber-assoc-browser) + assoc-browser)) + (set-buffer-modified-p nil) + (setq buffer-read-only t))) + (switch-to-buffer new-ticket-buffer))) + (defun rt-liber-jump-to-latest-correspondence () "Move point to the newest correspondence section." (interactive) |