unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
@ 2012-09-09 16:00 Stephen Berman
  2012-09-09 18:47 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2012-09-09 16:00 UTC (permalink / raw)
  To: 12396

[-- Attachment #1: Type: text/plain, Size: 2756 bytes --]

This is a feature request accompanied by a possible implementation.

When reading (with Gnus) Emacs mailing lists or news groups that have
bug references in the subject line, typing `M-x
gnus-read-ephemeral-emacs-bug-group' is a nice way to browse the whole
bug thread by opening it as an temporary group.  However, this command
offers the bug number in the subject as default in the minibuffer prompt
only if point is on the number, which usually means having to navigate
to it.  It would be more convenient if the bug number in the current
line in the Group buffer were offered as default regardless of where
point is in the line.  The first patch (against bzr trunk revision
109955) below does this.  It makes a number in the subject line the
default if it is preceded by "bug" or "Bug", possibly with a space, `#'
or `=' in between (the latter to grab the bug number in a URL to the
Emacs bugtracker, which is clickable but calls a web browser via
browse-url).

In addition, since the subject line sometimes contains more than one bug
number, this patch allows selecting which one (counting from the left)
to offer as default, by typing a numerical prefix argument; with no
prefix argument the default is the leftmost bug number.  Furthermore, it
would be convenient to use gnus-read-ephemeral-emacs-bug-group if you
don't already having Gnus loaded, e.g. when visiting an Emacs ChangeLog,
so the patch adds an autoload cookie to this command to enable doing
this.

For ChangeLogs there is already bug-reference.el, which uses browse-url;
it would be nice to have the option of using
gnus-read-ephemeral-emacs-bug-group to follow bug references by clicking
the bug reference links in the ChangeLog file (as an alternative to
calling it with `M-x').  So the second patch below does this by adding a
suitable user option which is used in bug-reference-push-button.

This approach could be generalized by replacing
gnus-get-emacs-bug-number by a function that also recognizes other bug
or issue numbers, maybe along the lines of bug-reference-bug-regexp, and
making bug-reference-push-button act appropriately; but since I've only
used gnus-read-ephemeral-emacs-bug-group and could test it, I leave this
as a todo.  (However, I don't think browse-url itself should be extended
to allow calling g-r-e-e-b-g by clicking a URL like the one mentioned in
the first paragraph above, since browse-url is intended to call a web
browser, and that's what I think users expect when they click relevant
links, and the presence of a bug number in a URL is a special case.  But
with bug-reference-push-button, the point is to follow a bug reference,
and since g-r-e-e-b-g also exists for this purpose, it seems reasonable
to allow calling it by clicking these links.)


[-- Attachment #2: Patch for gnus-group.el --]
[-- Type: text/plain, Size: 3727 bytes --]

=== 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  <stephen.berman@gmx.net>
+
+       * 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  <cyd@gnu.org>
 
        * 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.


[-- Attachment #3: Patch for bug-reference.el --]
[-- Type: text/plain, Size: 2615 bytes --]

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog      2012-09-09 11:03:37 +0000
+++ lisp/ChangeLog      2012-09-09 15:28:28 +0000
@@ -1,3 +1,9 @@
+2012-09-09  Stephen Berman  <stephen.berman@gmx.net>
+
+       * progmodes/bug-reference.el (bug-reference-push-button-action):
+       New defcustom to allow using gnus-read-ephemeral-emacs-bug-group.
+       (bug-reference-push-button): Use it.
+
 2012-09-09  Alan Mackenzie  <acm@muc.de>
 
        * progmodes/cc-engine.el (c-state-cache-init): Initialise

=== modified file 'lisp/progmodes/bug-reference.el'
--- lisp/progmodes/bug-reference.el     2012-08-22 06:47:00 +0000
+++ lisp/progmodes/bug-reference.el     2012-09-09 15:28:25 +0000
@@ -76,6 +76,12 @@
   :safe 'stringp
   :group 'bug-reference)
 
+(defcustom bug-reference-push-button-action 'url
+  "List of choices for visiting the bug referenced in the button."
+  :type '(radio (const :tag "Visit the bug's URL in a browser" url)
+               (const :tag "Visit the bug thread in Gnus" gnus))
+  :group 'bug-reference)
+
 (defun bug-reference-set-overlay-properties ()
   "Set properties of bug reference overlays."
   (put 'bug-reference 'evaporate t)
@@ -121,7 +127,11 @@
 
 ;; Taken from button.el.
 (defun bug-reference-push-button (&optional pos _use-mouse-action)
-  "Open URL corresponding to the bug reference at POS."
+  "Take appropriate action on the bug reference at POS.
+The action depends on the value of the user option
+`bug-reference-push-button-action': either visit the bug's URL in
+a browser or visit the bug thread in Gnus (N.B.: the latter only
+works for references to the Emacs bugtracker)."
   (interactive
    (list (if (integerp last-command-event) (point) last-command-event)))
   (if (and (not (integerp pos)) (eventp pos))
@@ -130,11 +140,14 @@
        (with-current-buffer (window-buffer (posn-window posn))
          (bug-reference-push-button (posn-point posn) t)))
     ;; POS is just normal position.
-    (dolist (o (overlays-at pos))
-      ;; It should only be possible to have one URL overlay.
-      (let ((url (overlay-get o 'bug-reference-url)))
-       (when url
-         (browse-url url))))))
+    (cond ((eq bug-reference-push-button-action 'url)
+          (dolist (o (overlays-at pos))
+            ;; It should only be possible to have one URL overlay.
+            (let ((url (overlay-get o 'bug-reference-url)))
+              (when url
+                (browse-url url)))))
+         ((eq bug-reference-push-button-action 'gnus)
+          (gnus-read-ephemeral-emacs-bug-group)))))
 
 ;;;###autoload
 (define-minor-mode bug-reference-mode


^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  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
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2012-09-09 18:47 UTC (permalink / raw)
  To: Stephen Berman; +Cc: 12396

Stephen Berman <stephen.berman@gmx.net> writes:

> It would be more convenient if the bug number in the current line in
> the Group buffer were offered as default regardless of where point is
> in the line.

It makes sense, but it's kinda not the way these function in Emacs
usually work.  `M-x find-file-at-point', `M-x man', etc, all react to
the thing under point.  And that's a very self-evident user interface.
Put point at the thing you're interested in, and then issue a command.

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Lars Magne Ingebrigtsen





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-09 18:47 ` Lars Ingebrigtsen
@ 2012-09-09 19:49   ` Stephen Berman
  2012-09-10 21:02     ` Stephen Berman
  2012-09-11 19:01     ` Juri Linkov
  0 siblings, 2 replies; 12+ messages in thread
From: Stephen Berman @ 2012-09-09 19:49 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 12396

On Sun, 09 Sep 2012 20:47:49 +0200 Lars Ingebrigtsen <larsi@gnus.org> wrote:

> Stephen Berman <stephen.berman@gmx.net> writes:
>
>> It would be more convenient if the bug number in the current line in
>> the Group buffer were offered as default regardless of where point is
>> in the line.
>
> It makes sense, but it's kinda not the way these function in Emacs
> usually work.  `M-x find-file-at-point', `M-x man', etc, all react to
> the thing under point.  And that's a very self-evident user interface.
> Put point at the thing you're interested in, and then issue a command.

I think there are significant differences between these three cases.
With ffap, the UI is already announced in the name, and any other
behavior would contradict it.  With man, the list of items naming man
pages is large and could always be augmented, i.e., pretty much any word
could be a potential target, so it makes sense to default to the word at
point.  But with g-r-e-e-b-g, even though bug numbers are in principle
unbounded, the context for identifying them can be narrowly specified,
as I tried to show; e.g., it won't grab a number in a subject line like
"Bug in forward-sexp starting with revision 340958".  In other words,
for g-r-e-e-b-g the typical use case will have a natural default (or
several, as I noted), which it therefore makes sense to use regardless
of where point is.  If this doesn't convince you, all I can add is that
I was annoyed enough times by having to navigate to the bug number to
avoid typing it in that I decided to code up a way to avoid having to do
that; having it in Emacs might spare others such annoyance. :-)

Steve Berman





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-09 19:49   ` Stephen Berman
@ 2012-09-10 21:02     ` Stephen Berman
  2012-09-11 19:01     ` Juri Linkov
  1 sibling, 0 replies; 12+ messages in thread
From: Stephen Berman @ 2012-09-10 21:02 UTC (permalink / raw)
  To: 12396

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)))))))





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-09 19:49   ` Stephen Berman
  2012-09-10 21:02     ` Stephen Berman
@ 2012-09-11 19:01     ` Juri Linkov
  2012-09-11 23:11       ` Stephen Berman
  1 sibling, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-09-11 19:01 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Lars Ingebrigtsen, 12396

>> It makes sense, but it's kinda not the way these function in Emacs
>> usually work.  `M-x find-file-at-point', `M-x man', etc, all react to
>> the thing under point.  And that's a very self-evident user interface.
>> Put point at the thing you're interested in, and then issue a command.
>
> I was annoyed enough times by having to navigate to the bug number to
> avoid typing it in that I decided to code up a way to avoid having to do
> that; having it in Emacs might spare others such annoyance. :-)

I agree with Lars that getting a default value from distant parts
of the buffer is non-standard behavior for thing-at-point.
It might cause more annoyance when it will do not what the user expects.
For instance, if it will get a bug number far away from point, then
the user might expect that it will also get a bug number on the next line
at the same column position, etc.  IOW, I don't oppose such a change
only if its logic would be simple and intuitive to users.

Also moving argument reading out of the `interactive' specification
in `gnus-read-ephemeral-emacs-bug-group' is a change for the worse.

However, I think that the second part of your proposal is very useful.

Do you think `bug-reference-push-button-action' can be a function?
So users could set it to `browse-url' or `gnus-read-ephemeral-emacs-bug-group'
(these values still need const tags like in your patch)
or any other function.  Also I wonder why you don't call
`gnus-read-ephemeral-emacs-bug-group' with a bug number argument
so users don't need to confirm it with RET.

BTW, bug-reference.el could be improved to support also links
to revision numbers like "revno:109985" that opens an URL like
http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/109985





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-11 19:01     ` Juri Linkov
@ 2012-09-11 23:11       ` Stephen Berman
  2012-09-12 20:54         ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2012-09-11 23:11 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 12396

On Tue, 11 Sep 2012 22:01:34 +0300 Juri Linkov <juri@jurta.org> wrote:

>>> It makes sense, but it's kinda not the way these function in Emacs
>>> usually work.  `M-x find-file-at-point', `M-x man', etc, all react to
>>> the thing under point.  And that's a very self-evident user interface.
>>> Put point at the thing you're interested in, and then issue a command.
>>
>> I was annoyed enough times by having to navigate to the bug number to
>> avoid typing it in that I decided to code up a way to avoid having to do
>> that; having it in Emacs might spare others such annoyance. :-)
>
> I agree with Lars that getting a default value from distant parts
> of the buffer is non-standard behavior for thing-at-point.

But my patch uses re-search-forward for getting the default value from
"distant parts of the buffer"; its use of thing-at-point is completely
standard.

> It might cause more annoyance when it will do not what the user expects.
> For instance, if it will get a bug number far away from point, then
> the user might expect that it will also get a bug number on the next line
> at the same column position, etc.  IOW, I don't oppose such a change
> only if its logic would be simple and intuitive to users.

Well, the use case that motivated my first patch is grabbing a bug
number in the subject line of a mail or posting, so the distance
involved is rather small.  Admittedly, the extension to ChangeLogs could
involve several lines between point and the bug number, which my patch
does not take into account.

> Also moving argument reading out of the `interactive' specification
> in `gnus-read-ephemeral-emacs-bug-group' is a change for the worse.

This was necessitated by the optional numerical prefix argument, which
is passed to gnus-get-emacs-bug-number, which supplies the default for
the argument reading; AFAICS it is impossible to have one argument
determine another argument within the same interactive spec.

> However, I think that the second part of your proposal is very useful.
>
> Do you think `bug-reference-push-button-action' can be a function?
> So users could set it to `browse-url' or `gnus-read-ephemeral-emacs-bug-group'

Certainly; see below.

> (these values still need const tags like in your patch)

Actually, function-item uses the doc string, so tags aren't needed.

> or any other function.  Also I wonder why you don't call
> `gnus-read-ephemeral-emacs-bug-group' with a bug number argument
> so users don't need to confirm it with RET.

Well, my second patch assumed my first patch, which changes
g-r-e-e-b-g's signature, so the bug number isn't passed as an argument.
However, I agree it is bad to request confirmation on clicking the
button in this case.  This appears to argue against the change in the
interactive spec.  I'll have to give it some thought.  In the mean time,
since my proposed change to g-r-e-e-b-g doesn't seem to be gaining
support and the implementation is problematical (though I still think
the feature is worth having), here's a reworking of the second patch
along the lines you suggested, using the existing g-r-e-e-b-g instead of
my proposed change.  I haven't yet made it a patch against the trunk
because I only tested it briefly, but it seems to work:

(defun bug-reference-browse-url (pos)
  "Visit the bug's URL in a web browser."
  (dolist (o (overlays-at pos))
    ;; It should only be possible to have one URL overlay.
    (let ((url (overlay-get o 'bug-reference-url)))
      (when url
	(browse-url url)))))
			      
(defun bug-reference-gnus-read-ephemeral-emacs-bug-group (pos)
  "Read the bug thread in a Gnus ephemeral group."
  (dolist (o (overlays-at pos))
    ;; It should only be possible to have one URL overlay.
    (let* ((url (overlay-get o 'bug-reference-url))
	   (num (when (string-match "http://debbugs\\.gnu\\.org/\\([0-9]+\\)$" url)
		  (string-to-number (match-string 1 url)))))
      (when num (gnus-read-ephemeral-emacs-bug-group num)))))

(defcustom bug-reference-push-button-action 'bug-reference-browse-url
  "Function called on clicking a bug reference button."
  :group 'bug-reference
  :type '(radio (function-item bug-reference-browse-url)
		(function-item bug-reference-gnus-read-ephemeral-emacs-bug-group)
		function))

(defun bug-reference-push-button (&optional pos _use-mouse-action)
  "Take appropriate action on the bug reference at POS.
The action depends on the value of the user option
`bug-reference-push-button-action'."
  (interactive
   (list (if (integerp last-command-event) (point) last-command-event)))
  (if (and (not (integerp pos)) (eventp pos))
      ;; POS is a mouse event; switch to the proper window/buffer
      (let ((posn (event-start pos)))
	(with-current-buffer (window-buffer (posn-window posn))
	  (bug-reference-push-button (posn-point posn) t)))
    ;; POS is just normal position.
    (funcall bug-reference-push-button-action pos)))

> BTW, bug-reference.el could be improved to support also links
> to revision numbers like "revno:109985" that opens an URL like
> http://bzr.savannah.gnu.org/lh/emacs/trunk/revision/109985

That would be useful, though it's going beyond bug references.

Steve Berman





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-11 23:11       ` Stephen Berman
@ 2012-09-12 20:54         ` Juri Linkov
  2012-09-13 20:38           ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-09-12 20:54 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Lars Ingebrigtsen, 12396

> Well, the use case that motivated my first patch is grabbing a bug
> number in the subject line of a mail or posting, so the distance
> involved is rather small.

Grabbing a bug number in the subject line is a well-defined goal,
but when I tried your latest version of `gnus-get-emacs-bug-number',
it can't get a bug number from the subject line.

> Admittedly, the extension to ChangeLogs could involve several lines
> between point and the bug number, which my patch does not take
> into account.

For ChangeLogs it could look only inside the current entry.

> Well, my second patch assumed my first patch, which changes
> g-r-e-e-b-g's signature, so the bug number isn't passed as an argument.
> However, I agree it is bad to request confirmation on clicking the
> button in this case.  This appears to argue against the change in the
> interactive spec.

Yes, there is no need to change the function signature
and no need to move its interactive spec to the function body.
You could just replace old (thing-at-point 'word)
with a call to a new function `gnus-get-emacs-bug-number'.
Replacing `read-string' with `read-number' in your patch
also makes sense.  But selecting one of several bug numbers
would be easier by supplying a list of bug numbers to `read-number'
and using e.g. `3 M-n' to select one of them (third in this example).

> (defun bug-reference-gnus-read-ephemeral-emacs-bug-group (pos)
>   "Read the bug thread in a Gnus ephemeral group."
>   (dolist (o (overlays-at pos))
>     ;; It should only be possible to have one URL overlay.
>     (let* ((url (overlay-get o 'bug-reference-url))
> 	   (num (when (string-match "http://debbugs\\.gnu\\.org/\\([0-9]+\\)$" url)
                                     ============================
This is a bad thing.  It is not your failure, it is by design of
bug-reference.el that you have to circumvent.  I think that
bug-reference.el should be improved to add a bug number to overlays
where it currently adds a bug URL.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-12 20:54         ` Juri Linkov
@ 2012-09-13 20:38           ` Stephen Berman
  2012-09-13 23:35             ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2012-09-13 20:38 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 12396

On Wed, 12 Sep 2012 23:54:05 +0300 Juri Linkov <juri@jurta.org> wrote:

>> Well, the use case that motivated my first patch is grabbing a bug
>> number in the subject line of a mail or posting, so the distance
>> involved is rather small.
>
> Grabbing a bug number in the subject line is a well-defined goal,
> but when I tried your latest version of `gnus-get-emacs-bug-number',
> it can't get a bug number from the subject line.

I guess you mean the version in this post:

<http://permalink.gmane.org/gmane.emacs.bugs/64081>

When I use it it does grab the bug number, at least in the types of
cases I had in mind (however, I didn't think of URLs like this one...).
Can you provide a recipe showing the failure?

>> Admittedly, the extension to ChangeLogs could involve several lines
>> between point and the bug number, which my patch does not take
>> into account.
>
> For ChangeLogs it could look only inside the current entry.
>
>> Well, my second patch assumed my first patch, which changes
>> g-r-e-e-b-g's signature, so the bug number isn't passed as an argument.
>> However, I agree it is bad to request confirmation on clicking the
>> button in this case.  This appears to argue against the change in the
>> interactive spec.
>
> Yes, there is no need to change the function signature
> and no need to move its interactive spec to the function body.
> You could just replace old (thing-at-point 'word)
> with a call to a new function `gnus-get-emacs-bug-number'.
> Replacing `read-string' with `read-number' in your patch
> also makes sense.  But selecting one of several bug numbers
> would be easier by supplying a list of bug numbers to `read-number'
> and using e.g. `3 M-n' to select one of them (third in this example).

I haven't had time to try out these ideas yet, but thanks for the
suggestions. 

>> (defun bug-reference-gnus-read-ephemeral-emacs-bug-group (pos)
>>   "Read the bug thread in a Gnus ephemeral group."
>>   (dolist (o (overlays-at pos))
>>     ;; It should only be possible to have one URL overlay.
>>     (let* ((url (overlay-get o 'bug-reference-url))
>> 	   (num (when (string-match "http://debbugs\\.gnu\\.org/\\([0-9]+\\)$" url)
>                                      ============================
> This is a bad thing.  It is not your failure, it is by design of
> bug-reference.el that you have to circumvent.  I think that
> bug-reference.el should be improved to add a bug number to overlays
> where it currently adds a bug URL.

I agree that would be cleaner.

Steve Berman





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-13 20:38           ` Stephen Berman
@ 2012-09-13 23:35             ` Juri Linkov
  2012-09-14 15:37               ` Stephen Berman
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-09-13 23:35 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Lars Ingebrigtsen, 12396

> When I use it it does grab the bug number, at least in the types of
> cases I had in mind (however, I didn't think of URLs like this one...).
> Can you provide a recipe showing the failure?

A recipe is just to put point anywhere in the message body
and evaluate M-: (gnus-get-emacs-bug-number) RET
It doesn't grab a bug number in the subject line,
but returns nil.  Please clarify where you intended point to be
to be able to grab a bug number from the subject line.

Actually there already exist similar functionality
in `Info-follow-reference'.  If you type in an Info node
`f TAB' it allows you to select one of the links to other nodes.
Since bug references are similar to links, you could do the same
and to collect bug references from the current buffer for completion.
Of course, the bug reference under point should be prefered over
all other bug references in the buffer and should be provided as
the first default value.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-13 23:35             ` Juri Linkov
@ 2012-09-14 15:37               ` Stephen Berman
  2012-09-14 22:54                 ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Stephen Berman @ 2012-09-14 15:37 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Lars Ingebrigtsen, 12396

On Fri, 14 Sep 2012 02:35:55 +0300 Juri Linkov <juri@jurta.org> wrote:

>> When I use it it does grab the bug number, at least in the types of
>> cases I had in mind (however, I didn't think of URLs like this one...).
>> Can you provide a recipe showing the failure?
>
> A recipe is just to put point anywhere in the message body and
> evaluate M-: (gnus-get-emacs-bug-number) RET It doesn't grab a bug
> number in the subject line, but returns nil.  Please clarify where you
> intended point to be to be able to grab a bug number from the subject
> line.

This is a use case I didn't have in mind.  I use the default window
configuration of Gnus, where when you visit a mail or news group, the
frame is split into two windows: one with the Summary buffer and one
with the Article buffer, and the Summary buffer is selected.  Each line
of the Summary buffer contains by default at least the subject line of
an article in the group, and typing SPC or RET opens, in the Article
buffer, the article listed at point in the Summary buffer.  In this
scenario, it suffices for the search space for gnus-get-emacs-bug-number
to be just the current line, that's why it doesn't work in your case.

> Actually there already exist similar functionality
> in `Info-follow-reference'.  If you type in an Info node
> `f TAB' it allows you to select one of the links to other nodes.
> Since bug references are similar to links, you could do the same
> and to collect bug references from the current buffer for completion.
> Of course, the bug reference under point should be prefered over
> all other bug references in the buffer and should be provided as
> the first default value.

This certainly is a better approach for your scenario, though for mine
it's probably too heavy, since there are may well be numerous bug
numbers in the Summary buffer, but when I call
gnus-read-ephemeral-emacs-bug-group, I most likely want to visit the
thread of the bug mentioned in the subject line at point, not that of
another subject line.  I suppose, though, if I did want to go to a bug
thread from a different subject, it would be useful to cycle through the
completions.  Even better would be if the bug numbers in the buffer are
highlighted as you cycle, so you can see their context.

Steve Berman





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-14 15:37               ` Stephen Berman
@ 2012-09-14 22:54                 ` Juri Linkov
  2012-12-25 21:54                   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2012-09-14 22:54 UTC (permalink / raw)
  To: Stephen Berman; +Cc: Lars Ingebrigtsen, 12396

> This is a use case I didn't have in mind.  I use the default window
> configuration of Gnus, where when you visit a mail or news group, the
> frame is split into two windows: one with the Summary buffer and one
> with the Article buffer, and the Summary buffer is selected.  Each line
> of the Summary buffer contains by default at least the subject line of
> an article in the group, and typing SPC or RET opens, in the Article
> buffer, the article listed at point in the Summary buffer.  In this
> scenario, it suffices for the search space for gnus-get-emacs-bug-number
> to be just the current line, that's why it doesn't work in your case.

I use the same configuration, but this still doesn't work in the
Summary buffer, because my Summary buffer is in the thread mode
where the subject line is displayed only for the top article of the
thread.  So for other articles in the thread in the Summary buffer
gnus-get-emacs-bug-number doesn't find a bug reference from the
current line.





^ permalink raw reply	[flat|nested] 12+ messages in thread

* bug#12396: 24.2.50; [PATCH] extend usability of gnus-read-ephemeral-emacs-bug-group
  2012-09-14 22:54                 ` Juri Linkov
@ 2012-12-25 21:54                   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2012-12-25 21:54 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 12396, Stephen Berman

My take on this is still that the most obvious interface here is to put
point at the bug number and then use the command.

So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  http://lars.ingebrigtsen.no  *  Lars Magne Ingebrigtsen





^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-12-25 21:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).