;;; ffap.el --- find file (or url) at point
;;
-;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+;; Copyright (C) 1995, 96, 97, 2000 Free Software Foundation, Inc.
;;
;; Author: Michelangelo Grigni <mic@mathcs.emory.edu>
;; Created: 29 Mar 1993
"\\`\\("
"news\\(post\\)?:\\|mailto:\\|file:" ; no host ok
"\\|"
- "\\(ftp\\|http\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host
+ "\\(ftp\\|https?\\|telnet\\|gopher\\|www\\|wais\\)://" ; needs host
"\\)." ; require one more character
)
"Regexp matching URL's. nil to disable URL features in ffap.")
(unwind-protect
(cond
;; Immediate rejects (/ and // are too common in C++):
- ((member name '("" "/" "//")) nil)
+ ((member name '("" "/" "//" ".")) nil)
+ ;; Immediately test local filenames. If default-directory is
+ ;; remote, you probably already have a connection.
+ ((and (not abs) (ffap-file-exists-string name)))
+ ;; Try stripping off line numbers; good for compilation/grep output.
+ ((and (not abs) (string-match ":[0-9]" name)
+ (ffap-file-exists-string (substring name 0 (match-beginning 0)))))
;; Immediately test local filenames. If default-directory is
;; remote, you probably already have a connection.
((and (not abs) (ffap-file-exists-string name)))
;;
;; Based on overlay highlighting in Emacs 19.28 isearch.el.
-(defvar ffap-highlight (and window-system t)
+(defvar ffap-highlight t
"If non-nil, ffap highlights the current buffer substring.")
(defvar ffap-highlight-overlay nil
(setq ffap-highlight-overlay
(apply 'make-overlay ffap-string-at-point-region))
(overlay-put ffap-highlight-overlay 'face
- (if (internal-find-face 'ffap)
- 'ffap 'highlight)))))
+ (if (facep 'ffap) 'ffap 'highlight)))))
\f
;;; Main Entrance (`find-file-at-point' == `ffap'):
filename))))))
;; Shortcut: allow {M-x ffap} rather than {M-x find-file-at-point}.
-;; The defun is for autoload.el; the defalias takes over at load time.
-;;;###autoload
-(defun ffap (&optional filename)
- "A short alias for the find-file-at-point command.")
-(defalias 'ffap 'find-file-at-point)
-
+;;;###autoload(defalias 'ffap 'find-file-at-point)
\f
;;; Menu support (`ffap-menu'):
(defvar ffap-menu-text-plist
(cond
- ((not window-system) nil)
- (t '(face bold mouse-face highlight))) ; keymap <mousy-map>
+ ((display-mouse-p) '(face bold mouse-face highlight)) ; keymap <mousy-map>
+ (t nil))
"Text properties applied to strings found by `ffap-menu-rescan'.
These properties may be used to fontify the menu references.")