branch: externals/debbugs
commit 38e30902ac6f1f2a4b3c396feda45f14d35ea868
Author: Michael Albinus <[email protected]>
Commit: Michael Albinus <[email protected]>

    Improve bookmarks integration
    
    * debbugs-bookmarks.el (debbugs-gnu-current-message)
    (debbugs-gnu-local-message): Declare.
    (debbugs-gnu-bookmark-name): Handle debbugs-org buffers.
    (debbugs-gnu-bookmark-make-record, debbugs-gnu-bookmark-jump):
    Set `debbugs-gnu-current-message'.
    
    * debbugs-gnu.el: Use `setq-local' consequently.
    (debbugs-gnu): Use `listp'.
    (debbugs-gnu-mode): Set `debbugs-gnu-local-message'.
    
    * debbugs-org.el: Use `setq-local' consequently.
    (debbugs-org-mode): Set `debbugs-gnu-local-message'.
---
 debbugs-bookmarks.el | 32 +++++++++++------
 debbugs-gnu.el       | 99 +++++++++++++++++++++++++++-------------------------
 debbugs-org.el       | 45 ++++++++++++------------
 3 files changed, 96 insertions(+), 80 deletions(-)

diff --git a/debbugs-bookmarks.el b/debbugs-bookmarks.el
index 6cc53167c6..53a6930be7 100644
--- a/debbugs-bookmarks.el
+++ b/debbugs-bookmarks.el
@@ -46,9 +46,11 @@
 (defvar debbugs-gnu-current-filter)
 (defvar debbugs-gnu-current-query)
 (defvar debbugs-gnu-current-suppress)
+(defvar debbugs-gnu-current-message)
 (defvar debbugs-gnu-local-query)
 (defvar debbugs-gnu-local-filter)
 (defvar debbugs-gnu-local-suppress)
