Gnus development mailing list
 help / color / mirror / Atom feed
From: Katsumi Yamaoka <yamaoka@jpl.org>
To: Christoph Conrad <christoph.conrad@gmx.de>
Cc: bugs@gnus.org, ding@gnus.org
Subject: Re: URIs wrapped in angle brackets are not extracted correctly
Date: Tue, 18 Sep 2007 20:45:41 +0900	[thread overview]
Message-ID: <b4mtzps19ju.fsf@jpl.org> (raw)
In-Reply-To: <874phvi0ui.fsf@ID-24456.user.uni-berlin.de>

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

(I added Cc: ding.)

>>>>> Christoph Conrad wrote:
> No Gnus v0.7
> GNU Emacs 23.0.50.1 (i686-pc-linux-gnu, GTK+ Version 2.10.13, multi-tty)
>  of 2007-09-03 on brabbelbox
> 200 news.gmane.org InterNetNews NNRP server INN 2.4.1 ready (posting ok).

> Hi,

> according to RFC 3986 Appendix C the following URI should be extracted
> correctly when embedded in angle brackets, containing a line break:

<http://www.faz.net/s/Rub560251485DC24AF181BBEF83E12CA16E/Doc~E990108D4B
D2D4C29A2BA6460BE3F10EC~ATpl~Ecommon~Scontent.html>

> This is not the case in current cvs-Gnus when pressing <RET>
> (widget-button-press). Only the first part of the URI before the line
> break is extracted.

There might be a reason neither `ffap-url-at-point' (ffap.el) nor
`thing-at-point' (thingatpt.el) works with such data.  I tried
making Gnus work (the patch is attached to this message).  However,
it currently does not work with the following ones:

>>>>> Christoph Conrad wrote:
> <http://www.faz.net/s/Rub560251485DC24AF181BBEF83E12CA16E/Doc~E990108D4B
> D2D4C29A2BA6460BE3F10EC~ATpl~Ecommon~Scontent.html>

Katsumi> <http://www.jpl.org/
Katsumi> Katsumi>

I think it is hard to make it work with any type of citations.
Any idea?

> ,----
>| In practice, URIs are delimited in a variety of ways, but usually within
>| double-quotes "http://example.com/", angle brackets
>| <http://example.com/>, or just by using whitespace
>| [...]
>| In some cases, extra whitespace (spaces, line-breaks, tabs, etc.) may
>| have to be added to break a long URI across lines. The whitespace should
>| be ignored when the URI is extracted.
> `----

> Best regards,
> Christoph


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Patch to gnus-art.el --]
[-- Type: text/x-patch, Size: 2207 bytes --]

--- gnus-art.el~	2007-08-24 10:22:10 +0000
+++ gnus-art.el	2007-09-18 11:43:14 +0000
@@ -7357,9 +7357,24 @@
 	(setq regexp (eval (car entry)))
 	(goto-char beg)
 	(while (re-search-forward regexp nil t)
-	  (let* ((start (and entry (match-beginning (nth 1 entry))))
-		 (end (and entry (match-end (nth 1 entry))))
+	  (let* ((start (match-beginning (nth 1 entry)))
+		 (end (match-end (nth 1 entry)))
 		 (from (match-beginning 0)))
+	    (when (eq (car entry) 'gnus-button-url-regexp)
+	      (let ((to (match-end 0)))
+		(goto-char end)
+		(when (or (looking-at "[\t\n ]*>")
+			  (progn
+			    (goto-char start)
+			    (and (or (eq (char-before) ?<)
+				     (and (search-backward "<" nil t)
+					  (string-match
+					   "url:[\t\n ]*"
+					   (buffer-substring (match-end 0)
+							     start))))
+				 (re-search-forward "[\t\n ]*>" nil t))))
+		  (setq end (match-beginning 0)))
+		(goto-char to)))
 	    (when (and (or (eq t (nth 2 entry))
 			   (eval (nth 2 entry)))
 		       (not (gnus-button-in-region-p
@@ -7450,6 +7465,27 @@
       (if (looking-at (eval (car entry)))
 	  (setq alist nil)
 	(setq entry nil)))
+    (when (and entry
+	       (eq (car entry) 'gnus-button-url-regexp))
+      (let ((start (point))
+	    end md)
+	(goto-char (match-end (nth 1 entry)))
+	(when (save-match-data
+		(when (or (looking-at "[\t\n ]*>")
+			  (progn
+			    (goto-char start)
+			    (and (or (eq (char-before) ?<)
+				     (and (search-backward "<" nil t)
+					  (string-match
+					   "url:[\t\n ]*"
+					   (buffer-substring (match-end 0)
+							     start))))
+				 (re-search-forward "[\t\n ]*>" nil t))))
+		  (setq end (match-beginning 0))))
+	  (setq md (match-data))
+	  (setcar (nthcdr (1+ (* (nth 1 entry) 2)) md) end)
+	  (set-match-data md))
+	(goto-char start)))
     entry))
 
 (defun gnus-button-push (marker)
@@ -7460,7 +7496,9 @@
 	   (inhibit-point-motion-hooks t)
 	   (fun (nth 3 entry))
 	   (args (mapcar (lambda (group)
-			   (let ((string (match-string group)))
+			   (let ((string (gnus-replace-in-string
+					  (match-string group)
+					  "\\(?:[\t ]*\n\\)+[\t ]*" "")))
 			     (set-text-properties
 			      0 (length string) nil string)
 			     string))

       reply	other threads:[~2007-09-18 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <874phvi0ui.fsf@ID-24456.user.uni-berlin.de>
2007-09-18 11:45 ` Katsumi Yamaoka [this message]
2007-09-18 19:26   ` Christoph Conrad
2007-09-18 21:03   ` Elias Oltmanns
2007-09-29 10:39   ` Reiner Steib
2007-09-29 10:50     ` Christoph Conrad
2007-09-30 23:55     ` Katsumi Yamaoka
2007-10-11 22:09       ` Katsumi Yamaoka

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4mtzps19ju.fsf@jpl.org \
    --to=yamaoka@jpl.org \
    --cc=bugs@gnus.org \
    --cc=christoph.conrad@gmx.de \
    --cc=ding@gnus.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.
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 NNTP newsgroup(s).