help-debbugs
[Top][All Lists]
Advanced

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

[PATCH 12/12] Download WSDL early and propagate it via keyword arguments


From: Felix Lechner
Subject: [PATCH 12/12] Download WSDL early and propagate it via keyword arguments.
Date: Sun, 10 Mar 2024 12:00:49 -0700

---
 debbugs-gnu.el | 61 ++++++++++++++++++++++++++++++--------------------
 debbugs-org.el | 12 ++++++----
 debbugs.el     |  3 ++-
 3 files changed, 47 insertions(+), 29 deletions(-)

diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 2b3a1aaaa6..953fc8df57 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -838,7 +838,8 @@ Shall be bound in `debbugs-org-*' functions.")
            (add-to-list 'debbugs-gnu-current-query (cons 'tag tag))))
 
        ;; Show result.
-       (funcall debbugs-gnu-show-reports-function))
+        (let ((soap-wsdl (debbugs-download-wsdl)))
+         (funcall debbugs-gnu-show-reports-function :soap-wsdl soap-wsdl)))
 
     ;; Reset query, filter and suppress.
     (setq debbugs-gnu-current-query nil
@@ -852,9 +853,11 @@ Shall be bound in `debbugs-org-*' functions.")
   "Retrieve the open bugs, that you submitted.
 This function assumes the variable `user-mail-address' is defined."
   (interactive)
-  (apply #'debbugs-gnu-bugs (debbugs-get-bugs '(:submitter "me" :status 
"open"))))
+  (let ((soap-wsdl (debbugs-download-wsdl)))
+    (apply #'debbugs-gnu-bugs (debbugs-get-bugs '(:submitter "me" :status 
"open")
+                                                :soap-wsdl soap-wsdl))))
 
-(defun debbugs-gnu-get-bugs (query)
+(cl-defun debbugs-gnu-get-bugs (query &key (soap-wsdl (debbugs-download-wsdl)))
   "Retrieve bug numbers from debbugs.gnu.org according search criteria."
   (let* ((bugs (assq 'bugs query))
         (tags (and (member '(severity . "tagged") query) (assq 'tag query)))
@@ -894,13 +897,13 @@ This function assumes the variable `user-mail-address' is 
defined."
      (phrase
       (mapcar
        (lambda (x) (cdr (assoc "id" x)))
-       (debbugs-search-est args)))
+       (debbugs-search-est args :soap-wsdl soap-wsdl)))
      ;; User tags.
      (tags
       (setq args (mapcar (lambda (x) (if (eq x :package) :user x)) args))
-      (debbugs-get-usertag args))
+      (debbugs-get-usertag args :soap-wsdl soap-wsdl))
      ;; Otherwise, we retrieve the bugs from the server.
-     (t (debbugs-get-bugs args)))))
+     (t (debbugs-get-bugs args :soap-wsdl soap-wsdl)))))
 
 (defun debbugs-gnu--split-address (string)
   "Split mail-like STRING into a name/email address pair."
@@ -912,7 +915,7 @@ This function assumes the variable `user-mail-address' is 
defined."
              (replace-regexp-in-string "\\`\"\\|\"\\'" "" name)))
     (cons string string)))
 
-(cl-defun debbugs-gnu-show-reports (&key (offline nil))
+(cl-defun debbugs-gnu-show-reports (&key (offline nil) (soap-wsdl 
(debbugs-download-wsdl)))
   "Show bug reports.
 If OFFLINE is non-nil, the query is not sent to the server.  Bugs
 are taken from the cache instead."
@@ -944,7 +947,8 @@ are taken from the cache instead."
                                  (push key ids))
                                debbugs-cache-data)
                       ids)
-                  (debbugs-gnu-get-bugs debbugs-gnu-local-query))))
+                  (debbugs-gnu-get-bugs debbugs-gnu-local-query
+                                         :soap-wsdl soap-wsdl))))
              ;; Sort so that if a new report gets merged with an old
              ;; report, it shows up under the new report.
              (lambda (s1 s2)
@@ -1217,8 +1221,9 @@ Interactively, it is non-nil with the prefix argument."
        (debbugs-gnu-current-filter debbugs-gnu-local-filter)
        (debbugs-gnu-current-suppress debbugs-gnu-local-suppress)
        (debbugs-gnu-current-print-function debbugs-gnu-local-print-function)
-       (debbugs-cache-expiry (if nocache t debbugs-cache-expiry)))
-    (funcall debbugs-gnu-show-reports-function)
+       (debbugs-cache-expiry (if nocache t debbugs-cache-expiry))
+        (soap-wsdl (debbugs-download-wsdl)))
+    (funcall debbugs-gnu-show-reports-function :soap-wsdl soap-wsdl)
     (when id
       (debbugs-gnu-goto id))))
 
