]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/debbugs/debbugs-gnu.el
Allow sending control messages offline
[gnu-emacs-elpa] / packages / debbugs / debbugs-gnu.el
index 78741a30c56d35027d41814fbb5176dd600392df..77f9cc52c03e6dfd9c01390a559db3de5c9f05f2 100644 (file)
@@ -276,7 +276,7 @@ If this is 'rmail, use Rmail instead."
   "Face for reports that are pending.")
 
 (defface debbugs-gnu-stale '((t (:foreground "orange")))
-  "Face for reports that have not been touched for a week.")
+  "Face for reports that have not been touched for two weeks.")
 
 (defface debbugs-gnu-done '((t (:foreground "DarkGrey")))
   "Face for closed bug reports.")
@@ -354,7 +354,7 @@ marked as \"client-side filter\"."
        (if (zerop (length phrase))
            (setq phrase nil)
          (add-to-list 'debbugs-gnu-current-query (cons 'phrase phrase)))
-       ;; We suppress the bugs if there is no phrase.
+       ;; We suppress closed bugs if there is no phrase.
        (setq debbugs-gnu-current-suppress (null phrase))
 
        ;; The other queries.
@@ -531,7 +531,7 @@ marked as \"client-side filter\"."
        debbugs-gnu-current-suppress nil))
 
 (defun debbugs-gnu-get-bugs (query)
-  "Retrieve bugs numbers from debbugs.gnu.org according search criteria."
+  "Retrieve bug numbers from debbugs.gnu.org according search criteria."
   (let* ((debbugs-port "gnu.org")
         (bugs (assoc 'bugs query))
         (tags (assoc 'tag query))
@@ -550,7 +550,7 @@ marked as \"client-side filter\"."
               (if phrase
                   (cond
                    ((eq (car elt) 'phrase)
-                    (list (list :phrase (cdr elt) :max 500)))
+                    (list (list :phrase (cdr elt))))
                    ((eq (car elt) 'date)
                     (list (list :date (cddr elt) (cadr elt)
                                 :operator "NUMBT")))
@@ -578,10 +578,9 @@ marked as \"client-side filter\"."
      ;; Otherwise, we retrieve the bugs from the server.
      (t (apply 'debbugs-get-bugs args)))))
 
-(defun debbugs-gnu-show-reports ()
+(defun debbugs-gnu-show-reports (&optional offline)
   "Show bug reports."
   (let ((inhibit-read-only t)
-       (debbugs-port "gnu.org")
        (buffer-name "*Emacs Bugs*"))
     ;; The tabulated mode sets several local variables.  We must get
     ;; rid of them.
@@ -593,7 +592,13 @@ marked as \"client-side filter\"."
     ;; Print bug reports.
     (dolist (status
             (apply 'debbugs-get-status
-                   (debbugs-gnu-get-bugs debbugs-gnu-local-query)))
+                   (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* ((id (cdr (assq 'id status)))
             (words
              (mapconcat
@@ -854,7 +859,8 @@ Used instead of `tabulated-list-print-entry'."
   (let ((id (debbugs-gnu-current-id))
        (debbugs-gnu-current-query debbugs-gnu-local-query)
        (debbugs-gnu-current-filter debbugs-gnu-local-filter)
-       (debbugs-gnu-current-suppress debbugs-gnu-local-suppress))
+       (debbugs-gnu-current-suppress debbugs-gnu-local-suppress)
+       (debbugs-cache-expiry (if current-prefix-arg t debbugs-cache-expiry)))
     (debbugs-gnu-show-reports)
     (when id
       (debbugs-gnu-goto id))))
@@ -1100,12 +1106,16 @@ interest to you."
   (let ((inhibit-read-only t))
     (erase-buffer)
     (when query
+      (insert ";; Query\n")
       (pp query (current-buffer))
       (insert "\n"))
     (when filter
+      (insert ";; Filter\n")
       (pp filter (current-buffer))
       (insert "\n"))
-    (when status (pp status (current-buffer)))
+    (when status
+      (insert ";; Status\n")
+      (pp status (current-buffer)))
     (goto-char (point-min)))
   (set-buffer-modified-p nil)
   (special-mode))
@@ -1220,6 +1230,9 @@ MERGED is the list of bugs merged with this one."
           (re-search-forward "#\\([0-9]+\\)" nil t)))
      (string-to-number (match-string 1)))))
 
+(defvar debbugs-gnu-send-mail-function nil
+  "A function to send control messages from debbugs.")
+
 (defun debbugs-gnu-send-control-message (message &optional reverse)
   "Send a control message for the current bug report.
 You can set the severity or add a tag, or close the report.  If
@@ -1239,6 +1252,7 @@ removed instead."
            "owner" "noowner"
            "invalid"
            "reassign"
+           "retitle"
            "patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
            "pending" "help" "security" "confirmed"
            "usertag")
@@ -1270,6 +1284,7 @@ removed instead."
       (insert "To: control@debbugs.gnu.org\n"
              "From: " (message-make-from) "\n"
              (format "Subject: control message for bug #%d\n" id)
+             mail-header-separator
              "\n"
              (cond
               ((member message '("unarchive" "unmerge" "reopen" "noowner"))
@@ -1291,6 +1306,8 @@ removed instead."
                  " ")))
               ((equal message "owner")
                (format "owner %d !\n" id))
+              ((equal message "retitle")
+               (format "retitle %d %s\n" id (read-string "New title: ")))
               ((equal message "reassign")
                (format "reassign %d %s\n" id (read-string "Package(s): ")))
               ((equal message "close")
@@ -1318,7 +1335,8 @@ removed instead."
                (format "tags %d%s %s\n"
                        id (if reverse " -" "")
                        message))))
-      (funcall send-mail-function)
+      (funcall (or debbugs-gnu-send-mail-function send-mail-function))
+      (remhash id debbugs-cache-data)
       (message-goto-body)
       (message "Control message sent:\n%s"
               (buffer-substring-no-properties (point) (1- (point-max)))))))
@@ -1453,7 +1471,7 @@ If given a prefix, patch in the branch directory instead."
     ;; buffer.  Determine which.
     (gnus-with-article-buffer
       (dolist (handle (mapcar 'cdr (gnus-article-mime-handles)))
-       (when (string-match "diff\\|patch" (mm-handle-media-type handle))
+       (when (string-match "diff\\|patch\\|plain" (mm-handle-media-type handle))
          (push (cons (mm-handle-encoding handle)
                      (mm-handle-buffer handle))
                patch-buffers))))
@@ -1462,11 +1480,11 @@ If given a prefix, patch in the branch directory instead."
       (article-decode-charset)
       (push (cons nil gnus-article-buffer) patch-buffers))
     (dolist (elem patch-buffers)
-      (with-temp-buffer
+      (with-current-buffer (generate-new-buffer "*debbugs input patch*")
        (insert-buffer-substring (cdr elem))
        (cond ((eq (car elem) 'base64)
               (base64-decode-region (point-min) (point-max)))
-             ((eq (car elem) 'qp)
+             ((eq (car elem) 'quoted-printable)
               (quoted-printable-decode-region (point-min) (point-max))))
        (debbugs-gnu-fix-patch dir)
        (call-process-region (point-min) (point-max)
@@ -1578,7 +1596,7 @@ If given a prefix, patch in the branch directory instead."
                          (cadr from))))))
          (goto-char (point-max))
          (end-of-line)
-         (insert "  (tiny change"))
+         (insert "  Copyright-paperwork-exempt: yes"))
        (goto-char point)))))
 
 (defvar debbugs-gnu-lisp-mode-map