+ (while (and (not (eobp))
+ (not (get-text-property (point) 'debbugs-status)))
+ (forward-line 1))
+ (save-restriction
+ (narrow-to-region
+ (point)
+ (progn
+ (goto-char (point-max))
+ (beginning-of-line)
+ (while (and (not (bobp))
+ (not (get-text-property (point) 'debbugs-status)))
+ (forward-line -1))
+ (forward-line 1)
+ (point)))
+ (goto-char (point-min))
+ (sort-subr
+ nil (lambda () (forward-line 1)) 'end-of-line
+ (lambda ()
+ (let ((id (debbugs-current-id)))
+ (if (eq debbugs-sort-state 'number)
+ id
+ ;; Sort the tagged ones at the end.
+ (or (and (memq id debbugs-local-tags)
+ 20)
+ (cdr (assq (get-text-property (+ (point) 7) 'face)
+ debbugs-state-preference))
+ 10))))))
+ (if (not current-bug)
+ (goto-char start-point)
+ (goto-char (point-min))
+ (re-search-forward (format "^%d" current-bug) nil t))))
+
+(defun debbugs-toggle-tag ()
+ "Toggle tag of the report in the current line."
+ (interactive)
+ (save-excursion
+ (beginning-of-line)
+ (let ((inhibit-read-only t)
+ (id (debbugs-current-id)))
+ (if (memq id debbugs-local-tags)
+ (progn
+ (setq debbugs-local-tags (delq id debbugs-local-tags))
+ (put-text-property (point) (+ (point) 5) 'face 'default))
+ (add-to-list 'debbugs-local-tags id)
+ (put-text-property
+ (+ (point) (- 5 (length (number-to-string id)))) (+ (point) 5)
+ 'face 'debbugs-tagged)))))
+
+(defun debbugs-suppress-done ()
+ "Suppress bugs marked as done."
+ (interactive)
+ (save-excursion
+ (unless (widget-get debbugs-current-widget :suppress-done)
+ (let ((inhibit-read-only t))
+ (widget-put debbugs-current-widget :suppress-done t)
+ (goto-char (point-min))
+ (while (and (not (eobp))
+ (not (get-text-property (point) 'debbugs-status)))
+ (forward-line 1))
+ (while (and (not (eobp))
+ (get-text-property (point) 'debbugs-status))
+ (if (equal (cdr (assq 'pending (debbugs-current-status))) "done")
+ (kill-region (point) (progn (forward-line 1) (point)))
+ (forward-line 1)))))))
+
+(defvar debbugs-bug-number nil)
+
+(defun debbugs-current-id (&optional noerror)
+ (or (cdr (assq 'id (debbugs-current-status)))
+ (and (not noerror)
+ (error "No bug on the current line"))))
+
+(defun debbugs-current-status ()
+ (get-text-property (line-beginning-position)
+ 'debbugs-status))
+
+(defun debbugs-display-status (status)
+ "Display the status of the report on the current line."
+ (interactive (list (debbugs-current-status)))
+ (pop-to-buffer "*Bug Status*")
+ (erase-buffer)
+ (pp status (current-buffer))
+ (goto-char (point-min)))