Up: 完美的配置   [Contents][Index]

22.5.1 在Emacs内部浏览漏洞

Emacs has a nice minor mode called bug-reference, which, when combined with ‘emacs-debbugs’ (the Emacs package), can be used to open links such as ‘<https://bugs.gnu.org/58697>’ or ‘<https://issues.guix.gnu.org/58697>’ as bug report buffers. From there you can easily consult the email thread via the Gnus interface, reply or modify the bug status, all without leaving the comfort of Emacs! Below is a sample configuration to add to your ~/.emacs configuration file:

;;; Bug references.
(require 'bug-reference)
(add-hook 'prog-mode-hook #'bug-reference-prog-mode)
(add-hook 'gnus-mode-hook #'bug-reference-mode)
(add-hook 'erc-mode-hook #'bug-reference-mode)
(add-hook 'gnus-summary-mode-hook #'bug-reference-mode)
(add-hook 'gnus-article-mode-hook #'bug-reference-mode)

;;; 这扩展了默认表达式(最上面的第一个表达式提供给'or')来匹配
;;; url,例如 <https://issues.guix.gnu.org/58697>或
;;; <https://bugs.gnu.org/58697>。它也被扩展到检测
;;; “Fixes: #NNNNN” git trailers。
(setq bug-reference-bug-regexp
      (rx (group (or (seq word-boundary
                          (or (seq (char "Bb") "ug"
                                   (zero-or-one " ")
                                   (zero-or-one "#"))
                              (seq (char "Pp") "atch"
                                   (zero-or-one " ")
                              (seq (char "Ff") "ixes"
                                   (zero-or-one ":")
                                   (zero-or-one " ") "#")
                              (seq "RFE"
                                   (zero-or-one " ") "#")
                              (seq "PR "
                                   (one-or-more (char "a-z+-")) "/"))
                          (group (one-or-more (char "0-9"))
                                  (seq "#" (one-or-more
                                            (char "0-9"))))))
                     (seq (? "<") "https://bugs.gnu.org/"
                          (group-n 2 (one-or-more (char "0-9")))
                          (? ">"))
                     (seq (? "<") "https://issues.guix.gnu.org/"
                          (? "issue/")
                          (group-n 2 (one-or-more (char "0-9")))
                          (? ">"))))))
(setq bug-reference-url-format "https://issues.guix.gnu.org/%s")

(require 'debbugs)
(require 'debbugs-browse)
(add-hook 'bug-reference-mode-hook #'debbugs-browse-mode)
(add-hook 'bug-reference-prog-mode-hook #'debbugs-browse-mode)

;; The following allows Emacs Debbugs user to open the issue directly within
;; Emacs.
(setq debbugs-browse-url-regexp
      (rx line-start
          "http" (zero-or-one "s") "://"
          (or "debbugs" "issues.guix" "bugs")
          ".gnu.org" (one-or-more "/")
          (group (zero-or-one "cgi/bugreport.cgi?bug="))
          (group-n 3 (one-or-more digit))

;; 修改当运行 'M-x debbugs-gnu' 时的默认值.
(setq debbugs-gnu-default-packages '("guix" "guix-patches"))

;; 显示功能需求。
(setq debbugs-gnu-default-severities
 '("serious" "important" "normal" "minor" "wishlist"))

更多信息,请查询Bug Reference in The GNU Emacs ManualMinor Mode in The Debbugs User Guide