changeset 107751:e130bb78db87

(bug-reference-bug-regexp): Also accept "patch" and "RFE". (bug-reference-fontify): `bug-reference-url-format' can also be a function to be able to handle the bug kind. (turn-on-bug-reference-mode, turn-on-bug-reference-prog-mode): Add
author Sam Steingold <sds@gnu.org>
date Fri, 02 Apr 2010 13:24:37 -0400
parents 9523f7085efd
children 1734936f6133
files lisp/ChangeLog lisp/progmodes/bug-reference.el
diffstat 2 files changed, 29 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Apr 02 11:26:24 2010 -0400
+++ b/lisp/ChangeLog	Fri Apr 02 13:24:37 2010 -0400
@@ -3,6 +3,12 @@
 	* vc-hg.el (vc-hg-push, vc-hg-pull): Use `apply' when calling
 	`vc-hg-command' with a list of flags.
 
+	* progmodes/bug-reference.el (bug-reference-bug-regexp): Also
+	accept "patch" and "RFE".
+	(bug-reference-fontify): `bug-reference-url-format' can also be a
+	function to be able to handle the bug kind.
+	(turn-on-bug-reference-mode, turn-on-bug-reference-prog-mode): Add
+
 2010-04-02  Jan Djärv  <jan.h.d@swipnet.se>
 
 	* tmm.el (tmm-get-keymap): Check with symbolp before passing
--- a/lisp/progmodes/bug-reference.el	Fri Apr 02 11:26:24 2010 -0400
+++ b/lisp/progmodes/bug-reference.el	Fri Apr 02 13:24:37 2010 -0400
@@ -41,13 +41,20 @@
 (defvar bug-reference-url-format nil
   "Format used to turn a bug number into a URL.
 The bug number is supplied as a string, so this should have a single %s.
+This can also be a function designator; it is called without arguments
+ and should return a string.
+It can use `match-string' to get parts matched against
+`bug-reference-bug-regexp', specifically:
+ 1. issue kind (bug, patch, rfe &c)
+ 2. issue number.
+
 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 ?#\\|[Pp]atch ?#\\|RFE ?#\\|PR [a-z-+]+/\\)\\([0-9]+\\)"
   "Regular expression which matches bug references.")
 
 (defun bug-reference-set-overlay-properties ()
@@ -87,9 +94,11 @@
 	    (overlay-put overlay 'category 'bug-reference)
 	    ;; 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))))))))))
+              (overlay-put overlay 'bug-reference-url
+                           (if (stringp bug-reference-url-format)
+                               (format bug-reference-url-format
+                                       (match-string-no-properties 2))
+                             (funcall bug-reference-url-format))))))))))
 
 ;; Taken from button.el.
 (defun bug-reference-push-button (&optional pos use-mouse-action)
@@ -121,6 +130,11 @@
       (widen)
       (bug-reference-unfontify (point-min) (point-max)))))
 
+(defun turn-on-bug-reference-mode ()
+  "Unconditionally turn bug reference mode on."
+  (unless bug-reference-mode
+    (bug-reference-mode)))
+
 ;;;###autoload
 (define-minor-mode bug-reference-prog-mode
   "Like `bug-reference-mode', but only buttonize in comments and strings."
@@ -134,5 +148,10 @@
       (widen)
       (bug-reference-unfontify (point-min) (point-max)))))
 
+(defun turn-on-bug-reference-prog-mode ()
+  "Unconditionally turn bug reference prog mode on."
+  (unless bug-reference-prog-mode
+    (bug-reference-prog-mode)))
+
 ;; arch-tag: b138abce-e5c3-475e-bd58-7afba40387ea
 ;;; bug-reference.el ends here