@@ -1815,34 +1820,37 @@ Looks at current line and then backwards from point."
         (re-search-backward "#\\([0-9]+\\)" nil t))
      (string-to-number (match-string 1)))))
 
-(defun debbugs-gnu-proper-bug-number (id)
+(cl-defun debbugs-gnu-proper-bug-number (id &key (soap-wsdl 
(debbugs-download-wsdl)))
   "Check that ID is a number string and in the range of existing bugs."
   (and (string-match "^[1-9][0-9]*$" id)
-       (<= (string-to-number id) (car (debbugs-newest-bugs 1)))))
+       (<= (string-to-number id) (car (debbugs-newest-bugs 1 :soap-wsdl 
soap-wsdl)))))
 
 (defvar debbugs-gnu-completion-table
   (completion-table-dynamic
    (lambda (string)
      (let* ((split (split-string string "-"))
            (from (and (cdr split) (car split)))
-           (to (or (car (cdr split)) (car split))))
+           (to (or (car (cdr split)) (car split)))
+            (soap-wsdl (debbugs-download-wsdl)))
        (cond
        ((> (length split) 2) nil)
-       ((and (or (zerop (length from)) (debbugs-gnu-proper-bug-number from))
+       ((and (or (zerop (length from))
+                  (debbugs-gnu-proper-bug-number from :soap-wsdl soap-wsdl))
              (string-equal to ""))
         (mapcar
          (lambda (x) (concat string x))
          (cons (unless from "-") '("1" "2" "3" "4" "5" "6" "7" "8" "9"))))
-       ((and (or (zerop (length from)) (debbugs-gnu-proper-bug-number from))
-             (debbugs-gnu-proper-bug-number to))
+       ((and (or (zerop (length from))
+                  (debbugs-gnu-proper-bug-number from) :soap-wsdl soap-wsdl)
+             (debbugs-gnu-proper-bug-number to) :soap-wsdl soap-wsdl)
         (mapcar
          (lambda (x)
-           (and (debbugs-gnu-proper-bug-number (concat to x))
+           (and (debbugs-gnu-proper-bug-number (concat to x) :soap-wsdl 
soap-wsdl)
                 (concat string x)))
          '("" "0" "1" "2" "3" "4" "5" "6" "7" "8" "9")))))))
   "Dynamic completion table for reading bug numbers.")
 
-(defun debbugs-gnu-expand-bug-number-list (bug-number-list)
+(cl-defun debbugs-gnu-expand-bug-number-list (bug-number-list &key (soap-wsdl 
(debbugs-download-wsdl)))
   "Expand BUG-NUMBER-LIST to a list of single bug numbers.
 BUG-NUMBER-LIST is a list of bug numbers or bug number ranges, as
 returned by `debbugs-gnu-bugs'."
@@ -1863,7 +1871,7 @@ returned by `debbugs-gnu-bugs'."
           (append
            (mapcar
             #'number-to-string
-            (debbugs-newest-bugs (string-to-number to)))
+            (debbugs-newest-bugs (string-to-number to) :soap-wsdl soap-wsdl))
            result))
          (t (append
              (mapcar
@@ -2004,7 +2012,8 @@ removed instead."
                    ;; Unexpected version format?
                    (_ emacs-version))))
             ;; Don't put a version.
-            "")))
+            ""))
+         (soap-wsdl (debbugs-download-wsdl)))
     (unless buffer
       (setq buffer
             (pop-to-buffer
@@ -2050,7 +2059,8 @@ removed instead."
            (debbugs-gnu-expand-bug-number-list
             (completing-read-multiple
              (format "%s with bug(s) #: " (capitalize message))
-             debbugs-gnu-completion-table))
+             debbugs-gnu-completion-table)
+            :soap-wsdl soap-wsdl)
            " ")))
         ((member message '("block" "unblock"))
          (format
@@ -2062,7 +2072,8 @@ removed instead."
              (if (equal message "unblock")
                  (mapcar #'number-to-string (alist-get 'blockedby status))
                debbugs-gnu-completion-table)
-             nil (and (equal message "unblock") status)))
+             nil (and (equal message "unblock") status))
+            :soap-wsdl soap-wsdl)
            " ")))
         ((equal message "owner")
          (format "owner %d !\n" bugid))
@@ -2419,7 +2430,8 @@ successfully sent."
   (let ((inhibit-read-only t)
        (buffer-name "*Emacs User Tags*")
        (user-tab-length
-        (1+ (apply #'max (length "User") (mapcar #'length users)))))
+        (1+ (apply #'max (length "User") (mapcar #'length users))))
+        ((soap-wsdl (debbugs-download-wsdl))))
 
     ;; Initialize variables.
     (when (and (file-exists-p debbugs-gnu-persistency-file)
@@ -2440,7 +2452,8 @@ successfully sent."
 
     ;; Retrieve user tags.
     (dolist (user users)
-      (dolist (tag (sort (debbugs-get-usertag '(:user user)) #'string<))
+      (dolist (tag (sort (debbugs-get-usertag '(:user user) :soap-wsdl 
soap-wsdl)
+                         #'string<))
        (add-to-list
         'tabulated-list-entries
         ;; `tabulated-list-id' is the parameter list for `debbugs-gnu'.
diff --git a/debbugs-org.el b/debbugs-org.el
index 4051f09ebe..2d37c0d0ad 100644
--- a/debbugs-org.el
+++ b/debbugs-org.el
@@ -186,7 +186,7 @@ marked as \"client-side filter\"."
   (let ((debbugs-gnu-show-reports-function #'debbugs-org-show-reports))
     (call-interactively #'debbugs-gnu)))
 
-(defun debbugs-org-show-reports ()
+(cl-defun debbugs-org-show-reports (&key (soap-wsdl (debbugs-download-wsdl)))
   "Show bug reports as retrieved via `debbugs-gnu-current-query'."
   (let ((inhibit-read-only t)
        (org-startup-folded t))
@@ -200,7 +200,9 @@ marked as \"client-side filter\"."
             ;; `debbugs-get-status' returns in random order, so we must sort.
             (sort
              (debbugs-get-status
-              (debbugs-gnu-get-bugs debbugs-gnu-local-query))
+              (debbugs-gnu-get-bugs debbugs-gnu-local-query
+                                     :soap-wsdl soap-wsdl)
+               :soap-wsdl soap-wsdl)
              (lambda (a b) (> (alist-get 'id a) (alist-get 'id b)))))
       (let* ((beg (point))
             (id (alist-get 'id status))
@@ -365,8 +367,10 @@ or bug ranges, with default to 
`debbugs-gnu-default-bug-number-list'."
 This function assumes the variable `user-mail-address' is
 defined."
   (interactive)
-  (let ((debbugs-gnu-show-reports-function #'debbugs-org-show-reports))
-    (apply #'debbugs-gnu-bugs (debbugs-get-bugs '(:submitter "me" :status 
"open")))))
+  (let ((debbugs-gnu-show-reports-function #'debbugs-org-show-reports)
+        (soap-wsdl (debbugs-download-wsdl)))
+    (apply #'debbugs-gnu-bugs (debbugs-get-bugs '(:submitter "me" :status 
"open")
+                                                :soap-wsdl soap-wsdl))))
 
 ;; TODO
 
diff --git a/debbugs.el b/debbugs.el
index 995f0f7784..b65de07765 100644
--- a/debbugs.el
+++ b/debbugs.el
@@ -828,7 +828,8 @@ Examples:
                     (append
                      phrase `(:skip ,skip)
                      `(:max ,debbugs-max-hits-per-request)))
-                   query))
+                   query)
+                   :soap-wsdl soap-wsdl)
                  skip (and (= (length result1) debbugs-max-hits-per-request)
                            (+ skip debbugs-max-hits-per-request))
                  result (append result result1))))
-- 
2.41.0




reply via email to

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