]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/debbugs/debbugs-gnu.el
Add trie.el
[gnu-emacs-elpa] / packages / debbugs / debbugs-gnu.el
index 6a8d588b345cbfc79fa1c4a003352ed4defc69a5..cc959918309647338fcaa945b4d3354104d6ba16 100644 (file)
@@ -656,6 +656,9 @@ Used instead of `tabulated-list-print-entry'."
        (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
@@ -749,6 +752,7 @@ Used instead of `tabulated-list-print-entry'."
     (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.
@@ -759,8 +763,8 @@ All normal editing commands are switched off.
 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)
@@ -846,26 +850,34 @@ The following commands are available:
 (defun debbugs-gnu-widen ()
   "Display all the currently selected bug reports."
   (interactive)
-  (let ((id (debbugs-gnu-current-id t)))
+  (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)
-  "Only display the bugs matching STRING."
-  (interactive "sNarrow to: ")
+(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)
-    (debbugs-gnu-widen)
+    (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)))
-              (not (string-match string (cdr (assq 'originator status))))
-              (not (string-match string (cdr (assq 'subject 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))))
@@ -873,7 +885,8 @@ The following commands are available:
 (defun debbugs-gnu-goto (id)
   "Go to the line displaying bug ID."
   (goto-char (point-min))
-  (while (not (equal (debbugs-gnu-current-id t) id))
+  (while (and (not (eobp))
+             (not (equal (debbugs-gnu-current-id t) id)))
     (forward-line 1)))
 
 (defun debbugs-gnu-toggle-tag ()