]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/debbugs/debbugs-gnu.el
Merge commit '67fa7e1a60966e49eccf21b02110af12afa995e0'
[gnu-emacs-elpa] / packages / debbugs / debbugs-gnu.el
index 77f9cc52c03e6dfd9c01390a559db3de5c9f05f2..378937b5cc674467f273285972216f618d016e43 100644 (file)
 (autoload 'diff-goto-source "diff-mode")
 (autoload 'diff-hunk-file-names "diff-mode")
 (autoload 'gnus-article-mime-handles "gnus-art")
+(autoload 'gnus-fetch-field "gnus-util")
 (autoload 'gnus-read-ephemeral-emacs-bug-group "gnus-group")
 (autoload 'gnus-summary-article-header "gnus-sum")
 (autoload 'gnus-summary-select-article "gnus-sum")
@@ -579,7 +580,9 @@ marked as \"client-side filter\"."
      (t (apply 'debbugs-get-bugs args)))))
 
 (defun debbugs-gnu-show-reports (&optional offline)
-  "Show bug reports."
+  "Show bug reports.
+If OFFLINE is non-nil, the query is not sent to the server.  Bugs
+are taken from the cache instead."
   (let ((inhibit-read-only t)
        (buffer-name "*Emacs Bugs*"))
     ;; The tabulated mode sets several local variables.  We must get
@@ -591,14 +594,16 @@ marked as \"client-side filter\"."
 
     ;; Print bug reports.
     (dolist (status
-            (apply 'debbugs-get-status
-                   (if offline
-                       (let ((ids nil))
-                         (maphash (lambda (key elem)
-                                    (push (cdr (assq 'id elem)) ids))
-                                  debbugs-cache-data)
-                         (sort ids '<))
-                     (debbugs-gnu-get-bugs debbugs-gnu-local-query))))
+            (let ((debbugs-cache-expiry (if offline nil debbugs-cache-expiry))
+                  ids)
+              (apply 'debbugs-get-status
+                     (if offline
+                         (progn
+                           (maphash (lambda (key _elem)
+                                      (push key ids))
+                                    debbugs-cache-data)
+                           (sort ids '<))
+                       (debbugs-gnu-get-bugs debbugs-gnu-local-query)))))
       (let* ((id (cdr (assq 'id status)))
             (words
              (mapconcat
@@ -1662,6 +1667,17 @@ If given a prefix, patch in the branch directory instead."
    (switch-to-buffer "*vc-diff*")
    (other-window 1))
 
+(defun debbugs-gnu-save-cache ()
+  "Save the bugs cache to a file."
+  (interactive)
+  (unless debbugs-cache-data
+    (error "No data to cache"))
+  (unless (file-exists-p "~/.emacs.d/debbugs-cache")
+    (make-directory "~/.emacs.d/debbugs-cache" t))
+  (let ((coding-system-for-write 'utf-8))
+    (with-temp-file "~/.emacs.d/debbugs-cache/list"
+      (prin1 debbugs-cache-data (current-buffer)))))
+
 (provide 'debbugs-gnu)
 
 ;;; TODO: