summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoni Rabkin <yoni@rabkins.net>2020-08-09 13:25:02 -0400
committerYoni Rabkin <yoni@rabkins.net>2020-08-09 13:25:02 -0400
commit1504bab14f90261bf7ea04fdf9750d0a494f83bf (patch)
treed40198e3f8da7ec00df0d96af37d2d7069a8b4dd
parentacd2fe0fda9e4a4f1e4413d2745860b4e8b74713 (diff)
Move functions around to fix compiler warnings.
-rw-r--r--rt-liberation-rest.el46
-rw-r--r--rt-liberation.el134
2 files changed, 40 insertions, 140 deletions
diff --git a/rt-liberation-rest.el b/rt-liberation-rest.el
index 7782665..99f6ce9 100644
--- a/rt-liberation-rest.el
+++ b/rt-liberation-rest.el
@@ -20,9 +20,7 @@
;; License along with this program; if not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
;; MA 02111-1307, USA.
-;;
-;; Note: Licensed under GPLv2+ and not GPLv3+ in order to be
-;; compatible with the license of RT.
+
;;; History:
;;
@@ -33,9 +31,7 @@
(require 'url)
(require 'url-util)
-;; (require 'rt-liberation) ; FIXME: Circular dependency
-(declare-function rt-liber-parse-answer "rt-liberation" (answer-string parser-f))
-(declare-function rt-liber-ticket-base-retriever-parser-f "rt-liberation" ())
+
(defvar rt-liber-rest-debug-buffer-name "*rt-liber-rest debug log*"
"Buffer name of debug capture.")
@@ -176,24 +172,6 @@
(re-search-forward rt-ok-regexp (point-max)))
(error "bad HTTP response from server")))) ;FIXME: Unused string!
-(defun rt-liber-rest-ticketsql-runner-parser-f ()
- "Parser function for a textual list of tickets."
- (let (idsub-list)
- (rt-liber-rest-parse-http-header)
- (while (re-search-forward "ticket/\\([0-9].+\\)" (point-max) t)
- ;; the output should be compatible with the input to
- ;; `rt-liber-create-tickets-string'
- (push (list (match-string-no-properties 1)
- ".")
- idsub-list))
- idsub-list))
-
-(defun rt-liber-rest-run-ls-query (query)
- "Run an \"ls\" type query against the server with QUERY."
- (rt-liber-parse-answer
- (rt-liber-rest-query-runner "ls" query)
- 'rt-liber-rest-ticketsql-runner-parser-f))
-
(defun rt-liber-rest-show-process (response)
"Process and return the show query response."
(when (not (stringp response))
@@ -228,20 +206,6 @@
(message "done retrieving %d tickets" l)))
(buffer-substring (point-min) (point-max))))
-(defun rt-liber-rest-run-show-base-query (idsublist)
- "Run \"show\" type query against the server with IDSUBLIST."
- (rt-liber-parse-answer
- (rt-liber-rest-show-query-runner idsublist)
- #'rt-liber-ticket-base-retriever-parser-f))
-
-(defun rt-liber-rest-run-ticket-history-base-query (ticket-id)
- "Run history query against server for TICKET-ID."
- (rt-liber-parse-answer
- (rt-liber-rest-query-runner "history" ticket-id)
- #'(lambda ()
- (rt-liber-rest-parse-http-header)
- (buffer-substring (point) (point-max)))))
-
(defun rt-liber-rest-handle-response (buffer)
"Handle the response provided in BUFFER."
(with-current-buffer buffer
@@ -270,12 +234,6 @@
(rt-liber-rest-handle-response response-buffer)))
(message "edit command ended at %s" (current-time-string)))
-(defun rt-liber-rest-command-set (id field status)
- "Set ticket ID status to be STATUS."
- (rt-liber-parse-answer
- (rt-liber-rest-edit-runner id field status)
- 'rt-liber-command-runner-parser-f))
-
(provide 'rt-liberation-rest)
diff --git a/rt-liberation.el b/rt-liberation.el
index c1a7e76..6649bb0 100644
--- a/rt-liberation.el
+++ b/rt-liberation.el
@@ -5,7 +5,7 @@
;; Author: Yoni Rabkin <yrk@gnu.org>
;; Authors: Aaron S. Hawley <aaron.s.hawley@gmail.com>, John Sullivan <johnsu01@wjsullivan.net>
;; Maintainer: Yoni Rabkin <yrk@gnu.org>
-;; Version: 1.00
+;; Version: 1.01
;; Keywords: rt, tickets
;; Package-Type: multi
;; url: http://www.nongnu.org/rtliber/
@@ -395,20 +395,41 @@ AFTER date after predicate."
continue t))
ticketbase-list))
-;; accept the output of `rt-liber-ticketsql-runner-parser-f' and
-;; return a string suitable for an RT "show" query
-(defun rt-liber-create-tickets-string (idsublist)
- "Create a RT CLI ticket \"show\" string from IDSUBLIST."
- (let ((ticket-list (mapcar #'(lambda (e) (car e)) idsublist)))
- (if ticket-list
- (concat "ticket/"
- (if (= (length ticket-list) 1)
- (format "%s" (car ticket-list))
- (cl-reduce
- #'(lambda (a b)
- (format "%s,%s" a b))
- ticket-list)))
- (signal 'rt-liber-no-result-from-query-error nil))))
+(defun rt-liber-rest-ticketsql-runner-parser-f ()
+ "Parser function for a textual list of tickets."
+ (let (idsub-list)
+ (rt-liber-rest-parse-http-header)
+ (while (re-search-forward "ticket/\\([0-9].+\\)" (point-max) t)
+ (push (list (match-string-no-properties 1)
+ ".")
+ idsub-list))
+ idsub-list))
+
+(defun rt-liber-rest-run-ls-query (query)
+ "Run an \"ls\" type query against the server with QUERY."
+ (rt-liber-parse-answer
+ (rt-liber-rest-query-runner "ls" query)
+ 'rt-liber-rest-ticketsql-runner-parser-f))
+
+(defun rt-liber-rest-run-show-base-query (idsublist)
+ "Run \"show\" type query against the server with IDSUBLIST."
+ (rt-liber-parse-answer
+ (rt-liber-rest-show-query-runner idsublist)
+ #'rt-liber-ticket-base-retriever-parser-f))
+
+(defun rt-liber-rest-run-ticket-history-base-query (ticket-id)
+ "Run history query against server for TICKET-ID."
+ (rt-liber-parse-answer
+ (rt-liber-rest-query-runner "history" ticket-id)
+ #'(lambda ()
+ (rt-liber-rest-parse-http-header)
+ (buffer-substring (point) (point-max)))))
+
+(defun rt-liber-rest-command-set (id field status)
+ "Set ticket ID status to be STATUS."
+ (rt-liber-parse-answer
+ (rt-liber-rest-edit-runner id field status)
+ 'rt-liber-command-runner-parser-f))
;;; --------------------------------------------------------
@@ -538,7 +559,7 @@ AFTER date after predicate."
"Key map for ticket viewer.")
(define-derived-mode rt-liber-viewer-mode nil
- "RT Liberation Viewer"
+ "RT Liberation Viewer"
"Major Mode for viewing RT tickets.
\\{rt-liber-viewer-mode-map}"
(set
@@ -929,79 +950,6 @@ and as such always return t."
;;; --------------------------------------------------------
-;;; Version comparison functions
-;;; --------------------------------------------------------
-
-;; rt-liber-version-<: string * string -> t-or-nil
-(defun rt-liber-version-< (vnum1 vnum2)
- "Test whehther version number VNUM1 is less than VNUM2.
-Arguments must be strings Lisp objects, and not numbers.
-
-Examples:
- (rt-liber-version-< \"1.01\" \"1.11\")
- => t
-
- (rt-liber-version-< \"1.1\" \"1.0.1\")
- => nil"
- (rt-liber-version-<- (rt-liber-version-value
- (rt-liber-version-read vnum1))
- (rt-liber-version-value
- (rt-liber-version-read vnum2))))
-
-;; rt-liber-version-read: string -> list string
-(defun rt-liber-version-read (str)
- "Tokenize version number STR whenever the syntax class changes.
-
- Example:
- \"1.043.0-1_=+\" \
-==> (\"1\" \".\" \"043\" \".\" \"0\" \"-\" \"1\" \"_=+\")"
- (let ((tokens nil)
- (start 0)
- (re (mapconcat 'identity '("[[:digit:]]+" "[[:punct:]]+") "\\|")))
- (while (and (string-match re (substring str start))
- (> (length str) start))
- (setq tokens (cons (match-string 0 (substring str start)) tokens))
- (setq start (+ start (match-end 0))))
- (if (< start (length str))
- (error "Unknown character: %s" (substring str start (1+ start))))
- (reverse tokens)))
-
-;; rt-liber-version-value: list string -> list number
-(defun rt-liber-version-value (tokens)
- "Convert list of TOKENS to a comparable number list."
- (mapcar #'(lambda (tk)
- (if (string-match "^0+$" tk)
- 1
- (if (string-match "^[[:digit:]]+$" tk)
- (if (string-match "^0+" tk)
- (1+ (* (string-to-number tk)
- (expt 10
- (- (length
- (match-string 0 tk))))))
- (1+ (string-to-number tk)))
- (if (string-match "^[[:punct:]]+$" tk)
- 0
- ;; else (string-match "[^[:digit:][:punct:]]" tk)
- -1))))
- tokens))
-
-;; rt-liber-version-<-: list number -> t-or-nil
-(defun rt-liber-version-<- (vals1 vals2)
- "Test whether version representation VALS1 is less than VALS2."
- (if (and (null vals1) (null vals2))
- nil
- (if (null vals2)
- nil
- (if (null vals1)
- t
- (if (= (car vals1) (car vals2))
- (rt-liber-version-<- (cdr vals1) (cdr vals2))
- (if (< (car vals1) (car vals2))
- t
- nil))))))
-
-
-;;; --------------------------------------------------------
;;; Entry points
;;; --------------------------------------------------------
@@ -1075,7 +1023,7 @@ returned as no associated text properties."
"Key map for ticket browser.")
(define-derived-mode rt-liber-browser-mode nil
- "RT Liberation Browser"
+ "RT Liberation Browser"
"Major Mode for browsing RT tickets.
\\{rt-liber-browser-mode-map}"
(set (make-local-variable 'revert-buffer-function)
@@ -1168,12 +1116,6 @@ returned as no associated text properties."
status-symbol
rt-liber-status-dictionary))
-(defun rt-liber-command-get-custom-field-string (custom-field-symbol)
- "Return value associated with key CUSTOM-FIELD-SYMBOL."
- (rt-liber-command-get-dictionary-value
- custom-field-symbol
- rt-liber-custom-field-dictionary))
-
(defun rt-liber-command-runner-parser-f ()
"Display command return status from the server to the user."
(message (buffer-string)))