1 ;; debbugs-browse.el --- browse bug URLs with debbugs-gnu or debbugs-org
3 ;; Copyright (C) 2015-2016 Free Software Foundation, Inc.
5 ;; Author: Michael Albinus <michael.albinus@gmx.de>
6 ;; Keywords: comm, hypermedia, maint
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This file provides a minor mode for browsing bug URLs with
27 ;; `debbugs-gnu-bugs' or `debbugs-org-bugs'.
31 (defcustom debbugs-browse-function 'debbugs-gnu-bugs
32 "The debbugs function used for showing bugs.
33 This can be either `debbugs-gnu-bugs' or `debbugs-org-bugs'."
35 :type '(choice (const debbugs-gnu-bugs)
36 (const debbugs-org-bugs))
39 (defun debbugs-browse-url (url &optional _new-window)
40 (when (and (stringp url)
43 "^%s\\(%s\\)?\\([[:digit:]]+\\)$"
44 (regexp-quote "http://debbugs.gnu.org/")
45 (regexp-quote "cgi/bugreport.cgi?bug="))
47 (funcall debbugs-browse-function (string-to-number (match-string 2 url)))
48 ;; Return t for add-function mechanery.
52 (define-minor-mode debbugs-browse-mode
53 "Browse GNU Debbugs bug URLs with debbugs-gnu or debbugs-org.
54 With a prefix argument ARG, enable Debbugs Browse mode if ARG is
55 positive, and disable it otherwise. If called from Lisp, enable
56 the mode if ARG is omitted or nil.
57 The customer option `debbugs-browse-function' controls, which of
58 the two packages is used for showing bugs."
62 (if debbugs-browse-mode
64 :before-until (local 'browse-url-browser-function) 'debbugs-browse-url)
65 (remove-function (local 'browse-url-browser-function) 'debbugs-browse-url)))
67 (provide 'debbugs-browse)
68 ;;; debbugs-browse.el ends here