]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/bug-reference.el
(bug-reference-fontify): Check for
[gnu-emacs] / lisp / progmodes / bug-reference.el
index c6306fde2fce1e3cb16045d1dd146b626d0edd93..98e0dddb50a9924fff0bd5b7adc6434674b20ce7 100644 (file)
@@ -1,6 +1,6 @@
 ;; bug-reference.el --- buttonize bug references
 
-;; Copyright (C) 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: Tom Tromey <tromey@redhat.com>
 ;; Created: 21 Mar 2007
@@ -8,10 +8,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,9 +19,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -34,7 +32,7 @@
 
 (defvar bug-reference-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mouse-1] 'bug-reference-push-button)
+    (define-key map [down-mouse-1] 'bug-reference-push-button)
     (define-key map (kbd "C-c RET") 'bug-reference-push-button)
     map)
   "Keymap used by bug reference buttons.")
 The bug number is supplied as a string, so this should have a single %s.
 There is no default setting for this, it must be set per file.")
 
+;;;###autoload
+(put 'bug-reference-url-format 'safe-local-variable 'stringp)
+
 (defconst bug-reference-bug-regexp
-  "\\(?:[Bb]ug #\\|PR [a-z-+]+/\\)\\([0-9]+\\)"
+  "\\(?:[Bb]ug ?#\\|PR [a-z-+]+/\\)\\([0-9]+\\)"
   "Regular expression which matches bug references.")
 
 (defun bug-reference-set-overlay-properties ()
@@ -84,9 +85,11 @@ There is no default setting for this, it must be set per file.")
          (let ((overlay (make-overlay (match-beginning 0) (match-end 0)
                                       nil t nil)))
            (overlay-put overlay 'category 'bug-reference)
-           (overlay-put overlay 'bug-reference-url
-                        (format bug-reference-url-format
-                                (match-string-no-properties 1)))))))))
+           ;; Don't put a link if format is undefined
+           (when bug-reference-url-format
+             (overlay-put overlay 'bug-reference-url
+                          (format bug-reference-url-format
+                                  (match-string-no-properties 1))))))))))
 
 ;; Taken from button.el.
 (defun bug-reference-push-button (&optional pos use-mouse-action)
@@ -107,14 +110,12 @@ There is no default setting for this, it must be set per file.")
 
 ;;;###autoload
 (define-minor-mode bug-reference-mode
-  "Minor mode to buttonize bugzilla references in the current buffer.
-Requires `bug-reference-url-format' to be set in the buffer."
+  "Minor mode to buttonize bugzilla references in the current buffer."
   nil
   ""
   nil
   (if bug-reference-mode
-      (when bug-reference-url-format
-       (jit-lock-register #'bug-reference-fontify))
+      (jit-lock-register #'bug-reference-fontify)
     (jit-lock-unregister #'bug-reference-fontify)
     (save-restriction
       (widen)
@@ -127,8 +128,7 @@ Requires `bug-reference-url-format' to be set in the buffer."
   ""
   nil
   (if bug-reference-prog-mode
-      (when bug-reference-url-format
-       (jit-lock-register #'bug-reference-fontify))
+      (jit-lock-register #'bug-reference-fontify)
     (jit-lock-unregister #'bug-reference-fontify)
     (save-restriction
       (widen)