From: Stephen Berman <stephen.berman@gmx.net>
To: 12396@debbugs.gnu.org
Subject: bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
Date: Mon, 10 Sep 2012 23:02:18 +0200 [thread overview]
Message-ID: <877gs18ucl.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: <878vcjt1se.fsf@rosalinde.fritz.box> (Stephen Berman's message of "Sun, 09 Sep 2012 21:49:05 +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)))))))
next prev parent reply other threads:[~2012-09-10 21:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-09 16:00 bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group Stephen Berman
2012-09-09 18:47 ` Lars Ingebrigtsen
2012-09-09 19:49 ` Stephen Berman
2012-09-10 21:02 ` Stephen Berman [this message]
2012-09-11 19:01 ` Juri Linkov
2012-09-11 23:11 ` Stephen Berman
2012-09-12 20:54 ` Juri Linkov
2012-09-13 20:38 ` Stephen Berman
2012-09-13 23:35 ` Juri Linkov
2012-09-14 15:37 ` Stephen Berman
2012-09-14 22:54 ` Juri Linkov
2012-12-25 21:54 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gs18ucl.fsf@rosalinde.fritz.box \
--to=stephen.berman@gmx.net \
--cc=12396@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).