+(defvar debbugs-gnu-local-message)
 (defvar debbugs-gnu-show-reports-function)
 
 (defun debbugs-gnu-bookmark-name (query)
@@ -66,20 +68,22 @@ Examples of generated names follows:
 - Bugs about \"something\" reported by [email protected]
 - Tagged bugs
 - Bugs"
-  (let* ((bugs (cdr (assq 'bugs query)))
+  (let* ((org (when (bound-and-true-p debbugs-org-mode) "Org "))
+         (bugs (cdr (assq 'bugs query)))
         (bug-count (length bugs))
         (bugs-substring
          (cond
           ((eq bug-count 0) nil)
-          ((eq bug-count 1) (concat "Bug #" (int-to-string (car bugs))))
-          ((concat "Bugs "
+          ((eq bug-count 1) (concat org "Bug #" (int-to-string (car bugs))))
+          ((concat org "Bugs "
                     (string-join
                      (mapcar (lambda (elt) (concat "#" (int-to-string elt)))
                              bugs)
                      ", "))))))
     (if bugs-substring
         bugs-substring
-      (let* ((packages (mapcar 'cdr
+      (let* ((org (when (bound-and-true-p debbugs-org-mode) "Org"))
+             (packages (mapcar 'cdr
                               (seq-filter
                                (lambda (elt) (eq (car elt) 'package))
                                query)))
@@ -103,8 +107,8 @@ Examples of generated names follows:
               (when submitter (concat "reported by " submitter))))
         (string-join (append (seq-filter
                               (lambda (x) x)
-                              (list first-token phrase-token submitter-token
-                                    packages-token)))
+                              (list org first-token phrase-token
+                                    submitter-token packages-token)))
                      " ")))))
 
 ;;;###autoload
@@ -120,6 +124,7 @@ such buffers."
       (debbugs-gnu-current-filter . ,debbugs-gnu-local-filter)
       (debbugs-gnu-current-query . ,debbugs-gnu-local-query)
       (debbugs-gnu-current-suppress . ,debbugs-gnu-local-suppress)
+      (debbugs-gnu-current-message . ,debbugs-gnu-local-message)
       (debbugs-gnu-show-reports-function
        . ,(if (eq major-mode 'debbugs-gnu-mode)
               #'debbugs-gnu-show-reports #'debbugs-org-show-reports)))))
@@ -131,11 +136,18 @@ such buffers."
   "Provide the `bookmark-jump' behavior for a Debbugs buffer.
 This implements the `handler' function interface for the record
 type returned by `debbugs-gnu-bookmark-make-record'."
-  (let* ((debbugs-gnu-current-filter (bookmark-prop-get bmk 
'debbugs-gnu-current-filter))
-        (debbugs-gnu-current-query (bookmark-prop-get bmk 
'debbugs-gnu-current-query))
-        (debbugs-gnu-current-suppress (bookmark-prop-get bmk 
'debbugs-gnu-current-suppress))
-         (debbugs-gnu-show-reports-function (bookmark-prop-get bmk 
'debbugs-gnu-show-reports-function))
+  (let* ((debbugs-gnu-current-filter
+          (bookmark-prop-get bmk 'debbugs-gnu-current-filter))
+        (debbugs-gnu-current-query
+          (bookmark-prop-get bmk 'debbugs-gnu-current-query))
+        (debbugs-gnu-current-suppress
+          (bookmark-prop-get bmk 'debbugs-gnu-current-suppress))
          (buf (progn ;; Don't use save-window-excursion (bug#39722)
+               (setq debbugs-gnu-current-message
+                      (bookmark-prop-get bmk 'debbugs-gnu-current-message)
+                      debbugs-gnu-show-reports-function
+                      (bookmark-prop-get
+                       bmk 'debbugs-gnu-show-reports-function))
                (debbugs-gnu nil)
                 debbugs-gnu-current-buffer)))
     (bookmark-default-handler
diff --git a/debbugs-gnu.el b/debbugs-gnu.el
index 3961c48a70..258c03099d 100644
--- a/debbugs-gnu.el
+++ b/debbugs-gnu.el
@@ -865,12 +865,12 @@ value, like in `debbugs-gnu-get-bugs' or 
`debbubgs-gnu-tagged'."
     (setq debbugs-gnu-current-suppress t))
 
   ;; Add queries.
-  (dolist (severity (if (consp severities) severities (list severities)))
+  (dolist (severity (if (listp severities) severities (list severities)))
     (when (not (zerop (length severity)))
       (when (string-equal severity "tagged")
        (setq debbugs-gnu-current-suppress nil))
       (add-to-list 'debbugs-gnu-current-query (cons 'severity severity))))
-  (dolist (package (if (consp packages) packages (list packages)))
+  (dolist (package (if (listp packages) packages (list packages)))
     (when (not (zerop (length package)))
       (add-to-list 'debbugs-gnu-current-query (cons 'package package))))
   (when archivedp
@@ -880,7 +880,7 @@ value, like in `debbugs-gnu-get-bugs' or 
`debbubgs-gnu-tagged'."
     (setq debbugs-gnu-current-suppress t)
     (add-to-list 'debbugs-gnu-current-query '(status . "open"))
     (add-to-list 'debbugs-gnu-current-query '(status . "forwarded")))
-  (dolist (tag (if (consp tags) tags (list tags)))
+  (dolist (tag (if (listp tags) tags (list tags)))
     (when (not (zerop (length tag)))
       (add-to-list 'debbugs-gnu-current-query (cons 'tag tag))))
 
@@ -1375,18 +1375,16 @@ In order to retrieve the actual bug status after it has 
been
 modified on the debbugs server, consider typing \\`C-u g'.
 
 \\{debbugs-gnu-mode-map}"
-  (set (make-local-variable 'debbugs-gnu-sort-state) 'number)
-  (set (make-local-variable 'debbugs-gnu-limit) nil)
-  (set (make-local-variable 'debbugs-gnu-local-query)
-       debbugs-gnu-current-query)
-  (set (make-local-variable 'debbugs-gnu-local-filter)
-       debbugs-gnu-current-filter)
-  (set (make-local-variable 'debbugs-gnu-local-suppress)
-       debbugs-gnu-current-suppress)
-  (set (make-local-variable 'debbugs-gnu-local-print-function)
-       debbugs-gnu-current-print-function)
-  (set (make-local-variable 'tabulated-list-entries) nil)
-  (setq-local bookmark-make-record-function #'debbugs-gnu-bookmark-make-record)
+  (setq-local
+   debbugs-gnu-sort-state 'number
+   debbugs-gnu-limit nil
+   debbugs-gnu-local-query debbugs-gnu-current-query
+   debbugs-gnu-local-filter debbugs-gnu-current-filter
+   debbugs-gnu-local-suppress debbugs-gnu-current-suppress
+   debbugs-gnu-local-message debbugs-gnu-current-message
+   debbugs-gnu-local-print-function debbugs-gnu-current-print-function
+   bookmark-make-record-function #'debbugs-gnu-bookmark-make-record
+   tabulated-list-entries nil)
   (setq tabulated-list-format
         `[("Id" ,debbugs-gnu-width-id debbugs-gnu-sort-id)
          ("State" ,debbugs-gnu-width-state debbugs-gnu-sort-state)
@@ -1821,9 +1819,10 @@ IDS is the list of bug IDs."
        ;; the same face.
        (while (< rmail-current-message rmail-total-messages)
          (rmail-show-message (1+ rmail-current-message)))))
-    ;; (set (make-local-variable 'debbugs-gnu-bug-number) id)
-    ;; (set (make-local-variable 'debbugs-gnu-subject)
-    ;;          (format "Re: bug#%d: %s" id (alist-get 'subject status)))
+    ;; (setq-local
+    ;;  debbugs-gnu-bug-number id
+    ;;  debbugs-gnu-subject
+    ;;  (format "Re: bug#%d: %s" id (alist-get 'subject status)))
     (rmail-summary)
     (define-key rmail-summary-mode-map "C" #'debbugs-gnu-send-control-message)
     (define-key rmail-summary-mode-map "E" #'debbugs-gnu-make-control-message)
@@ -1892,9 +1891,10 @@ MERGED is the list of bugs merged with this one."
          ;; the same face.
          (while (< rmail-current-message rmail-total-messages)
            (rmail-show-message (1+ rmail-current-message))))))
-    (set (make-local-variable 'debbugs-gnu-bug-number) id)
-    (set (make-local-variable 'debbugs-gnu-subject)
-        (format "Re: bug#%d: %s" id (alist-get 'subject status)))
+    (setq-local
+     debbugs-gnu-bug-number id
+     debbugs-gnu-subject
+     (format "Re: bug#%d: %s" id (alist-get 'subject status)))
     (rmail-summary)
     (define-key rmail-summary-mode-map "C" #'debbugs-gnu-send-control-message)
     (define-key rmail-summary-mode-map "E" #'debbugs-gnu-make-control-message)
@@ -1918,9 +1918,10 @@ MERGED is the list of bugs merged with this one."
    (cons (current-buffer)
         (current-window-configuration)))
   (with-current-buffer (window-buffer (selected-window))
-    (set (make-local-variable 'debbugs-gnu-bug-number) id)
-    (set (make-local-variable 'debbugs-gnu-subject)
-        (format "Re: bug#%d: %s" id (alist-get 'subject status)))
+    (setq-local
+     debbugs-gnu-bug-number id
+     debbugs-gnu-subject
+     (format "Re: bug#%d: %s" id (alist-get 'subject status)))
     (debbugs-gnu-summary-mode 1)))
 
 (defcustom debbugs-gnu-summary-keep-subject
@@ -1969,30 +1970,32 @@ This is checked against 
`debbugs-gnu-summary-keep-subject'."
 
 \\{debbugs-gnu-summary-mode-map}"
   :lighter " Debbugs" :keymap debbugs-gnu-summary-mode-map
-  (set (make-local-variable 'gnus-posting-styles)
-       `(;; We apply them first, because we want to keep our own
-         ;; posting-styles prior the others.
-         ,@(and debbugs-gnu-summary-keep-posting-styles
-                (default-value 'gnus-posting-styles))
-         (".*"
-         (eval
-          (when (buffer-live-p gnus-article-copy)
-            (with-current-buffer gnus-article-copy
-              (set (make-local-variable 'message-prune-recipient-rules)
-                   '((".*@debbugs.*" "emacs-pretest-bug")
-                     (".*@debbugs.*" "bug-gnu-emacs")
-                     ("[0-9]+@debbugs.*" "[email protected]")
-                     ("[0-9]+@debbugs.*" "[email protected]")))
-              (set (make-local-variable 'message-alter-recipients-function)
-                   (lambda (address)
-                     (if (string-match "\\([0-9]+\\)@donarmstrong"
-                                       (car address))
-                         (let ((new (format "%[email protected]"
-                                            (match-string 1 (car address)))))
-                           (cons new new))
-                       address))))))
-         ,@(and (stringp debbugs-gnu-subject)
-                '((subject debbugs-gnu-keep-subject)))))))
+(setq-local
+ gnus-posting-styles
+ `(;; We apply them first, because we want to keep our own
+   ;; posting-styles prior the others.
+   ,@(and debbugs-gnu-summary-keep-posting-styles
+          (default-value 'gnus-posting-styles))
+   (".*"
+    (eval
+     (when (buffer-live-p gnus-article-copy)
+       (with-current-buffer gnus-article-copy
+        (setq-local
+          message-prune-recipient-rules
+         '((".*@debbugs.*" "emacs-pretest-bug")
+           (".*@debbugs.*" "bug-gnu-emacs")
+           ("[0-9]+@debbugs.*" "[email protected]")
+           ("[0-9]+@debbugs.*" "[email protected]"))
+          message-alter-recipients-function
+          (lambda (address)
+           (if (string-match "\\([0-9]+\\)@donarmstrong"
+                             (car address))
+               (let ((new (format "%[email protected]"
+                                  (match-string 1 (car address)))))
+                 (cons new new))
+             address))))))
+    ,@(and (stringp debbugs-gnu-subject)
+          '((subject debbugs-gnu-keep-subject)))))))
 
 (defun debbugs-gnu-guess-current-id ()
   "Guess the ID based on \"#23\".
diff --git a/debbugs-org.el b/debbugs-org.el
index 0e6f0e38bb..110e79897e 100644
--- a/debbugs-org.el
+++ b/debbugs-org.el
@@ -340,28 +340,29 @@ the corresponding buffer (e.g. by closing Emacs)."
 
 \\{debbugs-org-mode-map}"
   :lighter " Debbugs" :keymap debbugs-org-mode-map
-  (set (make-local-variable 'debbugs-gnu-local-query) 
debbugs-gnu-current-query)
-  (set (make-local-variable 'debbugs-gnu-local-filter)
-       debbugs-gnu-current-filter)
-  ;; Needed for bookmarks only.
-  (set (make-local-variable 'debbugs-gnu-local-suppress)
-       debbugs-gnu-current-suppress)
-  ;; FIXME: Does not show any effect.
-  (set (make-local-variable 'org-priority-faces) debbugs-org-priority-faces)
-  (set (make-local-variable 'gnus-posting-styles)
-       `((".*"
-         (eval
-          (when (buffer-live-p gnus-article-copy)
-            (with-current-buffer gnus-article-copy
-              (set (make-local-variable 'message-prune-recipient-rules)
-                   '((".*@debbugs.*" "emacs-pretest-bug")
-                     (".*@debbugs.*" "bug-gnu-emacs")
-                     ("[0-9]+@debbugs.*" "[email protected]")
-                     ("[0-9]+@debbugs.*" "[email protected]")))
-              ;; `gnus-posting-styles' is eval'ed after
-              ;; `message-simplify-subject'.  So we cannot use m-s-s.
-              (setq subject ,debbugs-gnu-subject)))))))
-  (setq-local bookmark-make-record-function #'debbugs-gnu-bookmark-make-record)
+  (setq-local
+   debbugs-gnu-local-query debbugs-gnu-current-query
+   debbugs-gnu-local-filter debbugs-gnu-current-filter
+   ;; Needed for bookmarks only.
+   debbugs-gnu-local-suppress debbugs-gnu-current-suppress
+   debbugs-gnu-local-message debbugs-gnu-current-message
+   ;; FIXME: Does not show any effect.
+   org-priority-faces debbugs-org-priority-faces
+   gnus-posting-styles
+   `((".*"
+      (eval
+       (when (buffer-live-p gnus-article-copy)
+        (with-current-buffer gnus-article-copy
+          (setq-local
+            message-prune-recipient-rules
+           '((".*@debbugs.*" "emacs-pretest-bug")
+             (".*@debbugs.*" "bug-gnu-emacs")
+             ("[0-9]+@debbugs.*" "[email protected]")
+             ("[0-9]+@debbugs.*" "[email protected]")))
+          ;; `gnus-posting-styles' is eval'ed after
+          ;; `message-simplify-subject'.  So we cannot use m-s-s.
+          (setq subject ,debbugs-gnu-subject))))))
+   bookmark-make-record-function #'debbugs-gnu-bookmark-make-record)
   (debbugs-org-regenerate-status))
 
 ;;;###autoload

Reply via email to