X-Git-Url: http://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a1c9b4d08012aa6794ad817904596265aa3e6d55..be64abcf66a59f892b077ef50becde97d57f32ea:/lisp/thingatpt.el diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 88a2807538..214f6dcfde 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -1,6 +1,6 @@ ;;; thingatpt.el --- Get the `thing' at point -;; Copyright (C) 1991,92,93,94,95,96,1997 Free Software Foundation, Inc. +;; Copyright (C) 1991,92,93,94,95,96,97,1998 Free Software Foundation, Inc. ;; Author: Mike Williams ;; Keywords: extensions, matching, mouse @@ -241,9 +241,12 @@ This may contain whitespace (including newlines) .") (put 'url 'thing-at-point 'thing-at-point-url-at-point) (defun thing-at-point-url-at-point () "Return the URL around or before point. -Search backwards for the start of a URL ending at or after -point. If no URL found, return nil. The access scheme, `http://' -will be prepended if absent." + +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) (if (or (setq strip (thing-at-point-looking-at thing-at-point-markedup-url-regexp)) @@ -256,10 +259,15 @@ will be prepended if absent." (match-end 0))) (and strip (setq url (substring url 5 -1))) ; Drop "" ;; strip whitespace - (while (string-match "\\s +\\|\n+" url) + (while (string-match "[ \t\n\r]+" url) (setq url (replace-match "" t t url))) - (and short (setq url (concat (if (string-match "@" url) - "mailto:" "http://") url))) + (and short (setq url (concat (cond ((string-match "@" url) + "mailto:") + ;; e.g. ftp.swiss... or ftp-swiss... + ((string-match "^ftp" url) + "ftp://") + (t "http://")) + url))) (if (string-equal "" url) nil url))))) @@ -376,9 +384,13 @@ Signal an error if the entire string was not used." (error nil)))) (if (or (not pred) (funcall pred sexp)) sexp))) +;;;###autoload (defun sexp-at-point () (form-at-point 'sexp)) +;;;###autoload (defun symbol-at-point () (form-at-point 'sexp 'symbolp)) +;;;###autoload (defun number-at-point () (form-at-point 'sexp 'numberp)) +;;;###autoload (defun list-at-point () (form-at-point 'list 'listp)) ;; thingatpt.el ends here.