all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Add more URI schemes to thing-at-point-uri-schemes.
@ 2006-11-18 20:58 Diane Murray
  2006-11-19 21:11 ` Bob Rogers
  0 siblings, 1 reply; 5+ messages in thread
From: Diane Murray @ 2006-11-18 20:58 UTC (permalink / raw)


Running (thing-at-point 'url) on a URL starting with "irc:" returns
"http://irc:".  This is because `thing-at-point-uri-schemes' doesn't
have "irc:" in its definition.

<http://www.iana.org/assignments/uri-schemes.html> doesn't list irc as
an official URI scheme, but it does have quite a few new ones that
haven't been added to `thing-at-point-uri-schemes'.

The following patch adds the new schemes and "irc:".  It also adds two
others that I see often, "mms://" and "mmsh://", which are comparable
to rtsp.


2006-11-18  Diane Murray  <disumu@x3y2z1.net>

	* thingatpt.el (thing-at-point-uri-schemes): Added schemes that
	are new to the list at IANA.  Also added irc, mms, mmsh.


--- thingatpt.el	18 Sep 2006 15:04:32 +0200	1.37
+++ thingatpt.el	18 Nov 2006 17:40:22 +0100	
@@ -214,15 +214,18 @@
 ``thing-at-point-url-regexp''.")
 
 (defvar thing-at-point-uri-schemes
-  ;; Officials from http://www.iana.org/assignments/uri-schemes
+  ;; Officials from http://www.iana.org/assignments/uri-schemes.html
   '("ftp://" "http://" "gopher://" "mailto:" "news:" "nntp:"
     "telnet://" "wais://" "file:/" "prospero:" "z39.50s:" "z39.50r:"
     "cid:" "mid:" "vemmi:" "service:" "imap:" "nfs:" "acap:" "rtsp:"
     "tip:" "pop:" "data:" "dav:" "opaquelocktoken:" "sip:" "tel:" "fax:"
     "modem:" "ldap:" "https://" "soap.beep:" "soap.beeps:" "urn:" "go:"
     "afs:" "tn3270:" "mailserver:"
+    "crid:" "dict:" "dns:" "dtn:" "h323:" "im:" "info:" "ipp:"
+    "iris.beep:" "mtqp:" "mupdate:" "pres:" "sips:" "snmp:" "tag:"
+    "tftp:" "xmlrpc.beep:" "xmlrpc.beeps:" "xmpp:"
   ;; Compatibility
-    "snews:")
+    "snews:" "irc:" "mms://" "mmsh://")
   "Uniform Resource Identifier (URI) Schemes.")
 
 (defvar thing-at-point-url-regexp

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

* Add more URI schemes to thing-at-point-uri-schemes.
  2006-11-18 20:58 Add more URI schemes to thing-at-point-uri-schemes Diane Murray
@ 2006-11-19 21:11 ` Bob Rogers
  2006-11-19 21:15   ` David Kastrup
  2006-11-20 13:00   ` Richard Stallman
  0 siblings, 2 replies; 5+ messages in thread
From: Bob Rogers @ 2006-11-19 21:11 UTC (permalink / raw)
  Cc: emacs-devel

[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 1573 bytes --]

   From: Diane Murray <disumu@x3y2z1.net>
   Date: Sat, 18 Nov 2006 21:58:50 +0100

   Running (thing-at-point 'url) on a URL starting with "irc:" returns
   "http://irc:".  This is because `thing-at-point-uri-schemes' doesn't
   have "irc:" in its definition.

This does fix the problem, but the "irc:" URL is currently being matched
by thing-at-point-short-url-regexp in thing-at-point-url-at-point, which
subsequently attaches the "http://" prefix.  The attached patch avoids
prefixing one scheme with another, which is incorrect regardless of how
many schemes `thing-at-point-uri-schemes' knows about (and is therefore
independent of your patch).

   <http://www.iana.org/assignments/uri-schemes.html> doesn't list irc as
   an official URI scheme, but it does have quite a few new ones that
   haven't been added to `thing-at-point-uri-schemes'.

   The following patch adds the new schemes and "irc:".  It also adds two
   others that I see often, "mms://" and "mmsh://", which are comparable
   to rtsp.

If thing-at-point-short-url-regexp will match these anyway, do we really
need to ensure that thing-at-point-uri-schemes is comprehensive?
Perhaps the latter should only be for schemes that are known to be
harder to parse.  Is there a benefit to being biased toward officially-
recognized schemes?

					-- Bob Rogers
					   http://rgrjr.dyndns.org/

------------------------------------------------------------------------
2006-11-19  Bob Rogers  <rogers-emacs@rgrjr.dyndns.org>

	* thingatpt.el (thing-at-point-url-at-point):  Don't add a
	redundant scheme.


[-- Attachment #2: Type: text/plain, Size: 1179 bytes --]

Index: lisp/thingatpt.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/thingatpt.el,v
retrieving revision 1.37
diff -c -r1.37 thingatpt.el
*** lisp/thingatpt.el	13 Sep 2006 17:46:25 -0000	1.37
--- lisp/thingatpt.el	19 Nov 2006 21:08:46 -0000
***************
*** 275,281 ****
  	  ;; strip whitespace
  	  (while (string-match "[ \t\n\r]+" url)
  	    (setq url (replace-match "" t t url)))
! 	  (and short (setq url (concat (cond ((string-match "@" url)
                                                "mailto:")
  					     ;; e.g. ftp.swiss... or ftp-swiss...
                                               ((string-match "^ftp" url)
--- 275,284 ----
  	  ;; strip whitespace
  	  (while (string-match "[ \t\n\r]+" url)
  	    (setq url (replace-match "" t t url)))
! 	  (and short (setq url (concat (cond ((string-match "^[a-zA-Z]+:" url)
! 					       ;; already has a URL scheme.
! 					       "")
! 					     ((string-match "@" url)
                                                "mailto:")
  					     ;; e.g. ftp.swiss... or ftp-swiss...
                                               ((string-match "^ftp" url)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

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

* Re: Add more URI schemes to thing-at-point-uri-schemes.
  2006-11-19 21:11 ` Bob Rogers
@ 2006-11-19 21:15   ` David Kastrup
  2006-11-19 22:21     ` Bob Rogers
  2006-11-20 13:00   ` Richard Stallman
  1 sibling, 1 reply; 5+ messages in thread
From: David Kastrup @ 2006-11-19 21:15 UTC (permalink / raw)
  Cc: Diane Murray, emacs-devel

Bob Rogers <rogers-emacs@rgrjr.dyndns.org> writes:

>    From: Diane Murray <disumu@x3y2z1.net>
>    Date: Sat, 18 Nov 2006 21:58:50 +0100
>
>    Running (thing-at-point 'url) on a URL starting with "irc:" returns
>    "http://irc:".  This is because `thing-at-point-uri-schemes' doesn't
>    have "irc:" in its definition.
>
> This does fix the problem, but the "irc:" URL is currently being matched
> by thing-at-point-short-url-regexp in thing-at-point-url-at-point, which
> subsequently attaches the "http://" prefix.  The attached patch avoids
> prefixing one scheme with another, which is incorrect regardless of how
> many schemes `thing-at-point-uri-schemes' knows about (and is therefore
> independent of your patch).

What does it do with

file:///C:/windows

or something similar?

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

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

* Re: Add more URI schemes to thing-at-point-uri-schemes.
  2006-11-19 21:15   ` David Kastrup
@ 2006-11-19 22:21     ` Bob Rogers
  0 siblings, 0 replies; 5+ messages in thread
From: Bob Rogers @ 2006-11-19 22:21 UTC (permalink / raw)
  Cc: Diane Murray, emacs-devel

   From: David Kastrup <dak@gnu.org>
   Date: Sun, 19 Nov 2006 22:15:11 +0100

   Bob Rogers <rogers-emacs@rgrjr.dyndns.org> writes:

   > This does fix the problem, but the "irc:" URL is currently being matched
   > by thing-at-point-short-url-regexp in thing-at-point-url-at-point, which
   > subsequently attaches the "http://" prefix.  The attached patch avoids
   > prefixing one scheme with another, which is incorrect regardless of how
   > many schemes `thing-at-point-uri-schemes' knows about (and is therefore
   > independent of your patch).

   What does it do with

   file:///C:/windows

   or something similar?

If "file:///C:/windows" is what's under point in the buffer, then that
string is exactly what is returned.  This case not affected by the
posted patch, because "file:/" is a known scheme, so the
thing-at-point-short-url-regexp path is not taken,

					-- Bob

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

* Re: Add more URI schemes to thing-at-point-uri-schemes.
  2006-11-19 21:11 ` Bob Rogers
  2006-11-19 21:15   ` David Kastrup
@ 2006-11-20 13:00   ` Richard Stallman
  1 sibling, 0 replies; 5+ messages in thread
From: Richard Stallman @ 2006-11-20 13:00 UTC (permalink / raw)
  Cc: disumu, emacs-devel

I will install this.  Thanks.

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

end of thread, other threads:[~2006-11-20 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-18 20:58 Add more URI schemes to thing-at-point-uri-schemes Diane Murray
2006-11-19 21:11 ` Bob Rogers
2006-11-19 21:15   ` David Kastrup
2006-11-19 22:21     ` Bob Rogers
2006-11-20 13:00   ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.