=== modified file 'lisp/gnus/ChangeLog' --- lisp/gnus/ChangeLog 2012-09-07 04:07:00 +0000 +++ lisp/gnus/ChangeLog 2012-09-09 15:24:48 +0000 @@ -1,3 +1,9 @@ +2012-09-09 Stephen Berman + + * gnus-group.el (gnus-get-emacs-bug-number): New function. + (gnus-read-ephemeral-emacs-bug-group): Use it; change function's + signature and interactive spec accordingly. Add autoload cookie. + 2012-09-07 Chong Yidong * gnus-util.el === modified file 'lisp/gnus/gnus-group.el' --- lisp/gnus/gnus-group.el 2012-09-07 04:07:00 +0000 +++ lisp/gnus/gnus-group.el 2012-09-09 15:24:45 +0000 @@ -2498,21 +2498,54 @@ (defvar debbugs-gnu-bug-number) ; debbugs-gnu -(defun gnus-read-ephemeral-emacs-bug-group (ids &optional window-conf) - "Browse Emacs bugs IDS as an ephemeral group." - (interactive (list (string-to-number - (read-string "Enter bug number: " - (thing-at-point 'word) nil)))) - (unless (listp ids) - (setq ids (list ids))) - (gnus-read-ephemeral-bug-group - ids - (cdr (assoc 'emacs gnus-bug-group-download-format-alist)) - window-conf) - (when (fboundp 'debbugs-gnu-summary-mode) - (with-current-buffer (window-buffer (selected-window)) - (debbugs-gnu-summary-mode 1) - (set (make-local-variable 'debbugs-gnu-bug-number) (car ids))))) +(defun gnus-get-emacs-bug-number (&optional n) + "Return an Emacs bug number in this line, if any. +If point is on a recognizable bug number, return it; otherwise, +if argument N is a positive integer, return the Nth bug number in +this line, counting from the left, or nil if there is no Nth bug +number." + (save-excursion + ;; Get the number if point is anywhere within a string like "bug#1234", + ;; "Bug#1234", bug #1234", "Bug #1234", bug 1234", "Bug 1234" as well as + ;; "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11735" + (when (or (string= (thing-at-point 'word) "Bug") + (string= (thing-at-point 'word) "bug")) + (forward-word) + (skip-chars-forward " #=")) + (let* ((str (thing-at-point 'word)) + (num (if str (string-to-number str)))) + (if (and num (not (zerop num))) + num + ;; Otherwise look for the Nth bug number on + ;; this line. + (let ((case-fold-search t)) + (goto-char (line-beginning-position)) + (when (re-search-forward "bug ?[#=]? ?\\([0-9]+\\)" + (line-end-position) t n) + (string-to-number (match-string 1)))))))) + +;;;###autoload +(defun gnus-read-ephemeral-emacs-bug-group (&optional n window-conf) + "Browse an Emacs bug report thread as an ephemeral group. +If point is on a recognizable bug number, offer it as default; +otherwise, offer the first, or with numerical prefix argument N, +the Nth bug number in this line, counting from the left. If +there is no bug number in this line, or too few, prompt for a +number without offering a default." + (interactive "P") + (let ((ids (read-number "Enter bug number: " + (gnus-get-emacs-bug-number + (if (and (integerp n) (> n 1)) n 1))))) + (unless (listp ids) + (setq ids (list ids))) + (gnus-read-ephemeral-bug-group + ids + (cdr (assoc 'emacs gnus-bug-group-download-format-alist)) + window-conf) + (when (fboundp 'debbugs-gnu-summary-mode) + (with-current-buffer (window-buffer (selected-window)) + (debbugs-gnu-summary-mode 1) + (set (make-local-variable 'debbugs-gnu-bug-number) (car ids)))))) (defun gnus-group-jump-to-group (group &optional prompt) "Jump to newsgroup GROUP.