[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/rt-liberation aa3aa83 15/72: * rt-liberation.el: Add pr
From: |
Stefan Monnier |
Subject: |
[elpa] externals/rt-liberation aa3aa83 15/72: * rt-liberation.el: Add priority update and display. |
Date: |
Wed, 5 Aug 2020 11:57:34 -0400 (EDT) |
branch: externals/rt-liberation
commit aa3aa832491e4b1654de0f9dbde7ca7facdb0391
Author: Yoni Rabkin <yonirabkin@member.fsf.org>
Commit: Yoni Rabkin <yonirabkin@member.fsf.org>
* rt-liberation.el: Add priority update and display.
---
rt-liberation.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/rt-liberation.el b/rt-liberation.el
index 7ebe5bf..2ecd32e 100644
--- a/rt-liberation.el
+++ b/rt-liberation.el
@@ -130,6 +130,9 @@ function returns a truth value.")
(defvar rt-liber-browser-time-format-string "%b %d %Y %H:%M"
"String passed to `format-time-string' in the ticket browser.")
+(defvar rt-liber-browser-priority-cutoff 0
+ "Tickets with a priority higher than this are high priority.")
+
(defface rt-liber-ticket-face
'((((class color) (background dark))
(:foreground "DarkSeaGreen"))
@@ -140,6 +143,16 @@ function returns a truth value.")
(t (:background "Blue")))
"Face for tickets in browser buffer.")
+(defface rt-liber-priority-ticket-face
+ '((((class color) (background dark))
+ (:foreground "Orange"))
+ (((class color) (background light))
+ (:foreground "Orange"))
+ (((type tty) (class mono))
+ (:inverse-video t))
+ (t (:background "Black")))
+ "Face for high priority tickets in browser buffer.")
+
(defconst rt-liber-viewer-font-lock-keywords
(let ((header-regexp (regexp-opt '("id: " "Ticket: " "TimeTaken: "
"Type: " "Field: " "OldValue: "
@@ -520,6 +533,15 @@ AFTER date after predicate."
(substring (cdr (assoc "id" ticket-alist)) 7)
nil))
+(defun rt-liber-ticket-priority-only (ticket-alist)
+ "Return an integer value priority or NIL."
+ (if ticket-alist
+ (let ((p-str (cdr (assoc "Priority" ticket-alist))))
+ (if p-str
+ (string-to-number p-str)
+ nil))
+ nil))
+
(defun rt-liber-viewer-visit-in-browser ()
"Visit this ticket in the RT Web interface."
(interactive)
@@ -755,6 +777,16 @@ ASSOC-BROWSER if non-nil should be a ticket browser."
(cond ((eq char ?%) "%") ;; escape sequence for %
(t (or v "")))))
+(defun rt-liber-high-priority-p (ticket-alist)
+ "Return t if TICKET-ALIST is high priority.
+
+The ticket's priority is compared to the variable
+ `rt-liber-browser-priority-cutoff'."
+ (let ((p (rt-liber-ticket-priority-only ticket-alist)))
+ (if p
+ (< rt-liber-browser-priority-cutoff p)
+ nil)))
+
(defun rt-liber-format (format ticket-alist)
"Substitute %-sequences in FORMAT."
(let ((alist (rt-liber-format-function ticket-alist)))
@@ -770,6 +802,14 @@ ASSOC-BROWSER if non-nil should be a ticket browser."
(add-text-properties (point-at-bol)
(point-at-eol)
'(face rt-liber-ticket-face))
+ (when (rt-liber-high-priority-p ticket)
+ (let ((p (point)))
+ (insert (format " HIGH PRIORITY (%d)"
+ (rt-liber-ticket-priority-only ticket)))
+ (add-text-properties p
+ (point-at-eol)
+ '(face rt-liber-priority-ticket-face))))
+
(newline)
(insert (rt-liber-format " [%o] %R: %s" ticket))
(let ((p (point)))
@@ -1239,6 +1279,23 @@ If FIELD already exists, update to VALUE."
(rt-liber-command-runner command args)
'rt-liber-command-runner-parser-f)))
+(defun rt-liber-command-set-priority (id priority)
+ "Set ticket ID priority to be PRIORITY."
+ (let ((command (rt-liber-command-get-command-string 'edit))
+ (args
+ (format "ticket/%s set priority=%s"
+ id
+ (if (= priority 0)
+ ;; this is to work around a weird bug in RT
+ ;; (3.8.8) in which the CLI command to set the
+ ;; priority to 0 doesn't work, but sending 00
+ ;; does
+ "00"
+ (format "%d" priority)))))
+ (rt-liber-parse-answer
+ (rt-liber-command-runner command args)
+ 'rt-liber-command-runner-parser-f)))
+
(defun rt-liber-command-set-status-deleted (id)
"Set the status of ticket ID to `deleted'."
(rt-liber-command-set-status
@@ -1286,6 +1343,14 @@ If FIELD already exists, update to VALUE."
(rt-liber-command-runner command args)
'rt-liber-command-runner-parser-f)))
+(defun rt-liber-browser-prioritize (n)
+ "Assigng current ticket priority N."
+ (interactive "nPriority (number): ")
+ (rt-liber-command-set-priority
+ (rt-liber-browser-ticket-id-at-point)
+ n)
+ (rt-liber-browser-refresh-and-return))
+
(defun rt-liber-browser-assign (name)
"Assign current ticket to a user NAME."
(interactive "sAssign to: ")
- [elpa] externals/rt-liberation 146b0ed 07/72: Add makefile., (continued)
- [elpa] externals/rt-liberation 146b0ed 07/72: Add makefile., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 1aa19e9 08/72: Fix compilation errors., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e81b0a3 09/72: * rt-liberation-gnus.el: Fix compile warnings., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 4dd2f82 11/72: * rt-liberation-gnus.el: Fix single line and leading space bugs., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 7bc66d0 12/72: * rt-liberation.el: Add %-sequence support for priority., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 6a51214 13/72: * rt-liberation.el: Add a custom time format string., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 2c9b357 10/72: Fix compilation warnings., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation f0cf810 23/72: * doc/rt-liberation.texinfo: Update manual., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation b506154 14/72: * rt-liberation.el: Update the browser display format., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 757d808 16/72: * rt-liberation.el: Add keybinding., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation aa3aa83 15/72: * rt-liberation.el: Add priority update and display.,
Stefan Monnier <=
- [elpa] externals/rt-liberation 28b08a4 17/72: * doc/rt-liberation.texinfo: Document new features., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 7ee937c 18/72: * doc/rt-liberation.texinfo: Add dependencies to the manual., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation bd60dc3 20/72: * rt-liberation-rest.el: Document the show query issue., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 60ead31 24/72: * rt-liberation-gnus.el: Improve Gnus integration., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation c654b30 26/72: * rt-liberation.el: Mark spam feature as very broken., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation b640bb7 25/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation e06992e 27/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 3e4a424 29/72: Merge branch 'master' into rest, Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation 6e75dbb 31/72: * rt-liberation-rest.el: Start work on `show' query., Stefan Monnier, 2020/08/05
- [elpa] externals/rt-liberation f67581b 32/72: Implement and start using REST show query., Stefan Monnier, 2020/08/05