GNU bug report logs - #12396
24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group

Previous Next

Packages: gnus, emacs;

Reported by: Stephen Berman <stephen.berman <at> gmx.net>

Date: Sun, 9 Sep 2012 16:02:01 UTC

Severity: wishlist

Tags: patch

Found in version 24.2.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 12396 <at> debbugs.gnu.org (full text, mbox):

From: Stephen Berman <stephen.berman <at> gmx.net>
To: 12396 <at> debbugs.gnu.org
Subject: Re: bug#12396: 24.2.50;
	[PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
Date: Mon, 10 Sep 2012 23:02:18 +0200
I discovered that the definition of gnus-get-emacs-bug-number in my
patch was deficient, so, in hopes that this feature may still make it
into Emacs, here is an improved definition (though the bit about bug
number 0 is probably dispensible).  I'll be happy to provide an updated
patch if desired.

Steve Berman

(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", or
    ;; similar strings with a capital "B" or with a space before or after "#",
    ;; or without "#", as well as strings like
    ;; "http://debbugs.gnu.org/cgi/bugreport.cgi?bug=1234".
    (when (or (eq (char-after) ?#) (eq (char-before) ?#)
	      (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)))
	   (case-fold-search t))
      (if (and num
	       ;; If bug number 0 is allowed (though it isn't in the Emacs
	       ;; bugtracker), it requires special handling, since
	       ;; string-to-number also returns 0 if str is alphabetical.
	       (or (string= "0" str) (not (zerop num)))
	       ;; Make sure this is a bug number, not just any number.
	       (beginning-of-thing 'word) (looking-back "bug ?[#=]? ?"))
	  num
	;; Otherwise look for the Nth bug number on this line.
	(goto-char (line-beginning-position))
	(when (re-search-forward "bug ?[#=]? ?\\([0-9]+\\)"
				 (line-end-position) t n)
	    (string-to-number (match-string 1)))))))




This bug report was last modified 12 years and 229 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.