emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add more URI schemes to thing-at-point-uri-schemes.


From: Bob Rogers
Subject: Add more URI schemes to thing-at-point-uri-schemes.
Date: Sun, 19 Nov 2006 16:11:42 -0500

   From: Diane Murray <address@hidden>
   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  <address@hidden>

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

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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]