;;; Commentary:
;; This package provides an interface to bug reports which are located
-;; on the GNU bug tracker debbugs.gnu.org. It's main purpose is to
+;; on the GNU bug tracker debbugs.gnu.org. Its main purpose is to
;; show and manipulate bug reports from Emacs, but it could be used
;; also for other GNU projects which use the same bug tracker.
:group 'debbugs
:version "24.1")
-(defcustom debbugs-gnu-default-severities '("normal")
+(defcustom debbugs-gnu-default-severities '("serious" "important" "normal")
"*The list severities bugs are searched for.
\"tagged\" is not a severity but marks locally tagged bugs."
:group 'debbugs-gnu
:group 'debbugs-gnu
:type '(set (const "automake")
(const "coreutils")
+ (const "debbugs.gnu.org")
(const "emacs")
+ (const "emacs-xwidgets")
(const "gnus")
- (const "libtool"))
+ (const "guile")
+ (const "libtool")
+ (const "woodchuck"))
:version "24.1")
(defcustom debbugs-gnu-default-hits-per-page 500
(setq value (read-string prompt initial-contents)))
value))
+(defconst debbugs-gnu-phrase-prompt
+ (propertize
+ "Enter search phrase: "
+ 'help-echo "\
+The search phrase contains words to be searched for, combined by
+operators like AND, ANDNOT and OR. If there is no operator
+between the words, AND is used by default. The phrase can also
+be empty, in this case only the following attributes are used for
+search."))
+
;;;###autoload
(defun debbugs-gnu-search ()
"Search for Emacs bugs interactively.
marked as \"client-side filter\"."
(interactive)
- ;; Reset query and filter.
- (setq debbugs-gnu-current-query nil
- debbugs-gnu-current-filter nil)
-
- (let ((date-format "\\([[:digit:]]\\{4\\}\\)-\\([[:digit:]]\\{1,2\\}\\)-\\([[:digit:]]\\{1,2\\}\\)")
- key val1 val2 phrase severities packages archivedp)
-
- ;; Check for the phrase.
- (setq phrase (read-string "Enter search phrase: "))
- (if (zerop (length phrase))
- (setq phrase nil)
- (add-to-list 'debbugs-gnu-current-query (cons 'phrase phrase)))
-
- ;; The other queries.
- (catch :finished
- (while t
- (setq key (completing-read
- "Enter attribute: "
- (if phrase
- '("severity" "package" "tags" "submitter" "date"
- "subject" "status")
- '("severity" "package" "archive" "src" "tag"
- "owner" "submitter" "maint" "correspondent"
- "date" "log_modified" "last_modified"
- "found_date" "fixed_date" "unarchived"
- "subject" "done" "forwarded" "msgid" "summary"))
- nil t))
- (cond
- ;; Server-side queries.
- ((equal key "severity")
- (setq
- severities
- (completing-read-multiple
- "Enter severities: "
- (mapcar
- 'cadr (cdr (get 'debbugs-gnu-default-severities 'custom-type)))
- nil t (mapconcat 'identity debbugs-gnu-default-severities ","))))
-
- ((equal key "package")
- (setq
- packages
- (completing-read-multiple
- "Enter packages: "
- (mapcar
- 'cadr (cdr (get 'debbugs-gnu-default-packages 'custom-type)))
- nil t (mapconcat 'identity debbugs-gnu-default-packages ","))))
-
- ((equal key "archive")
- ;; We simplify, by assuming just archived bugs are requested.
- (setq archivedp t))
-
- ((member key '("src" "tag" "tags"))
- (setq val1 (read-string (format "Enter %s: " key)))
- (when (not (zerop (length val1)))
- (add-to-list 'debbugs-gnu-current-query (cons (intern key) val1))))
-
- ((member key '("owner" "submitter" "maint" "correspondent"))
- (setq val1 (read-string "Enter email address: "))
- (when (not (zerop (length val1)))
- (add-to-list 'debbugs-gnu-current-query (cons (intern key) val1))))
-
- ;; Client-side filters.
- ((member key '("date" "log_modified" "last_modified"
- "found_date" "fixed_date" "unarchived"))
- (setq val1
- (debbugs-gnu-calendar-read
- (format "Enter %s before YYYY-MM-DD%s: "
- key (if phrase "" " (client-side filter)"))
- (lambda (x)
- (string-match (concat "^\\(" date-format "\\|\\)$") x))))
- (if (string-match date-format val1)
- (setq val1 (floor
- (float-time
- (encode-time
- 0 0 0
- (string-to-number (match-string 3 val1))
- (string-to-number (match-string 2 val1))
- (string-to-number (match-string 1 val1))))))
- (setq val1 nil))
- (setq val2
- (debbugs-gnu-calendar-read
- (format "Enter %s after YYYY-MM-DD%s: "
- key (if phrase "" " (client-side filter)"))
- (lambda (x)
- (string-match (concat "^\\(" date-format "\\|\\)$") x))))
- (if (string-match date-format val2)
- (setq val2 (floor
- (float-time
- (encode-time
- 0 0 0
- (string-to-number (match-string 3 val2))
- (string-to-number (match-string 2 val2))
- (string-to-number (match-string 1 val2))))))
- (setq val2 nil))
- (when (or val1 val2)
- (add-to-list
- (if phrase 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
- (cons (intern key) (cons val1 val2)))))
-
- ((not (zerop (length key)))
- (setq val1
- (funcall
- (if phrase 'read-string 'read-regexp)
- (format "Enter %s%s"
- key (if phrase ": " " (client-side filter)"))))
- (when (not (zerop (length val1)))
+ (unwind-protect
+ (let ((date-format "\\([[:digit:]]\\{4\\}\\)-\\([[:digit:]]\\{1,2\\}\\)-\\([[:digit:]]\\{1,2\\}\\)")
+ key val1 val2 phrase severities packages archivedp)
+
+ ;; Check for the phrase.
+ (setq phrase (read-string debbugs-gnu-phrase-prompt))
+ (if (zerop (length phrase))
+ (setq phrase nil)
+ (add-to-list 'debbugs-gnu-current-query (cons 'phrase phrase)))
+
+ ;; The other queries.
+ (catch :finished
+ (while t
+ (setq key (completing-read
+ "Enter attribute: "
+ (if phrase
+ '("severity" "package" "tags" "submitter" "date"
+ "subject" "status")
+ '("severity" "package" "archive" "src" "tag"
+ "owner" "submitter" "maint" "correspondent"
+ "date" "log_modified" "last_modified"
+ "found_date" "fixed_date" "unarchived"
+ "subject" "done" "forwarded" "msgid" "summary"))
+ nil t))
+ (cond
+ ;; Server-side queries.
+ ((equal key "severity")
+ (setq
+ severities
+ (completing-read-multiple
+ "Enter severities: "
+ (mapcar
+ 'cadr (cdr (get 'debbugs-gnu-default-severities 'custom-type)))
+ nil t
+ (mapconcat 'identity debbugs-gnu-default-severities ","))))
+
+ ((equal key "package")
+ (setq
+ packages
+ (completing-read-multiple
+ "Enter packages: "
+ (mapcar
+ 'cadr (cdr (get 'debbugs-gnu-default-packages 'custom-type)))
+ nil t (mapconcat 'identity debbugs-gnu-default-packages ","))))
+
+ ((equal key "archive")
+ ;; We simplify, by assuming just archived bugs are requested.
+ (setq archivedp t))
+
+ ((member key '("src" "tag" "tags"))
+ (setq val1 (read-string (format "Enter %s: " key)))
+ (when (not (zerop (length val1)))
+ (add-to-list
+ 'debbugs-gnu-current-query (cons (intern key) val1))))
+
+ ((member key '("owner" "submitter" "maint" "correspondent"))
+ (setq val1 (read-string "Enter email address: "))
+ (when (not (zerop (length val1)))
+ (add-to-list
+ 'debbugs-gnu-current-query (cons (intern key) val1))))
+
+ ((equal key "status")
+ (setq
+ val1
+ (completing-read "Enter status: " '("done" "forwarded" "open")))
+ (when (not (zerop (length val1)))
(add-to-list
- (if phrase 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
- (cons (intern key) val1))))
+ 'debbugs-gnu-current-query (cons (intern key) val1))))
+
+ ;; Client-side filters.
+ ((member key '("date" "log_modified" "last_modified"
+ "found_date" "fixed_date" "unarchived"))
+ (setq val1
+ (debbugs-gnu-calendar-read
+ (format "Enter %s before YYYY-MM-DD%s: "
+ key (if phrase "" " (client-side filter)"))
+ (lambda (x)
+ (string-match (concat "^\\(" date-format "\\|\\)$") x))))
+ (if (string-match date-format val1)
+ (setq val1 (floor
+ (float-time
+ (encode-time
+ 0 0 0
+ (string-to-number (match-string 3 val1))
+ (string-to-number (match-string 2 val1))
+ (string-to-number (match-string 1 val1))))))
+ (setq val1 nil))
+ (setq val2
+ (debbugs-gnu-calendar-read
+ (format "Enter %s after YYYY-MM-DD%s: "
+ key (if phrase "" " (client-side filter)"))
+ (lambda (x)
+ (string-match (concat "^\\(" date-format "\\|\\)$") x))))
+ (if (string-match date-format val2)
+ (setq val2 (floor
+ (float-time
+ (encode-time
+ 0 0 0
+ (string-to-number (match-string 3 val2))
+ (string-to-number (match-string 2 val2))
+ (string-to-number (match-string 1 val2))))))
+ (setq val2 nil))
+ (when (or val1 val2)
+ (add-to-list
+ (if phrase
+ 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
+ (cons (intern key) (cons val1 val2)))))
+
+ ((not (zerop (length key)))
+ (setq val1
+ (funcall
+ (if phrase 'read-string 'read-regexp)
+ (format "Enter %s%s"
+ key (if phrase ": " " (client-side filter)"))))
+ (when (not (zerop (length val1)))
+ (add-to-list
+ (if phrase
+ 'debbugs-gnu-current-query 'debbugs-gnu-current-filter)
+ (cons (intern key) val1))))
+
+ ;; The End.
+ (t (throw :finished nil)))))
- ;; The End.
- (t (throw :finished nil)))))
+ ;; Do the search.
+ (debbugs-gnu severities packages archivedp))
- ;; Do the search.
- (debbugs-gnu severities packages archivedp)))
+ ;; Reset query and filter.
+ (setq debbugs-gnu-current-query nil
+ debbugs-gnu-current-filter nil)))
;;;###autoload
(defun debbugs-gnu (severities &optional packages archivedp suppress)
:buffer-name "*Emacs Bugs*"
:bug-ids ids
:query debbugs-gnu-current-query
- :filter debbugs-gnu-current-filter)))))
+ :filter debbugs-gnu-current-filter))))
- ;; Reset query and filter.
- (setq debbugs-gnu-current-query nil
- debbugs-gnu-current-filter nil))
+ ;; Reset query and filter.
+ (setq debbugs-gnu-current-query nil
+ debbugs-gnu-current-filter nil)))
(defun debbugs-gnu-get-bugs (query)
"Retrieve bugs numbers from debbugs.gnu.org according search criteria."
merged
(mapconcat 'number-to-string merged ","))
words)))
- (add-to-list
- 'tabulated-list-entries
- (list
- status
- (vector
- (propertize
- (format "%5d" id)
- 'face
- ;; Mark tagged bugs.
- (if (memq id debbugs-gnu-local-tags)
- 'debbugs-gnu-tagged
- 'default))
- (propertize
- ;; Mark status and age.
- words
- 'face
- (cond
- ((equal (cdr (assq 'pending status)) "done")
- 'debbugs-gnu-done)
- ((member "pending" (cdr (assq 'keywords status)))
- 'debbugs-gnu-pending)
- ((= (cdr (assq 'date status))
- (cdr (assq 'log_modified status)))
- 'debbugs-gnu-new)
- ((< (- (float-time)
- (cdr (assq 'log_modified status)))
- (* 60 60 24 7))
- 'debbugs-gnu-handled)
- (t
- 'debbugs-gnu-stale)))
- (propertize
- ;; Prefer the name over the address.
- (or (cdr address)
- (car address))
- 'face
- ;; Mark own submitted bugs.
- (if (and (stringp (car address))
- (string-equal (car address) user-mail-address))
- 'debbugs-gnu-tagged
- 'default))
- (propertize
- subject
- 'face
- ;; Mark owned bugs.
- (if (and (stringp owner)
- (string-equal owner user-mail-address))
- 'debbugs-gnu-tagged
- 'default))))
- 'append)))
+ (when (or (not merged)
+ (not (let ((found nil))
+ (dolist (id (if (listp merged)
+ merged
+ (list merged)))
+ (dolist (entry tabulated-list-entries)
+ (when (equal id (cdr (assq 'id (car entry))))
+ (setq found t))))
+ found)))
+ (add-to-list
+ 'tabulated-list-entries
+ (list
+ status
+ (vector
+ (propertize
+ (format "%5d" id)
+ 'face
+ ;; Mark tagged bugs.
+ (if (memq id debbugs-gnu-local-tags)
+ 'debbugs-gnu-tagged
+ 'default))
+ (propertize
+ ;; Mark status and age.
+ words
+ 'face
+ (cond
+ ((equal (cdr (assq 'pending status)) "done")
+ 'debbugs-gnu-done)
+ ((member "pending" (cdr (assq 'keywords status)))
+ 'debbugs-gnu-pending)
+ ((= (cdr (assq 'date status))
+ (cdr (assq 'log_modified status)))
+ 'debbugs-gnu-new)
+ ((< (- (float-time)
+ (cdr (assq 'log_modified status)))
+ (* 60 60 24 7 2))
+ 'debbugs-gnu-handled)
+ (t
+ 'debbugs-gnu-stale)))
+ (propertize
+ ;; Prefer the name over the address.
+ (or (cdr address)
+ (car address))
+ 'face
+ ;; Mark own submitted bugs.
+ (if (and (stringp (car address))
+ (string-equal (car address) user-mail-address))
+ 'debbugs-gnu-tagged
+ 'default))
+ (propertize
+ subject
+ 'face
+ ;; Mark owned bugs.
+ (if (and (stringp owner)
+ (string-equal owner user-mail-address))
+ 'debbugs-gnu-tagged
+ 'default))))
+ 'append))))
(tabulated-list-init-header)
(tabulated-list-print)
(title (aref cols 3))
(title-length (nth 1 (aref tabulated-list-format 3))))
(when (and
+ ;; We may have a narrowing in effect.
+ (or (not debbugs-gnu-current-limit)
+ (memq (cdr (assq 'id list-id)) debbugs-gnu-current-limit))
;; Filter suppressed bugs.
(or (not (widget-get debbugs-gnu-current-widget :suppress))
(not (catch :suppress
(define-key map "\r" 'debbugs-gnu-select-report)
(define-key map [mouse-1] 'debbugs-gnu-select-report)
(define-key map [mouse-2] 'debbugs-gnu-select-report)
- (define-key map "q" 'bury-buffer)
(define-key map "s" 'debbugs-gnu-toggle-sort)
(define-key map "t" 'debbugs-gnu-toggle-tag)
(define-key map "d" 'debbugs-gnu-display-status)
(define-key map "g" 'debbugs-gnu-rescan)
(define-key map "x" 'debbugs-gnu-toggle-suppress)
+ (define-key map "/" 'debbugs-gnu-narrow-to-status)
+ (define-key map "w" 'debbugs-gnu-widen)
(define-key map "C" 'debbugs-gnu-send-control-message)
map))
(goto-char pos)))
(defvar debbugs-gnu-sort-state 'number)
+(defvar debbugs-gnu-current-limit nil)
(define-derived-mode debbugs-gnu-mode tabulated-list-mode "Debbugs"
"Major mode for listing bug reports.
The following commands are available:
\\{debbugs-gnu-mode-map}"
- (set (make-local-variable 'debbugs-gnu-sort-state)
- 'number)
+ (set (make-local-variable 'debbugs-gnu-sort-state) 'number)
+ (set (make-local-variable 'debbugs-gnu-current-limit) nil)
(setq tabulated-list-format [("Id" 5 debbugs-gnu-sort-id)
("State" 20 debbugs-gnu-sort-state)
("Submitter" 25 t)
(tabulated-list-init-header)
(tabulated-list-print))
+(defun debbugs-gnu-widen ()
+ "Display all the currently selected bug reports."
+ (interactive)
+ (let ((id (debbugs-gnu-current-id t))
+ (inhibit-read-only t))
+ (setq debbugs-gnu-current-limit nil)
+ (tabulated-list-init-header)
+ (tabulated-list-print)
+ (when id
+ (debbugs-gnu-goto id))))
+
+(defun debbugs-gnu-narrow-to-status (string &optional status-only)
+ "Only display the bugs matching STRING.
+If STATUS-ONLY (the prefix), ignore matches in the From and
+Subject fields."
+ (interactive "sNarrow to: \np")
+ (let ((id (debbugs-gnu-current-id t))
+ (inhibit-read-only t)
+ status)
+ (setq debbugs-gnu-current-limit nil)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (setq status (debbugs-gnu-current-status))
+ (if (and (not (member string (assq 'keywords status)))
+ (not (member string (assq 'severity status)))
+ (or status-only
+ (not (string-match string (cdr (assq 'originator status)))))
+ (or status-only
+ (not (string-match string (cdr (assq 'subject status))))))
+ (delete-region (point) (progn (forward-line 1) (point)))
+ (push (cdr (assq 'id status)) debbugs-gnu-current-limit)
+ (forward-line 1)))
+ (when id
+ (debbugs-gnu-goto id))))
+
+(defun debbugs-gnu-goto (id)
+ "Go to the line displaying bug ID."
+ (goto-char (point-min))
+ (while (and (not (eobp))
+ (not (equal (debbugs-gnu-current-id t) id)))
+ (forward-line 1)))
+
(defun debbugs-gnu-toggle-tag ()
"Toggle tag of the report in the current line."
(interactive)
"merge" "forcemerge"
"owner" "noowner"
"invalid"
+ "reassign"
"patch" "wontfix" "moreinfo" "unreproducible" "fixed" "notabug"
"pending" "help" "security" "confirmed")
nil t)
(read-string "Merge with bug #: ")))
((equal message "owner")
(format "owner %d !\n" id))
+ ((equal message "reassign")
+ (format "reassign %d %s\n" id (read-string "Package: ")))
((equal message "close")
(format "close %d %s\n" id version))
((equal message "done")