diff options
| author | Dave Love | 1998-02-25 23:16:42 +0000 |
|---|---|---|
| committer | Dave Love | 1998-02-25 23:16:42 +0000 |
| commit | 340483df0d0ff3d04beac29684aa8949d9b995ea (patch) | |
| tree | 4ed31186d8b9805ee55e27d1461337b6e417d544 | |
| parent | bc69581bb2682a507919481f306653fdb9d107ec (diff) | |
| download | emacs-340483df0d0ff3d04beac29684aa8949d9b995ea.tar.gz emacs-340483df0d0ff3d04beac29684aa8949d9b995ea.zip | |
(thing-at-point-url-at-point): Intuit ftp:// on `short' URLs.
| -rw-r--r-- | lisp/thingatpt.el | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 88a2807538b..0f3ff229f68 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | ;;; thingatpt.el --- Get the `thing' at point | 1 | ;;; thingatpt.el --- Get the `thing' at point |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1991,92,93,94,95,96,1997 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1991,92,93,94,95,96,97,1998 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Mike Williams <mikew@gopher.dosli.govt.nz> | 5 | ;; Author: Mike Williams <mikew@gopher.dosli.govt.nz> |
| 6 | ;; Keywords: extensions, matching, mouse | 6 | ;; Keywords: extensions, matching, mouse |
| @@ -241,9 +241,12 @@ This may contain whitespace (including newlines) .") | |||
| 241 | (put 'url 'thing-at-point 'thing-at-point-url-at-point) | 241 | (put 'url 'thing-at-point 'thing-at-point-url-at-point) |
| 242 | (defun thing-at-point-url-at-point () | 242 | (defun thing-at-point-url-at-point () |
| 243 | "Return the URL around or before point. | 243 | "Return the URL around or before point. |
| 244 | Search backwards for the start of a URL ending at or after | 244 | |
| 245 | point. If no URL found, return nil. The access scheme, `http://' | 245 | Search backwards for the start of a URL ending at or after point. If |
| 246 | will be prepended if absent." | 246 | no URL found, return nil. The access scheme will be prepended if |
| 247 | absent: \"mailto:\" if the string contains \"@\", \"ftp://\" if it | ||
| 248 | starts with \"ftp\" and not \"ftp:/\", or \"http://\" by default." | ||
| 249 | |||
| 247 | (let ((url "") short strip) | 250 | (let ((url "") short strip) |
| 248 | (if (or (setq strip (thing-at-point-looking-at | 251 | (if (or (setq strip (thing-at-point-looking-at |
| 249 | thing-at-point-markedup-url-regexp)) | 252 | thing-at-point-markedup-url-regexp)) |
| @@ -258,8 +261,13 @@ will be prepended if absent." | |||
| 258 | ;; strip whitespace | 261 | ;; strip whitespace |
| 259 | (while (string-match "\\s +\\|\n+" url) | 262 | (while (string-match "\\s +\\|\n+" url) |
| 260 | (setq url (replace-match "" t t url))) | 263 | (setq url (replace-match "" t t url))) |
| 261 | (and short (setq url (concat (if (string-match "@" url) | 264 | (and short (setq url (concat (cond ((string-match "@" url) |
| 262 | "mailto:" "http://") url))) | 265 | "mailto:") |
| 266 | ;; e.g. ftp.swiss... or ftp-swiss... | ||
| 267 | ((string-match "^ftp" url) | ||
| 268 | "ftp://") | ||
| 269 | (t "http://")) | ||
| 270 | url))) | ||
| 263 | (if (string-equal "" url) | 271 | (if (string-equal "" url) |
| 264 | nil | 272 | nil |
| 265 | url))))) | 273 | url))))) |