summaryrefslogtreecommitdiff
path: root/lisp/ffap.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ffap.el')
-rw-r--r--lisp/ffap.el79
1 files changed, 23 insertions, 56 deletions
diff --git a/lisp/ffap.el b/lisp/ffap.el
index 9de0dd40d16..ffed9f9759d 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -24,10 +24,10 @@
;;; Commentary:
-;;
-;; Command find-file-at-point replaces find-file. With a prefix, it
-;; behaves exactly like find-file. Without a prefix, it first tries
-;; to guess a default file or URL from the text around the point
+
+;; Command `find-file-at-point' replaces `find-file'. With a prefix,
+;; it behaves exactly like find-file. Without a prefix, it first
+;; tries to guess a default file or URL from the text around the point
;; (`ffap-require-prefix' swaps these behaviors). This is useful for
;; following references in situations such as mail or news buffers,
;; README's, MANIFEST's, and so on. Submit bugs or suggestions with
@@ -68,29 +68,27 @@
;; If you do not like these bindings, modify the variable
;; `ffap-bindings', or write your own.
;;
-;; If you use ange-ftp, browse-url, complete, efs, it is best to load
-;; or autoload them before ffap. If you use ff-paths, load it
-;; afterwards. Try apropos {C-h a ffap RET} to get a list of the many
-;; option variables. In particular, if ffap is slow, try these:
+;; If you use ange-ftp, it is best to load or autoload it before ffap.
+;; If you use ff-paths, load it afterwards. Try apropos {C-h a ffap
+;; RET} to get a list of the many option variables. In particular, if
+;; ffap is slow, try these:
;;
;; (setq ffap-alist nil) ; faster, dumber prompting
-;; (setq ffap-machine-p-known 'accept) ; no pinging
;; (setq ffap-url-regexp nil) ; disable URL features in ffap
;; (setq ffap-shell-prompt-regexp nil) ; disable shell prompt stripping
;; (setq ffap-gopher-regexp nil) ; disable gopher bookmark matching
;;
;; ffap uses `browse-url' to fetch URLs.
-;; For a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
;; Also, you can add `ffap-menu-rescan' to various hooks to fontify
;; the file and URL references within a buffer.
+;;; Code:
+
;;; Change Log:
-;;
-;; The History and Contributors moved to ffap.LOG (same ftp site),
+;; The History and Contributors moved to ffap.LOG,
;; which also has some old examples and commentary from ffap 1.5.
-
;;; Todo list:
;; * let "/dir/file#key" jump to key (tag or regexp) in /dir/file
;; * find file of symbol if TAGS is loaded (like above)
@@ -98,13 +96,10 @@
;; * notice node in "(dired)Virtual Dired" (quotes, parentheses, whitespace)
;; * notice "machine.dom blah blah blah dir/file" (how?)
;; * regexp options for ffap-string-at-point, like font-lock (MCOOK)
-;; * v19: could replace `ffap-locate-file' with a quieter `locate-library'
+;; * could replace `ffap-locate-file' with a quieter `locate-library'
;; * handle "$(VAR)" in Makefiles
;; * use the font-lock machinery
-
-;;; Code:
-
(eval-when-compile (require 'cl-lib))
(require 'url-parse)
(require 'thingatpt)
@@ -173,7 +168,7 @@ well-formed, such as \"user@host\" or \"<user@host>\"."
(defcustom ffap-ftp-default-user "anonymous"
"User name in FTP file names generated by `ffap-host-to-filename'.
Note this name may be omitted if it equals the default
-\(either `efs-default-user' or `ange-ftp-default-user')."
+(`ange-ftp-default-user')."
:type 'string
:group 'ffap)
@@ -273,8 +268,7 @@ ffap most of the time."
:risky t)
(defcustom ffap-url-fetcher 'browse-url
- "A function of one argument, called by ffap to fetch an URL.
-For a fancy alternative, get `ffap-url.el'."
+ "A function of one argument, called by ffap to fetch an URL."
:type '(choice (const browse-url)
function)
:group 'ffap
@@ -433,13 +427,6 @@ Returned values:
t means that HOST answered.
`accept' means the relevant variable told us to accept.
\"mesg\" means HOST exists, but does not respond for some reason."
- ;; Try some (Emory local):
- ;; (ffap-machine-p "ftp" nil nil 'ping)
- ;; (ffap-machine-p "nonesuch" nil nil 'ping)
- ;; (ffap-machine-p "ftp.mathcs.emory.edu" nil nil 'ping)
- ;; (ffap-machine-p "mathcs" 5678 nil 'ping)
- ;; (ffap-machine-p "foo.bonk" nil nil 'ping)
- ;; (ffap-machine-p "foo.bonk.com" nil nil 'ping)
(if (or (string-match "[^-[:alnum:].]" host) ; Invalid chars (?)
(not (string-match "[^0-9]" host))) ; 1: a number? 2: quick reject
nil
@@ -495,16 +482,13 @@ Returned values:
(defun ffap-replace-file-component (fullname name)
"In remote FULLNAME, replace path with NAME. May return nil."
- ;; Use efs if loaded, but do not load it otherwise.
- (if (fboundp 'efs-replace-path-component)
- (funcall 'efs-replace-path-component fullname name)
- (and (stringp fullname)
- (stringp name)
- (concat (file-remote-p fullname) name))))
-;; (ffap-replace-file-component "/who@foo.com:/whatever" "/new")
+ (and (stringp fullname)
+ (stringp name)
+ (concat (file-remote-p fullname) name)))
(defun ffap-file-suffix (file)
"Return trailing `.foo' suffix of FILE, or nil if none."
+ (declare (obsolete file-name-extension "29.1"))
(let ((pos (string-match "\\.[^./]*\\'" file)))
(and pos (substring file pos nil))))
@@ -528,7 +512,7 @@ The optional NOMODIFY argument suppresses the extra search."
;; three reasons to suppress search:
(nomodify nil)
((not (rassq 'jka-compr-handler file-name-handler-alist)) nil)
- ((member (ffap-file-suffix file) ffap-compression-suffixes) nil)
+ ((member (file-name-extension file t) ffap-compression-suffixes) nil)
(t ; ok, do the search
(let ((list ffap-compression-suffixes) try ret)
(while list
@@ -539,9 +523,6 @@ The optional NOMODIFY argument suppresses the extra search."
(defun ffap-file-remote-p (filename)
"If FILENAME looks remote, return it (maybe slightly improved)."
- ;; (ffap-file-remote-p "/user@foo.bar.com:/pub")
- ;; (ffap-file-remote-p "/cssun.mathcs.emory.edu://dir")
- ;; (ffap-file-remote-p "/ffap.el:80")
(or (and ffap-ftp-regexp
(string-match ffap-ftp-regexp filename)
;; Convert "/host.com://dir" to "/host:/dir", to handle a dying
@@ -568,9 +549,8 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
""
(let ((user ffap-ftp-default-user))
;; Avoid including the user if it is same as default:
- (if (or (equal user (ffap-symbol-value 'ange-ftp-default-user))
- (equal user (ffap-symbol-value 'efs-default-user)))
- (setq user nil))
+ (when (equal user (ffap-symbol-value 'ange-ftp-default-user))
+ (setq user nil))
(concat "/" user (and user "@") host ":"))))
(defun ffap-fixup-machine (mach)
@@ -583,7 +563,7 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
;; www.ncsa.uiuc.edu
((and (string-match "\\`w\\(ww\\|eb\\)[-.]" mach))
(concat "http://" mach "/"))
- ;; More cases? Maybe "telnet:" for archie?
+ ;; More cases?
(ffap-ftp-regexp (ffap-host-to-filename mach))
))
@@ -643,18 +623,6 @@ Looks at `ffap-ftp-default-user', returns \"\" for \"localhost\"."
;;; File Name Handling:
-;;
-;; The upcoming ffap-alist actions need various utilities to prepare
-;; and search directories. Too many features here.
-
-;; (defun ffap-last (l) (while (cdr l) (setq l (cdr l))) l)
-;; (defun ffap-splice (func inlist)
-;; "Equivalent to (apply 'nconc (mapcar FUNC INLIST)), but less consing."
-;; (let* ((head (cons 17 nil)) (last head))
-;; (while inlist
-;; (setcdr last (funcall func (car inlist)))
-;; (setq last (ffap-last last) inlist (cdr inlist)))
-;; (cdr head)))
(defun ffap-list-env (env &optional empty)
"Return a list of strings parsed from environment variable ENV.
@@ -793,7 +761,6 @@ This uses `ffap-file-exists-string', which may try adding suffixes from
("\\.\\(tex\\|sty\\|doc\\|cls\\)\\'" . ffap-tex)
("\\.bib\\'" . ffap-bib) ; search ffap-bib-path
("\\`\\." . ffap-home) ; .emacs, .bashrc, .profile
- ("\\`~/" . ffap-lcd) ; |~/misc/ffap.el.Z|
;; This used to have a blank, but ffap-string-at-point doesn't
;; handle blanks.
;; https://lists.gnu.org/r/emacs-devel/2008-01/msg01058.html
@@ -1041,7 +1008,7 @@ out of NAME."
;; Maybe a "Lisp Code Directory" reference:
(defun ffap-lcd (name)
- ;; FIXME: Is this still in use?
+ (declare (obsolete nil "29.1"))
(and
(or
;; lisp-dir-apropos output buffer: