From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.devel Subject: Re: [sdl.web@gmail.com: 23.0.0; (thing-at-point 'url) returns invalid urls] Date: Fri, 31 Aug 2007 23:35:08 +0200 Message-ID: <87wsvbie0j.fsf@gnuvola.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1188596156 29964 80.91.229.12 (31 Aug 2007 21:35:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 31 Aug 2007 21:35:56 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 31 23:35:55 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IRE9h-0005tz-3V for ged-emacs-devel@m.gmane.org; Fri, 31 Aug 2007 23:35:53 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IRE9g-0004nr-FB for ged-emacs-devel@m.gmane.org; Fri, 31 Aug 2007 17:35:52 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IRE9d-0004mr-0y for emacs-devel@gnu.org; Fri, 31 Aug 2007 17:35:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IRE9b-0004lD-9m for emacs-devel@gnu.org; Fri, 31 Aug 2007 17:35:48 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IRE9a-0004l1-Oo for emacs-devel@gnu.org; Fri, 31 Aug 2007 17:35:46 -0400 Original-Received: from ppp-144-38.21-151.libero.it ([151.21.38.144] helo=localhost.localdomain) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IRE9a-0001DB-5A for emacs-devel@gnu.org; Fri, 31 Aug 2007 17:35:46 -0400 Original-Received: from ttn by localhost.localdomain with local (Exim 4.63) (envelope-from ) id 1IRE8y-0003pZ-34 for emacs-devel@gnu.org; Fri, 31 Aug 2007 23:35:08 +0200 In-Reply-To: (Drew Adams's message of "Fri\, 31 Aug 2007 13\:34\:41 -0700") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-Detected-Kernel: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:77511 Archived-At: () "Drew Adams" () Fri, 31 Aug 2007 13:34:41 -0700 That's OK too. I thought people were asking for the ability to get only "valid" URLs in the sense of having live targets. Isn't that what the initial request was for? iiuc the initial request was to disambiguate the two cases whereby (thing-at-point 'url) when point is on one of: something http://something (both cases return "http://something"). i posted a suggestion (to gnu-emacs-help but i guess it got dropped somehow) along the lines of adding a variable thing-at-point-url-autoprefix which when t would do the heuristic autoprefixing (http:// or ftp://) that is the present behavior, and when nil, would not. default value is another question, of course. below is a quick patch. here are some tests from *scratch*: (defun test (setting text) (setq thing-at-point-url-autoprefix setting) (save-excursion (insert text)) (prog1 (thing-at-point 'url) (delete-char (length text)))) (test t "http://something") "http://something" (test nil "http://something") "http://something" (test t "something") "http://something" (test nil "something") "something" seems harmless enough. what do people think? thi _______________________________________ *** thingatpt.el 26 Jul 2007 05:26:35 -0000 1.43 --- thingatpt.el 31 Aug 2007 21:26:54 -0000 *************** *** 238,243 **** --- 238,247 ---- "A regular expression matching a URL marked up per RFC1738. This may contain whitespace (including newlines) .") + (defvar thing-at-point-url-autoprefix nil + "Controls how `thing-at-point' recognizes URLs. + If nil, no access scheme is presumed.") + (put 'url 'bounds-of-thing-at-point 'thing-at-point-bounds-of-url-at-point) (defun thing-at-point-bounds-of-url-at-point () (let ((strip (thing-at-point-looking-at *************** *** 261,267 **** Search backwards for the start of a URL ending at or after point. If no URL found, return nil. The access scheme will be prepended if ! absent: \"mailto:\" if the string contains \"@\", \"ftp://\" if it starts with \"ftp\" and not \"ftp:/\", or \"http://\" by default." (let ((url "") short strip) --- 265,272 ---- Search backwards for the start of a URL ending at or after point. If no URL found, return nil. The access scheme will be prepended if ! absent (and if `thing-at-point-url-autoprefix' has non-nil value), ! one of \"mailto:\" if the string contains \"@\", \"ftp://\" if it starts with \"ftp\" and not \"ftp:/\", or \"http://\" by default." (let ((url "") short strip) *************** *** 278,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) --- 283,290 ---- ;; strip whitespace (while (string-match "[ \t\n\r]+" url) (setq url (replace-match "" t t url))) ! (and short thing-at-point-url-autoprefix ! (setq url (concat (cond ((string-match "^[a-zA-Z]+:" url) ;; already has a URL scheme. "") ((string-match "@" url)